diff mbox

[RFC,4/5] xen/arm: move vpidr from arch_domain to arch_vcpu

Message ID 1474250936-27962-5-git-send-email-peng.fan@nxp.com (mailing list archive)
State New, archived
Headers show

Commit Message

Peng Fan Sept. 19, 2016, 2:08 a.m. UTC
From: Peng Fan <peng.fan@nxp.com>

Move vpidr from arch_domain to arch_vcpu.

In order to support Big.Little, Big CPUs and Little CPUs are
assigned to different cpupools.

when a new domain is to be created with cpupool specificed, the domain
is first assigned to cpupool0 and then the domain moved from cpupool0
to the specified cpupool.

In domain creation process arch_domain_create, vpidr is initialized
with boot_cpu_data.midr.bits. But Big cpupool and Little cpupool have
different midr, the guest vcpu midr should use the midr info from
cpupool which the domain runs in.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
Cc: Stefano Stabellini <sstabellini@kernel.org>
Cc: Julien Grall <julien.grall@arm.com>
---
 xen/arch/arm/domain.c        | 9 +++++----
 xen/arch/arm/traps.c         | 2 +-
 xen/include/asm-arm/domain.h | 9 ++++++---
 3 files changed, 12 insertions(+), 8 deletions(-)
diff mbox

Patch

diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c
index 20bb2ba..934c112 100644
--- a/xen/arch/arm/domain.c
+++ b/xen/arch/arm/domain.c
@@ -14,6 +14,7 @@ 
 #include <xen/init.h>
 #include <xen/lib.h>
 #include <xen/sched.h>
+#include <xen/sched-if.h>
 #include <xen/softirq.h>
 #include <xen/wait.h>
 #include <xen/errno.h>
@@ -150,7 +151,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 */
@@ -521,6 +522,9 @@  int vcpu_initialise(struct vcpu *v)
 
     v->arch.actlr = READ_SYSREG32(ACTLR_EL1);
 
+    /* The virtual ID matches the physical id of the cpu in the cpupool */
+    v->arch.vpidr = v->domain->cpupool->info.midr;
+
     processor_vcpu_initialise(v);
 
     if ( (rc = vcpu_vgic_init(v)) != 0 )
@@ -562,9 +566,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/traps.c b/xen/arch/arm/traps.c
index 683bcb2..c0ad97e 100644
--- a/xen/arch/arm/traps.c
+++ b/xen/arch/arm/traps.c
@@ -1975,7 +1975,7 @@  static 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 |= ((d->vcpu[0]->arch.vpidr >> 20) & 0xf) | (d->vcpu[0]->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 9452fcd..b998c6d 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;
@@ -173,6 +170,12 @@  struct arch_vcpu
     uint32_t esr;
 #endif
 
+    /*
+     * Holds the value of the Virtualization Processor ID.
+     * This is the value returned by Non-secure EL1 reads of MIDR_EL1.
+     */
+    uint32_t vpidr;
+
     uint32_t ifsr; /* 32-bit guests only */
     uint32_t afsr0, afsr1;