From patchwork Fri Feb 2 15:16:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kleber Sacilotto de Souza X-Patchwork-Id: 868624 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) by ozlabs.org (Postfix) with ESMTP id 3zY0v107f2z9t20; Sat, 3 Feb 2018 02:16:29 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1ehd4j-0007X4-Id; Fri, 02 Feb 2018 15:16:25 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.86_2) (envelope-from ) id 1ehd4h-0007WB-5z for kernel-team@lists.ubuntu.com; Fri, 02 Feb 2018 15:16:23 +0000 Received: from mail-wm0-f70.google.com ([74.125.82.70]) by youngberry.canonical.com with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.76) (envelope-from ) id 1ehd4g-0005m6-V5 for kernel-team@lists.ubuntu.com; Fri, 02 Feb 2018 15:16:22 +0000 Received: by mail-wm0-f70.google.com with SMTP id h17so4107040wmc.6 for ; Fri, 02 Feb 2018 07:16:22 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id; bh=YlMhCx6Y3pXorn2F53JFcTcuKHWIqnwPJqiqIlRS4vo=; b=eQ71deSiHWg48cQmydaKer1ZYX5bd2Q/ckIkP/dIzwE35S87Mizlz8s2BZu7LCGwj9 uV2r12WMcfarL6Yn3t3ChNUeE7oUxaVPadYkrG3YO3ALg/6EzYE/0zo5gUakQjUeQmwL YOrM2nieutTCvgB4zM0/m94l+xwDaBBMxQQOvveQXnEOEpCM1tBBAeNWPS1Vmpw5ErHk bi6cYjiRAPJ4AU3Yfe7MJ47LNZov/K9RGt+L6PNIM4JK1aQMzw3rcWGEJ+0SQoG16djZ DsRTuDBt55lLbQYqvbwjCPBWtCr6u3hSbmFNtc206rrZVdXAJ33N6YOBdzR5BY0DWpgI tvcg== X-Gm-Message-State: AKwxytcetA4BsdiidLuH3p7gCUtBvWd4bWqer6mLcMNFfNexe7xJ+PGB +wULcNuzJjKrecVEMo9T1AOwQg35NayCsC14ppONDGwTtsh0Kt4qkTjcJrGbiIznxK7AHoPmrlN BlwcWXtcNx6vEeGQ0UPlJ37/Vjw8wQVxwNSDMoYqF4A== X-Received: by 10.223.187.141 with SMTP id q13mr17167508wrg.65.1517584582347; Fri, 02 Feb 2018 07:16:22 -0800 (PST) X-Google-Smtp-Source: AH8x2244x55UFMoIzx2CvIwg+NF/xw9bmz+eKTXesdzYFHoNbe8Sqm1VQWqRf7RpOpoayVUgEjNOpQ== X-Received: by 10.223.187.141 with SMTP id q13mr17167484wrg.65.1517584581900; Fri, 02 Feb 2018 07:16:21 -0800 (PST) Received: from localhost ([2a02:8109:98c0:1604:e0bc:dea5:ede9:cfef]) by smtp.gmail.com with ESMTPSA id r1sm1656258wmg.22.2018.02.02.07.16.20 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 02 Feb 2018 07:16:20 -0800 (PST) From: Kleber Sacilotto de Souza To: kernel-team@lists.ubuntu.com Subject: [SRU][Artful][PATCH] x86/mm: Fix overlap of i386 CPU_ENTRY_AREA with FIX_BTMAP Date: Fri, 2 Feb 2018 16:16:19 +0100 Message-Id: <20180202151619.11126-1-kleber.souza@canonical.com> X-Mailer: git-send-email 2.14.1 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: William Grant 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 Signed-off-by: Thomas Gleixner Cc: stable@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 Acked-by: Colin Ian King --- 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)