Christoph Egger
2010-Apr-15 12:39 UTC
[Xen-devel] [PATCH 14/18] Nested Virtualization: svm specific implementation
Signed-off-by: Christoph Egger <Christoph.Egger@amd.com> -- ---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 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Tim Deegan
2010-Apr-16 13:22 UTC
Re: [Xen-devel] [PATCH 14/18] Nested Virtualization: svm specific implementation
> +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.> + > + 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; > +}-- Tim Deegan <Tim.Deegan@citrix.com> Principal Software Engineer, XenServer Engineering Citrix Systems UK Ltd. (Company #02937203, SL9 0BG) _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel