]> git.proxmox.com Git - mirror_qemu.git/commit - target/riscv/cpu_helper.c
target/riscv/cpu_helper.c: Fix mxr bit behavior
authorIvan Klokov <ivan.klokov@syntacore.com>
Tue, 21 Nov 2023 07:17:57 +0000 (10:17 +0300)
committerAlistair Francis <alistair.francis@wdc.com>
Wed, 22 Nov 2023 04:03:37 +0000 (14:03 +1000)
commit6bca4d7d1ff2b8857486c3ff31f5c6fc3e3984b4
tree8e2d8bc57253633fb3de08300f26f64703a45f1e
parent82d53adfbb1aa0dbe7dac09b61ad86014efe81a7
target/riscv/cpu_helper.c: Fix mxr bit behavior

According to RISCV Specification sect 9.5 on two stage translation when
V=1 the vsstatus(mstatus in QEMU's terms) field MXR, which makes
execute-only pages readable, only overrides VS-stage page protection.
Setting MXR at HS-level(mstatus_hs), however, overrides both VS-stage
and G-stage execute-only permissions.

The hypervisor extension changes the behavior of MXR\MPV\MPRV bits.
Due to RISCV Specification sect. 9.4.1 when MPRV=1, explicit memory
accesses are translated and protected, and endianness is applied, as
though the current virtualization mode were set to MPV and the current
nominal privilege mode were set to MPP. vsstatus.MXR makes readable
those pages marked executable at the VS translation stage.

Fixes: 36a18664ba ("target/riscv: Implement second stage MMU")
Signed-off-by: Ivan Klokov <ivan.klokov@syntacore.com>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Reviewed-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
Message-ID: <20231121071757.7178-3-ivan.klokov@syntacore.com>
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
target/riscv/cpu_helper.c