On big.LITTLE systems not all cores have the same midr. Instead of
storing only one vpidr per domain, make it per vcpu and 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 <sstabell...@kernel.org>

---

- remove warning message
- make vpidr per vcpu
---
 xen/arch/arm/domain.c        | 6 ++----
 xen/arch/arm/vcpreg.c        | 4 ++--
 xen/include/asm-arm/domain.h | 6 +++---
 3 files changed, 7 insertions(+), 9 deletions(-)

diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c
index fb51415..41d5d25 100644
--- a/xen/arch/arm/domain.c
+++ b/xen/arch/arm/domain.c
@@ -180,7 +180,7 @@ static void ctxt_switch_to(struct vcpu *n)
 
     p2m_restore_state(n);
 
-    WRITE_SYSREG32(n->domain->arch.vpidr, VPIDR_EL2);
+    WRITE_SYSREG32(n->arch.vpidr, VPIDR_EL2);
     WRITE_SYSREG(n->arch.vmpidr, VMPIDR_EL2);
 
     /* VGIC */
@@ -316,6 +316,7 @@ static void continue_new_vcpu(struct vcpu *prev)
 {
     current->arch.actlr = READ_SYSREG32(ACTLR_EL1);
     processor_vcpu_initialise(current);
+    current->arch.vpidr = current_cpu_data.midr.bits;
 
     schedule_tail(prev);
 
@@ -595,9 +596,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);
diff --git a/xen/arch/arm/vcpreg.c b/xen/arch/arm/vcpreg.c
index e363183..ee53405 100644
--- a/xen/arch/arm/vcpreg.c
+++ b/xen/arch/arm/vcpreg.c
@@ -230,7 +230,7 @@ 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;
+    struct vcpu *v = current;
 
     if ( !check_conditional_instr(regs, hsr) )
     {
@@ -295,7 +295,7 @@ 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 |= ((v->arch.vpidr >> 20) & 0xf) | (v->arch.vpidr & 0xf);
         set_user_reg(regs, regidx, val);
 
         break;
diff --git a/xen/include/asm-arm/domain.h b/xen/include/asm-arm/domain.h
index 4fe189b..049fc2d 100644
--- a/xen/include/asm-arm/domain.h
+++ b/xen/include/asm-arm/domain.h
@@ -63,9 +63,6 @@ struct arch_domain
         RELMEM_done,
     } relmem;
 
-    /* Virtual CPUID */
-    uint32_t vpidr;
-
     struct {
         uint64_t offset;
     } phys_timer_base;
@@ -219,6 +216,9 @@ struct arch_vcpu
     uint32_t actlr, sctlr;
     uint32_t cpacr;
 
+    /* Virtual CPUID */
+    uint32_t vpidr;
+
     uint32_t contextidr;
     register_t tpidr_el0;
     register_t tpidr_el1;
-- 
1.9.1


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

Reply via email to