|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH RFC 32/44] x86: Always reload the LDT on vcpu context switch
... and always zero the LDT for HVM contexts. This causes erroneous execution
which manages to reference the LDT fail with a straight #GP fault, rather than
possibly finding a stale loaded LDT and wandering the #PF handler.
Future changes will cause the loading of LDT to be lazy, at which point
load_LDT() will be a nop for all cases other than context switching to/from a
PV vcpu with an LDT loaded.
Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
---
xen/arch/x86/domain.c | 5 ++---
xen/include/asm-x86/ldt.h | 4 ++--
2 files changed, 4 insertions(+), 5 deletions(-)
diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c
index ce5337b..4671c9b 100644
--- a/xen/arch/x86/domain.c
+++ b/xen/arch/x86/domain.c
@@ -1660,6 +1660,8 @@ static void __context_switch(void)
lgdt(&gdt_desc);
}
+ load_LDT(n);
+
if ( pd != nd )
cpumask_clear_cpu(cpu, pd->domain_dirty_cpumask);
cpumask_clear_cpu(cpu, p->vcpu_dirty_cpumask);
@@ -1723,10 +1725,7 @@ void context_switch(struct vcpu *prev, struct vcpu *next)
local_irq_enable();
if ( is_pv_domain(nextd) )
- {
- load_LDT(next);
load_segments(next);
- }
ctxt_switch_levelling(next);
}
diff --git a/xen/include/asm-x86/ldt.h b/xen/include/asm-x86/ldt.h
index 589daf8..6fbce93 100644
--- a/xen/include/asm-x86/ldt.h
+++ b/xen/include/asm-x86/ldt.h
@@ -7,9 +7,9 @@
static inline void load_LDT(struct vcpu *v)
{
struct desc_struct *desc;
- unsigned long ents;
+ unsigned int ents = is_pv_vcpu(v) && v->arch.pv_vcpu.ldt_ents;
- if ( (ents = v->arch.pv_vcpu.ldt_ents) == 0 )
+ if ( ents == 0 )
lldt(0);
else
{
--
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 |