[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <alpine.DEB.2.21.1906252100290.32342@nanos.tec.linutronix.de>
Date: Tue, 25 Jun 2019 21:04:39 +0200 (CEST)
From: Thomas Gleixner <tglx@...utronix.de>
To: "Kirill A. Shutemov" <kirill@...temov.name>
cc: Ingo Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>,
"H. Peter Anvin" <hpa@...or.com>,
Dave Hansen <dave.hansen@...ux.intel.com>,
Andy Lutomirski <luto@...nel.org>,
Peter Zijlstra <peterz@...radead.org>, x86@...nel.org,
linux-kernel@...r.kernel.org,
"Kirill A. Shutemov" <kirill.shutemov@...ux.intel.com>
Subject: Re: [PATCH] x86/boot/64: Fix crash if kernel images crosses page
table boundary
On Thu, 20 Jun 2019, Kirill A. Shutemov wrote:
> @@ -190,18 +190,18 @@ unsigned long __head __startup_64(unsigned long physaddr,
> pgd[i + 0] = (pgdval_t)p4d + pgtable_flags;
> pgd[i + 1] = (pgdval_t)p4d + pgtable_flags;
>
> - i = (physaddr >> P4D_SHIFT) % PTRS_PER_P4D;
> - p4d[i + 0] = (pgdval_t)pud + pgtable_flags;
> - p4d[i + 1] = (pgdval_t)pud + pgtable_flags;
> + i = physaddr >> P4D_SHIFT;
> + p4d[(i + 0) % PTRS_PER_P4D] = (pgdval_t)pud + pgtable_flags;
> + p4d[(i + 1) % PTRS_PER_P4D] = (pgdval_t)pud + pgtable_flags;
> } else {
> i = (physaddr >> PGDIR_SHIFT) % PTRS_PER_PGD;
> pgd[i + 0] = (pgdval_t)pud + pgtable_flags;
> pgd[i + 1] = (pgdval_t)pud + pgtable_flags;
> }
>
> - i = (physaddr >> PUD_SHIFT) % PTRS_PER_PUD;
> - pud[i + 0] = (pudval_t)pmd + pgtable_flags;
> - pud[i + 1] = (pudval_t)pmd + pgtable_flags;
> + i = physaddr >> PUD_SHIFT;
> + pud[(i + 0) % PTRS_PER_PUD] = (pudval_t)pmd + pgtable_flags;
> + pud[(i + 1) % PTRS_PER_PUD] = (pudval_t)pmd + pgtable_flags;
>
> pmd_entry = __PAGE_KERNEL_LARGE_EXEC & ~_PAGE_GLOBAL;
> /* Filter out unsupported __PAGE_KERNEL_* bits: */
> @@ -211,8 +211,8 @@ unsigned long __head __startup_64(unsigned long physaddr,
> pmd_entry += physaddr;
>
> for (i = 0; i < DIV_ROUND_UP(_end - _text, PMD_SIZE); i++) {
> - int idx = i + (physaddr >> PMD_SHIFT) % PTRS_PER_PMD;
> - pmd[idx] = pmd_entry + i * PMD_SIZE;
> + int idx = i + (physaddr >> PMD_SHIFT);;
double semicolon
> + pmd[idx % PTRS_PER_PMD] = pmd_entry + i * PMD_SIZE;
This part is functionally equivivalent. So what's the value of this change?
Thanks,
tglx
Powered by blists - more mailing lists