aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTony Luck <tony.luck@intel.com>2020-10-26 08:05:48 -0700
committerTony Luck <tony.luck@intel.com>2020-10-26 08:05:48 -0700
commitc7ad657475ea3d09d096ed6cd5f6b63e6ef3b6ec (patch)
treee7296e51314697e0c45065c59247f4f50f983ac5
parenta4e0b6bd25871482e26b2e2eb8ff5a0e11d16134 (diff)
downloadras-tools-c7ad657475ea3d09d096ed6cd5f6b63e6ef3b6ec.tar.gz
vtop: Multiply by "pagesize" instead of hardcode shift by 12
When convering a page frame number to an address there is a hard-coded shift by 12 but the mask for the low order bits is computed based on the "pagesize" variable. Fix this inconsistency by swapping out the shift for a multiply. Reported-by: 葛士建 <geshijian@bytedance.com> Signed-off-by: Tony Luck <tony.luck@intel.com>
-rw-r--r--hornet.c2
-rw-r--r--mca-recover.c2
-rw-r--r--proc_pagemap.c2
-rw-r--r--vtop.c2
4 files changed, 4 insertions, 4 deletions
diff --git a/hornet.c b/hornet.c
index cc42464..dea8c0c 100644
--- a/hornet.c
+++ b/hornet.c
@@ -196,7 +196,7 @@ again:
}
goto again;
}
- *phys = ((pinfo & 0x007ffffffffffffful) << 12) + (a & (pagesize - 1));
+ *phys = ((pinfo & 0x007ffffffffffffful) * pagesize) + (a & (pagesize - 1));
return a;
fail:
close(fd);
diff --git a/mca-recover.c b/mca-recover.c
index 4ec3cfe..ce2be29 100644
--- a/mca-recover.c
+++ b/mca-recover.c
@@ -50,7 +50,7 @@ unsigned long long vtop(unsigned long long addr)
printf("page not present\n");
exit(1);
}
- return ((pinfo & 0x007fffffffffffffull) << 12) + (addr & (pagesize - 1));
+ return ((pinfo & 0x007fffffffffffffull) * pagesize) + (addr & (pagesize - 1));
}
/*
diff --git a/proc_pagemap.c b/proc_pagemap.c
index bfc29ed..d92aa90 100644
--- a/proc_pagemap.c
+++ b/proc_pagemap.c
@@ -45,5 +45,5 @@ unsigned long long vtop(unsigned long long addr)
printf("page not present\n");
return ~0ull;
}
- return ((pinfo & 0x007fffffffffffffull) << 12) + (addr & (pagesize - 1));
+ return ((pinfo & 0x007fffffffffffffull) * pagesize) + (addr & (pagesize - 1));
}
diff --git a/vtop.c b/vtop.c
index f292218..7ffcf36 100644
--- a/vtop.c
+++ b/vtop.c
@@ -55,7 +55,7 @@ unsigned long long vtop(unsigned long long addr, int proc_id)
printf("page not present\n");
exit(1);
}
- return ((pinfo & 0x007fffffffffffffull) << 12) + (addr & (pagesize - 1));
+ return ((pinfo & 0x007fffffffffffffull) * pagesize) + (addr & (pagesize - 1));
}
int main(int argc, char **argv)