Received: by 10.223.176.5 with SMTP id f5csp448065wra; Fri, 9 Feb 2018 01:35:20 -0800 (PST) X-Google-Smtp-Source: AH8x225WFevT/x4JeyJbg/9DdSswQfZIXW6Y/BeofgF4KX0BMOIvM1NKXLjyU0zZG85kFoG8Kwri X-Received: by 10.99.120.139 with SMTP id t133mr1850305pgc.382.1518168920400; Fri, 09 Feb 2018 01:35:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518168920; cv=none; d=google.com; s=arc-20160816; b=Sji1qulzYCrTH0tOPVxw2Jr847ALHf8ULXAHuM3wJ8COKW9d0JslDXksbdme8cZW3A /wg2SVolpCKbGJvh/hYYYqsHTzmDyKvvnByvFVPBLLYDT88kj4RJnPCtoMrAcWGkggQd Yqz/0nfnidsrMbruP+dXUdQOEZB2DgA8PccKbrbTcAkRpClLiLBlvOTpQ4LS8IujEo28 djPEeG8adskyQaXyj0iNDONlorrBWEREeterPrXALx/QhRdNueSatzak96TbVo4mp+Qv lzEXIBllIAiY5LbJSHqg1T/Fq2BwaBJw7k+l0pelGAAJg1lL+REgGShpcM32uzYOyplw VrEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=3/5kUbIEAs/f7+jNQG0KP0VmXR4ogAxlEw45KqMVs0Y=; b=z4L37aUu0rzUuN64L3WlgzUVAftIc1x70Iy8eY/XPp1Gk4Cq0pbaOtt79j4+oIrALP cUwL+CLyc8eAfH2jgmTUtwyKkYordaiI3UEPSM9EY7xld753ixzCa9zQao7wpIeN7cFF aLt2JdorkbE6DPkSE9rceuRBvQB4/S4IoEVBsUvaeuSEMLUVUusUcz2e5WfSJdsTJLhV nEFuo9SgE/TGfYVSmrfUslIxi7SRRqP3tRqBQEn97tUGg1kNKWAu1d31xi3GwXYkjJVh I1939al5oYDL0PtKAHXWtTSOnYMe1XwEUEktyIvV/PhOTG/iSYGlU5uGUGMdPP//dROQ hEJA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail (test mode) header.i=@8bytes.org header.s=mail-1 header.b=FD80PHkg; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=8bytes.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r5si1161938pgt.92.2018.02.09.01.35.06; Fri, 09 Feb 2018 01:35:20 -0800 (PST) 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; dkim=fail (test mode) header.i=@8bytes.org header.s=mail-1 header.b=FD80PHkg; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=8bytes.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752844AbeBIJcG (ORCPT + 99 others); Fri, 9 Feb 2018 04:32:06 -0500 Received: from 8bytes.org ([81.169.241.247]:43132 "EHLO theia.8bytes.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751041AbeBIJ0B (ORCPT ); Fri, 9 Feb 2018 04:26:01 -0500 Received: by theia.8bytes.org (Postfix, from userid 1000) id A5DFB79E; Fri, 9 Feb 2018 10:25:52 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=8bytes.org; s=mail-1; t=1518168353; bh=Rq1vu31DF2ieJHt7Lf4POH0Ef2HaCba1UjgDOdvsl+s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FD80PHkg4jeYpOX00gOH7sBXu0qzDrags6AvX04yRf3HIy9jZCWQoUcQntXbhi3Nw le3Clp3NtHEJ0fx8t8zNH5ERZxogQhriLzsiXRpKA0kTIzmsgHFgHSJq0022sc1RKD 2Fe8BWiuP4CigNMG2ufV6V6wR9AzBAwM43xtRYr1w53Rd+fXjRCpW+IzZuKRmucJpJ UWmBm84xncVZCvayxe3jYLgY3UqoWq45EIlvtD1EDPFv/5vDhs6gYT5SfPEpSZyTX2 5os8zHqjf/RAJz6TM3nPh8P/St13o+n4V1VDRxvVLI4JMle6zXEBBcm82L3b7T0Sts Af32mNLCFpqqg== From: Joerg Roedel To: Thomas Gleixner , Ingo Molnar , "H . Peter Anvin" Cc: x86@kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Linus Torvalds , Andy Lutomirski , Dave Hansen , Josh Poimboeuf , Juergen Gross , Peter Zijlstra , Borislav Petkov , Jiri Kosina , Boris Ostrovsky , Brian Gerst , David Laight , Denys Vlasenko , Eduardo Valentin , Greg KH , Will Deacon , aliguori@amazon.com, daniel.gruss@iaik.tugraz.at, hughd@google.com, keescook@google.com, Andrea Arcangeli , Waiman Long , Pavel Machek , jroedel@suse.de, joro@8bytes.org Subject: [PATCH 17/31] x86/pgtable: Move pti_set_user_pgd() to pgtable.h Date: Fri, 9 Feb 2018 10:25:26 +0100 Message-Id: <1518168340-9392-18-git-send-email-joro@8bytes.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1518168340-9392-1-git-send-email-joro@8bytes.org> References: <1518168340-9392-1-git-send-email-joro@8bytes.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Joerg Roedel There it is also usable from 32 bit code. Signed-off-by: Joerg Roedel --- arch/x86/include/asm/pgtable.h | 23 +++++++++++++++++++++++ arch/x86/include/asm/pgtable_64.h | 21 --------------------- 2 files changed, 23 insertions(+), 21 deletions(-) diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h index 0a9f746..c9d3cf9 100644 --- a/arch/x86/include/asm/pgtable.h +++ b/arch/x86/include/asm/pgtable.h @@ -618,8 +618,31 @@ static inline int is_new_memtype_allowed(u64 paddr, unsigned long size, pmd_t *populate_extra_pmd(unsigned long vaddr); pte_t *populate_extra_pte(unsigned long vaddr); + +#ifdef CONFIG_PAGE_TABLE_ISOLATION +pgd_t __pti_set_user_pgd(pgd_t *pgdp, pgd_t pgd); + +/* + * Take a PGD location (pgdp) and a pgd value that needs to be set there. + * Populates the user and returns the resulting PGD that must be set in + * the kernel copy of the page tables. + */ +static inline pgd_t pti_set_user_pgd(pgd_t *pgdp, pgd_t pgd) +{ + if (!static_cpu_has(X86_FEATURE_PTI)) + return pgd; + return __pti_set_user_pgd(pgdp, pgd); +} +#else /* CONFIG_PAGE_TABLE_ISOLATION */ +static inline pgd_t pti_set_user_pgd(pgd_t *pgdp, pgd_t pgd) +{ + return pgd; +} +#endif /* CONFIG_PAGE_TABLE_ISOLATION */ + #endif /* __ASSEMBLY__ */ + #ifdef CONFIG_X86_32 # include #else diff --git a/arch/x86/include/asm/pgtable_64.h b/arch/x86/include/asm/pgtable_64.h index 58d7f10..396664d 100644 --- a/arch/x86/include/asm/pgtable_64.h +++ b/arch/x86/include/asm/pgtable_64.h @@ -145,27 +145,6 @@ static inline bool pgdp_maps_userspace(void *__ptr) return (ptr & ~PAGE_MASK) < (PAGE_SIZE / 2); } -#ifdef CONFIG_PAGE_TABLE_ISOLATION -pgd_t __pti_set_user_pgd(pgd_t *pgdp, pgd_t pgd); - -/* - * Take a PGD location (pgdp) and a pgd value that needs to be set there. - * Populates the user and returns the resulting PGD that must be set in - * the kernel copy of the page tables. - */ -static inline pgd_t pti_set_user_pgd(pgd_t *pgdp, pgd_t pgd) -{ - if (!static_cpu_has(X86_FEATURE_PTI)) - return pgd; - return __pti_set_user_pgd(pgdp, pgd); -} -#else -static inline pgd_t pti_set_user_pgd(pgd_t *pgdp, pgd_t pgd) -{ - return pgd; -} -#endif - static inline void native_set_p4d(p4d_t *p4dp, p4d_t p4d) { #if defined(CONFIG_PAGE_TABLE_ISOLATION) && !defined(CONFIG_X86_5LEVEL) -- 2.7.4