]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
target/loongarch: Reserve higher 48 bit PTE attribute with huge page
authorBibo Mao <maobibo@loongson.cn>
Wed, 27 Aug 2025 03:53:07 +0000 (11:53 +0800)
committerBibo Mao <maobibo@loongson.cn>
Thu, 23 Oct 2025 11:41:56 +0000 (19:41 +0800)
With PTE entry, high bit 48-63 is valid HW bit for PTE attribute,
for example bit 63 is RPLV and bit 62 is NX. With page directory table,
it is physical address of page table from view of HW, so high bit
48-63 need be discarded.

Here reverve high bit 48-63 with huge page since it is PTE entry, and
only discard it with page directory table.

Signed-off-by: Bibo Mao <maobibo@loongson.cn>
Reviewed-by: Song Gao <gaosong@loongson.cn>
target/loongarch/cpu_helper.c

index 8af6ee7fb15ad4641a31a87adaf019c717caccf2..8388bfb7823a09c2e4026fd2079479ff05afa279 100644 (file)
@@ -134,10 +134,13 @@ static TLBRet loongarch_ptw(CPULoongArchState *env, MMUContext *context,
         /* get next level page directory */
         index = (address >> dir_base) & ((1 << dir_width) - 1);
         phys = base | index << 3;
-        base = ldq_phys(cs->as, phys) & TARGET_PHYS_MASK;
+        base = ldq_phys(cs->as, phys);
         if (FIELD_EX64(base, TLBENTRY, HUGE)) {
             /* base is a huge pte */
             break;
+        } else {
+            /* Discard high bits with page directory table */
+            base &= TARGET_PHYS_MASK;
         }
     }