@@ -30,7 +30,7 @@ impl UhProcessor<'_, HypervisorBacked> {
30
30
pub ( crate ) fn set_tlb_lock ( & mut self , requesting_vtl : Vtl , target_vtl : GuestVtl ) {
31
31
debug_assert_eq ! ( requesting_vtl, Vtl :: Vtl2 ) ;
32
32
33
- if self . is_tlb_locked ( requesting_vtl, target_vtl) {
33
+ if self . vtls_tlb_locked . get ( requesting_vtl, target_vtl) {
34
34
return ;
35
35
}
36
36
@@ -52,19 +52,26 @@ impl UhProcessor<'_, HypervisorBacked> {
52
52
debug_assert_eq ! ( requesting_vtl, Vtl :: Vtl2 ) ;
53
53
let locally_locked = self . vtls_tlb_locked . get ( requesting_vtl, target_vtl) ;
54
54
// The hypervisor may lock the TLB without us knowing, but the inverse should never happen.
55
- #[ expect(
56
- clippy:: debug_assert_with_mut_call,
57
- reason = "just sanity checking, but the function can update the cached value in the non-debug-assert branch"
58
- ) ]
59
55
if locally_locked {
60
- debug_assert ! ( self . is_tlb_locked_in_hypervisor ( requesting_vtl , target_vtl) ) ;
56
+ debug_assert ! ( self . is_tlb_locked_in_hypervisor_noncaching ( target_vtl) ) ;
61
57
true
62
58
} else {
63
59
self . is_tlb_locked_in_hypervisor ( requesting_vtl, target_vtl)
64
60
}
65
61
}
66
62
67
63
fn is_tlb_locked_in_hypervisor ( & mut self , requesting_vtl : Vtl , target_vtl : GuestVtl ) -> bool {
64
+ let result = self . is_tlb_locked_in_hypervisor_noncaching ( target_vtl) ;
65
+ // The hypervisor may lock the TLB without us knowing, but the inverse should never happen.
66
+ if result {
67
+ self . vtls_tlb_locked . set ( requesting_vtl, target_vtl, true ) ;
68
+ } else {
69
+ assert ! ( !self . vtls_tlb_locked. get( requesting_vtl, target_vtl) ) ;
70
+ }
71
+ result
72
+ }
73
+
74
+ fn is_tlb_locked_in_hypervisor_noncaching ( & self , target_vtl : GuestVtl ) -> bool {
68
75
let name = HvAllArchRegisterName (
69
76
HvAllArchRegisterName :: VsmVpSecureConfigVtl0 . 0 + target_vtl as u32 ,
70
77
) ;
@@ -74,14 +81,7 @@ impl UhProcessor<'_, HypervisorBacked> {
74
81
. get_vp_register ( name, HvInputVtl :: CURRENT_VTL )
75
82
. expect ( "failure is a misconfiguration" ) ;
76
83
let config = hvdef:: HvRegisterVsmVpSecureVtlConfig :: from ( result. as_u64 ( ) ) ;
77
- let result = config. tlb_locked ( ) ;
78
- // The hypervisor may lock the TLB without us knowing, but the inverse should never happen.
79
- if result {
80
- self . vtls_tlb_locked . set ( requesting_vtl, target_vtl, true ) ;
81
- } else {
82
- assert ! ( !self . vtls_tlb_locked. get( requesting_vtl, target_vtl) ) ;
83
- }
84
- result
84
+ config. tlb_locked ( )
85
85
}
86
86
87
87
/// Marks the TLBs of all lower VTLs as unlocked.
0 commit comments