|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [RFC PATCH] Added the logic to decode 32 bit ldr/str post-indexing instructions
Hi Ayan, On 19/11/2021 16:52, Ayan Kumar Halder wrote: At present, post indexing instructions are not emulated by Xen. Can you explain in the commit message why this is a problem? Hmmm.... Don't you also need to update the register x1 after the instruction was emulated?When Xen gets the exception, EL2_ESR.ISV bit not set. Thus as a result, data abort is triggered. Added the logic to decode ldr/str post indexing instructions. With this, Xen can decode instructions like these:- ldr w2, [x1], #4 Thus, domU can read ioreg with post indexing instructions. Signed-off-by: Ayan Kumar Halder <ayankuma@xxxxxxxxxx> --- Note to reviewer:- This patch is based on an issue discussed in https://lists.xenproject.org/archives/html/xen-devel/2021-11/msg00969.html "Xen/ARM - Query about a data abort seen while reading GICD registers" xen/arch/arm/decode.c | 77 +++++++++++++++++++++++++++++++++++++++++++ xen/arch/arm/io.c | 14 ++++++-- 2 files changed, 88 insertions(+), 3 deletions(-) diff --git a/xen/arch/arm/decode.c b/xen/arch/arm/decode.c index 792c2e92a7..7b60bedbc5 100644 --- a/xen/arch/arm/decode.c +++ b/xen/arch/arm/decode.c @@ -84,6 +84,80 @@ bad_thumb2: return 1; }+static inline int32_t extract32(uint32_t value, int start, int length) Any reason to have start and length signed? This would be easier to read if you use GENMASK(). Should all those variables need to be signed? The page number varies between revision of the Armv8 spec. So can you specify which version you used?+ + /* For details on decoding, refer to Armv8 Architecture reference manual + * Section - "Load/store register (immediate post-indexed)", Pg 318 + */ The coding style for comment in Xen is: /* * Foo * Bar */ + if ( raw_copy_from_guest(&instr, (void * __user)pc, sizeof (instr)) ) + return -EFAULT; + + /* First, let's check for the fixed values */ + + /* As per the "Encoding table for the Loads and Stores group", Pg 299 Same question here about the version. + * op4 = 1 - Load/store register (immediate post-indexed) + */ Coding style. + if ( extract32(instr, 10, 2) != 1 ) + goto bad_64bit_loadstore; + + /* For the following, refer to "Load/store register (immediate post-indexed)" + * to get the fixed values at various bit positions. + */ + if ( extract32(instr, 21, 1) != 0 ) + goto bad_64bit_loadstore; + + if ( extract32(instr, 24, 2) != 0 ) + goto bad_64bit_loadstore; + + if ( extract32(instr, 27, 3) != 7 ) + goto bad_64bit_loadstore; + + size = extract32(instr, 30, 2); + v = extract32(instr, 26, 1); + opc = extract32(instr, 22, 1); + + /* At the moment, we support STR(immediate) - 32 bit variant and + * LDR(immediate) - 32 bit variant only. + */ Coding style. + if (!((size==2) && (v==0) && ((opc==0) || (opc==1)))) The coding style for this should be: if ( !(( size == 2 ) && ( ... ) ... ) ) + goto bad_64bit_loadstore; + + rt = extract32(instr, 0, 5); + imm9 = extract32(instr, 12, 9); + + if ( imm9 < 0 ) + update_dabt(dabt, rt, size, true); + else + update_dabt(dabt, rt, size, false); This could be simplified with: update_dabt(dabt, rt, size, imm9 < 0); You can still run 32-bit code in 64-bit domain. So I think you want to check the SPSR mode. I think this comment should now be updated to "unhandled 32-bit ...". diff --git a/xen/arch/arm/io.c b/xen/arch/arm/io.c I am afraid this is wrong. The problem here is the processor didn't provide a valid syndrom for post-indexing ldr/str instructions. So in order to support them, Xen must decode. + */ + rc = decode_instruction(regs, &info.dabt); I actually expect this to also be useful when forwarding the I/O to device-model. So I would move the decoding earlier in the code and the check of dabt.valid earlier. + if ( rc ) + return IO_ABORT; + }/* Cheers, -- Julien Grall
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |