[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 18/25] target/riscv: Fix incorrect PTE merge in walk_pte
From: |
Alistair Francis |
Subject: |
[PULL 18/25] target/riscv: Fix incorrect PTE merge in walk_pte |
Date: |
Fri, 29 Apr 2022 14:31:12 +1000 |
From: Ralf Ramsauer <ralf.ramsauer@oth-regensburg.de>
Two non-subsequent PTEs can be mapped to subsequent paddrs. In this
case, walk_pte will erroneously merge them.
Enforce the split up, by tracking the virtual base address.
Let's say we have the mapping:
0x81200000 -> 0x89623000 (4K)
0x8120f000 -> 0x89624000 (4K)
Before, walk_pte would have shown:
vaddr paddr size attr
---------------- ---------------- ---------------- -------
0000000081200000 0000000089623000 0000000000002000 rwxu-ad
as it only checks for subsequent paddrs. With this patch, it becomes:
vaddr paddr size attr
---------------- ---------------- ---------------- -------
0000000081200000 0000000089623000 0000000000001000 rwxu-ad
000000008120f000 0000000089624000 0000000000001000 rwxu-ad
Signed-off-by: Ralf Ramsauer <ralf.ramsauer@oth-regensburg.de>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Message-Id: <20220423215907.673663-1-ralf.ramsauer@oth-regensburg.de>
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
---
target/riscv/monitor.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/target/riscv/monitor.c b/target/riscv/monitor.c
index 7efb4b62c1..17e63fab00 100644
--- a/target/riscv/monitor.c
+++ b/target/riscv/monitor.c
@@ -84,6 +84,7 @@ static void walk_pte(Monitor *mon, hwaddr base, target_ulong
start,
{
hwaddr pte_addr;
hwaddr paddr;
+ target_ulong last_start = -1;
target_ulong pgsize;
target_ulong pte;
int ptshift;
@@ -111,12 +112,13 @@ static void walk_pte(Monitor *mon, hwaddr base,
target_ulong start,
* A leaf PTE has been found
*
* If current PTE's permission bits differ from the last one,
- * or current PTE's ppn does not make a contiguous physical
- * address block together with the last one, print out the last
- * contiguous mapped block details.
+ * or the current PTE breaks up a contiguous virtual or
+ * physical mapping, address block together with the last one,
+ * print out the last contiguous mapped block details.
*/
if ((*last_attr != attr) ||
- (*last_paddr + *last_size != paddr)) {
+ (*last_paddr + *last_size != paddr) ||
+ (last_start + *last_size != start)) {
print_pte(mon, va_bits, *vbase, *pbase,
*last_paddr + *last_size - *pbase, *last_attr);
@@ -125,6 +127,7 @@ static void walk_pte(Monitor *mon, hwaddr base,
target_ulong start,
*last_attr = attr;
}
+ last_start = start;
*last_paddr = paddr;
*last_size = pgsize;
} else {
--
2.35.1
- [PULL 08/25] crypto: move sm4_sbox from target/arm, (continued)
- [PULL 08/25] crypto: move sm4_sbox from target/arm, Alistair Francis, 2022/04/29
- [PULL 09/25] target/riscv: rvk: add support for zknd/zkne extension in RV32, Alistair Francis, 2022/04/29
- [PULL 10/25] target/riscv: rvk: add support for zkne/zknd extension in RV64, Alistair Francis, 2022/04/29
- [PULL 11/25] target/riscv: rvk: add support for sha256 related instructions in zknh extension, Alistair Francis, 2022/04/29
- [PULL 12/25] target/riscv: rvk: add support for sha512 related instructions for RV32 in zknh extension, Alistair Francis, 2022/04/29
- [PULL 13/25] target/riscv: rvk: add support for sha512 related instructions for RV64 in zknh extension, Alistair Francis, 2022/04/29
- [PULL 14/25] target/riscv: rvk: add support for zksed/zksh extension, Alistair Francis, 2022/04/29
- [PULL 15/25] target/riscv: rvk: add CSR support for Zkr, Alistair Francis, 2022/04/29
- [PULL 16/25] disas/riscv.c: rvk: add disas support for Zbk* and Zk* instructions, Alistair Francis, 2022/04/29
- [PULL 17/25] target/riscv: rvk: expose zbk* and zk* properties, Alistair Francis, 2022/04/29
- [PULL 18/25] target/riscv: Fix incorrect PTE merge in walk_pte,
Alistair Francis <=
- [PULL 19/25] target/riscv: add scalar crypto related extenstion strings to isa_string, Alistair Francis, 2022/04/29
- [PULL 20/25] hw/riscv: virt: Add a machine done notifier, Alistair Francis, 2022/04/29
- [PULL 21/25] hw/core: Move the ARM sysbus-fdt to core, Alistair Francis, 2022/04/29
- [PULL 22/25] hw/riscv: virt: Create a platform bus, Alistair Francis, 2022/04/29
- [PULL 23/25] hw/riscv: virt: Add support for generating platform FDT entries, Alistair Francis, 2022/04/29
- [PULL 24/25] hw/riscv: virt: Add device plug support, Alistair Francis, 2022/04/29
- [PULL 25/25] hw/riscv: Enable TPM backends, Alistair Francis, 2022/04/29
- Re: [PULL 00/25] riscv-to-apply queue, Richard Henderson, 2022/04/29