xen/arm: Remove processor specific setup in vcpu_initialise
authorJulien Grall <julien.grall@linaro.org>
Wed, 5 Mar 2014 04:46:25 +0000 (12:46 +0800)
committerIan Campbell <ian.campbell@citrix.com>
Fri, 14 Mar 2014 14:56:23 +0000 (14:56 +0000)
This patch introduces the possibility to have specific processor callbacks
that can be called in various place.

Currently VCPU initialisation code contains processor specific setup (for
Cortex A7 and Cortex A15) for the ACTRL registers. It's possible to have
processor with a different layout for this register.

Move this setup in a specific callback for ARM v7 processor.

Signed-off-by: Julien Grall <julien.grall@linaro.org>
Reviewed-by: Tim Deegan <tim@xen.org>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Cc: marc.ceeeee@gmail.com
xen/arch/arm/Makefile
xen/arch/arm/arm32/Makefile
xen/arch/arm/arm32/proc-caxx.c [new file with mode: 0644]
xen/arch/arm/arm32/proc-v7.S
xen/arch/arm/domain.c
xen/arch/arm/processor.c [new file with mode: 0644]
xen/arch/arm/setup.c
xen/include/asm-arm/procinfo.h

index d70f6d5ca0b2969353f33284452242f7c2705cb5..63e0460f7caf16e38b5428a32aef8350fa53a1b9 100644 (file)
@@ -32,6 +32,7 @@ obj-y += vuart.o
 obj-y += hvm.o
 obj-y += device.o
 obj-y += decode.o
+obj-y += processor.o
 
 #obj-bin-y += ....o
 
index 65ecff4f7c0339e4b3fab29cd30435369d09176f..df0e7dee0a100f963427201a7fae69ab2de9084c 100644 (file)
@@ -1,7 +1,7 @@
 subdir-y += lib
 
 obj-y += entry.o
-obj-y += proc-v7.o
+obj-y += proc-v7.o proc-caxx.o
 
 obj-y += traps.o
 obj-y += domain.o
diff --git a/xen/arch/arm/arm32/proc-caxx.c b/xen/arch/arm/arm32/proc-caxx.c
new file mode 100644 (file)
index 0000000..9166a1d
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * xen/arch/arm/arm32/proc-caxx.c
+ *
+ * arm V7 Cortex A15 and A7 initialisation
+ *
+ * Julien Grall <julien.grall@linaro.org>
+ * Copyright (c) 2014 Linaro Limited.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+#include <asm/procinfo.h>
+#include <asm/processor.h>
+
+#define ACTLR_SMP (1 << 6)
+
+static void caxx_vcpu_initialise(struct vcpu *v)
+{
+    /* If the guest has more 1 VCPU, enable the SMP bit in ACTLR */
+    if ( v->domain->max_vcpus > 1 )
+        v->arch.actlr |= ACTLR_SMP;
+    else
+        v->arch.actlr &= ~ACTLR_SMP;
+}
+
+const struct processor caxx_processor = {
+    .vcpu_initialise = caxx_vcpu_initialise,
+};
index 8fb42dbca29bc28ac44815ebd0be9580037c60b6..b0d534347e2c88f798d9b8ea810e4558cb11a1ac 100644 (file)
@@ -35,6 +35,7 @@ __v7_ca15mp_proc_info:
         .long 0x410FC0F0             /* Cortex-A15 */
         .long 0xFF0FFFF0             /* Mask */
         .long ca15mp_init
+        .long caxx_processor
         .size __v7_ca15mp_proc_info, . - __v7_ca15mp_proc_info
 
         .section ".init.proc.info", #alloc, #execinstr
@@ -43,6 +44,7 @@ __v7_ca7mp_proc_info:
         .long 0x410FC070             /* Cortex-A7 */
         .long 0xFF0FFFF0             /* Mask */
         .long ca7mp_init
+        .long caxx_processor
         .size __v7_ca7mp_proc_info, . - __v7_ca7mp_proc_info
 
         .section ".init.proc.info", #alloc, #execinstr
@@ -51,6 +53,7 @@ __v7_brahma15mp_proc_info:
         .long 0x420F00F2             /* Broadcom Brahma-B15 */
         .long 0xFF0FFFFF             /* Mask */
         .long brahma15mp_init
+        .long caxx_processor
         .size __v7_brahma15mp_proc_info, . - __v7_brahma15mp_proc_info
 
 /*
index 8f20fdf728b95ddc226e2a1c8ee8e9c3cfca4464..82a1e7965b0351044c3edae5fc2405c06cd8a2c3 100644 (file)
@@ -28,7 +28,7 @@
 #include <asm/irq.h>
 #include <asm/cpufeature.h>
 #include <asm/vfp.h>
-#include <asm/processor-ca15.h>
+#include <asm/procinfo.h>
 
 #include <asm/gic.h>
 #include <asm/platform.h>
@@ -480,11 +480,7 @@ int vcpu_initialise(struct vcpu *v)
 
     v->arch.actlr = READ_SYSREG32(ACTLR_EL1);
 
-    /* XXX: Handle other than CA15 cpus */
-    if ( v->domain->max_vcpus > 1 )
-        v->arch.actlr |= ACTLR_CA15_SMP;
-    else
-        v->arch.actlr &= ~ACTLR_CA15_SMP;
+    processor_vcpu_initialise(v);
 
     if ( (rc = vcpu_vgic_init(v)) != 0 )
         return rc;
diff --git a/xen/arch/arm/processor.c b/xen/arch/arm/processor.c
new file mode 100644 (file)
index 0000000..8c425ce
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * xen/arch/arm/processor.c
+ *
+ * Helpers to execute processor specific code.
+ *
+ * Julien Grall <julien.grall@linaro.org>
+ * Copyright (C) 2014 Linaro Limited.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+#include <asm/procinfo.h>
+
+static const struct processor *processor = NULL;
+
+void __init processor_setup(void)
+{
+    const struct proc_info_list *procinfo;
+
+    procinfo = lookup_processor_type();
+    if ( !procinfo )
+        return;
+
+    processor = procinfo->processor;
+}
+
+void processor_vcpu_initialise(struct vcpu *v)
+{
+    if ( !processor || !processor->vcpu_initialise )
+        return;
+
+    processor->vcpu_initialise(v);
+}
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
index 9480f42cac6640bba224042d1af9aac6fc179383..4a3016a9540d9d205f9d696f388e0f21e09125c7 100644 (file)
@@ -43,6 +43,7 @@
 #include <asm/gic.h>
 #include <asm/cpufeature.h>
 #include <asm/platform.h>
+#include <asm/procinfo.h>
 
 struct cpuinfo_arm __read_mostly boot_cpu_data;
 
@@ -149,6 +150,8 @@ static void __init processor_id(void)
     {
         printk("32-bit Execution: Unsupported\n");
     }
+
+    processor_setup();
 }
 
 static void dt_unreserved_regions(paddr_t s, paddr_t e,
index 9d3feb7d0a03a4b375e8467452d60d963358ec62..26306b35f81c447b56d1b39e726aedfd90a00c25 100644 (file)
 #ifndef __ASM_ARM_PROCINFO_H
 #define __ASM_ARM_PROCINFO_H
 
+#include <xen/sched.h>
+
+struct processor {
+    /* Initialize specific processor register for the new VPCU*/
+    void (*vcpu_initialise)(struct vcpu *v);
+};
+
 struct proc_info_list {
-       unsigned int            cpu_val;
-       unsigned int            cpu_mask;
+    unsigned int        cpu_val;
+    unsigned int        cpu_mask;
     void                (*cpu_init)(void);
+    struct processor    *processor;
 };
 
+const __init struct proc_info_list *lookup_processor_type(void);
+
+void __init processor_setup(void);
+void processor_vcpu_initialise(struct vcpu *v);
+
 #endif