Skip to content

Commit

Permalink
core: riscv: core_mmu_arch: fix PPN field extraction from PTE
Browse files Browse the repository at this point in the history
The upper bits of page table entry may contain other fields
introduced since Priv. ISA spec. v1.11 (20211203), such as PBMT
and N bits, thus PPN field should be masked out with PTE_PPN.

Signed-off-by: Yu Chien Peter Lin <peterlin@andestech.com>
Reviewed-by: Alvin Chang <alvinga@andestech.com>
Tested-by: Alvin Chang <alvinga@andestech.com>
Reviewed-by: Marouene Boubakri <marouene.boubakri@nxp.com>
  • Loading branch information
lyctw authored and jforissier committed Aug 14, 2024
1 parent 8448708 commit eadb6be
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions core/arch/riscv/include/encoding.h
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@
#define PTE_A 0x040 /* Accessed */
#define PTE_D 0x080 /* Dirty */
#define PTE_SOFT 0x300 /* Reserved for Software */
#define PTE_PPN 0x003FFFFFFFFFFC00 /* PPN */
#define PTE_RSVD 0x1FC0000000000000 /* Reserved for future standard use */
#define PTE_PBMT 0x6000000000000000 /* Svpbmt: Page-based memory types */
#define PTE_N 0x8000000000000000 /* Svnapot: NAPOT translation contiguity */
Expand Down
2 changes: 1 addition & 1 deletion core/arch/riscv/mm/core_mmu_arch.c
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ static unsigned long core_mmu_ptp_create(unsigned long ppn)

static unsigned long core_mmu_pte_ppn(struct mmu_pte *pte)
{
return pte->entry >> PTE_PPN_SHIFT;
return (pte->entry & PTE_PPN) >> PTE_PPN_SHIFT;
}

static unsigned long pa_to_ppn(paddr_t pa)
Expand Down

0 comments on commit eadb6be

Please sign in to comment.