xen/arm64: io: Support instructions (for which ISS is not valid) on emulated MMIO...
authorAyan Kumar Halder <ayan.kumar.halder@xilinx.com>
Thu, 10 Mar 2022 17:44:59 +0000 (17:44 +0000)
committerJulien Grall <jgrall@amazon.com>
Mon, 14 Mar 2022 17:58:40 +0000 (17:58 +0000)
commit9e5a68a6652cc54ce3cb3b0ce208eeed79d5aeb5
tree12465e9743dac71611faebefbc1a9e9a5031c22c
parentf9dd8436e3b826e4ca2284effa4c0285527ea763
xen/arm64: io: Support instructions (for which ISS is not valid) on emulated MMIO region using MMIO/ioreq handler

When an instruction is trapped in Xen due to translation fault, Xen
checks if the ISS is invalid (for data abort) or it is an instruction
abort. If so, Xen tries to resolve the translation fault using p2m page
tables. In case of data abort, Xen will try to map the mmio region to
the guest (ie tries to emulate the mmio region).

If the ISS is not valid and it is a data abort, then Xen tries to
decode the instruction. In case of ioreq, Xen  saves the decoding state,
rn and imm9 to vcpu_io. Whenever the vcpu handles the ioreq successfully,
it will read the decoding state to determine if the instruction decoded
was a ldr/str post indexing (ie INSTR_LDR_STR_POSTINDEXING). If so, it
uses these details to post increment rn.

In case of mmio handler, if the mmio operation was successful, then Xen
retrives the decoding state, rn and imm9. For state ==
INSTR_LDR_STR_POSTINDEXING, Xen will update rn.

If there is an error encountered while decoding/executing the instruction,
Xen will forward the abort to the guest.

Also, the logic to infer the type of instruction has been moved from
try_handle_mmio() to try_decode_instruction() which is called before.
try_handle_mmio() is solely responsible for handling the mmio operation.

Signed-off-by: Ayan Kumar Halder <ayankuma@xilinx.com>
Acked-by: Julien Grall <jgrall@amazon.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
xen/arch/arm/arm32/traps.c
xen/arch/arm/arm64/traps.c
xen/arch/arm/decode.c
xen/arch/arm/include/asm/domain.h
xen/arch/arm/include/asm/mmio.h
xen/arch/arm/include/asm/traps.h
xen/arch/arm/io.c
xen/arch/arm/ioreq.c
xen/arch/arm/traps.c
xen/arch/x86/include/asm/ioreq.h
xen/include/xen/sched.h