From patchwork Wed Aug 22 06:40:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juerg Haefliger X-Patchwork-Id: 960793 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=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=canonical.com Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41wHwz6GLZz9s7X; Wed, 22 Aug 2018 16:40:35 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1fsMod-0006t7-RC; Wed, 22 Aug 2018 06:40:27 +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 1fsMoc-0006sm-Fr for kernel-team@lists.ubuntu.com; Wed, 22 Aug 2018 06:40:26 +0000 Received: from mail-ed1-f70.google.com ([209.85.208.70]) by youngberry.canonical.com with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.76) (envelope-from ) id 1fsMoc-0004EZ-8Y for kernel-team@lists.ubuntu.com; Wed, 22 Aug 2018 06:40:26 +0000 Received: by mail-ed1-f70.google.com with SMTP id g11-v6so475735edi.8 for ; Tue, 21 Aug 2018 23:40:26 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=dgYDeRztlICVCRIOVxJ45x3nTzd+nsC5qZ2yjsdWrE8=; b=gpg1ez6SiNMfhVuRC6tdkslfHf5F8dmL7Uro3qoBmZx2uRae+mdr29PIgzsQExZGZI LWtQfO1XY+wHcrquliiC04JAHBGB5YZ+I7PwEa1QJjbXNNtkaZJ5b2R+mFFE4VZuMo7q 6w3gDfciIsndcJYFDaCjITn8FcdQ6KQ0n9EhkeKHTPAXjRFvVVTa2sGSuH39DfO7T1aj q3Z8XBdl6DS+wdicwpD0i2LOipImDRJxGXdZTDm1SmiHzktjyqBylU8eaNiBCOY9Qy1B ELiRdJRzSCktrihiek2fyX+RfS6oOCWOTZCsyQo0NZNBzA0yDzMtHgqNi1agVK1Jq4o7 SRAQ== X-Gm-Message-State: APzg51A/p0JG1beJ/7fnNE/jvDB5FOKXbgLmsjWrH8efajvqFUOZII8R 6Y+9rad3mJSSQ5x9zxtKcx/0rJzTQgNAXF+sJqFMiLVL49YHaHd7YiRc9PvgCk0m+7cNQTR3BjK hErWQa9pbdZ2c5ceZS9GjOKYfP1ji5cLddfVT8nJRlQ== X-Received: by 2002:a50:a5af:: with SMTP id a44-v6mr16188348edc.289.1534920025757; Tue, 21 Aug 2018 23:40:25 -0700 (PDT) X-Google-Smtp-Source: AA+uWPzF8ntjXIo4ETZDasRyg6Y5OrmsZVCg2l7LtGgdffJIWK2zLqRdzYBG0k+IftisWuGKHaGigQ== X-Received: by 2002:a50:a5af:: with SMTP id a44-v6mr16188337edc.289.1534920025614; Tue, 21 Aug 2018 23:40:25 -0700 (PDT) Received: from localhost.localdomain ([81.221.205.149]) by smtp.gmail.com with ESMTPSA id j23-v6sm529350edh.29.2018.08.21.23.40.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 21 Aug 2018 23:40:24 -0700 (PDT) From: Juerg Haefliger X-Google-Original-From: Juerg Haefliger To: kernel-team@lists.ubuntu.com Subject: [SRU][Trusty][PATCH 1/7] mm: x86 pgtable: drop unneeded preprocessor ifdef Date: Wed, 22 Aug 2018 08:40:15 +0200 Message-Id: <20180822064021.17216-2-juergh@canonical.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180822064021.17216-1-juergh@canonical.com> References: <20180822064021.17216-1-juergh@canonical.com> 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: , Cc: juergh@canonical.com MIME-Version: 1.0 Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Cyrill Gorcunov _PAGE_BIT_FILE (bit 6) is always less than _PAGE_BIT_PROTNONE (bit 8), so drop redundant #ifdef. Signed-off-by: Cyrill Gorcunov Cc: Linus Torvalds Cc: Mel Gorman Cc: Peter Anvin Cc: Ingo Molnar Cc: Steven Noonan Cc: Rik van Riel Cc: David Vrabel Cc: Peter Zijlstra Cc: Pavel Emelyanov Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds CVE-2018-3620 CVE-2018-3646 (backported from commit 2373eaecff33db5972bde9418f92d6401b4a945c) [juergh: - Added additional comment from commit bcd11afa7ada ("x86/speculation/l1tf: Change order of offset/type in swap entry"). - Added a compile-time error for _PAGE_BIT_FILE > _PAGE_BIT_PROTNONE.] Signed-off-by: Juerg Haefliger --- arch/x86/include/asm/pgtable-2level.h | 10 ---------- arch/x86/include/asm/pgtable_64.h | 21 +++++++++++++++------ 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/arch/x86/include/asm/pgtable-2level.h b/arch/x86/include/asm/pgtable-2level.h index c3625ecf5e3e..b405a0e5f053 100644 --- a/arch/x86/include/asm/pgtable-2level.h +++ b/arch/x86/include/asm/pgtable-2level.h @@ -105,13 +105,8 @@ static inline pmd_t native_pmdp_get_and_clear(pmd_t *xp) */ #define PTE_FILE_MAX_BITS 29 #define PTE_FILE_SHIFT1 (_PAGE_BIT_PRESENT + 1) -#if _PAGE_BIT_FILE < _PAGE_BIT_PROTNONE #define PTE_FILE_SHIFT2 (_PAGE_BIT_FILE + 1) #define PTE_FILE_SHIFT3 (_PAGE_BIT_PROTNONE + 1) -#else -#define PTE_FILE_SHIFT2 (_PAGE_BIT_PROTNONE + 1) -#define PTE_FILE_SHIFT3 (_PAGE_BIT_FILE + 1) -#endif #define PTE_FILE_BITS1 (PTE_FILE_SHIFT2 - PTE_FILE_SHIFT1 - 1) #define PTE_FILE_BITS2 (PTE_FILE_SHIFT3 - PTE_FILE_SHIFT2 - 1) @@ -135,13 +130,8 @@ static inline pmd_t native_pmdp_get_and_clear(pmd_t *xp) #endif /* CONFIG_MEM_SOFT_DIRTY */ /* Encode and de-code a swap entry */ -#if _PAGE_BIT_FILE < _PAGE_BIT_PROTNONE #define SWP_TYPE_BITS (_PAGE_BIT_FILE - _PAGE_BIT_PRESENT - 1) #define SWP_OFFSET_SHIFT (_PAGE_BIT_PROTNONE + 1) -#else -#define SWP_TYPE_BITS (_PAGE_BIT_PROTNONE - _PAGE_BIT_PRESENT - 1) -#define SWP_OFFSET_SHIFT (_PAGE_BIT_FILE + 1) -#endif #define MAX_SWAPFILES_CHECK() BUILD_BUG_ON(MAX_SWAPFILES_SHIFT > SWP_TYPE_BITS) diff --git a/arch/x86/include/asm/pgtable_64.h b/arch/x86/include/asm/pgtable_64.h index 975962a32a20..a39a0afe65be 100644 --- a/arch/x86/include/asm/pgtable_64.h +++ b/arch/x86/include/asm/pgtable_64.h @@ -165,19 +165,28 @@ static inline int pgd_large(pgd_t pgd) { return 0; } #define pte_offset_map(dir, address) pte_offset_kernel((dir), (address)) #define pte_unmap(pte) ((void)(pte))/* NOP */ +#if _PAGE_BIT_FILE > _PAGE_BIT_PROTNONE +#error "Unsupported PTE bit arrangement" +#endif + /* * Encode and de-code a swap entry * + * | ... | 11| 10| 9|8|7|6|5| 4| 3|2|1|0| <- bit number + * | ... |SW3|SW2|SW1|G|L|D|A|CD|WT|U|W|P| <- bit names + * | TYPE (59-63) | ~OFFSET (9-58) |0|X|X|X| X| X|X|X|0| <- swp entry + * + * G (8) is aliased and used as a PROT_NONE indicator for + * !present ptes. We need to start storing swap entries above + * there. We also need to avoid using A and D because of an + * erratum where they can be incorrectly set by hardware on + * non-present PTEs. + * * The offset is inverted by a binary not operation to make the high * physical bits set. -*/ -#if _PAGE_BIT_FILE < _PAGE_BIT_PROTNONE + */ #define SWP_TYPE_BITS (_PAGE_BIT_FILE - _PAGE_BIT_PRESENT - 1) #define SWP_OFFSET_FIRST_BIT (_PAGE_BIT_PROTNONE + 1) -#else -#define SWP_TYPE_BITS (_PAGE_BIT_PROTNONE - _PAGE_BIT_PRESENT - 1) -#define SWP_OFFSET_FIRST_BIT (_PAGE_BIT_FILE + 1) -#endif /* We always extract/encode the offset by shifting it all the way up, and then down again */ #define SWP_OFFSET_SHIFT (SWP_OFFSET_FIRST_BIT+SWP_TYPE_BITS)