From patchwork Wed Jul 18 09:40:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joerg Roedel X-Patchwork-Id: 10531851 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 5775C600F4 for ; Wed, 18 Jul 2018 09:42:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 45D7828FBC for ; Wed, 18 Jul 2018 09:42:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 38C5228FC6; Wed, 18 Jul 2018 09:42:20 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BC25B28FBC for ; Wed, 18 Jul 2018 09:42:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B20686B027D; Wed, 18 Jul 2018 05:41:33 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id AD2006B0280; Wed, 18 Jul 2018 05:41:33 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 950236B0281; Wed, 18 Jul 2018 05:41:33 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) by kanga.kvack.org (Postfix) with ESMTP id 1EC846B0280 for ; Wed, 18 Jul 2018 05:41:33 -0400 (EDT) Received: by mail-ed1-f69.google.com with SMTP id d5-v6so1699681edq.3 for ; Wed, 18 Jul 2018 02:41:33 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references; bh=0szeeWZq7YDkX4FZF20B/hjvVyBxCS1iOAcH4DAevJw=; b=C6d3AqZ/v6j+tfbPK7XKVGQoObG4W4RAHsCEjXQnJSXw+U6sLhxUM2oS2UQsYV5OWr waoWl8SL/S1lXXGU/cHfpqsRk3z7td9dJTo/V0KXsD4HEHYAXzrOnJajNKuvmoxPwXtA 5SNsIaByEjnS8eXS9CHn8T18TuCcvdPQJsq3+nrn7f78DiGn/ifJ6UZBvnST58bWalLf 4Bf6iAgYy/E2lWNwxFgtczvVqjsnYpsS1Ka2tLRUTZKs7vI5ZOU/Ab5DPCmkm1ROPqUB 8d/084G2wwLTke59jxFnI9K/r7vqE9TBumALMiV742GAWUasI3aGy/v0/iUnXosGY45W z4Kw== X-Gm-Message-State: AOUpUlFT2Vu8uAXoT93gCRHHWjU7lL3FQ7ADKOnV8xCH89rj2cWa/IOd qLAeNA2vdvhzKgziBhq6z47nEKjMlKeGUC2fdO8WQTZAK5BLVqhO/89EBx8wNmptArpJrDS7vjn y/rZhIUDasVaOLDKMpIAt3UXhtlBVyb9tSXrfxzp3FFxamL5UDpaEDy/bS+5675G9lw== X-Received: by 2002:a50:ace2:: with SMTP id x89-v6mr6406439edc.152.1531906892683; Wed, 18 Jul 2018 02:41:32 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfX+ZJvLAZ5rddyL3sWhbrquq0a1y1SAIgPj0LspGosRU7pKCjnwdUN8PG8TKTlFtsCpL4e X-Received: by 2002:a50:ace2:: with SMTP id x89-v6mr6406406edc.152.1531906892025; Wed, 18 Jul 2018 02:41:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531906892; cv=none; d=google.com; s=arc-20160816; b=bi12kzLM5zj62AirIZKWh70PuDs3SC7kygePzhTcokGpoKjGIQyK5wNXhewOBvI7c1 w+AtK6aL49rTTIdkgkJcb6GdRni1UeBjGh1bI44Ux18+ucC4Mn73azzoRDrSYL+5vDq8 xNWliRji+JIP2h7QFpJs6hPeIaDnAGR1kW8yByy9A2yUOL8t7tnbDIxcAE08287kc7co VrwRPuCavk3Y0LzEGGxvUexp0UKsOD4gl7uVQ1qTdpF0uVREm2daoDL7/bF5t9HKYKA/ wEIne1Y50Rhxo9UdGmwGP2ynkZlPsl6hICItEIXS2IRGVd3OxxPG5oZXmCrmcnxPOYvo gAQA== 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=0szeeWZq7YDkX4FZF20B/hjvVyBxCS1iOAcH4DAevJw=; b=WV9WlE5pd7173LBNFnxcx+UwWjkfrmxbKzBWCVsh6GNRIN8WXuGlpzBm7CqI191uLp kmu3090CjBrupr67XxCpnBKu/OxNZnOMzSnJud/Qlr5ZA0qjWwp/DSf5ot+y2phk/7NM fiQ4Gl+qkIJEEzOKrhTkJ//NdAWQIFGTEwwj1trXjcf/rFSPOUJXf5ERBMlql+mUk6Jk rjgA28jqEk0/MrWTPNvonPPxWRWFXy2Ujc1PYVYo74YfzMj30tqndhwPK83LhgOleSM6 MUFhrM3hMhE/wwmlgsrlKCTEamfgjc/sKkju1Pv1StBd3/nlx6R2pqh2c4AYdE060LCb BLvw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@8bytes.org header.s=mail-1 header.b=PtCL21px; 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 Received: from theia.8bytes.org (8bytes.org. [2a01:238:4383:600:38bc:a715:4b6d:a889]) by mx.google.com with ESMTPS id o16-v6si659572edo.118.2018.07.18.02.41.31 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 18 Jul 2018 02:41:32 -0700 (PDT) Received-SPF: pass (google.com: domain of joro@8bytes.org designates 2a01:238:4383:600:38bc:a715:4b6d:a889 as permitted sender) client-ip=2a01:238:4383:600:38bc:a715:4b6d:a889; Authentication-Results: mx.google.com; dkim=pass (test mode) header.i=@8bytes.org header.s=mail-1 header.b=PtCL21px; 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 Received: by theia.8bytes.org (Postfix, from userid 1000) id 00BFD7D5; Wed, 18 Jul 2018 11:41:21 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=8bytes.org; s=mail-1; t=1531906882; bh=wdFK4c7N0vVUj2/eoP/DxBsYH1HhiIX6pQY/IoaNsLU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PtCL21px7r0N1DA0xPJMQhGMw/kBZo5v8JbJBpjo3vk4Dq74vrRSdzf2Gzkv4JJBf XwndAhhF9ixRa//GyUE315Nd7uAUxcfPBO/5lt9bRuO9uUn45r//miHY+cSshpWB2H ZPGWQjjurAJnUln3piA4QUOaPBhiQ4r60RwPsM08plrj0vqZp+NwvS+2pk6Q5RBt/U /1i5FN+P8o/tmIDdd8DmB0PyDWy9ooNEkLqOIMMXLx8HuHLrOBJwmCNDCL7zecU+eH kit163f9x09d+fqwE5Dj8C+iD2c0pi1536SVDWvLuVS5afpS+YdnFlR//yAU0HIEWn /YGHj/49X9HJg== 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 , "David H . Gutteridge" , jroedel@suse.de, joro@8bytes.org Subject: [PATCH 19/39] x86/pgtable: Move pti_set_user_pgtbl() to pgtable.h Date: Wed, 18 Jul 2018 11:40:56 +0200 Message-Id: <1531906876-13451-20-git-send-email-joro@8bytes.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1531906876-13451-1-git-send-email-joro@8bytes.org> References: <1531906876-13451-1-git-send-email-joro@8bytes.org> X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP From: Joerg Roedel There it is also usable from 32 bit code. Signed-off-by: Joerg Roedel --- arch/x86/include/asm/pgtable.h | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h index eb47432..cc117161 100644 --- a/arch/x86/include/asm/pgtable.h +++ b/arch/x86/include/asm/pgtable.h @@ -640,8 +640,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