From patchwork Wed Jul 18 09:41:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joerg Roedel X-Patchwork-Id: 10531907 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 B1C75600F4 for ; Wed, 18 Jul 2018 09:43:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A206028FBC for ; Wed, 18 Jul 2018 09:43:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9618E28FCD; Wed, 18 Jul 2018 09:43: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=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 340D328FBC for ; Wed, 18 Jul 2018 09:43:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4BD6D6B02AB; Wed, 18 Jul 2018 05:41:42 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 432806B02AD; Wed, 18 Jul 2018 05:41:42 -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 2BC336B02AE; Wed, 18 Jul 2018 05:41:42 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) by kanga.kvack.org (Postfix) with ESMTP id BEEFE6B02AB for ; Wed, 18 Jul 2018 05:41:41 -0400 (EDT) Received: by mail-ed1-f71.google.com with SMTP id f8-v6so1702954eds.6 for ; Wed, 18 Jul 2018 02:41:41 -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=md2QWf9SL+ToWHkpCY/B0L2x6eWKbiK62YQuH+EWnHj6nOE2sC8QwhiLqT/vA3+2hY JEEzNi3TGX9uxzO78nozjZyml4Yre0IcXEXV/iN1/5DDT2bqIpmOiN2DlVW6e96Y54O4 ml+yIt8I0sBP/SXhvpDHDRF3uqm+paP/+zJFcjWYLcDa0sxBlQJ9xvzPWUyAeEzvCMeT orK9noXaVhYpt1kfeSl6uNGT/8h9jsicuF1nEEY6g0pSUWUpSFGLZvyJxC7i4CK0Phlb FqA1j51isD2qwq+TMBpsdOz4zO6FTipu977xCnAGBao23i6wnKF290Gz3vsY01DSDeC/ XIIQ== X-Gm-Message-State: AOUpUlHfxrxp+sUk/5iaLKPwBFR/JWKFGyLM2qGQRiKtLX9pyrz1/stZ wFjup3Z4ntFMHLsn/4wO7upQmq7y9/Y5a/o0oxzi19vCD0GUrP/QZHPsx+UD1Gz087e+Yn5E70W PYlhrDa37LjwOVI4317ApWKjebrNW1vgkYTLTRlYL3lH/3yVEnzq1aCK/dOqge/6Ycg== X-Received: by 2002:a50:c251:: with SMTP id t17-v6mr6315570edf.108.1531906901345; Wed, 18 Jul 2018 02:41:41 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcOu/KR3v46o+hoCqkyJBdNdUP7XFpgj1Rjoa1Y7HpUDvV3ITRGNIymb1tfB3IBrsI1suAm X-Received: by 2002:a50:c251:: with SMTP id t17-v6mr6315522edf.108.1531906900410; Wed, 18 Jul 2018 02:41:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531906900; cv=none; d=google.com; s=arc-20160816; b=qAxcjHdEZ9pw5LSLshla8B3YVSX/+xUaz2j9IiNq8DxRHph42RP9uOzsmE/ljCjBiE guAEZ6kOktp32dhIQCu3HFjvXM93v+pg5X+tP0AK3t4JIdqOp5QdsO+sVFebuiGn011V 0EJs18TplYS7dd0kQkLe6zt9DAMr4mlkXCuhGU5ZdCO0o7R3Z3sqeRBF9eBjCj+ODBZE Ko4Ob2xT2ZGemnJeCVJRtu2hB3zip8SuHabWHHmjUQYeAvokmnk9CjOmouZx0jcMMYNo Ctpi/eDF3TRyo0OXWak3HYluf7Cff9h3OvaNViG6zcUoywcjeVCKus34cPD8EqMOPz6l r99w== 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=diILxPXslEz2+Y8MI18rIn0ihP3k43azg+asKgfCX5HT7Mg+Dd9T9WVOg7Wxjq+dEZ 0N/LvOPX3HAuUUNVW4PaZ9cf7B75RDIdbVLruIYpyfX9KRbtcDKBTkLcbu4Y4fifbTn/ koVDV3vAYwvvPxoBjOLnejFOcXagniKUMKYdtHQC1DCdFB9ngDxZZk5GRi4JChPumzaR tcoS0o5L8AE6EKcVHoI58LX+BrHGVN3rC1/rGOh1uF6r1U8cX4H6picCipsXRdvtn4gr fGxoULcDoBDMwLk6WA8T4JirUCXubLtLrFoAMxI+WiN+p/PNzuLfk8QDmlNpRYKeCWL7 LyHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@8bytes.org header.s=mail-1 header.b=QY0PK5Me; 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 p27-v6si3148874edi.276.2018.07.18.02.41.40 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 18 Jul 2018 02:41:40 -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=QY0PK5Me; 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 996463C8C; Wed, 18 Jul 2018 11:41:24 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=8bytes.org; s=mail-1; t=1531906886; bh=Jfm7mY27FLX9BG6L/38y95AXYhceF3pCU1GA56dJNi8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QY0PK5MeNc9LqpYAJqrZs7TjC8bi4nUTPSERvumJM1P5h3hInggYkzGpzmssddjpT jhoSOS7ZXEPV1/voyMoWHf0eaIZtJpwjKf7bzybhfmDgNgSiTwatUBAxIwNGJ5VwFF ugW9FTeF9MVnqPO75B5i9CBjKWWsBj+EULC6Li5LQ6J6gu/d2QlFaXOsHAtFCCGyo6 B76UlnebLzRNteuiP1Ke0o+/MHIwEp1IKdBwx0WnYvuVmIl1DXvyN5uaZZAbBKrhIY Dx5FHlk41MNa5CvFsehQK5G/El6FyzZVysNZ+6/VxAfEbamtGjRb/xUWf7SDRwiW26 MTU3lW6q++zWw== 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, 18 Jul 2018 11:41:10 +0200 Message-Id: <1531906876-13451-34-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 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; }