* [PATCH] x86/hyperv: use pointed-to type size for page table offsets
@ 2026-11-01 8:20 mdshahid03
0 siblings, 0 replies; only message in thread
From: mdshahid03 @ 2026-11-01 8:20 UTC (permalink / raw)
To: haiyangz, wei.liu, decui
Cc: tglx, mingo, bp, dave.hansen, hpa, x86, linux-hyperv,
linux-kernel, Mohammad Shahid
From: Mohammad Shahid <mdshahid03@gmail.com>
The Hyper-V crash trampoline code calculated page table entry
offsets using sizeof() on pointer variables.
Use sizeof(*ptr) instead to calculates the size of the
pointed-to page table entry.
This makes entry size explicit and avoids relying on the
pointer size matching the page table entry size.
This issue was reported by Coccinelle script noderef.cocci.
Signed-off-by: Mohammad Shahid <mdshahid03@gmail.com>
---
arch/x86/hyperv/hv_crash.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/arch/x86/hyperv/hv_crash.c b/arch/x86/hyperv/hv_crash.c
index 5ffcc23255de..810eb1a4a0a2 100644
--- a/arch/x86/hyperv/hv_crash.c
+++ b/arch/x86/hyperv/hv_crash.c
@@ -512,20 +512,20 @@ static void hv_crash_build_tramp_pt(void)
pte_t *pte;
u64 pa, addr = trampoline_pa;
- p4d = hv_crash_ptpgs[0] + pgd_index(addr) * sizeof(p4d);
+ p4d = hv_crash_ptpgs[0] + pgd_index(addr) * sizeof(*p4d);
pa = virt_to_phys(hv_crash_ptpgs[1]);
set_p4d(p4d, __p4d(_PAGE_TABLE | pa));
p4d->p4d &= ~(_PAGE_NX); /* enable execute */
- pud = hv_crash_ptpgs[1] + pud_index(addr) * sizeof(pud);
+ pud = hv_crash_ptpgs[1] + pud_index(addr) * sizeof(*pud);
pa = virt_to_phys(hv_crash_ptpgs[2]);
set_pud(pud, __pud(_PAGE_TABLE | pa));
- pmd = hv_crash_ptpgs[2] + pmd_index(addr) * sizeof(pmd);
+ pmd = hv_crash_ptpgs[2] + pmd_index(addr) * sizeof(*pmd);
pa = virt_to_phys(hv_crash_ptpgs[3]);
set_pmd(pmd, __pmd(_PAGE_TABLE | pa));
- pte = hv_crash_ptpgs[3] + pte_index(addr) * sizeof(pte);
+ pte = hv_crash_ptpgs[3] + pte_index(addr) * sizeof(*pte);
set_pte(pte, pfn_pte(addr >> PAGE_SHIFT, PAGE_KERNEL_EXEC));
}
--
2.43.0
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-11-01 8:21 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-01 8:20 [PATCH] x86/hyperv: use pointed-to type size for page table offsets mdshahid03
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®