sev/utils: Use iterator combinators for pvalidate and RMP revoke paths#915
Conversation
|
The changes look good to me, but I wonder if in these functions we should attempt to walk back whenever there is an error and restore state (like we do in |
In the case of validation, a failure to validate always indicates either a security attack from the host or a security-critical error in guest-side logic. In both cases, it is most appropriate to panic once a failure is detected so that the security posture does not erode further. The caller is not usefully equipped to handle a validation failure (or an invalidation failure) anyway. Beyond that, reverting the validation state (which is not possible on TDX at all) is no more guaranteed to succeed than the operation that failed in the first place, so reversion can never be relied upon. In the case of page permission adjustment, there is really no reasonable case in which failure can occur at all; just like with validation, an error here either represents a security attack (if the host unexpectedly revokes a validated page) or a security-critical error in guest-side logic (if the guest erroneously forgets to validate a page before adjusting it). Following the same reason as stated above for validation, it's best just to panic on an adjustment failure rather than to try to let execution continue past the point of failure. |
When servicing
We can detect if the reversion fails. This is what we do in I think at least we should let the caller know how far the operation got through if there was an error, and let them take the right action based on this information. |
|
I do not think there is a point in undoing changes |
Yes, I agree. This would perhaps let us simplify the logic in |
Returning the virtual address instead of the hardware error value makes sense to me. Should I fold that change in this PR or would you prefer a separate one? |
13d9e2a to
ddf1f18
Compare
|
I get an early crash with these changes: Can you please have a look? |
joergroedel
left a comment
There was a problem hiding this comment.
test-in-svsm passes, but Linux boot crashes early in OVMF.
Switch pvalidate_range_4k() and rmp_revoke_guest_access() to iterator- based try_for_each for cleaner, idiomatic Rust. No functional changes. Signed-off-by: Vaishali Thakkar <vaishali.thakkar@suse.com>
Use the failing virtual address as the error value for PVALIDATE-related failures instead of returning hardware error codes in pvalidate_range and pvalidate_range_4k. Signed-off-by: Vaishali Thakkar <vaishali.thakkar@suse.com>
ddf1f18 to
3bbe429
Compare
|
These changes have been tested with Carlos's fix in the planes branch: coconut-svsm/linux#19 + revert of the commit 5396242 in svsm. I have been able to boot the linux guest. |
Switch pvalidate_range_4k() and rmp_revoke_guest_access() to iterator- based try_for_each for cleaner, idiomatic Rust.
No functional changes.