|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH RFC 08/44] x86/pv: Avoid an opencoded mov to %cr3 in toggle_guest_mode()
Xen will need to track which %cr3 it is running on. Propagate a
tlb_maintenance parameter down into write_ptbase(), so toggle_guest_mode() can
retain its optimisation of not flushing global mappings and not ticking the
TLB clock.
Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
---
xen/arch/x86/mm.c | 9 +++++++--
xen/arch/x86/pv/domain.c | 2 +-
xen/include/asm-x86/processor.h | 6 +++++-
3 files changed, 13 insertions(+), 4 deletions(-)
diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c
index 14cfa93..25f9588 100644
--- a/xen/arch/x86/mm.c
+++ b/xen/arch/x86/mm.c
@@ -497,9 +497,14 @@ void make_cr3(struct vcpu *v, mfn_t mfn)
v->arch.cr3 = mfn_x(mfn) << PAGE_SHIFT;
}
-void write_ptbase(struct vcpu *v)
+void do_write_ptbase(struct vcpu *v, bool tlb_maintenance)
{
- write_cr3(v->arch.cr3);
+ unsigned long new_cr3 = v->arch.cr3;
+
+ if ( tlb_maintenance )
+ write_cr3(new_cr3);
+ else
+ asm volatile ( "mov %0, %%cr3" :: "r" (new_cr3) : "memory" );
}
/*
diff --git a/xen/arch/x86/pv/domain.c b/xen/arch/x86/pv/domain.c
index 2234128..7e4566d 100644
--- a/xen/arch/x86/pv/domain.c
+++ b/xen/arch/x86/pv/domain.c
@@ -246,7 +246,7 @@ void toggle_guest_pt(struct vcpu *v)
v->arch.flags ^= TF_kernel_mode;
update_cr3(v);
/* Don't flush user global mappings from the TLB. Don't tick TLB clock. */
- asm volatile ( "mov %0, %%cr3" : : "r" (v->arch.cr3) : "memory" );
+ do_write_ptbase(v, false);
if ( !(v->arch.flags & TF_kernel_mode) )
return;
diff --git a/xen/include/asm-x86/processor.h b/xen/include/asm-x86/processor.h
index a0c524b..c206080 100644
--- a/xen/include/asm-x86/processor.h
+++ b/xen/include/asm-x86/processor.h
@@ -479,7 +479,11 @@ DECLARE_PER_CPU(struct tss_struct, init_tss);
extern void init_int80_direct_trap(struct vcpu *v);
-extern void write_ptbase(struct vcpu *v);
+extern void do_write_ptbase(struct vcpu *v, bool tlb_maintenance);
+static inline void write_ptbase(struct vcpu *v)
+{
+ do_write_ptbase(v, true);
+}
/* REP NOP (PAUSE) is a good thing to insert into busy-wait loops. */
static always_inline void rep_nop(void)
--
2.1.4
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |