From patchwork Thu Aug 30 12:52:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juerg Haefliger X-Patchwork-Id: 963858 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 421Mpw3xpPz9s2P; Thu, 30 Aug 2018 22:52:56 +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 1fvMRM-0003uZ-Lr; Thu, 30 Aug 2018 12:52:48 +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 1fvMRK-0003su-3A for kernel-team@lists.ubuntu.com; Thu, 30 Aug 2018 12:52:46 +0000 Received: from mail-ed1-f69.google.com ([209.85.208.69]) by youngberry.canonical.com with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.76) (envelope-from ) id 1fvMRJ-0000cQ-S4 for kernel-team@lists.ubuntu.com; Thu, 30 Aug 2018 12:52:45 +0000 Received: by mail-ed1-f69.google.com with SMTP id g11-v6so3485883edi.8 for ; Thu, 30 Aug 2018 05:52:45 -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=ZbRYzs/WO6Zl0SZNhix+quumFV9p+WQ2Q3GAhr/bWoE=; b=DT4IM5gVu6UkGslDv5XQ/R8wy/r/nm25NeDNUZFLlRnkkmgTflBdbT4WL2ZR610G3o P5KIH0jcTxEWCJZ/tOp++aqQhlMGos9wNPSU4rSdVret3BKluGWSPf2u318UIpiJ5sS+ Ac2kCcvhYthZCI5jlILxOdeA5UtNXWov13AF1ajloUsI1qA6vRAOeN2Q7jC+TQGC7ohi CtftP5CQkbZq8Asq29bwOK6JIkZxk9vj6ulNFBtrDoPcqzeKI2Pfy2qoJq5NLQd8UQdp 72sIVyNrSFKB/ef7PnvORwWtsuHv5y7IEaexgNDnh4nqmbgF5J9c321VUEtiJum6a6XH Dxvw== X-Gm-Message-State: APzg51D1E7IbK+B+QnUloMyymz+s3jajkWLdnzYrrO4Pxu+AMY31JYJq FX88Dhi7aHDvn8uO+gFftrO2pnd1pM2fLR12SwYh3ZU4CKx32zZr8dADWdVhM/YPWp/Cb1+tGTp u0n9Xy7gYxEgT79UeO6UqZTmdmbfksTvs9hMu045yvQ== X-Received: by 2002:a50:f002:: with SMTP id r2-v6mr12640829edl.91.1535633565419; Thu, 30 Aug 2018 05:52:45 -0700 (PDT) X-Google-Smtp-Source: ANB0Vdbx/MA2tjByUqiYFr2NOCupxpV8k+UHisuiDMFYz7CkOtDA3jZBWUvWXyg0+sTxN9YKRDP8mw== X-Received: by 2002:a50:f002:: with SMTP id r2-v6mr12640819edl.91.1535633565288; Thu, 30 Aug 2018 05:52:45 -0700 (PDT) Received: from localhost.localdomain ([81.221.205.149]) by smtp.gmail.com with ESMTPSA id y27-v6sm2953550edb.20.2018.08.30.05.52.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 30 Aug 2018 05:52:44 -0700 (PDT) From: Juerg Haefliger X-Google-Original-From: Juerg Haefliger To: kernel-team@lists.ubuntu.com Subject: [SRU][Trusty][PATCH v2 4/7] x86/asm: Fix pud/pmd interfaces to handle large PAT bit Date: Thu, 30 Aug 2018 14:52:36 +0200 Message-Id: <20180830125239.16775-5-juergh@canonical.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180830125239.16775-1-juergh@canonical.com> References: <20180822064021.17216-1-juergh@canonical.com> <20180830125239.16775-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: Toshi Kani Now that we have pud/pmd mask interfaces, which handle pfn & flags mask properly for the large PAT bit. Fix pud/pmd pfn & flags interfaces by replacing PTE_PFN_MASK and PTE_FLAGS_MASK with the pud/pmd mask interfaces. Suggested-by: Juergen Gross Signed-off-by: Toshi Kani Cc: Andrew Morton Cc: Juergen Gross Cc: H. Peter Anvin Cc: Ingo Molnar Cc: Borislav Petkov Cc: Konrad Wilk Cc: Robert Elliot Cc: linux-mm@kvack.org Link: http://lkml.kernel.org/r/1442514264-12475-5-git-send-email-toshi.kani@hpe.com Signed-off-by: Thomas Gleixner CVE-2018-3620 CVE-2018-3646 (backported from commit f70abb0fc3da1b2945c92751ccda2744081bf2b7) [juergh: Adjusted for already applied commits: - "x86/mm: Simplify p[g4um]d_page() macros" - "x86/speculation/l1tf: Protect PROT_NONE PTEs against speculation".] Signed-off-by: Juerg Haefliger --- arch/x86/include/asm/pgtable.h | 8 ++++---- arch/x86/include/asm/pgtable_types.h | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h index 6d26abf00939..9b5f836cf7ca 100644 --- a/arch/x86/include/asm/pgtable.h +++ b/arch/x86/include/asm/pgtable.h @@ -158,14 +158,14 @@ static inline unsigned long pmd_pfn(pmd_t pmd) { phys_addr_t pfn = pmd_val(pmd); pfn ^= protnone_mask(pfn); - return (pfn & PTE_PFN_MASK) >> PAGE_SHIFT; + return (pfn & pmd_pfn_mask(pmd)) >> PAGE_SHIFT; } static inline unsigned long pud_pfn(pud_t pud) { phys_addr_t pfn = pud_val(pud); pfn ^= protnone_mask(pfn); - return (pfn & PTE_PFN_MASK) >> PAGE_SHIFT; + return (pfn & pud_pfn_mask(pud)) >> PAGE_SHIFT; } static inline unsigned long pgd_pfn(pgd_t pgd) @@ -539,7 +539,7 @@ static inline int pmd_none(pmd_t pmd) static inline unsigned long pmd_page_vaddr(pmd_t pmd) { - return (unsigned long)__va(pmd_val(pmd) & PTE_PFN_MASK); + return (unsigned long)__va(pmd_val(pmd) & pmd_pfn_mask(pmd)); } /* @@ -612,7 +612,7 @@ static inline int pud_present(pud_t pud) static inline unsigned long pud_page_vaddr(pud_t pud) { - return (unsigned long)__va((unsigned long)pud_val(pud) & PTE_PFN_MASK); + return (unsigned long)__va(pud_val(pud) & pud_pfn_mask(pud)); } /* diff --git a/arch/x86/include/asm/pgtable_types.h b/arch/x86/include/asm/pgtable_types.h index a71489cc88c2..00a871c5d0af 100644 --- a/arch/x86/include/asm/pgtable_types.h +++ b/arch/x86/include/asm/pgtable_types.h @@ -346,7 +346,7 @@ static inline pudval_t pud_flags_mask(pud_t pud) static inline pudval_t pud_flags(pud_t pud) { - return native_pud_val(pud) & PTE_FLAGS_MASK; + return native_pud_val(pud) & pud_flags_mask(pud); } static inline pmdval_t pmd_pfn_mask(pmd_t pmd) @@ -367,7 +367,7 @@ static inline pmdval_t pmd_flags_mask(pmd_t pmd) static inline pmdval_t pmd_flags(pmd_t pmd) { - return native_pmd_val(pmd) & PTE_FLAGS_MASK; + return native_pmd_val(pmd) & pmd_flags_mask(pmd); } static inline pte_t native_make_pte(pteval_t val)