# HG changeset patch
# User cegger
# Date 1298892114 -3600
# Node ID 340862a9e1cc39f3fa74874e51cc6e2f69f589b6
# Parent c856533343bf2de46b507ac4f815097e4779806f
Allow guest to enable SVM in EFER
Signed-off-by: Christoph Egger <Christoph.Egger@xxxxxxx>
Acked-by: Eddie Dong <eddie.dong@xxxxxxxxx>
Acked-by: Tim Deegan <Tim.Deegan@xxxxxxxxxx>
Committed-by: Tim Deegan <Tim.Deegan@xxxxxxxxxx>
---
diff -r c856533343bf -r 340862a9e1cc xen/arch/x86/hvm/hvm.c
--- a/xen/arch/x86/hvm/hvm.c Mon Feb 28 12:21:52 2011 +0100
+++ b/xen/arch/x86/hvm/hvm.c Mon Feb 28 12:21:54 2011 +0100
@@ -645,10 +645,15 @@
return 0;
}
-static bool_t hvm_efer_valid(uint64_t value, uint64_t efer_validbits)
+static bool_t hvm_efer_valid(struct domain *d,
+ uint64_t value, uint64_t efer_validbits)
{
+ if ( nestedhvm_enabled(d) && cpu_has_svm )
+ efer_validbits |= EFER_SVME;
+
return !((value & ~efer_validbits) ||
((sizeof(long) != 8) && (value & EFER_LME)) ||
+ (!cpu_has_svm && (value & EFER_SVME)) ||
(!cpu_has_nx && (value & EFER_NX)) ||
(!cpu_has_syscall && (value & EFER_SCE)) ||
(!cpu_has_lmsl && (value & EFER_LMSLE)) ||
@@ -662,6 +667,7 @@
struct vcpu *v;
struct hvm_hw_cpu ctxt;
struct segment_register seg;
+ uint64_t efer_validbits;
/* Which vcpu is this? */
vcpuid = hvm_load_instance(h);
@@ -700,9 +706,9 @@
return -EINVAL;
}
- if ( !hvm_efer_valid(
- ctxt.msr_efer,
- EFER_FFXSE | EFER_LMSLE | EFER_LME | EFER_LMA | EFER_NX | EFER_SCE) )
+ efer_validbits = EFER_FFXSE | EFER_LMSLE | EFER_LME | EFER_LMA
+ | EFER_NX | EFER_SCE;
+ if ( !hvm_efer_valid(d, ctxt.msr_efer, efer_validbits) )
{
gdprintk(XENLOG_ERR, "HVM restore: bad EFER 0x%"PRIx64"\n",
ctxt.msr_efer);
@@ -1294,14 +1300,15 @@
int hvm_set_efer(uint64_t value)
{
struct vcpu *v = current;
+ uint64_t efer_validbits;
value &= ~EFER_LMA;
- if ( !hvm_efer_valid(value,
- EFER_FFXSE | EFER_LMSLE | EFER_LME | EFER_NX | EFER_SCE) )
+ efer_validbits = EFER_FFXSE | EFER_LMSLE | EFER_LME | EFER_NX | EFER_SCE;
+ if ( !hvm_efer_valid(v->domain, value, efer_validbits) )
{
gdprintk(XENLOG_WARNING, "Trying to set reserved bit in "
- "EFER: %"PRIx64"\n", value);
+ "EFER: 0x%"PRIx64"\n", value);
hvm_inject_exception(TRAP_gp_fault, 0, 0);
return X86EMUL_EXCEPTION;
}
diff -r c856533343bf -r 340862a9e1cc xen/include/asm-x86/cpufeature.h
--- a/xen/include/asm-x86/cpufeature.h Mon Feb 28 12:21:52 2011 +0100
+++ b/xen/include/asm-x86/cpufeature.h Mon Feb 28 12:21:54 2011 +0100
@@ -212,6 +212,8 @@
#define cpu_has_rdtscp boot_cpu_has(X86_FEATURE_RDTSCP)
+#define cpu_has_svm boot_cpu_has(X86_FEATURE_SVM)
+
#endif /* __ASM_I386_CPUFEATURE_H */
/*
_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog
|