APPLIED: [SRU][Artful][PATCH] x86/mm: Fix overlap of i386 CPU_ENTRY_AREA with FIX_BTMAP
Kleber Souza
kleber.souza at canonical.com
Fri Feb 2 16:16:06 UTC 2018
On 02/02/18 16:16, Kleber Sacilotto de Souza wrote:
> From: William Grant <william.grant at canonical.com>
>
> BugLink: http://bugs.launchpad.net/bugs/1745118
>
> Since commit 92a0f81d8957 ("x86/cpu_entry_area: Move it out of the
> fixmap"), i386's CPU_ENTRY_AREA has been mapped to the memory area just
> below FIXADDR_START. But already immediately before FIXADDR_START is the
> FIX_BTMAP area, which means that early_ioremap can collide with the entry
> area.
>
> It's especially bad on PAE where FIX_BTMAP_BEGIN gets aligned to exactly
> match CPU_ENTRY_AREA_BASE, so the first early_ioremap slot clobbers the
> IDT and causes interrupts during early boot to reset the system.
>
> The overlap wasn't a problem before the CPU entry area was introduced,
> as the fixmap has classically been preceded by the pkmap or vmalloc
> areas, neither of which is used until early_ioremap is out of the
> picture.
>
> Relocate CPU_ENTRY_AREA to below FIX_BTMAP, not just below the permanent
> fixmap area.
>
> Fixes: commit 92a0f81d8957 ("x86/cpu_entry_area: Move it out of the fixmap")
> Signed-off-by: William Grant <william.grant at canonical.com>
> Signed-off-by: Thomas Gleixner <tglx at linutronix.de>
> Cc: stable at vger.kernel.org
> Link: https://lkml.kernel.org/r/7041d181-a019-e8b9-4e4e-48215f841e2c@canonical.com
> (cherry picked from commit 55f49fcb879fbeebf2a8c1ac7c9e6d90df55f798 git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git)
> Signed-off-by: Kleber Sacilotto de Souza <kleber.souza at canonical.com>
> ---
> arch/x86/include/asm/fixmap.h | 6 ++++--
> arch/x86/include/asm/pgtable_32_types.h | 5 +++--
> 2 files changed, 7 insertions(+), 4 deletions(-)
>
> diff --git a/arch/x86/include/asm/fixmap.h b/arch/x86/include/asm/fixmap.h
> index a6ff9e1a6189..75d9ea3fedcd 100644
> --- a/arch/x86/include/asm/fixmap.h
> +++ b/arch/x86/include/asm/fixmap.h
> @@ -137,8 +137,10 @@ enum fixed_addresses {
>
> extern void reserve_top_address(unsigned long reserve);
>
> -#define FIXADDR_SIZE (__end_of_permanent_fixed_addresses << PAGE_SHIFT)
> -#define FIXADDR_START (FIXADDR_TOP - FIXADDR_SIZE)
> +#define FIXADDR_SIZE (__end_of_permanent_fixed_addresses << PAGE_SHIFT)
> +#define FIXADDR_START (FIXADDR_TOP - FIXADDR_SIZE)
> +#define FIXADDR_TOT_SIZE (__end_of_fixed_addresses << PAGE_SHIFT)
> +#define FIXADDR_TOT_START (FIXADDR_TOP - FIXADDR_TOT_SIZE)
>
> extern int fixmaps_set;
>
> diff --git a/arch/x86/include/asm/pgtable_32_types.h b/arch/x86/include/asm/pgtable_32_types.h
> index 67b60e11b70d..5b8e9f1d61d8 100644
> --- a/arch/x86/include/asm/pgtable_32_types.h
> +++ b/arch/x86/include/asm/pgtable_32_types.h
> @@ -43,8 +43,9 @@ extern bool __vmalloc_start_set; /* set once high_memory is set */
> */
> #define CPU_ENTRY_AREA_PAGES (NR_CPUS * 40)
>
> -#define CPU_ENTRY_AREA_BASE \
> - ((FIXADDR_START - PAGE_SIZE * (CPU_ENTRY_AREA_PAGES + 1)) & PMD_MASK)
> +#define CPU_ENTRY_AREA_BASE \
> + ((FIXADDR_TOT_START - PAGE_SIZE * (CPU_ENTRY_AREA_PAGES + 1)) \
> + & PMD_MASK)
>
> #define PKMAP_BASE \
> ((CPU_ENTRY_AREA_BASE - PAGE_SIZE) & PMD_MASK)
>
Applied to artful/master-next branch.
Thanks,
Kleber
More information about the kernel-team
mailing list