From patchwork Wed Jul 11 11:29:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joerg Roedel X-Patchwork-Id: 10519479 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 4C8F5603D7 for ; Wed, 11 Jul 2018 11:31:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4D69E26861 for ; Wed, 11 Jul 2018 11:31:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4058B28837; Wed, 11 Jul 2018 11:31:29 +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 D472C26861 for ; Wed, 11 Jul 2018 11:31:28 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2A89A6B0283; Wed, 11 Jul 2018 07:30:15 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 206AE6B0284; Wed, 11 Jul 2018 07:30:15 -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 085186B0285; Wed, 11 Jul 2018 07:30:14 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) by kanga.kvack.org (Postfix) with ESMTP id 9829B6B0283 for ; Wed, 11 Jul 2018 07:30:14 -0400 (EDT) Received: by mail-ed1-f72.google.com with SMTP id i26-v6so3990761edr.4 for ; Wed, 11 Jul 2018 04:30:14 -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=SIS9EGTSEtKzK+0/95jSQZPOK14UDQnVMCVfch8EEIoWH6HNZiCpC2/OdHXeYn6tsC vxAB6ACIBJbAMdREE3dmySNcaU0ZVhxy5kNZvFZODgm8NbMhPgYj//BtbdaOFCLLxB4O 9S5YCYBDaXClzgpfTIUEYEtS9CR3PqUSzyN7gQKNRSwQ8P1flB8FTk2dkLJ71HtNdBWh FWN6R6gTVbdzBuHSjm69XbP/TCCZeExkEXt4JD25MVi0tLlrUdE0EmzQ0L/NXFoq0tS8 bYVFGrOOgbe8gIpp57j47FlZaWg7aLhZeGBxKnq1Rxf9+4nfjWbmACvk7UTw7th9ACea 8z6g== X-Gm-Message-State: APt69E0XvpnGYUesdp3X3hoveQ+ao3CmNVH8lFHFku1+YsIZiLSZZKFK HtBXUDDtKSI6ngZ2j5IvY1x/F4IBpBUAdVVT+AyYYeUnHRtnYisdgAads3eLBz1wOA0B0qZpXKV 0dzR09peaBta9Ecu07nKEaX5RAPs/J6KUQKf1xu7kG1zjj2ay5IZF3cciaRsGE9A/2Q== X-Received: by 2002:aa7:c641:: with SMTP id z1-v6mr1776738edr.9.1531308614189; Wed, 11 Jul 2018 04:30:14 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcr3AS44FwndWxL5wvr5GOf/5KPBxir3h3G2bzXyi5HjAf3B/9cIKEY/sc38Vte1Ym9Yfta X-Received: by 2002:aa7:c641:: with SMTP id z1-v6mr1776697edr.9.1531308613456; Wed, 11 Jul 2018 04:30:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531308613; cv=none; d=google.com; s=arc-20160816; b=0dlTxyCyW7qRxGZd8Io94a7phDLvLzxMW8jmMQB9ikRt6hZ1cWGdKtBguIcWi/WUBj nB+cKlA/EMccblT0YbygRCwpJHnBC2NKHUiux71DTiqPBSVZO+Mz2tSNA+GSLfxrScUf tyEIwTJEolOATVFqWsQDty/yU32Hl79xPEMWDbflQS3VE3sqUvy6RRPoMyyvQ3E6N53s 4Piqeso6C0DibDbRr6yRS06xsoEiPioifn0w6eZ5qkbHnriklioCvWKnP1Nn7+o8wTvn Xi+SUh9p8YmdjislWZ4ClbxMSPbRTa19Y5/zuBaiALum/ZfCKYFfZ4+TaHNrJ3pMLojE ij/g== 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=QRJlrC2nxixUv4mfY4FhY+jkWeWgm07n0NQkxsaFDAQbBBmzEMlljmqAVDpcP0QuS2 cDqQKlRpqFuPxg1ZzF1XonMGw33V3gSCgjDM/77lpWiqbV8xT1/h5OU/rFQMfg33EeSC TzwH0WtGwKLu5hnONxQmBf8DiAwWR0lQb6VAyO7EcNrLN67tdwJD8YyRD4/VPzEuY3q+ m9KcBwarOo0LmWwhQj/g2zSjCpzfHnckhNJ6duZgaNWVPhrYudYLWVXQdlncXOYCSAou dL9vM7T4Ivms0L9bwHD9oYqV+0c1UVdAeMWfMVkt9jTAi8Vgbi6ftxVSSQZAJw4Dr8Ck aZgQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@8bytes.org header.s=mail-1 header.b=hiJVXgRl; 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 t9-v6si740934edd.196.2018.07.11.04.30.13 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 11 Jul 2018 04:30:13 -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=hiJVXgRl; 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 98A8AA63; Wed, 11 Jul 2018 13:30:03 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=8bytes.org; s=mail-1; t=1531308604; bh=wdFK4c7N0vVUj2/eoP/DxBsYH1HhiIX6pQY/IoaNsLU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hiJVXgRlFkV7GuDU5CAEDJrQnCS1yl+1MC0HFPxkh83AH7MiSAwk7qL6We/FA24e1 hMkFolfRePsD0aXZxH40IhteBHcWy4yhC5BQmdeS3G2/vclso2p7F31/4OOFvnTcAR zm7jGTQIuam03z0R84wMGjLP5km81TD4zg0vKefw7twW1y56xVQ7NjOS+Pz0WDSam8 doIEmzi2Ggtu+mIBes3uJOzLoSejaGejYgFQp/gf0qJ+SPFqbdSxS7AEPba9eOWzIR 4sARnzq+MyAUoWjeUGhxSag6g7ll2awwyNx5/zvchD4jb7LxnVyE4QNQUEljB6WPNY IinwK3NMBH6QQ== 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, 11 Jul 2018 13:29:26 +0200 Message-Id: <1531308586-29340-20-git-send-email-joro@8bytes.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1531308586-29340-1-git-send-email-joro@8bytes.org> References: <1531308586-29340-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