Received: by 2002:a4a:311b:0:0:0:0:0 with SMTP id k27-v6csp4807215ooa; Tue, 14 Aug 2018 10:49:28 -0700 (PDT) X-Google-Smtp-Source: AA+uWPwyfWKhGSabls199V+nDESxuaxG35wvKzXy7mOEmu6YJxMjqEYMAbkgpSGKbqA11kedHylS X-Received: by 2002:a63:6a45:: with SMTP id f66-v6mr21256245pgc.81.1534268968828; Tue, 14 Aug 2018 10:49:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534268968; cv=none; d=google.com; s=arc-20160816; b=FyMgtauoBrdDIuyG0mwXJKDz/PBx8s0uM05u/6mXAPWaIXOqIj/6Fl6SCx4oU3u9rD D02xkdPVdiDkdm+/Hv4z613i9sMeKbKAaXHr8LCnhSON9qVpPl4hlBvJ8xBYKnhuWKMW ZNjb2h0PMdl49PvFwz6lc9RGDu2xWp3GZTObhrvmfuoGHBIytANWutqmG/gpj44US53z cow878Z2BgckWkxTtYIGiuBduvMRzfkZFEz5IdI9hu5vkClq08af0htlRGBcwfmzGyYs cZRZOAVlsgivSO6RmIJpFRqKikQwXRE1TP9Vp6VcVjm6Yex2zxh2vwonIzB+SE3ZaWlz 2Ijg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=SYm4c/RYt4vXycHSWN0X6ADqrxWVpJdVViM5V4o5q6w=; b=oiyghBb2DL0Dv96zPr2KTeHxwJB3RL3FKmiK/mW4TfF06R+cGQr2X/tXVo0vWNtKrL VaArYhyiaALbjoS8mM4zma+0Ds2o3HaozNsjrRl47CIT8WgVKcgfEwvi0HBerd4ipPTF TMoetEWJ1tbdrIFsupDhU9bk49IC1bo6tqHUdEx/DzUU/JS7cAXNkFs1/13Xxm2c2JX0 nFLg1xny2gTIPBOGX5KNKmJTqA4Am4tpY1TgVIi/suaZNXU6c9AsMh4jMszKDUZWn9yB 1M8tPadpIBWOftuV/XcFfErXg3n26Gmk5qvY+rUeGg2mwlVkJAbiCfAC1uzAIrAGQ6rU s/Aw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 2-v6si22872838pfd.39.2018.08.14.10.49.14; Tue, 14 Aug 2018 10:49:28 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391273AbeHNUgS (ORCPT + 99 others); Tue, 14 Aug 2018 16:36:18 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:32916 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390875AbeHNUgR (ORCPT ); Tue, 14 Aug 2018 16:36:17 -0400 Received: from localhost (unknown [194.244.16.108]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 523C0C74; Tue, 14 Aug 2018 17:48:04 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jan Beulich , Michal Hocko , Thomas Gleixner , Vlastimil Babka , David Woodhouse , Guenter Roeck Subject: [PATCH 4.4 38/43] x86/speculation/l1tf: Fix up pte->pfn conversion for PAE Date: Tue, 14 Aug 2018 19:18:14 +0200 Message-Id: <20180814171519.579666720@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180814171517.014285600@linuxfoundation.org> References: <20180814171517.014285600@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Michal Hocko commit e14d7dfb41f5807a0c1c26a13f2b8ef16af24935 upstream Jan has noticed that pte_pfn and co. resp. pfn_pte are incorrect for CONFIG_PAE because phys_addr_t is wider than unsigned long and so the pte_val reps. shift left would get truncated. Fix this up by using proper types. [dwmw2: Backport to 4.9] Fixes: 6b28baca9b1f ("x86/speculation/l1tf: Protect PROT_NONE PTEs against speculation") Reported-by: Jan Beulich Signed-off-by: Michal Hocko Signed-off-by: Thomas Gleixner Acked-by: Vlastimil Babka Signed-off-by: David Woodhouse Signed-off-by: Guenter Roeck Signed-off-by: Greg Kroah-Hartman --- arch/x86/include/asm/pgtable.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) --- a/arch/x86/include/asm/pgtable.h +++ b/arch/x86/include/asm/pgtable.h @@ -154,21 +154,21 @@ static inline u64 protnone_mask(u64 val) static inline unsigned long pte_pfn(pte_t pte) { - unsigned long pfn = pte_val(pte); + phys_addr_t pfn = pte_val(pte); pfn ^= protnone_mask(pfn); return (pfn & PTE_PFN_MASK) >> PAGE_SHIFT; } static inline unsigned long pmd_pfn(pmd_t pmd) { - unsigned long pfn = pmd_val(pmd); + phys_addr_t pfn = pmd_val(pmd); pfn ^= protnone_mask(pfn); return (pfn & pmd_pfn_mask(pmd)) >> PAGE_SHIFT; } static inline unsigned long pud_pfn(pud_t pud) { - unsigned long pfn = pud_val(pud); + phys_addr_t pfn = pud_val(pud); pfn ^= protnone_mask(pfn); return (pfn & pud_pfn_mask(pud)) >> PAGE_SHIFT; } @@ -369,7 +369,7 @@ static inline pgprotval_t massage_pgprot static inline pte_t pfn_pte(unsigned long page_nr, pgprot_t pgprot) { - phys_addr_t pfn = page_nr << PAGE_SHIFT; + phys_addr_t pfn = (phys_addr_t)page_nr << PAGE_SHIFT; pfn ^= protnone_mask(pgprot_val(pgprot)); pfn &= PTE_PFN_MASK; return __pte(pfn | massage_pgprot(pgprot)); @@ -377,7 +377,7 @@ static inline pte_t pfn_pte(unsigned lon static inline pmd_t pfn_pmd(unsigned long page_nr, pgprot_t pgprot) { - phys_addr_t pfn = page_nr << PAGE_SHIFT; + phys_addr_t pfn = (phys_addr_t)page_nr << PAGE_SHIFT; pfn ^= protnone_mask(pgprot_val(pgprot)); pfn &= PHYSICAL_PMD_PAGE_MASK; return __pmd(pfn | massage_pgprot(pgprot));