-
Notifications
You must be signed in to change notification settings - Fork 189
feat(ssnpm): Add support for pointer masking #354
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -81,6 +81,46 @@ void vmm_arch_init() | |
| } | ||
| } | ||
|
|
||
| #if CPU_HAS_EXTENSION(CPU_EXT_SSNPM) | ||
| #if defined(RV32) | ||
| #error "Ssnpm extension is not available for RV32. Please disable CPU_EXT_SSNPM." | ||
| #elif !defined(CPU_EXT_SSNPM_PMM_MODE) | ||
| #error "Ssnpm extension PMM mode is not defined. Please define CPU_EXT_SSNPM_PMM_MODE." | ||
| #else | ||
| /** | ||
| * Program the guest-visible Ssnpm PMM mode if the hypervisor was | ||
| * configured to use it (via the CPU_EXT_SSNPM_PMM_MODE macro). | ||
| * Otherwise, henvcfg keeps the reset value written above. | ||
| */ | ||
| uint64_t pmm_val = 0; | ||
|
|
||
| switch (CPU_EXT_SSNPM_PMM_MODE) { | ||
| case HENVCFG_PMM_DISABLED: | ||
| if (cpu_is_master()) { | ||
| WARNING("Ssnpm extension is enabled but PMM mode is set to disabled.\r\n"); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should actually be "extension is present". But I don't believe this is worth it. I don't think we should allow the configruation in this way. Either we: (i) simply disable support for the extension for now, or (ii) allow to set this in the config in a config global .arch field (i believe we have to add this) (e.g., .arch.npm_mode) or (ii) allow to set the mode per vm, in the a vm config arch field (e.g., arch.npm_mode field) |
||
| } | ||
| pmm_val = HENVCFG_PMM_DISABLED << HENVCFG_PMM_OFF; | ||
| break; | ||
| case HENVCFG_PMM_PMLEN_7: | ||
| pmm_val = HENVCFG_PMM_PMLEN_7 << HENVCFG_PMM_OFF; | ||
| break; | ||
| case HENVCFG_PMM_PMLEN_16: | ||
| pmm_val = HENVCFG_PMM_PMLEN_16 << HENVCFG_PMM_OFF; | ||
| break; | ||
| default: | ||
| if (cpu_is_master()) { | ||
| ERROR("Unsupported PMM mode for Ssnpm extension.\r\n"); | ||
| } | ||
| } | ||
|
|
||
| csrs_henvcfg_set(pmm_val); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To make sure we do this cleanly dont we first need to csrs_henvcfg_clear(HENVCFG_PMM_MSK) ? |
||
| bool ssnpm_present = ((csrs_henvcfg_read() & pmm_val) == pmm_val); | ||
| if (cpu_is_master() && !ssnpm_present) { | ||
| ERROR("Platform configured to use Ssnpm extension, but extension not present.\r\n"); | ||
| } | ||
| #endif | ||
| #endif | ||
|
|
||
| /** | ||
| * Configure the State Enable mechanism (Ssstateen). | ||
| * | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think these checks should be here. What I'd suggest is to have a private function vmm_arch_config_ssmpm and then an if (CPU_HAS_EXT(...)) vmm_arch_config_ssmpm().