Nested Virtualization: svm specific implementation
PATCH 14/18 Nested Virtualization: svm specific implementation
Signed-off-by Christoph Egger <[email protected]>
Signature · 6 lines
---to satisfy European Law for business letters: Advanced Micro Devices GmbH Karl-Hammerschmidt-Str. 34, 85609 Dornach b. Muenchen Geschaeftsfuehrer: Andrew Bowd, Thomas M. McCoy, Giuliano Meroni Sitz: Dornach, Gemeinde Aschheim, Landkreis Muenchen Registergericht Muenchen, HRB Nr. 43632
# HG changeset patch
# User cegger
# Date 1271330309 -7200
Implement SVM specific part for Nested Virtualization.
xen/arch/x86/hvm/svm/emulate.c +11 -1
@@ -100,6 +100,11 @@ MAKE_INSTR(VMCALL, 3, 0x0f, 0x01, 0xd9);MAKE_INSTR (HLT ,1 ,0xf4 );MAKE_INSTR (INT3 ,1 ,0xcc );MAKE_INSTR (RDTSC ,2 ,0x0f ,0x31 ); +MAKE_INSTR (VMRUN ,3 ,0x0f ,0x01 ,0xd8 ); +MAKE_INSTR (VMLOAD ,3 ,0x0f ,0x01 ,0xda ); +MAKE_INSTR (VMSAVE ,3 ,0x0f ,0x01 ,0xdb ); +MAKE_INSTR (STGI ,3 ,0x0f ,0x01 ,0xdc ); +MAKE_INSTR (CLGI ,3 ,0x0f ,0x01 ,0xdd );static const u8 *opc_bytes[INSTR_MAX_COUNT ] = {
@@ -111,7 +116,12 @@ static const u8 *opc_bytes[INSTR_MAX_COU [INSTR_VMCALL] = OPCODE_VMCALL, [INSTR_HLT] = OPCODE_HLT, [INSTR_INT3] = OPCODE_INT3, - [INSTR_RDTSC] = OPCODE_RDTSC + [INSTR_RDTSC] = OPCODE_RDTSC, + [INSTR_VMRUN] = OPCODE_VMRUN, + [INSTR_VMLOAD] = OPCODE_VMLOAD, + [INSTR_VMSAVE] = OPCODE_VMSAVE, + [INSTR_STGI] = OPCODE_STGI, + [INSTR_CLGI] = OPCODE_CLGI, };static int fetch (struct vcpu *v,u8 *buf,unsigned long addr,int len)
xen/arch/x86/hvm/svm/svm.c +836 -13
942 lines not on this page · raw message
xen/include/asm-x86/hvm/svm/emulate.h +5 -0
@@ -31,6 +31,11 @@ enum instruction_index {INSTR_HLT ,INSTR_INT3 ,INSTR_RDTSC , +INSTR_VMRUN , +INSTR_VMLOAD , +INSTR_VMSAVE , +INSTR_STGI , +INSTR_CLGI ,INSTR_MAX_COUNT /* Must be last - Number of instructions supported */ };
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
xen/arch/x86/hvm/svm/svm.c static int svm_cpu_prepare(unsigned int · line 1099
Quoted 10 lines
xen/arch/x86/hvm/svm/svm.c +10
-0+static int nsvm_vmrun_permissionmap (struct vcpu *v) +{ +struct arch_svm_struct *arch_svm = &v->arch.hvm_svm; +struct vmcb_struct *ns_vmcb =VCPU_NESTEDHVM (v).nh_vmcb; +struct vmcb_struct *host_vmcb = arch_svm->vmcb; +unsigned long *ns_iopm_ptr, *ns_msrpm_ptr; +unsigned int i; +/* Must be static or hvm_copy_from_guest_phys fails, otherwise. */ + static uint8_t ns_iopm[IOPM_SIZE] __attribute__((__aligned__)); + static uint8_t ns_msrpm[MSRPM_SIZE] __attribute__((__aligned__));
*boggle*
Maybe I missed the locking that makes this safe.
Tim.
Quoted 25 lines
xen/arch/x86/hvm/svm/svm.c +25
-0+ + ns_iopm_ptr = (unsigned long *)ns_iopm; + ns_msrpm_ptr = (unsigned long *)ns_msrpm; + +hvm_copy_from_guest_phys (ns_iopm, ns_vmcb->iopm_base_pa,IOPM_SIZE ); +hvm_copy_from_guest_phys (ns_msrpm, ns_vmcb->msrpm_base_pa,MSRPM_SIZE ); +/* hvm_io_bitmap has type unsigned long, thus +* BYTES_PER_LONG. +*/ +for (i =0 ; i <IOPM_SIZE /BYTES_PER_LONG ; i++) +VCPU_NESTEDHVM (v).nh_iopm[i] = hvm_io_bitmap[i] | ns_iopm_ptr[i]; + +/* v->arch.hvm_svm.msrpm has type unsigned long, thus +* BYTES_PER_LONG. +*/ +for (i =0 ; i <MSRPM_SIZE /BYTES_PER_LONG ; i++) +VCPU_NESTEDHVM (v).nh_msrpm[i] = arch_svm->msrpm[i] | ns_msrpm_ptr[i]; + + host_vmcb->iopm_base_pa = + (uint64_t )virt_to_maddr (VCPU_NESTEDHVM (v).nh_iopm); + host_vmcb->msrpm_base_pa = + (uint64_t )virt_to_maddr (VCPU_NESTEDHVM (v).nh_msrpm); + +return 0 ; +}
Signature · 3 lines
Tim Deegan <[email protected]> Principal Software Engineer, XenServer Engineering Citrix Systems UK Ltd. (Company #02937203, SL9 0BG)