* [PATCH] x86/PV: guest_get_eff_kern_l1e() may still need to switch page tables
@ 2020-12-14 13:57 Jan Beulich
2020-12-14 14:37 ` Andrew Cooper
2020-12-14 16:07 ` Manuel Bouyer
0 siblings, 2 replies; 3+ messages in thread
From: Jan Beulich @ 2020-12-14 13:57 UTC (permalink / raw)
To: xen-devel; +Cc: Andrew Cooper, Wei Liu, Roger Pau Monné, Manuel Bouyer
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.
Fixes: 9ff970564764 ("x86/mm: drop guest_get_eff_l1e()")
Reported-by: Manuel Bouyer <bouyer@antioche.eu.org>
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
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.
--- a/xen/arch/x86/pv/mm.h
+++ b/xen/arch/x86/pv/mm.h
@@ -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;
}
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] x86/PV: guest_get_eff_kern_l1e() may still need to switch page tables
2020-12-14 13:57 [PATCH] x86/PV: guest_get_eff_kern_l1e() may still need to switch page tables Jan Beulich
@ 2020-12-14 14:37 ` Andrew Cooper
2020-12-14 16:07 ` Manuel Bouyer
1 sibling, 0 replies; 3+ messages in thread
From: Andrew Cooper @ 2020-12-14 14:37 UTC (permalink / raw)
To: Jan Beulich, xen-devel; +Cc: Wei Liu, Roger Pau Monné, Manuel Bouyer
On 14/12/2020 13:57, Jan Beulich wrote:
> 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.
>
> Fixes: 9ff970564764 ("x86/mm: drop guest_get_eff_l1e()")
> Reported-by: Manuel Bouyer <bouyer@antioche.eu.org>
> Signed-off-by: Jan Beulich <jbeulich@suse.com>
> Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
> ---
> 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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] x86/PV: guest_get_eff_kern_l1e() may still need to switch page tables
2020-12-14 13:57 [PATCH] x86/PV: guest_get_eff_kern_l1e() may still need to switch page tables Jan Beulich
2020-12-14 14:37 ` Andrew Cooper
@ 2020-12-14 16:07 ` Manuel Bouyer
1 sibling, 0 replies; 3+ messages in thread
From: Manuel Bouyer @ 2020-12-14 16:07 UTC (permalink / raw)
To: Jan Beulich; +Cc: xen-devel, Andrew Cooper, Wei Liu, Roger Pau Monné
On Mon, Dec 14, 2020 at 02:57:53PM +0100, Jan Beulich wrote:
> 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.
>
> Fixes: 9ff970564764 ("x86/mm: drop guest_get_eff_l1e()")
> Reported-by: Manuel Bouyer <bouyer@antioche.eu.org>
> Signed-off-by: Jan Beulich <jbeulich@suse.com>
> Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
> ---
> 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 !
--
Manuel Bouyer <bouyer@antioche.eu.org>
NetBSD: 26 ans d'experience feront toujours la difference
--
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-12-14 16:08 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-14 13:57 [PATCH] x86/PV: guest_get_eff_kern_l1e() may still need to switch page tables Jan Beulich
2020-12-14 14:37 ` Andrew Cooper
2020-12-14 16:07 ` Manuel Bouyer
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.