-
Notifications
You must be signed in to change notification settings - Fork 232
PMM (Pointer Masking) ACTs #484
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: dev
Are you sure you want to change the base?
Conversation
Hi, |
To run the coverage locally, use the following command:
|
Signed-off-by: Umer Shahid <[email protected]>
Signed-off-by: Umer Shahid <[email protected]>
Hi all! I am currently using these tests to validate the implementation of the pointer masking extension for Sail. I have come across a few issues that I wanted to share:
this is due to the size of the RAM, which is for these tests to small, changing the configuration and increasing the RAM size (in my case to 8 exabyte) will get rid of the problem:
Snippet from Spike:
I believe there are a few more issues that still need to be resolved, and I am currently investigating their root causes. |
@nadime15 Thank you for pointing out the issues. This is a really old PR and the sail model has changed a lot since then. I will update the changes in the next commit. |
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.
Thanks for your reply! I just noticed a few additional points that might save you some time down the line:
-
The test cases for
pmm_float
are not being executed. -
The test cases for Supervisor (and User modes) are triggering illegal instruction exceptions due to incorrectly defined addresses in the page table setup (details below).
I have also included a few more observations further down.
/* | ||
Verification Goal: Set PMM = 01 in the menvcfg and tag bits are 0xFFFF with bit[47]=1, | ||
test whether or not pointer masking with PMLEN = 16 is enabled or not in M-Mode in sv48 | ||
Description: | ||
If Pointer Masking is enabled, then the Effective Address will be masked accordingly, no exception will be generated, | ||
If Pointer Masking is disabled, then the Effective Address will be valid, no exceptions will be created | ||
due to the invalid Virtual Address, | ||
*/ |
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.
The filenames in the pmm_float directory aren't right for M-Mode, they use SV48
(uppercase), but everything else uses sv48
.
Verification Goal: Set PMM = 01 in the menvcfg and tag bits are 0xABAB with bit[47]=0, | ||
test whether or not pointer masking with PMLEN = 16 is enabled or not in M-Mode in sv48 | ||
Description: | ||
If Pointer Masking is enabled, then the Effective Address will be masked accordingly, no exception will be generated, | ||
If Pointer Masking is disabled, then the Effective Address will be invalid, exceptions will be created | ||
due to the invalid Virtual Address, |
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.
For pmm_atomics, the files:
-
PMM_atomic_01_M_sv48_tag02.S
-
PMM_atomic_01_M_sv48_tag03
.S
end in decimal, but they should use the binary form instead, tag10.S
and tag11.S
.
# --------------------------- Define Addresses ------------------------------- | ||
.set pa_rvtest_code_begin, 0x8000000000039c // 56-bit physical address of the code section | ||
.set pa_rvtest_data_begin, 0x80000000003530 // 56-bit physical address of the data section | ||
.set pa_rvtest_sig_begin, 0x80000000006218 // 56-bit physical address of the signature section | ||
.set va_rvtest_code_begin, 0xFFFF80000000039c // 48-bit virtual address of the code section | ||
.set va_rvtest_data_begin, 0xFFFF900000000000 // 48-bit virtual address of the data section | ||
.set va_rvtest_sig_begin, 0xFFFF900000006218 // 48-bit virtual address of the signature section | ||
.set va_rvtest_vmem_begin, 0xFFFF900000000000 // 48-bit virtual address of vmem |
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.
Ok this one is quite tricky and it took me literally days to find out what is going on here:
So the way it's set up right now you will run into an illegal instruction exception once you go from M-Mode to Supervisor-Mode:
[411] [S]: 0xFFFF800000000774 (0x0000) c.illegal 0x0 // From Sail, tries to execute first instruction of `vm_en`
This happens because of how the addresses were picked and the use of sv48, plus, the fact that PTE's at LEVEL3 are leaves with gigapages instead of using a multi-level page table with a page table walk and using a smaller page size.
So the problem is the following paddr:
.set pa_rvtest_code_begin, 0x8000000000039c // 56-bit physical address of the code section
this will eventually create a mapping from VA 0xFFFF900000000000
to PA 0x8000000000039C
, which points to nowhere.
From what I can tell by reading the code, there is no remapping of the code from its initial addr:
0x80000000 <rvtest_entry_point>:
to
0x80000000000000 <rvtest_entry_point>:
so the initialization of the PTE down below:
LI (a0, pa_rvtest_code_begin) // Load physical address of code
LI (a1, (PTE_V | PTE_A | PTE_W | PTE_R | PTE_D | PTE_X)) // Set permission bits
PTE_SETUP_RV64(a0, a1, t0, t1, va_rvtest_code_begin, LEVEL3, sv48) // Set up level 3 PTE
will not work as intended.
Unfortunately you can't just change the mapping from:
.set pa_rvtest_code_begin, 0x8000000000039c
to
.set pa_rvtest_code_begin, 0x8000039c
because as i said at the beginning, the fact that the code tries to set up gigabyte pages will result later in a page-fault because of the following rule:
5 ) A leaf PTE has been reached. If i>0 and pte.ppn[i-1:0] ≠ 0, this is a misaligned superpage; stop
and raise a page-fault exception corresponding to the original access type.
ppn[2:0]
of 0x8000039c
is non zero
So there are a few ways to get around this:
1 ) You actually have to remap your code from 0x8000039c to 0x8000000000039c (basically copy-paste it while in M-Mode)
2 ) You have to set up a proper multi-level page table and deal with smaller page sizes (meaning you have to go down to LEVEL2 or maybe even LEVEL0)
3 ) You modify the linker script to link the code at 0x80000000000000 instead of 0x80000000.
I decided to go for 3 ) which I only did to the get the test running, but we can not push this solution because this would modify the linker script.
On top of that you have to pay attention to these addresses:
.set va_rvtest_code_begin, 0xFFFF80000000039c // 48-bit virtual address of the code section
.set va_rvtest_data_begin, 0xFFFF900000000000 // 48-bit virtual address of the data section
They have different VPN[3]
values, so va_rvtest_code_begin.VPN[3] != va_rvtest_data_begin.VPN[3]
, meaning each will map to a different memory address for their corresponding PTE entry.
And finally, I modify the defined addresses.:
# --------------------------- Define Addresses ------------------------------- | |
.set pa_rvtest_code_begin, 0x8000000000039c // 56-bit physical address of the code section | |
.set pa_rvtest_data_begin, 0x80000000003530 // 56-bit physical address of the data section | |
.set pa_rvtest_sig_begin, 0x80000000006218 // 56-bit physical address of the signature section | |
.set va_rvtest_code_begin, 0xFFFF80000000039c // 48-bit virtual address of the code section | |
.set va_rvtest_data_begin, 0xFFFF900000000000 // 48-bit virtual address of the data section | |
.set va_rvtest_sig_begin, 0xFFFF900000006218 // 48-bit virtual address of the signature section | |
.set va_rvtest_vmem_begin, 0xFFFF900000000000 // 48-bit virtual address of vmem | |
# --------------------------- Define Addresses ------------------------------- | |
.set pa_rvtest_code_begin, 0x8000000000039c // 56-bit physical address of the code section | |
.set pa_rvtest_data_begin, 0x80000000003530 // 56-bit physical address of the data section | |
.set pa_rvtest_sig_begin, 0x80000000006218 // 56-bit physical address of the signature section | |
.set va_rvtest_code_begin, 0xFFFF80000000039c // 48-bit virtual address of the code section | |
.set va_rvtest_data_begin, 0xFFFF800000003530 // 48-bit virtual address of the data section | |
.set va_rvtest_sig_begin, 0xFFFF800000006218 // 48-bit virtual address of the signature section | |
.set va_rvtest_vmem_begin, 0xFFFF800000000000 // 48-bit virtual address of vmem |
After these changes I was able to successfully run the test.
similar changes in regard to the addresses must be made for the other 3 cases as well (tag00
, tag01
and tag10
)
Description
Ratified/Unratified Extensions
List Extensions
Reference Model Used
Mandatory Checklist:
Optional Checklist: