Nested Virtualization: CRn & paged real mode
PATCH 5/13 Nested Virtualization: CRn & paged real mode
Signature · 6 lines
---to satisfy European Law for business letters: Advanced Micro Devices GmbH Einsteinring 24, 85609 Dornach b. Muenchen Geschaeftsfuehrer: Alberto Bozzo, Andrew Bowd Sitz: Dornach, Gemeinde Aschheim, Landkreis Muenchen Registergericht Muenchen, HRB Nr. 43632
# HG changeset patch
# User cegger
# Date 1283345878 -7200
Allow paged real mode during vmrun emulation. Emulate cr0 and cr4 when guest does not intercept them.
xen/arch/x86/hvm/hvm.c +7 -2
@@ -54,6 +54,7 @@#include <asm/hvm/support.h> #include <asm/hvm/cacheattr.h> #include <asm/hvm/trace.h> +#include <asm/hvm/nestedhvm.h> #include <asm/mtrr.h> #include <asm/apic.h> #include <public/sched.h>
@@ -1109,9 +1110,13 @@ int hvm_set_cr0(unsigned long value)/* ET is reserved and should be always be 1. */ value |=X86_CR0_ET ; -if ( (value & (X86_CR0_PE |X86_CR0_PG )) ==X86_CR0_PG ) +if ( !nestedhvm_vmentry_emulate (v) && + (value & (X86_CR0_PE |X86_CR0_PG )) ==X86_CR0_PG ) goto gpf; +if (nestedhvm_vcpu_in_guestmode (v) ) + value &= ~(X86_CR0_CD |X86_CR0_NW ); +if ( (value &X86_CR0_PG ) && !(old_value &X86_CR0_PG ) ) {if ( v->arch.hvm_vcpu.guest_efer &EFER_LME )
@@ -1163,7 +1168,7 @@ int hvm_set_cr0(unsigned long value) } } -if (has_arch_mmios (v->domain) ) +if ( !nestedhvm_vmentry_emulate (v) &&has_arch_mmios (v->domain) ) {if ( (value &X86_CR0_CD ) && !(value &X86_CR0_NW ) ) {
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Hi,
Quoted 12 lines
diff -r
0199b689a2d0-re0eae5b67977xen/arch/x86/hvm/hvm.cxen/arch/x86/hvm/hvm.c +1
-0@@ -54,6 +54,7 @@#include <asm/hvm/support.h> #include <asm/hvm/cacheattr.h> #include <asm/hvm/trace.h> +#include <asm/hvm/nestedhvm.h> #include <asm/mtrr.h> #include <asm/apic.h> #include <public/sched.h>
xen/arch/x86/hvm/hvm.c int hvm_set_cr0(unsigned long value) · line 1115
Quoted 7 lines
xen/arch/x86/hvm/hvm.c +2
-1@@ -1109,9 +1110,13 @@ int hvm_set_cr0(unsigned long value)/* ET is reserved and should be always be 1. */ value |=X86_CR0_ET ; -if ( (value & (X86_CR0_PE |X86_CR0_PG )) ==X86_CR0_PG ) +if ( !nestedhvm_vmentry_emulate (v) && + (value & (X86_CR0_PE |X86_CR0_PG )) ==X86_CR0_PG ) goto gpf;
The change above makes perfect sense: nested SVM guests should be allowed to enter paged real mode.
But I don't understand either of the changes below. Can you explain why the cache control bits get special treatment?
Tim.
Quoted 15 lines
xen/arch/x86/hvm/hvm.c +4
-1+if (nestedhvm_vcpu_in_guestmode (v) ) + value &= ~(X86_CR0_CD |X86_CR0_NW ); +if ( (value &X86_CR0_PG ) && !(old_value &X86_CR0_PG ) ) {if ( v->arch.hvm_vcpu.guest_efer &EFER_LME )@@ -1163,7 +1168,7 @@ int hvm_set_cr0(unsigned long value) } } -if (has_arch_mmios (v->domain) ) +if ( !nestedhvm_vmentry_emulate (v) &&has_arch_mmios (v->domain) ) {if ( (value &X86_CR0_CD ) && !(value &X86_CR0_NW ) ) {
Signature · 3 lines
Tim Deegan <[email protected]> Principal Software Engineer, XenServer Engineering Citrix Systems UK Ltd. (Company #02937203, SL9 0BG)
Quoted 25 lines · On Wednesday 08 September 2010 17:11:33 Tim Deegan wrote:
Hi,
Quoted 12 lines
diff -r
0199b689a2d0-re0eae5b67977xen/arch/x86/hvm/hvm.cxen/arch/x86/hvm/hvm.c +1
-0@@ -54,6 +54,7 @@#include <asm/hvm/support.h> #include <asm/hvm/cacheattr.h> #include <asm/hvm/trace.h> +#include <asm/hvm/nestedhvm.h> #include <asm/mtrr.h> #include <asm/apic.h> #include <public/sched.h> xen/arch/x86/hvm/hvm.c int hvm_set_cr0(unsigned long value) · line 1115
Quoted 7 lines
xen/arch/x86/hvm/hvm.c +2
-1@@ -1109,9 +1110,13 @@ int hvm_set_cr0(unsigned long value)/* ET is reserved and should be always be 1. */ value |=X86_CR0_ET ; -if ( (value & (X86_CR0_PE |X86_CR0_PG )) ==X86_CR0_PG ) +if ( !nestedhvm_vmentry_emulate (v) && + (value & (X86_CR0_PE |X86_CR0_PG )) ==X86_CR0_PG ) goto gpf;The change above makes perfect sense: nested SVM guests should be allowed to enter paged real mode.
Quoted 2 lines
But I don't understand either of the changes below. Can you explain why the cache control bits get special treatment?
Your question confuses me related to this mail:
http://lists.xensource.com/archives/html/xen-devel/2010-08/msg00432.html
Please explain what you want to know.
Christoph
Quoted 17 lines
Tim.
Quoted 15 lines
xen/arch/x86/hvm/hvm.c +4
-1+if (nestedhvm_vcpu_in_guestmode (v) ) + value &= ~(X86_CR0_CD |X86_CR0_NW ); +if ( (value &X86_CR0_PG ) && !(old_value &X86_CR0_PG ) ) {if ( v->arch.hvm_vcpu.guest_efer &EFER_LME )@@ -1163,7 +1168,7 @@ int hvm_set_cr0(unsigned long value) } } -if (has_arch_mmios (v->domain) ) +if ( !nestedhvm_vmentry_emulate (v) &&has_arch_mmios (v->domain) ) {if ( (value &X86_CR0_CD ) && !(value &X86_CR0_NW ) ) {
Signature · 6 lines
---to satisfy European Law for business letters: Advanced Micro Devices GmbH Einsteinring 24, 85609 Dornach b. Muenchen Geschaeftsfuehrer: Alberto Bozzo, Andrew Bowd Sitz: Dornach, Gemeinde Aschheim, Landkreis Muenchen Registergericht Muenchen, HRB Nr. 43632
Quoted 26 lines · Christoph Egger
Quoted 25 lines · On Wednesday 08 September 2010 17:11:33 Tim Deegan wrote:
Hi,
Quoted 12 lines
diff -r
0199b689a2d0-re0eae5b67977xen/arch/x86/hvm/hvm.cxen/arch/x86/hvm/hvm.c +1
-0@@ -54,6 +54,7 @@#include <asm/hvm/support.h> #include <asm/hvm/cacheattr.h> #include <asm/hvm/trace.h> +#include <asm/hvm/nestedhvm.h> #include <asm/mtrr.h> #include <asm/apic.h> #include <public/sched.h> xen/arch/x86/hvm/hvm.c int hvm_set_cr0(unsigned long value) · line 1115
Quoted 7 lines
xen/arch/x86/hvm/hvm.c +2
-1@@ -1109,9 +1110,13 @@ int hvm_set_cr0(unsigned long value)/* ET is reserved and should be always be 1. */ value |=X86_CR0_ET ; -if ( (value & (X86_CR0_PE |X86_CR0_PG )) ==X86_CR0_PG ) +if ( !nestedhvm_vmentry_emulate (v) && + (value & (X86_CR0_PE |X86_CR0_PG )) ==X86_CR0_PG ) goto gpf;The change above makes perfect sense: nested SVM guests should be allowed to enter paged real mode.
Quoted 7 lines
Quoted 2 lines
But I don't understand either of the changes below. Can you explain why the cache control bits get special treatment?
Your question confuses me related to this mail:
http://lists.xensource.com/archives/html/xen-devel/2010-08/msg00432.htmlPlease explain what you want to know.
Sorry, I misread the patch last time.
| I understand the paged-real-mode case, but why do you also allow CR0.CD | and CR0.NW for nested VMs?
because the patch seemed to do two things:
- allow nested VMs to ask for paged real mode; and
- honour CR0.CD and CR0.NW for nested VMs
and I didn't understand the second one. I see now that it actually explicitly _doesn't_ honour CR0.CD and CR0.NW for nested VMs, which makes more sense. Sorry for the confusing reply.
I don't think that needs to happen -- it's up to the L1 VMM to decide whether the L2 VMM should be allowed to set cache control bits in CR0, so only the first change in this patch is needed.
Cheers,
Tim.
Signature · 3 lines
Tim Deegan <[email protected]> Principal Software Engineer, XenServer Engineering Citrix Systems UK Ltd. (Company #02937203, SL9 0BG)