Received: by 10.223.185.116 with SMTP id b49csp2474717wrg; Mon, 5 Mar 2018 03:37:33 -0800 (PST) X-Google-Smtp-Source: AG47ELurlQb9lj3KoF9+q8mO3LVuW0AmTLg3X3qSfZ7pCkoqnZEtzKJDsPIj72Var5UQ8ktAVZ27 X-Received: by 2002:a17:902:7d93:: with SMTP id a19-v6mr9278839plm.160.1520249853247; Mon, 05 Mar 2018 03:37:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520249853; cv=none; d=google.com; s=arc-20160816; b=DC22aDsWfQ5OnRQGmzkyiC8zoJuGpzNHqVLLA8pMm36CFd4fMTB7Q+9XiQgYEmhMGD kMoTGrylODpBXAnfpRpqhTRwlGO9lYnEX3GS9MLeEwiKGoiksMKQrfLQXsvaF3NUnj0t oMKGSTbxgdvIX2+Zf6iFeV0wTI3xzwYTKBOhr99+r2FbRmyD7OjBbQ+/kr++1Tx6B7uv f0MBHQKfQR3QVKxBCqwZtYingHZWgBu9YHT0LPflnIGhcl2ZZOO0aB+9606zBDYXm70u zPAyzl/w/QxO03bkZGFlR9Dk63rAEMl/JX/sxoFv3DjgnEJp8M+Zvpwj/eHjAYatp6eF 6pAA== 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=5pIUFR3j827UoBgxXj6zwaByJODpiTnnoQVsy0h1RsQ=; b=XEqFCDlXOmN9kYfRkZXnyv8nuSURcf33p08Qup5W5WdQC4WsZoMHiYAejUtqn1pukf speQAAjFjF20j8buqN2yra8QR+1bZTuKDaubuanWInHoofVdhc4kAsPxDRfAzuLpaTVo TcbHp8BScloCJy9w3du2GlHaBT/gLXDxLKZ1vD33T7wfy1S6qnnDCcNzlqaI6wiP8mos Ieoj1pm7wDbmXueuNaFW+cfT95cffBUaEyxMGjMXhZhfSuED1/qTpfakHzo7Bibo5dhT zW5hxUAw2MZhUrymQTMbPGpWVP/SymnIyZHSOa+i2t/ftUoZJkSJ4mAr8JZU1uzTDpc9 Pj5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail (test mode) header.i=@8bytes.org header.s=mail-1 header.b=HE+aEPls; 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 g69si10090810pfe.237.2018.03.05.03.37.19; Mon, 05 Mar 2018 03:37:33 -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=HE+aEPls; 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 S934166AbeCEK34 (ORCPT + 99 others); Mon, 5 Mar 2018 05:29:56 -0500 Received: from 8bytes.org ([81.169.241.247]:54894 "EHLO theia.8bytes.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933772AbeCEK0R (ORCPT ); Mon, 5 Mar 2018 05:26:17 -0500 Received: by theia.8bytes.org (Postfix, from userid 1000) id A2BC71F32; Mon, 5 Mar 2018 11:26:07 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=8bytes.org; s=mail-1; t=1520245568; bh=9V0347NXFt5xJUBTUBQQwe4jgdexD5B60hAhs1VS5ME=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HE+aEPlsUhbzqfdS5x+IcDNCoIEHSpgHGERMOuFhrWAkzpSSaZwzNl2hglDabgrrn lBnu6u7sXNge318lTQKArnpkibuXcEtK5gLHZ6itETobzV402cLLccCsu9ZkSwdkya 28ktun3znHDRcWAy2a8JkTZ+9xnr6Yw9J3yv8WL/E/KqK/YlIo8ANdDjOy3YZrBlta nXafBDgN6zL+Qlmcf6EHURM3nKT15Xlm4/lJzRUElpy4LeIGbgPKfGuGkGJuvQLhSJ aIRTnbk4zs8zR0ZRdt4NR1EcnrPzswOzwg9KnO/ycWzKTAOSy2CQYT2BY4H9KpovPI gK4U4uCDKvaYw== 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> 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..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