On 2025/7/26 上午9:19, Richard Henderson wrote:
On 7/24/25 15:37, Bibo Mao wrote:
Common function loongarch_check_pte() is to check tlb entry, return
the physical address and access priviledge. Also it can be used with
page table entry, which is used in page table walker.
Signed-off-by: Bibo Mao <maob...@loongson.cn>
---
target/loongarch/cpu-mmu.h | 10 +++++
target/loongarch/cpu_helper.c | 62 ++++++++++++++++++++++++++++++
target/loongarch/tcg/tlb_helper.c | 63 ++++++-------------------------
3 files changed, 84 insertions(+), 51 deletions(-)
diff --git a/target/loongarch/cpu-mmu.h b/target/loongarch/cpu-mmu.h
index 4c5cbd7425..62b3acfbc7 100644
--- a/target/loongarch/cpu-mmu.h
+++ b/target/loongarch/cpu-mmu.h
@@ -19,7 +19,17 @@ enum {
TLBRET_PE = 7,
};
+typedef struct mmu_context {
+ target_ulong vaddr;
Use the 'vaddr' type.
will do in this way. It is simple and work on 32-bit guest vm on 64-bit
host also.
+ uint64_t pte;
+ hwaddr physical;
+ int ps; /* page size shift */
+ int prot;
+} mmu_context;
QEMU coding style prefers CamelCase.
Will do, how about the name MMUContext?
+int loongarch_check_pte(CPULoongArchState *env, mmu_context *context,
+ int access_type, int mmu_idx)
Use MMUAccessType access_type.
And fix loongarch_map_tlb_entry in a separate patch.
Will do this in a new patch.
That's the type from loongarch_get_addr_from_tlb and above.
Regards
Bibo Mao
r~