Implement erratum 766422
v5 cover Implement erratum 766422
This is fifth version of this patch series. It allows a guest kernel to use THUMB set instructions on the processor affected by the errata 766422 (for instance the Arndale board).
This patch series is divided in two patch:
- The first patch implements a basic decoder to fill the ISS field of the hsr_dabt struct
- The second patch implements the errata
Since the last version, only minor changes was made. See each patch, for the changes.
Cheers,
Julien Grall (2):
xen/arm: Start to implement an ARM decoder instruction xen/arm: erratum 766422: decode thumb store during data abort
xen/arch/arm/Makefile | 1 + xen/arch/arm/decode.c | 165 +++++++++++++++++++++++++++++++++ xen/arch/arm/decode.h | 49 ++++++++++ xen/arch/arm/traps.c | 15 +++ xen/include/asm-arm/arm32/processor.h | 4 + xen/include/asm-arm/arm64/processor.h | 2 + 6 files changed, 236 insertions(+) create mode 100644 xen/arch/arm/decode.c create mode 100644 xen/arch/arm/decode.h
Signature · 1 line
1.7.10.4
PATCH v5 1/2 xen/arm: Start to implement an ARM decoder instruction
Some errata on ARM processor requires to decode the instruction. The decoder will, obviously, decode and fill the ISS fields of the hsr_dabt.
For the moment, the decoder only supports:
- THUMB2 store instruction
- THUMB single load/store instruction
---
Changes in v5:
- Fix typo in commit
- Use gdprintk instead of printk
- Remove TODOs
- Add warning when it's an ARM instruction
Changes in v4:
- Add warning about the purpose of this function
- Add helper to update ISS (register, sign, size) field of DABT
- Improve decoding for THUMB 2 store instruction
- Only decode thumb instruction if it's a 32-bit guest
--- xen/arch/arm/Makefile | 1 + xen/arch/arm/decode.c | 165 +++++++++++++++++++++++++++++++++++++++++++++++++ xen/arch/arm/decode.h | 49 +++++++++++++++ 3 files changed, 215 insertions(+) create mode 100644 xen/arch/arm/decode.c create mode 100644 xen/arch/arm/decode.h
xen/arch/arm/Makefile +1 -0
@@ -30,6 +30,7 @@ obj-y += vtimer.o obj-y += vuart.o obj-y += hvm.o obj-y += device.o +obj-y += decode.o #obj-bin-y += ....o
xen/arch/arm/decode.c new file +165 -0
165 lines not on this page · raw message
xen/arch/arm/decode.h new file +49 -0
49 lines not on this page · raw message
Signature · 1 line
1.7.10.4
PATCH v5 2/2 xen/arm: erratum 766422: decode thumb store during data abort
In reply to Julien GrallFrom the errata document:
When a non-secure non-hypervisor memory operation instruction generates a stage2 page table translation fault, a trap to the hypervisor will be triggered. For an architecturally defined subset of instructions, the Hypervisor Syndrome Register (HSR) will have the Instruction Syndrome Valid (ISV) bit set to 1’b1, and the Rt field should reflect the source register (for stores) or destination register for loads.
On Cortex-A15, for Thumb and ThumbEE stores, the Rt value may be incorrect and should not be used, even if the ISV bit is set. All loads, and all ARM instruction set loads and stores, will have the correct Rt value if the ISV bit is set.
To avoid this issue, Xen needs to decode thumb store instruction and update the transfer register.
---
Changes in v5:
- Add gdprintk when the instruction decoding fails
- s/errata/erratum in patch and commit message
Changes in v3:
- Use unlikely to check if the processor is affected by the errata
- Move the decoder in another patch and use it
Changes in v2:
- Only decode the instruction on affected processor
- Handle ARM 32-bit instruction in read_instruction
--- xen/arch/arm/traps.c | 15 +++++++++++++++ xen/include/asm-arm/arm32/processor.h | 4 ++++ xen/include/asm-arm/arm64/processor.h | 2 ++ 3 files changed, 21 insertions(+)
xen/arch/arm/traps.c +15 -0
@@ -36,6 +36,7 @@#include <asm/cpregs.h> #include <asm/psci.h> +#include "decode.h" #include "io.h" #include "vtimer.h" #include <asm/gic.h>
@@ -1336,6 +1337,20 @@ static void do_trap_data_abort_guest(struct cpu_user_regs *regs,if ( !dabt.valid ) goto bad_data_abort; +/* +* Erratum 766422: Thumb store translation fault to Hypervisor may +* not have correct HSR Rt value. +*/ +if (cpu_has_erratum_766422 () && (regs->cpsr &PSR_THUMB ) && dabt.write ) + { + rc =decode_instruction (regs, &info.dabt); +if ( rc ) + { +gdprintk (XENLOG_ERR ,"Unable to decode instruction\n" ); + goto bad_data_abort; + } + } +if (handle_mmio (&info)) {advance_pc (regs, hsr);
xen/include/asm-arm/arm32/processor.h +4 -0
@@ -111,6 +111,10 @@ struct cpu_user_regs #define READ_SYSREG(R...) READ_SYSREG32(R) #define WRITE_SYSREG(V, R...) WRITE_SYSREG32(V, R) +/* Erratum 766422: only Cortex A15 r0p4 is affected */ +#define cpu_has_erratum_766422 () \ + (unlikely(current_cpu_data.midr.bits == 0x410fc0f4)) +#endif /* __ASSEMBLY__ */ #endif /* __ASM_ARM_ARM32_PROCESSOR_H */
xen/include/asm-arm/arm64/processor.h +2 -0
@@ -104,6 +104,8 @@ struct cpu_user_regs#define READ_SYSREG (name) READ_SYSREG64(name)#define WRITE_SYSREG (v, name) WRITE_SYSREG64(v, name) +#define cpu_has_erratum_766422 () 0 +#endif /* __ASSEMBLY__ */ #endif /* __ASM_ARM_ARM64_PROCESSOR_H */
Signature · 7 lines
1.7.10.4 _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel
Quoted 11 lines · Julien Grall
This is fifth version of this patch series. It allows a guest kernel to use THUMB set instructions on the processor affected by the errata 766422 (for instance the Arndale board).
This patch series is divided in two patch:
- The first patch implements a basic decoder to fill the ISS field of thehsr_dabtstruct
- The second patch implements the errataSince the last version, only minor changes was made. See each patch, for the changes.
I acked the first and applied both. Thanks.