-
Notifications
You must be signed in to change notification settings - Fork 70
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
Handle armv8m unpriv_access with SAU #486
base: master
Are you sure you want to change the base?
Conversation
if ((vmpu_unpriv_test_range(addr, UVISOR_UNPRIV_ACCESS_SIZE(size)) & (TT_RESP_NSRW_Msk | TT_RESP_SRVALID_Msk)) == (TT_RESP_NSRW_Msk | TT_RESP_SRVALID_Msk)) { | ||
//if ((vmpu_unpriv_test_range(addr, UVISOR_UNPRIV_ACCESS_SIZE(size)) & (TT_RESP_NSRW_Msk | TT_RESP_SRVALID_Msk)) == (TT_RESP_NSRW_Msk | TT_RESP_SRVALID_Msk)) { | ||
//this should be slower substantualy | ||
if (vmpu_buffer_access_is_ok(g_active_box, addr, UVISOR_UNPRIV_ACCESS_SIZE(size))){ |
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.
We shouldn't need to use the loop anymore, nor try to recover.
a35d01b
to
818ec82
Compare
works well on v8 |
f7a284b
to
07febfa
Compare
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.
squash the commits and write appropriate commit message describing the problem and the fix
} | ||
if (++tries > 1 || !vmpu_fault_recovery_mpu(0, 0, addr, 0)) { | ||
break; | ||
//if ((vmpu_unpriv_test_range(addr, UVISOR_UNPRIV_ACCESS_SIZE(size)) & (TT_RESP_NSRW_Msk | TT_RESP_SRVALID_Msk)) == (TT_RESP_NSRW_Msk | TT_RESP_SRVALID_Msk)) { |
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.
please remove legacy code
if (++tries > 1 || !vmpu_fault_recovery_mpu(0, 0, addr, 0)) { | ||
break; | ||
//if ((vmpu_unpriv_test_range(addr, UVISOR_UNPRIV_ACCESS_SIZE(size)) & (TT_RESP_NSRW_Msk | TT_RESP_SRVALID_Msk)) == (TT_RESP_NSRW_Msk | TT_RESP_SRVALID_Msk)) { | ||
//this should be slower substantualy |
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.
Please explain how and why this is slower in this comment.
} | ||
} | ||
|
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.
Make whitespace changes in a separate 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.
Don't add trailing whitespace.
//if ((vmpu_unpriv_test_range(addr, UVISOR_UNPRIV_ACCESS_SIZE(size)) & (TT_RESP_NSRW_Msk | TT_RESP_SRVALID_Msk)) == (TT_RESP_NSRW_Msk | TT_RESP_SRVALID_Msk)) { | ||
//this should be slower substantualy | ||
if (vmpu_buffer_access_is_ok(g_active_box, (const void *) addr, UVISOR_UNPRIV_ACCESS_SIZE(size))){ | ||
switch(size) { |
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.
Add a space after keywords like switch
, before the (
. It was wrong before. Please make style changes in a separate commit.
What testing has been done with v8-M? All v8-M tests pass? |
c9f3515
to
c0c6db1
Compare
@niklas-arm could you review the changes and compare it to your work? |
0f7c8ac
to
df08917
Compare
Looks like this is suffering from the same problem on the |
This is pretty similar to what I implemented. The issue is related to the SAU not being updated with the region containing the accessed memory anymore. For some reason this now leads to a hardfault. |
02a49a0
to
5499cc7
Compare
} | ||
|
||
if (++tries > 1 || !vmpu_fault_recovery_mpu(0, 0, addr, 0)) { |
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.
We should have to recover. vmpu_buffer_access_is_ok
should tell you what access you would have if you did recover. The access can happen from secure mode without the recovery happening.
|
||
return response_lower & (TT_RESP_NSRW_Msk | TT_RESP_NSR_Msk | TT_RESP_RW_Msk | TT_RESP_R_Msk | | ||
TT_RESP_S_Msk | TT_RESP_SRVALID_Msk | TT_RESP_SREGION_Msk); | ||
} | ||
|
||
extern int vmpu_fault_recovery_mpu(uint32_t pc, uint32_t sp, uint32_t fault_addr, uint32_t fault_status); | ||
|
||
uint32_t vmpu_unpriv_access(uint32_t addr, uint32_t size, uint32_t data) | ||
{ | ||
unsigned int tries = 0; | ||
while(1) { |
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.
We shouldn't have to loop here either.
98230cf
to
980c649
Compare
/* Upon execution return debug_handler will be executed. Upon return from | ||
* debug_handler, return_handler will be executed. */ | ||
|
||
//uint32_t caller = UVISOR_GET_NS_ALIAS(UVISOR_GET_NS_ADDRESS((uint32_t) debug_handler)); |
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.
@Patater @niklas-arm
my problem is how can i proceed from here
af7667e
to
249bea0
Compare
Previously when we got to unpriv_access we verfied the operation with the TT assembly command, we now switch to using the SAU with uVisor vmpu functions. This could slow down the operation since we switch an assembly command with a C function which scans the virtual regions.
249bea0
to
eb32d63
Compare
This is waiting for #497 to merge first, so that the debug box has a good context in which to run. |
This needs to wait, as not all the v8-M tests are passing if I merge this. |
No description provided.