xen: arm: handle thumb mode guest in continuations
PATCH 3/3 xen: arm: handle thumb mode guest in continuations
PC only needs adjusting by 2, otherwise we rerun the instruction prior to the hvc as well.
hvc is unpredictable if used within a Thumb IT (conditional execution) block, so we don't need to worry about rewinding any of that state.
---
Should be backported
--- xen/arch/arm/domain.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
xen/arch/arm/domain.c +2 -1
@@ -387,10 +387,11 @@ unsigned long hypercall_create_continuation( else#endif { +int is_thumb = (regs->cpsr &PSR_THUMB ); regs->r12 = op;/* Ensure the hypercall trap instruction is re-executed. */ - regs->pc -=4 ;/* re-execute 'hvc #XEN_HYPERCALL_TAG' */ + regs->pc -= is_thumb?2 :4 ;/* re-execute 'hvc #XEN_HYPERCALL_TAG' */ for ( i =0 ; *p !='\0' ; i++ ) {
Signature · 1 line
1.7.10.4
Hi Ian,
Quoted 2 lines · Ian Campbell
PC only needs adjusting by 2, otherwise we rerun the instruction prior to the hvc as well.
I don't understand why you have to adjust PC by 2 for thumb. The spec encodes the HVC thumb instruction on 32 bits (i.e 4 bytes).
Regards,
Signature · 1 line
Julien Grall
Quoted 8 lines · Julien Grall
Hi Ian,
Quoted 2 lines · Ian Campbell
PC only needs adjusting by 2, otherwise we rerun the instruction prior to the hvc as well.
I don't understand why you have to adjust PC by 2 for thumb. The spec encodes the HVC thumb instruction on 32 bits (i.e 4 bytes).
I was confused by Encoding T1 in the ARMv7 ARM B9.3.4 which has a 15 at the left most column, but actually it is 15..0,15..0, doh!
So we are fine here. I'll drop this patch and pull the regs->pc frobbing in the previous patch back out of the if into the common bit.
Ian.