Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception table support #212

Merged
merged 3 commits into from
Sep 10, 2021
Merged

Conversation

82marbag
Copy link
Contributor

@82marbag 82marbag commented Sep 6, 2021

Issue #, if available: #6

Description of changes:

This PR adds support for exception tables and uses them to implement rdmsr_safe and wrmsr_safe, that will fail by reporting the error in a boolean variable if the operation on an msr can't be completed due to an exception.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@82marbag 82marbag requested a review from wipawel September 6, 2021 20:04
@wipawel wipawel linked an issue Sep 7, 2021 that may be closed by this pull request
@wipawel wipawel added this to the v0.4.1 milestone Sep 7, 2021
@wipawel wipawel added feature New feature or request Priority: 2 Very important feature labels Sep 7, 2021
arch/x86/traps.c Show resolved Hide resolved
include/extables.h Outdated Show resolved Hide resolved
include/extables.h Outdated Show resolved Hide resolved
Comment on lines 33 to 35
uint64_t fault_addr;

uint64_t fixup;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe void * would be a better type?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually x86_reg_t would be a better one

include/extables.h Outdated Show resolved Hide resolved
include/extables.h Outdated Show resolved Hide resolved
include/lib.h Outdated Show resolved Hide resolved
include/lib.h Outdated
volatile bool _read = false;
uint32_t low, high;

asm volatile("1: rdmsr; movq $1, %[read];"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this code could be made simpler with asm goto directive, the supplied in label can point to the error condition.

@wipawel
Copy link
Contributor

wipawel commented Sep 7, 2021

Please also fix in the drivers/acpi/acpica/osl.c:

/* FIXME: Check if pages are mapped (with exception tables) */
BOOLEAN AcpiOsReadable(void *Memory, ACPI_SIZE Length) { return true; }

/* FIXME: Check if pages are mapped and writeable (with exception tables) */
BOOLEAN AcpiOsWriteable(void *Memory, ACPI_SIZE Length) { return true; }

@wipawel
Copy link
Contributor

wipawel commented Sep 7, 2021

nit: please also add empty init_extable() and call it from setup.c replacing /* TODO: Exception tables */

include/lib.h Outdated Show resolved Hide resolved
arch/x86/traps.c Outdated Show resolved Hide resolved
drivers/acpi/acpica/osl.c Outdated Show resolved Hide resolved
drivers/acpi/acpica/osl.c Outdated Show resolved Hide resolved
drivers/acpi/acpica/osl.c Outdated Show resolved Hide resolved
include/lib.h Outdated Show resolved Hide resolved
lib/lib.c Outdated Show resolved Hide resolved
lib/lib.c Outdated Show resolved Hide resolved
Add support for exception tables.
It is possible to register an address that triggers
an exception to call an handler, jump to a fixup address
or both.

Signed-off-by: Daniele Ahmed <[email protected]>
Add new rdmsr_safe and wrmsr_safe. These two functions
use exception tables to try performing their operations
and returning safely if the operation could not be performed.

Signed-off-by: Daniele Ahmed <[email protected]>
In AcpiOsReadable and AcpiOsWriteable the checks for mapped pages
and their permissions for reading and writing respectively
are performed with exception tables

Signed-off-by: Daniele Ahmed <[email protected]>
@wipawel wipawel merged commit 4431f14 into KernelTestFramework:mainline Sep 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request Priority: 2 Very important feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add exception tables support
2 participants