From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Google-Smtp-Source: AG47ELvf7NZjC9RV0H/+OdIgXz2NruXHOHLGEuhgmTZks1JrG1w8OURZr7VJMiy1LPZ7rulCS6bQ ARC-Seal: i=1; a=rsa-sha256; t=1520245576; cv=none; d=google.com; s=arc-20160816; b=pgr9M3dI4uwEpWrmGXUDUB/u4Q9KQ37Vi1QwwWpkcvYKxXO4qKvuGLvdkUeSCTxxlm dz2u6r0H4Xqagy3CKxONraVih0ffU33dlEQYRjcb5xA8/qPURrszhGmW/2b3gC2zc2ho kiRk5DET9kKOp33PbJXgLghCi3bymCvtukvfWaG7Au7262VrMpcYR6lG4JSosBL0p9bE nMDBVQFv7ey2M/czNBUm9E8kJDZHQOlrQsa6ky2MNlG6NYW0IKYnfHsDWlbGvbsjSc9J EWtEyOUqEISR0LIJII8ESQQhaCFPSXd9zrPjaS5jNoj5Q7IV8T9/sgdz73AHlvyqr1UE Rayg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=5pIUFR3j827UoBgxXj6zwaByJODpiTnnoQVsy0h1RsQ=; b=Gtk9w1Il/lAJiJNAT1PfFKnY2QGcaO8ppwfe9zwtc24mB1rxOSEf5Hy9TaagtUaj3A i0Iv+yNOZs0fuYnApMzld/PYLrvdf8WqpWIQ6V6dUKVCYTLGNRBWiB/U9KQxW8ljMBJr V7fXUwjaufZG+n+yxaU9a3oI7oBIEmmWDXvgRbHfz6V5NIRIGGHHQwD2D58ysaMHz9y8 WI+Sdhm8lZdb/GbF1aOVWul2/Ek/vSnZWWwx5UWSubd/TzpFKTU9eKY8CTtUZX05v8jO zh9g7I/8yiCuVJnMj19A/D0Cf0xqc5kjvqWkrNrc+oljcmeQjaqUiK4zj92p363yJhhQ j1nQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@8bytes.org header.s=mail-1 header.b=HE+aEPls; spf=pass (google.com: domain of joro@8bytes.org designates 2a01:238:4383:600:38bc:a715:4b6d:a889 as permitted sender) smtp.mailfrom=joro@8bytes.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=8bytes.org Authentication-Results: mx.google.com; dkim=pass (test mode) header.i=@8bytes.org header.s=mail-1 header.b=HE+aEPls; spf=pass (google.com: domain of joro@8bytes.org designates 2a01:238:4383:600:38bc:a715:4b6d:a889 as permitted sender) smtp.mailfrom=joro@8bytes.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=8bytes.org 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 19/34] x86/pgtable: Move pti_set_user_pgtbl() to pgtable.h Date: Mon, 5 Mar 2018 11:25:48 +0100 Message-Id: <1520245563-8444-20-git-send-email-joro@8bytes.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1520245563-8444-1-git-send-email-joro@8bytes.org> References: <1520245563-8444-1-git-send-email-joro@8bytes.org> X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: =?utf-8?q?1594093026255069886?= X-GMAIL-MSGID: =?utf-8?q?1594093026255069886?= X-Mailing-List: linux-kernel@vger.kernel.org List-ID: 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..1e900c1 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_pgtbl(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_pgtbl(pgd_t *pgdp, pgd_t pgd) +{ + if (!static_cpu_has(X86_FEATURE_PTI)) + return pgd; + return __pti_set_user_pgtbl(pgdp, pgd); +} +#else /* CONFIG_PAGE_TABLE_ISOLATION */ +static inline pgd_t pti_set_user_pgtbl(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 5e68083..4cbf517 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_pgtbl(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_pgtbl(pgd_t *pgdp, pgd_t pgd) -{ - if (!static_cpu_has(X86_FEATURE_PTI)) - return pgd; - return __pti_set_user_pgtbl(pgdp, pgd); -} -#else -static inline pgd_t pti_set_user_pgtbl(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