From patchwork Wed Jul 11 11:29:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joerg Roedel X-Patchwork-Id: 10519499 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 413266032A for ; Wed, 11 Jul 2018 11:31:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 441D626861 for ; Wed, 11 Jul 2018 11:31:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 35CF6284B3; Wed, 11 Jul 2018 11:31:54 +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=unavailable 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 CE2A026861 for ; Wed, 11 Jul 2018 11:31:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7DA7B6B028C; Wed, 11 Jul 2018 07:30:19 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 736EE6B028E; Wed, 11 Jul 2018 07:30:19 -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 5DBBC6B028D; Wed, 11 Jul 2018 07:30:19 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) by kanga.kvack.org (Postfix) with ESMTP id EED006B028B for ; Wed, 11 Jul 2018 07:30:18 -0400 (EDT) Received: by mail-ed1-f70.google.com with SMTP id r9-v6so6133621edh.14 for ; Wed, 11 Jul 2018 04:30:18 -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=FNkpIdmTGsuqQ9Ux2G5xY1N5gqtMQ7ptEmsItA646os=; b=XL3sR0Yx14WrN0J9gSbxr7EnDcNldljOHQOj+XUzYdpLblXrREKYeWi04mSSapFCVQ STVoGaJ4hyimJDS0kS15NaYEvm3aEdaQir70hG52fUi/J/GqYnQwJjPQkcZIjF4CAQRP ryTQYRX7OzfLrCLPPb+OxNxYfdL/thPgi+6Jh745q+dmwdotLueGbJfW9nt/Ip+rjfC/ hhzht5qFO2w1MBWaBmpRjMCwecgjNkkr4bQh/7DyTO4kAcm63LUqTFBCVoFqqLCQ+/V9 uIcBDvL0dOu6zBVYjbH/1tqpC2CuTTs1/uynzHzvlEbZmVzd94DooKM3NmcWhUTO0q2q KPsA== X-Gm-Message-State: APt69E0cEL0nUhigZnSgXASjlM62vxUFLl1jie9tYK0qseht9nIPlEfn 8WeMBsO/aLeVLdN/GfWx7bss6lLfB3ZzEceq7Cw+TKbqeRJkkNAOKODy9nbD0yie5h2qLisRYpX r1dNDCpd1l1yXfbRT9+ChrGET5gRqAvu67BFHFt+cHCOIWTtxB2U8U2w6DWGlh+JZJg== X-Received: by 2002:a50:9182:: with SMTP id g2-v6mr31529818eda.24.1531308618531; Wed, 11 Jul 2018 04:30:18 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeACe8TFVZJ4G1XOONAah7/NgMWxn8eHS72YFmT8z1zKh59rSIO7N4crfHrr/o942S2Gc3b X-Received: by 2002:a50:9182:: with SMTP id g2-v6mr31529781eda.24.1531308617736; Wed, 11 Jul 2018 04:30:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531308617; cv=none; d=google.com; s=arc-20160816; b=ooV0HAFxBHIMzBELPMWc+ImT+4zaMo79m1nwxb+WsWm0VWCDbrQ1/tdiwuQOeDXcjR DOEySXRNS2YgSMqATH8dUBpz3tQZO+TbM52QvOyN+gbT/A88g9DolEbz2w1J9b4Ey+W4 obPEFfAS4xWWqHDP69AUleqpTyxRr8GDXdTedWTr34KPwbCB04j6ZumBI7nluXDskmRM +DFO21Kwf+w/CQzcuCpxUJ61WT1m+LXV1obD3qY2Za7jbJybGjfaKmJePl1vPZjpzJtg dDENQOmDVo/ID5iZOJQ1vJyIeuqlF0PJLNcKQ7zRLHV6qiFAccofb78SNKGBHkxsgLfZ 6xbw== 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=FNkpIdmTGsuqQ9Ux2G5xY1N5gqtMQ7ptEmsItA646os=; b=EZLH25xlJhEEm+lt4BIrodICRmKLz0f/SLIjU1vQypsxUQBM35R3Z6Gh7U4TTwpT8X /+4PLKkUUya8yr19RMEzON2nEMG9VkdIom2EAp4dGPxi5N+iwOl9mhNAG78NlEZINQzH kDxiWOI0XEWaKx08nCYlTPlRj/yLR6LWoHLbEINuWCehsmljUlk0n7XE060tNwnS9MTN iW9lYAC1jlE2PqVGhhRwTlr7KevPVSbhYaT83vSqSDCxORxZMrzY4oMuV4FGqxf3Mb9K /PqXGIyDCO9RlfF5WGI5acv1DLyXm4LAZvYE4KTXYaGbepK9IePtqI1243IaYn9J1VyP FHzg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@8bytes.org header.s=mail-1 header.b=CBmzUBNp; 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 y19-v6si4136019edm.267.2018.07.11.04.30.17 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 11 Jul 2018 04:30:17 -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=CBmzUBNp; 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 9FF7CAB8; Wed, 11 Jul 2018 13:30:06 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=8bytes.org; s=mail-1; t=1531308606; bh=Jfm7mY27FLX9BG6L/38y95AXYhceF3pCU1GA56dJNi8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CBmzUBNpS8XbkBnDGIXUwcB0sMbWv3rBJ3b5k6zhUpXPjZONI5b9RIOxptq5nz59Z vh9u7KfZjO3IwD6zjBJBZG5lC1Kj77hXSNBjqSrjy+OpbzyWueOB4i5XpFC8/+Y62Q BEDW0t6EeENjohJ/cMo3o4Sv1c5viXyMbQNVnMfGuvQsEd77u6pXYEV1jf26QVrJAz A8MGH8gaJRctnFTANE4lY7iTetrqvUWQeEc7BUBMyMqUpBtBkWxw/4mXyxkTX6zRYs CdTu3121Wx8rHpLBbdxnjKtct668zhDS0fIcgz7f5Ql5kfLWUwVKBMdvyPr1XOM9bK rBfoxeKdWcCnA== 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 33/39] x86/ldt: Reserve address-space range on 32 bit for the LDT Date: Wed, 11 Jul 2018 13:29:40 +0200 Message-Id: <1531308586-29340-34-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 Reserve 2MB/4MB of address-space for mapping the LDT to user-space on 32 bit PTI kernels. Signed-off-by: Joerg Roedel --- arch/x86/include/asm/pgtable_32_types.h | 7 +++++-- arch/x86/mm/dump_pagetables.c | 9 +++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/arch/x86/include/asm/pgtable_32_types.h b/arch/x86/include/asm/pgtable_32_types.h index d9a001a..7297810 100644 --- a/arch/x86/include/asm/pgtable_32_types.h +++ b/arch/x86/include/asm/pgtable_32_types.h @@ -50,13 +50,16 @@ extern bool __vmalloc_start_set; /* set once high_memory is set */ ((FIXADDR_TOT_START - PAGE_SIZE * (CPU_ENTRY_AREA_PAGES + 1)) \ & PMD_MASK) -#define PKMAP_BASE \ +#define LDT_BASE_ADDR \ ((CPU_ENTRY_AREA_BASE - PAGE_SIZE) & PMD_MASK) +#define PKMAP_BASE \ + ((LDT_BASE_ADDR - PAGE_SIZE) & PMD_MASK) + #ifdef CONFIG_HIGHMEM # define VMALLOC_END (PKMAP_BASE - 2 * PAGE_SIZE) #else -# define VMALLOC_END (CPU_ENTRY_AREA_BASE - 2 * PAGE_SIZE) +# define VMALLOC_END (LDT_BASE_ADDR - 2 * PAGE_SIZE) #endif #define MODULES_VADDR VMALLOC_START diff --git a/arch/x86/mm/dump_pagetables.c b/arch/x86/mm/dump_pagetables.c index e6fd0cd..ccd92c4 100644 --- a/arch/x86/mm/dump_pagetables.c +++ b/arch/x86/mm/dump_pagetables.c @@ -123,6 +123,9 @@ enum address_markers_idx { #ifdef CONFIG_HIGHMEM PKMAP_BASE_NR, #endif +#ifdef CONFIG_MODIFY_LDT_SYSCALL + LDT_NR, +#endif CPU_ENTRY_AREA_NR, FIXADDR_START_NR, END_OF_SPACE_NR, @@ -136,6 +139,9 @@ static struct addr_marker address_markers[] = { #ifdef CONFIG_HIGHMEM [PKMAP_BASE_NR] = { 0UL, "Persistent kmap() Area" }, #endif +#ifdef CONFIG_MODIFY_LDT_SYSCALL + [LDT_NR] = { 0UL, "LDT remap" }, +#endif [CPU_ENTRY_AREA_NR] = { 0UL, "CPU entry area" }, [FIXADDR_START_NR] = { 0UL, "Fixmap area" }, [END_OF_SPACE_NR] = { -1, NULL } @@ -609,6 +615,9 @@ static int __init pt_dump_init(void) # endif address_markers[FIXADDR_START_NR].start_address = FIXADDR_START; address_markers[CPU_ENTRY_AREA_NR].start_address = CPU_ENTRY_AREA_BASE; +# ifdef CONFIG_MODIFY_LDT_SYSCALL + address_markers[LDT_NR].start_address = LDT_BASE_ADDR; +# endif #endif return 0; }