Since Linux v4.1 (specifically, "MIPS: Rearrange PTE bits into fixed
positions.", commit be0c37c985eddc46d0d67543898c086f60460e2e), the PTE
bits are at fixed locations. Since these are only macros as in the
kernel, we aren't able to determine them from the vmlinux, so add an
explicit version check to handle them.
---
mips.c | 43 ++++++++++++++++++++++++++-----------------
1 file changed, 26 insertions(+), 17 deletions(-)
diff --git a/mips.c b/mips.c
index 4b62d1e..a4fc8b6 100644
--- a/mips.c
+++ b/mips.c
@@ -100,30 +100,39 @@ mips_cmd_mach(void)
static void
mips_init_page_flags(void)
{
- ulonglong cpu_options;
- int rixi;
ulong shift = 0;
- ulong addr;
- addr = symbol_value("cpu_data") +
- MEMBER_OFFSET("cpuinfo_mips", "options");
- readmem(addr, KVADDR, &cpu_options, sizeof(cpu_options),
- "cpu_data[0].options", FAULT_ON_ERROR);
+ _PAGE_PRESENT = 1UL << shift++;
- rixi = cpu_options & MIPS_CPU_RIXI;
+ if (THIS_KERNEL_VERSION >= LINUX(4,1,0)) {
+ _PAGE_WRITE = 1UL << shift++;
+ _PAGE_ACCESSED = 1UL << shift++;
+ _PAGE_MODIFIED = 1UL << shift++;
+ _PAGE_NO_EXEC = 1UL << shift++;
+ _PAGE_READ = _PAGE_NO_READ = 1UL << shift++;
+ } else {
+ ulonglong cpu_options;
+ int rixi;
+ ulong addr;
- _PAGE_PRESENT = 1UL << shift++;
+ addr = symbol_value("cpu_data") +
+ MEMBER_OFFSET("cpuinfo_mips", "options");
+ readmem(addr, KVADDR, &cpu_options, sizeof(cpu_options),
+ "cpu_data[0].options", FAULT_ON_ERROR);
- if (!rixi)
- _PAGE_READ = 1UL << shift++;
+ rixi = cpu_options & MIPS_CPU_RIXI;
- _PAGE_WRITE = 1UL << shift++;
- _PAGE_ACCESSED = 1UL << shift++;
- _PAGE_MODIFIED = 1UL << shift++;
+ if (!rixi)
+ _PAGE_READ = 1UL << shift++;
- if (rixi) {
- _PAGE_NO_EXEC = 1UL << shift++;
- _PAGE_NO_READ = 1UL << shift++;
+ _PAGE_WRITE = 1UL << shift++;
+ _PAGE_ACCESSED = 1UL << shift++;
+ _PAGE_MODIFIED = 1UL << shift++;
+
+ if (rixi) {
+ _PAGE_NO_EXEC = 1UL << shift++;
+ _PAGE_NO_READ = 1UL << shift++;
+ }
}
_PAGE_GLOBAL = 1UL << shift++;
--
1.7.10.4