|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [PATCH v2 26/39] xen/riscv: add guest store emulation for trapped MMIO accesses
On 9/14/26 2:01 PM, Jan Beulich wrote: On 27.08.2026 17:21, Oleksii Kurochko wrote: Nothing can produce di.len > sizeof(register_t) today, as the 8-byte cases are all gated on xlen == 64, so I'd add the assertion at the point where the lengths are assigned, covering both emulate_load() (where the shift calculation would underflow) and emulate_store() at once: ASSERT(di->len <= sizeof(register_t)); right before decode_ldst_insn()'s final "return true".Probably it makes sense to have just "if (di->len >= sizeof(register_t) )" with the comment and then return false in deocde_lst_insn(): + /* + * An access wider than a register could not be carried through: the + * register operand guest_gpr() hands out is register_t-wide, as is the + * value an emulated access moves. None of the encodings above yields + * such an access, the 8-byte ones all being gated on XLEN=64, but a+ * future extension might (Zilsd, say, whose 8-byte accesses exist for a + * 32-bit guest). + */ + if ( di->len > sizeof(register_t) ) + return false;(i think that the same could be also true for D and Zdinx but I will mention only Zilsd as an example) Also, I think it make sense to add the comment to guest_gpr() than di->len is checked in decode_ldst_insn(). Alternative will be to update the proto of guest_gpr() and pass `di` and then have extra ASSERT() in guest_gpr() for the case if someone will try to use guest_gpr() without using insn_fetch_faulted() & decode_ldst_insn() before guest_gpr(). I will apply this alternative way, it looks to me better for now and then will add the following ASSERT:
/*
* decode_ldst_insn() is what fills @di in, and it rejects an access
* wider than a register.
*/
ASSERT(di->len <= sizeof(register_t));
Thanks.
~ Oleksii
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |