x86/PV: guest_get_eff_kern_l1e() may still need to switch page tables
PATCH 1/1 x86/PV: guest_get_eff_kern_l1e() may still need to switch page tables
While indeed unnecessary for pv_ro_page_fault(), pv_map_ldt_shadow_page() may run when guest user mode is active, and hence may need to switch to the kernel page tables in order to retrieve an LDT page mapping.
---
Manuel, could you test this again, just to be on the safe side before we throw it in (at which point we could then also again add a Tested-by)? Thanks.
xen/arch/x86/pv/mm.h +10 -2
@@ -11,10 +11,15 @@ int new_guest_cr3(mfn_t mfn);*/ static inline l1_pgentry_t guest_get_eff_kern_l1e(unsigned long linear) { + struct vcpu *curr = current; + bool user_mode = !(curr->arch.flags & TF_kernel_mode); l1_pgentry_t l1e; - ASSERT(!paging_mode_translate(current->domain)); - ASSERT(!paging_mode_external(current->domain)); + ASSERT(!paging_mode_translate(curr->domain)); + ASSERT(!paging_mode_external(curr->domain)); + + if ( user_mode ) + toggle_guest_pt(curr); if ( unlikely(!__addr_ok(linear)) || __copy_from_user(&l1e,
@@ -22,6 +27,9 @@ static inline l1_pgentry_t guest_get_eff sizeof(l1_pgentry_t)) ) l1e =l1e_empty (); +if ( user_mode ) +toggle_guest_pt (curr); +return l1e; }
Quoted 4 lines · Jan Beulich
While indeed unnecessary for
pv_ro_page_fault(),pv_map_ldt_shadow_page()may run when guest user mode is active, and hence may need to switch to the kernel page tables in order to retrieve an LDT page mapping.
Quoted 8 lines
Fixes 9ff970564764 ("x86/mm: drop guest_get_eff_l1e()")Reported-by Manuel Bouyer <[email protected]>Signed-off-by Jan Beulich <[email protected]>Reviewed-by Andrew Cooper <[email protected]>---
Manuel, could you test this again, just to be on the safe side before we throw it in (at which point we could then also again add a Tested-by)? Thanks.
I've got a repro of the issue (literally - just booting the netinstaller), and this does fix it.
~Andrew
Quoted 4 lines · Jan Beulich
While indeed unnecessary for
pv_ro_page_fault(),pv_map_ldt_shadow_page()may run when guest user mode is active, and hence may need to switch to the kernel page tables in order to retrieve an LDT page mapping.
Quoted 8 lines
Fixes 9ff970564764 ("x86/mm: drop guest_get_eff_l1e()")Reported-by Manuel Bouyer <[email protected]>Signed-off-by Jan Beulich <[email protected]>Reviewed-by Andrew Cooper <[email protected]>---
Manuel, could you test this again, just to be on the safe side before we throw it in (at which point we could then also again add a Tested-by)? Thanks.
Yes, this works for me. thanks !
Signature · 3 lines
Manuel Bouyer <[email protected]> NetBSD: 26 ans d'experience feront toujours la difference --