qemu/target
Irina Ryapolova 7bf14a2f37 target/riscv: Fix Guest Physical Address Translation
Before changing the flow check for sv39/48/57.

According to specification (for Supervisor mode):
Sv39 implementations support a 39-bit virtual address space, divided into 4 KiB
pages.
Instruction fetch addresses and load and store effective addresses, which are
64 bits,
must have bits 63–39 all equal to bit 38, or else a page-fault exception will
occur.
Likewise for Sv48 and Sv57.

So the high bits are equal to bit 38 for sv39.

According to specification (for Hypervisor mode):
For Sv39x4, address bits of the guest physical address 63:41 must all be zeros,
or else a
guest-page-fault exception occurs.

Likewise for Sv48x4 and Sv57x4.
For Sv48x4 address bits 63:50 must all be zeros, or else a guest-page-fault
exception occurs.
For Sv57x4 address bits 63:59 must all be zeros, or else a guest-page-fault
exception occurs.

For example we are trying to access address 0xffff_ffff_ff01_0000 with only
G-translation enabled.
So expected behavior is to generate exception. But qemu doesn't generate such
exception.

For the old check, we get
va_bits == 41, mask == (1 << 24) - 1, masked_msbs == (0xffff_ffff_ff01_0000 >>
40) & mask == mask.
Accordingly, the condition masked_msbs != 0 && masked_msbs != mask is not
fulfilled
and the check passes.

Signed-off-by: Irina Ryapolova <irina.ryapolova@syntacore.com>
Reviewed-by: Weiwei Li <liweiwei@iscas.ac.cn>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Message-Id: <20230418075423.26217-1-irina.ryapolova@syntacore.com>
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
2023-05-05 10:49:50 +10:00
..
alpha target/alpha: Remove NB_MMU_MODES define 2023-03-13 06:44:37 -07:00
arm target/arm: Add compile time asserts to load/store_cpu_field macros 2023-05-02 15:47:41 +01:00
avr target/avr: Avoid use of tcg_const_i32 throughout 2023-03-13 06:44:37 -07:00
cris target/cris: Avoid use of tcg_const_i32 throughout 2023-03-13 06:44:37 -07:00
hexagon Hexagon (target/hexagon) Add overrides for cache/sync/barrier instructions 2023-04-21 09:32:52 -07:00
hppa target/hppa: Avoid use of tcg_const_i32 throughout 2023-03-13 06:44:37 -07:00
i386 target/i386: Add support for PREFETCHIT0/1 in CPUID enumeration 2023-04-28 12:50:34 +02:00
loongarch target/loongarch: Enables plugins to get instruction codes 2023-04-04 19:33:23 +08:00
m68k target/m68k: Use tcg_constant_i32 in gen_ea_mode 2023-03-13 07:03:39 -07:00
microblaze target/microblaze: Remove NB_MMU_MODES define 2023-03-13 06:44:37 -07:00
mips target/mips: tcg: detect out-of-bounds accesses to cpu_gpr and cpu_gpr_hi 2023-04-20 11:17:35 +02:00
nios2 target/nios2: Remove NB_MMU_MODES define 2023-03-13 06:44:37 -07:00
openrisc target/openrisc: Remove NB_MMU_MODES define 2023-03-13 06:44:37 -07:00
ppc target/ppc: Fix temp usage in gen_op_arith_modw 2023-04-09 19:21:27 +02:00
riscv target/riscv: Fix Guest Physical Address Translation 2023-05-05 10:49:50 +10:00
rx target/rx: Avoid tcg_const_i32 2023-03-13 06:44:37 -07:00
s390x s390x/gdb: Split s390-virt.xml 2023-04-28 08:05:37 +02:00
sh4 target/sh4: Honor QEMU_LOG_FILENAME with QEMU_LOG=cpu 2023-03-16 10:31:25 +01:00
sparc tcg/sparc: Avoid tcg_const_tl in gen_edge 2023-03-13 06:44:37 -07:00
tricore target/tricore: Use min/max for saturate 2023-03-13 07:03:39 -07:00
xtensa target/xtensa: Remove NB_MMU_MODES define 2023-03-13 06:44:37 -07:00
Kconfig hw/loongarch: Add support loongson3 virt machine type. 2022-06-06 18:09:03 +00:00
meson.build target/loongarch: Add target build suport 2022-06-06 18:09:03 +00:00