From: Tim Deegan Subject: Re: [PATCH 14/18] Nested Virtualization: svm specific implementation Date: Fri, 16 Apr 2010 14:22:22 +0100 Message-ID: <20100416132222.GI31304@whitby.uk.xensource.com> References: <201004151439.15634.Christoph.Egger@amd.com> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Return-path: Content-Disposition: inline In-Reply-To: <201004151439.15634.Christoph.Egger@amd.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Christoph Egger Cc: "xen-devel@lists.xensource.com" List-Id: xen-devel@lists.xenproject.org > +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 Principal Software Engineer, XenServer Engineering Citrix Systems UK Ltd. (Company #02937203, SL9 0BG)