Implement VFP context switch for arm32
v4 cover Implement VFP context switch for arm32
Hello,
This is the fourth version of this patch series.
I have only implemented the VFP context switch support for arm32 and add dummy function to avoid avoid compilation breakage on arm64.
For all the changes see each patch.
Cheers,
Julien Grall (2):
xen/arm: don't enable VFP on XEN during the boot xen/arm32: implement VFP context switch
xen/arch/arm/Rules.mk | 2 +- xen/arch/arm/arm32/Makefile | 1 + xen/arch/arm/arm32/vfp.c | 95 +++++++++++++++++++++++++++++++++++++++ xen/arch/arm/arm64/Makefile | 1 + xen/arch/arm/arm64/vfp.c | 13 ++++++ xen/arch/arm/domain.c | 7 ++- xen/arch/arm/setup.c | 3 -- xen/arch/arm/smpboot.c | 2 - xen/include/asm-arm/arm32/vfp.h | 41 +++++++++++++++++ xen/include/asm-arm/arm64/vfp.h | 16 +++++++ xen/include/asm-arm/cpregs.h | 9 ++++ xen/include/asm-arm/domain.h | 4 ++ xen/include/asm-arm/vfp.h | 42 +++++------------ 13 files changed, 198 insertions(+), 38 deletions(-) create mode 100644 xen/arch/arm/arm32/vfp.c create mode 100644 xen/arch/arm/arm64/vfp.c create mode 100644 xen/include/asm-arm/arm32/vfp.h create mode 100644 xen/include/asm-arm/arm64/vfp.h
Signature · 1 line
1.7.10.4
PATCH v4 1/2 xen/arm: don't enable VFP on XEN during the boot
We can safely remove VFP support in XEN because:
- the guest will enable VFP support when a process requires it
- XEN doesn't use VFP
---
Changes in v2:
- Remove asm/vfp.h and all the inclusions of this header
--- xen/arch/arm/Rules.mk | 2 +- xen/arch/arm/setup.c | 3 --- xen/arch/arm/smpboot.c | 2 -- xen/include/asm-arm/vfp.h | 43 ------------------------------------------- 4 files changed, 1 insertion(+), 49 deletions(-) delete mode 100644 xen/include/asm-arm/vfp.h
xen/arch/arm/Rules.mk +1 -1
@@ -22,7 +22,7 @@ arm := y ifeq ($(TARGET_SUBARCH),arm32) # Prevent floating-point variables from creeping into Xen. CFLAGS += -msoft-float -CFLAGS += -mcpu=cortex-a15 -mfpu=vfpv3 -mfloat-abi=softfp +CFLAGS += -mcpu=cortex-a15 arm32 := y arm64 := n endif
xen/arch/arm/setup.c +0 -3
@@ -38,7 +38,6 @@#include <asm/page.h> #include <asm/current.h> #include <asm/setup.h> -#include <asm/vfp.h> #include <asm/early_printk.h> #include <asm/gic.h> #include <asm/cpufeature.h>
@@ -457,8 +456,6 @@ void __init start_xen(unsigned long boot_phys_offset,setup_virt_paging (); -enable_vfp (); -softirq_init ();tasklet_subsys_init ();
xen/arch/arm/smpboot.c +0 -2
@@ -28,7 +28,6 @@#include <xen/softirq.h> #include <xen/timer.h> #include <xen/irq.h> -#include <asm/vfp.h> #include <asm/gic.h> cpumask_t cpu_online_map;
@@ -153,7 +152,6 @@ void __cpuinit start_secondary(unsigned long boot_phys_offset,setup_virt_paging ();mmu_init_secondary_cpu (); -enable_vfp ();gic_init_secondary_cpu ();
xen/include/asm-arm/vfp.h deleted +0 -43
43 lines not on this page · raw message
Signature · 1 line
1.7.10.4
PATCH v4 2/2 xen/arm32: implement VFP context switch
In reply to Julien GrallAdd support for VFP context switch on arm32 and a dummy support for arm64
---
Changes in v4:
- Use Q in assembly constraint
Changes in v3:
- Add vfp_init to check if the processor supports VFP 3
- Add clobber memory
- Remove tmps
- s/COFNIG_ARM64/CONFIG_ARM64/ in include/asm/arm.h
Changes in v2:
- Fix all the small errors (type, lost headers...)
- Add some comments
--- xen/arch/arm/arm32/Makefile | 1 + xen/arch/arm/arm32/vfp.c | 95 +++++++++++++++++++++++++++++++++++++++ xen/arch/arm/arm64/Makefile | 1 + xen/arch/arm/arm64/vfp.c | 13 ++++++ xen/arch/arm/domain.c | 7 ++- xen/include/asm-arm/arm32/vfp.h | 41 +++++++++++++++++ xen/include/asm-arm/arm64/vfp.h | 16 +++++++ xen/include/asm-arm/cpregs.h | 9 ++++ xen/include/asm-arm/domain.h | 4 ++ xen/include/asm-arm/vfp.h | 25 +++++++++++ 10 files changed, 210 insertions(+), 2 deletions(-) create mode 100644 xen/arch/arm/arm32/vfp.c create mode 100644 xen/arch/arm/arm64/vfp.c create mode 100644 xen/include/asm-arm/arm32/vfp.h create mode 100644 xen/include/asm-arm/arm64/vfp.h create mode 100644 xen/include/asm-arm/vfp.h
xen/arch/arm/arm32/Makefile +1 -0
@@ -6,5 +6,6 @@ obj-y += proc-ca15.o obj-y += traps.o obj-y += domain.o +obj-y += vfp.o obj-$(EARLY_PRINTK) += debug.o
xen/arch/arm/arm32/vfp.c new file +95 -0
95 lines not on this page · raw message
xen/arch/arm/arm64/Makefile +1 -0
@@ -5,5 +5,6 @@ obj-y += mode_switch.o obj-y += traps.o obj-y += domain.o +obj-y += vfp.o obj-$(EARLY_PRINTK) += debug.o
xen/arch/arm/arm64/vfp.c new file +13 -0
@@ -0,0 +1,13 @@ +#include <xen/sched.h> +#include <asm/processor.h> +#include <asm/vfp.h> + +void vfp_save_state (struct vcpu *v) +{ +/* TODO: implement it */ +} + +void vfp_restore_state (struct vcpu *v) +{ +/* TODO: implement it */ +}
xen/arch/arm/domain.c +5 -2
@@ -27,6 +27,7 @@#include <asm/p2m.h> #include <asm/irq.h> #include <asm/cpufeature.h> +#include <asm/vfp.h> #include <asm/gic.h> #include "vtimer.h"
@@ -117,7 +118,8 @@ static void ctxt_switch_from(struct vcpu *p)/* XXX MPU */ -/* XXX VFP */ +/* VFP */ +vfp_save_state (p);/* VGIC */ gic_save_state (p);
@@ -143,7 +145,8 @@ static void ctxt_switch_to(struct vcpu *n)/* VGIC */ gic_restore_state (n); -/* XXX VFP */ +/* VFP */ +vfp_restore_state (n);/* XXX MPU */
xen/include/asm-arm/arm32/vfp.h new file +41 -0
41 lines not on this page · raw message
xen/include/asm-arm/arm64/vfp.h new file +16 -0
@@ -0,0 +1,16 @@ +#ifndef _ARM_ARM64_VFP_H +#define _ARM_ARM64_VFP_H + +struct vfp_state +{ +}; + +#endif /* _ARM_ARM64_VFP_H */ +/* +* Local variables: +* mode: C +* c-file-style: "BSD" +* c-basic-offset: 4 +* indent-tabs-mode: nil +* End: +*/
xen/include/asm-arm/cpregs.h +9 -0
@@ -60,6 +60,15 @@* arguments, which are cp,opc1,crn,crm,opc2. */ +/* Coprocessor 10 */ + +#define FPSID p10,7,c0,c0,0/* Floating-Point System ID Register */ +#define FPSCR p10,7,c1,c0,0/* Floating-Point Status and Control Register */ +#define MVFR0 p10,7,c7,c0,0/* Media and VFP Feature Register 0 */ +#define FPEXC p10,7,c8,c0,0/* Floating-Point Exception Control Register */ +#define FPINST p10,7,c9,c0,0/* Floating-Point Instruction Register */ +#define FPINST2 p10,7,c10,c0,0/* Floating-point Instruction Register 2 */ +/* Coprocessor 14 */ /* CP14 CR0: */
xen/include/asm-arm/domain.h +4 -0
@@ -6,6 +6,7 @@#include <xen/sched.h> #include <asm/page.h> #include <asm/p2m.h> +#include <asm/vfp.h> #include <public/hvm/params.h> /* Represents state corresponding to a block of 32 interrupts */
@@ -188,6 +189,9 @@ struct arch_vcpuuint32_t joscr, jmcr;#endif +/* Float-pointer */ +struct vfp_state vfp; +/* CP 15 */ uint32_t csselr;
xen/include/asm-arm/vfp.h new file +25 -0
@@ -0,0 +1,25 @@ +#ifndef _ASM_VFP_H +#define _ASM_VFP_H + +#include <xen/sched.h> + +#if defined(CONFIG_ARM_32 ) +# include <asm/arm32/vfp.h> +#elif defined(CONFIG_ARM_64 ) +# include <asm/arm64/vfp.h> +#else +# error "Unknown ARM variant" +#endif + +void vfp_save_state (struct vcpu *v); +void vfp_restore_state (struct vcpu *v); + +#endif /* _ASM_VFP_H */ +/* +* Local variables: +* mode: C +* c-file-style: "BSD" +* c-basic-offset: 4 +* indent-tabs-mode: nil +* End: +*/
Signature · 1 line
1.7.10.4
Re: [PATCH v4 2/2] xen/arm32: implement VFP context switch
Quoted 3 lines · Julien Grall
Add support for VFP context switch on arm32 and a dummy support for arm64
Signed-off-by Julien Grall <[email protected]>
This patch is causing failures for me with the gcc 4.6.3 cross compiler which I use and with gcc-linaro-arm-linux-gnueabihf-4.7-2013.04-20130415
vfp.c: In function 'vfp_restore_state':
vfp.c:45:27: error: memory input 0 is not directly addressable vfp.c:51:31: error: memory input 0 is not directly addressable
For some reason this didn't happen during my pre-commit build tests (or I somehow missed it), and the test system seems happy with it (no regression reported). But it does seem to fail on the same system (with the same compiler) I used for those pre-commit tests now.
Which compiler do you use?
I notice that Linux does its VFP context switch in a .S file, I wonder if this sort of issue is why?
Ian.
Re: [PATCH v4 2/2] xen/arm32: implement VFP context switch
Quoted 12 lines · Ian Campbell
Quoted 3 lines · Julien Grall
Add support for VFP context switch on arm32 and a dummy support for arm64
Signed-off-by Julien Grall <[email protected]>This patch is causing failures for me with the gcc 4.6.3 cross compiler which I use and with gcc-linaro-arm-linux-gnueabihf-4.7-2013.04-20130415
vfp.c: In function 'vfp_restore_state':
vfp.c:45:27: error: memory input 0 is not directly addressable vfp.c:51:31: error: memory input 0 is not directly addressable
Quoted 6 lines
For some reason this didn't happen during my pre-commit build tests (or I somehow missed it), and the test system seems happy with it (no regression reported). But it does seem to fail on the same system (with the same compiler) I used for those pre-commit tests now.
Which compiler do you use?
I'm using gcc 4.8.1.
Quoted 2 lines
I notice that Linux does its VFP context switch in a .S file, I wonder if this sort of issue is why?
Except if I missed something in the documentation, the constraint 'Q'([1]) doesn't produce the same assembly code on gcc 4.8.1 and gcc 4.6.3.
asm volatile("ldr r0, %0" : : "Q" (v));
- gcc 4.6.3 : ldr r0, [r1, #0]
- gcc 4.8.1 : ldr r0, [r1]
That's an issue for the VFP context switch, because I need to have [rd] otherwise gcc will complain because the assembly instruction has both pre-index and post-index.
[1] http://gcc.gnu.org/onlinedocs/gcc-4.8.1/gcc/Machine-Constraints.html#Machine-Constraints
--
Julien Grall
Re: [PATCH v4 2/2] xen/arm32: implement VFP context switch
In reply to Julien GrallQuoted 3 lines · Julien Grall
Add support for VFP context switch on arm32 and a dummy support for arm64
Signed-off-by Julien Grall <[email protected]>
This patch is causing failures for me with the gcc 4.6.3 cross compiler which I use and with gcc-linaro-arm-linux-gnueabihf-4.7-2013.04-20130415
vfp.c: In function 'vfp_restore_state':
vfp.c:45:27: error: memory input 0 is not directly addressable vfp.c:51:31: error: memory input 0 is not directly addressable
For some reason this didn't happen during my pre-commit build tests (or I somehow missed it), and the test system seems happy with it (no regression reported). But it does seem to fail on the same system (with the same compiler) I used for those pre-commit tests now.
Which compiler do you use?
I notice that Linux does its VFP context switch in a .S file, I wonder if this sort of issue is why?
Ian.
Quoted 6 lines · Julien Grall
Hello,
This is the fourth version of this patch series.
I have only implemented the VFP context switch support for arm32 and add dummy function to avoid avoid compilation breakage on arm64.
After speaking with Stefano we've decided that since this didn't actually address the SMP issue you were chasing and since we are now so close to the 4.3 release (this is partly my fault for being tardy with applying the patch, sorry) we will hold off on this change until 4.4 development opens. Shouldn't be long now before we branch...
Ian.
Quoted 28 lines
For all the changes see each patch.
Cheers,
Julien Grall (2):
xen/arm: don't enable VFP on XEN during the boot xen/arm32: implement VFP context switchxen/arch/arm/Rules.mk | 2 +- xen/arch/arm/arm32/Makefile | 1 + xen/arch/arm/arm32/vfp.c | 95 +++++++++++++++++++++++++++++++++++++++ xen/arch/arm/arm64/Makefile | 1 + xen/arch/arm/arm64/vfp.c | 13 ++++++ xen/arch/arm/domain.c | 7 ++- xen/arch/arm/setup.c | 3 -- xen/arch/arm/smpboot.c | 2 - xen/include/asm-arm/arm32/vfp.h | 41 +++++++++++++++++ xen/include/asm-arm/arm64/vfp.h | 16 +++++++ xen/include/asm-arm/cpregs.h | 9 ++++ xen/include/asm-arm/domain.h | 4 ++ xen/include/asm-arm/vfp.h | 42 +++++------------ 13 files changed, 198 insertions(+), 38 deletions(-) create mode 100644 xen/arch/arm/arm32/vfp.c create mode 100644 xen/arch/arm/arm64/vfp.c create mode 100644 xen/include/asm-arm/arm32/vfp.h create mode 100644 xen/include/asm-arm/arm64/vfp.h
Quoted 7 lines · Julien Grall
Hello,
This is the fourth version of this patch series.
I have only implemented the VFP context switch support for arm32 and add dummy function to avoid avoid compilation breakage on arm64.
Quoted 7 lines
For all the changes see each patch.
Cheers,
Julien Grall (2):
xen/arm: don't enable VFP on XEN during the boot xen/arm32: implement VFP context switch
Acked both and applied to staging.