]> xenbits.xensource.com Git - people/dariof/xen.git/commitdiff
xen/arm: set VPIDR based on the MIDR value of the underlying pCPU
authorStefano Stabellini <sstabellini@kernel.org>
Tue, 6 Mar 2018 19:29:23 +0000 (11:29 -0800)
committerStefano Stabellini <sstabellini@kernel.org>
Tue, 6 Mar 2018 19:32:51 +0000 (11:32 -0800)
On big.LITTLE systems not all cores have the same MIDR. Instead of
storing only one VPIDR per domain, initialize it to the value of the
MIDR of the pCPU where the vCPU will run.

This way, assuming that the vCPU has been created with the right pCPU
affinity, the guest will be able to read the right VPIDR value, matching
the one of the physical cpu.

Signed-off-by: Stefano Stabellini <sstabellini@kernel.org>
Reviewed-by: Julien Grall <julien.grall@arm.com>
xen/arch/arm/domain.c
xen/arch/arm/vcpreg.c
xen/include/asm-arm/domain.h

index fb514151066fc0bc8cb8e01a5fdd8cbf5c7a467e..8de4c0a34338589a5621572e909d3b30c3a6d141 100644 (file)
@@ -172,6 +172,8 @@ static void ctxt_switch_from(struct vcpu *p)
 
 static void ctxt_switch_to(struct vcpu *n)
 {
+    uint32_t vpidr;
+
     /* When the idle VCPU is running, Xen will always stay in hypervisor
      * mode. Therefore we don't need to restore the context of an idle VCPU.
      */
@@ -180,7 +182,8 @@ static void ctxt_switch_to(struct vcpu *n)
 
     p2m_restore_state(n);
 
-    WRITE_SYSREG32(n->domain->arch.vpidr, VPIDR_EL2);
+    vpidr = READ_SYSREG32(MIDR_EL1);
+    WRITE_SYSREG32(vpidr, VPIDR_EL2);
     WRITE_SYSREG(n->arch.vmpidr, VMPIDR_EL2);
 
     /* VGIC */
@@ -595,9 +598,6 @@ int arch_domain_create(struct domain *d, unsigned int domcr_flags,
     if ( (d->shared_info = alloc_xenheap_pages(0, 0)) == NULL )
         goto fail;
 
-    /* Default the virtual ID to match the physical */
-    d->arch.vpidr = boot_cpu_data.midr.bits;
-
     clear_page(d->shared_info);
     share_xen_page_with_guest(
         virt_to_page(d->shared_info), d, XENSHARE_writable);
index e363183ba80870c4b471d6f44c5a9e5cbeb3a01f..b04d996fd39d50d3b3f6364cdb3e2cb699737d6e 100644 (file)
@@ -230,7 +230,6 @@ void do_cp14_32(struct cpu_user_regs *regs, const union hsr hsr)
 {
     const struct hsr_cp32 cp32 = hsr.cp32;
     int regidx = cp32.reg;
-    struct domain *d = current->domain;
 
     if ( !check_conditional_instr(regs, hsr) )
     {
@@ -295,7 +294,8 @@ void do_cp14_32(struct cpu_user_regs *regs, const union hsr hsr)
          *  - Variant and Revision bits match MDIR
          */
         val = (1 << 24) | (5 << 16);
-        val |= ((d->arch.vpidr >> 20) & 0xf) | (d->arch.vpidr & 0xf);
+        val |= ((current_cpu_data.midr.bits >> 20) & 0xf) |
+                (current_cpu_data.midr.bits & 0xf);
         set_user_reg(regs, regidx, val);
 
         break;
index 4fe189b1c3bdcbf6e7071a510ec6e0709e111041..0dd8c954e2542d967feec282799641a694323b91 100644 (file)
@@ -63,9 +63,6 @@ struct arch_domain
         RELMEM_done,
     } relmem;
 
-    /* Virtual CPUID */
-    uint32_t vpidr;
-
     struct {
         uint64_t offset;
     } phys_timer_base;