From b0f4ae48904c093a5098ac1d2d72b328ec2c1c9a Mon Sep 17 00:00:00 2001 From: Balazs Gerofi Date: Wed, 7 Dec 2016 11:23:45 +0900 Subject: [PATCH] ihk_mc_pt_set_pte(): double check phys address alignment --- arch/x86/kernel/memory.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/arch/x86/kernel/memory.c b/arch/x86/kernel/memory.c index 4f8c1c32..d7ce7b86 100644 --- a/arch/x86/kernel/memory.c +++ b/arch/x86/kernel/memory.c @@ -1779,9 +1779,19 @@ int ihk_mc_pt_set_pte(page_table_t pt, pte_t *ptep, size_t pgsize, *ptep = phys | attr_to_l1attr(attr); } else if (pgsize == PTL2_SIZE) { + if (phys & (PTL2_SIZE - 1)) { + kprintf("%s: error: phys needs to be PTL2_SIZE aligned\n", __FUNCTION__); + error = -1; + goto out; + } *ptep = phys | attr_to_l2attr(attr | PTATTR_LARGEPAGE); } else if ((pgsize == PTL3_SIZE) && (use_1gb_page)) { + if (phys & (PTL3_SIZE - 1)) { + kprintf("%s: error: phys needs to be PTL3_SIZE aligned\n", __FUNCTION__); + error = -1; + goto out; + } *ptep = phys | attr_to_l3attr(attr | PTATTR_LARGEPAGE); } else {