]> git.proxmox.com Git - mirror_qemu.git/commit
target/riscv: fix wfi exception behavior
authorJose Martins <josemartins90@gmail.com>
Tue, 20 Apr 2021 21:36:56 +0000 (22:36 +0100)
committerAlistair Francis <alistair.francis@wdc.com>
Mon, 7 Jun 2021 23:59:42 +0000 (09:59 +1000)
commit719f0f603c2289f438b8d6ef4358d9407b4c2905
treedc5a7e257b094da89f5f740c4021d2294694115b
parent143897b50140cfd7540f867edca5d658e76aa9bf
target/riscv: fix wfi exception behavior

The wfi exception trigger behavior should take into account user mode,
hstatus.vtw, and the fact the an wfi might raise different types of
exceptions depending on various factors:

If supervisor mode is not present:

- an illegal instruction exception should be generated if user mode
executes and wfi instruction and mstatus.tw = 1.

If supervisor mode is present:

- when a wfi instruction is executed, an illegal exception should be triggered
if either the current mode is user or the mode is supervisor and mstatus.tw is
set.

Plus, if the hypervisor extensions are enabled:

- a virtual instruction exception should be raised when a wfi is executed from
virtual-user or virtual-supervisor and hstatus.vtw is set.

Signed-off-by: Jose Martins <josemartins90@gmail.com>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Message-id: 20210420213656.85148-1-josemartins90@gmail.com
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
target/riscv/cpu_bits.h
target/riscv/op_helper.c