From patchwork Wed Feb 15 13:58:24 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Borislav Petkov X-Patchwork-Id: 9574141 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 723B6601D8 for ; Wed, 15 Feb 2017 14:00:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 67740284CB for ; Wed, 15 Feb 2017 14:00:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5A3F4284CD; Wed, 15 Feb 2017 14:00:57 +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=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id C02FF284CB for ; Wed, 15 Feb 2017 14:00:56 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ce06c-0005gH-3B; Wed, 15 Feb 2017 13:58:50 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ce06b-0005g9-7c for xen-devel@lists.xenproject.org; Wed, 15 Feb 2017 13:58:49 +0000 Received: from [193.109.254.147] by server-7.bemta-6.messagelabs.com id 79/14-29440-89E54A85; Wed, 15 Feb 2017 13:58:48 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrHIsWRWlGSWpSXmKPExsVyuP0Ov+70uCU RBvdXWVt83zKZyYHR4/CHKywBjFGsmXlJ+RUJrBnbnnYwF1yWqzj84D1rA2OLVBcjJ4eEgJHE 24n/mLoYuTiEBBYySrT1f2YGSQgJpEs8WfadEcRmEVCV2LPqJCuIzSagJPH70zp2EFtEQENi6 uk9zCDNzAK7eSW2XFwAVMTBISwQLDG5KQukhlfAVGLdvD9sEDMtJP6/+8QKEReUODnzCQuIzS ygLvFn3iVmkFZmAWmJ5f84IMLyEs1bZ4OFOQUsJba8DQQJiwqoSMy6PIdlAqPALCSDZiEZNAt h0CwkgxYwsqxiVC9OLSpLLdI100sqykzPKMlNzMzRNTQw08tNLS5OTE/NSUwq1kvOz93ECAxX BiDYwTjvhP8hRkkOJiVR3vU+SyKE+JLyUyozEosz4otKc1KLDzHKcHAoSfBOiAXKCRalpqdWp GXmACMHJi3BwaMkwlsMkuYtLkjMLc5Mh0idYlSUEudtBEkIgCQySvPg2mDReolRVkqYlxHoEC GegtSi3MwSVPlXjOIcjErCvBYgU3gy80rgpr8CWswEtJg1biHI4pJEhJRUAyNrpZiExat5x1R 3LeA+M0nhSumT5MrHWczBnyJdShJfTkoS8Tqa+lxCwO1P+faroXvWWmcd3R/XOSPm91zva6sC VD0EA9OPdbS/4q00dp8lYXZ6SV/gsir+/8tmRbreuFPkf3NttM4jptt8up+Yztd8nBYyt/hIf p9pygJTGcXSn7tWB7BdklJiKc5INNRiLipOBACO/WLX0QIAAA== X-Env-Sender: bp@suse.de X-Msg-Ref: server-11.tower-27.messagelabs.com!1487167127!56735931!1 X-Originating-IP: [195.135.220.15] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.2.3; banners=-,-,- X-VirusChecked: Checked Received: (qmail 15654 invoked from network); 15 Feb 2017 13:58:47 -0000 Received: from mx2.suse.de (HELO mx2.suse.de) (195.135.220.15) by server-11.tower-27.messagelabs.com with DHE-RSA-CAMELLIA256-SHA encrypted SMTP; 15 Feb 2017 13:58:47 -0000 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id D85B3AAC7; Wed, 15 Feb 2017 13:58:44 +0000 (UTC) Received: by pd.tnic (Postfix, from userid 1000) id 5B5C31609A1; Wed, 15 Feb 2017 14:58:24 +0100 (CET) Date: Wed, 15 Feb 2017 14:58:24 +0100 From: Borislav Petkov To: Thomas Garnier Message-ID: <20170215135824.tflwuf3esu2npwwo@pd.tnic> References: <20170214194259.75960-1-thgarnie@google.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20170214194259.75960-1-thgarnie@google.com> User-Agent: NeoMutt/20161014 (1.7.1) Cc: linux-efi@vger.kernel.org, Stanislaw Gruszka , kvm@vger.kernel.org, Radim =?utf-8?B?S3LEjW3DocWZ?= , Matt Fleming , Paul Gortmaker , Alexander Potapenko , Pavel Machek , "H . Peter Anvin" , kernel-hardening@lists.openwall.com, Jiri Olsa , Boris Ostrovsky , Dave Hansen , Andi Kleen , xen-devel@lists.xenproject.org, Michael Ellerman , Joerg Roedel , x86@kernel.org, kasan-dev@googlegroups.com, Christian Borntraeger , Ingo Molnar , Andrey Ryabinin , Len Brown , Rik van Riel , Jiri Kosina , Kees Cook , Arnd Bergmann , He Chen , Brian Gerst , Rusty Russell , lguest@lists.ozlabs.org, Andy Lutomirski , Josh Poimboeuf , Thomas Gleixner , Adam Buchbinder , Dmitry Vyukov , Juergen Gross , Peter Zijlstra , Ard Biesheuvel , linux-pm@vger.kernel.org, "Rafael J . Wysocki" , linux-kernel@vger.kernel.org, Andy Lutomirski , "Luis R . Rodriguez" , Paolo Bonzini , Vitaly Kuznetsov , Tim Chen Subject: Re: [Xen-devel] [PATCH v3 1/4] x86/mm: Adapt MODULES_END based on Fixmap section size X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP On Tue, Feb 14, 2017 at 11:42:56AM -0800, Thomas Garnier wrote: > This patch aligns MODULES_END to the beginning of the Fixmap section. > It optimizes the space available for both sections. The address is > pre-computed based on the number of pages required by the Fixmap > section. > > It will allow GDT remapping in the Fixmap section. The current > MODULES_END static address does not provide enough space for the kernel > to support a large number of processors. > > Signed-off-by: Thomas Garnier > --- > Based on next-20170213 > --- > arch/x86/include/asm/fixmap.h | 8 ++++++++ > arch/x86/include/asm/pgtable_64_types.h | 3 --- > arch/x86/kernel/module.c | 1 + > arch/x86/mm/dump_pagetables.c | 1 + > arch/x86/mm/kasan_init_64.c | 1 + > 5 files changed, 11 insertions(+), 3 deletions(-) > > diff --git a/arch/x86/include/asm/fixmap.h b/arch/x86/include/asm/fixmap.h > index 8554f960e21b..20231189e0e3 100644 > --- a/arch/x86/include/asm/fixmap.h > +++ b/arch/x86/include/asm/fixmap.h > @@ -132,6 +132,14 @@ enum fixed_addresses { > > extern void reserve_top_address(unsigned long reserve); > > +/* On 64-bit, the module sections ends with the start of the fixmap */ > +#ifdef CONFIG_X86_64 > +#define MODULES_VADDR (__START_KERNEL_map + KERNEL_IMAGE_SIZE) > +#define MODULES_END __fix_to_virt(__end_of_fixed_addresses + 1) > +#define MODULES_LEN (MODULES_END - MODULES_VADDR) > +#endif /* CONFIG_X86_64 */ JFYI: so there's another patchset which adds KERNEL_MAPPING_SIZE: https://lkml.kernel.org/r/1486040077-3719-1-git-send-email-bhe@redhat.com and makes it a 1G, i.e., the KASLR default. I guess the above will have to be KERNEL_MAPPING_SIZE then. And why are you moving those to fixmap.h? What's wrong with including fixmap.h into pgtable_64_types.h so that you can get __end_of_fixed_addresses? FWIW, I didn't even have to add any includes with my .config, i.e., that builds: --- --- but I wouldn't be surprised if some strange configuration would need it. > #define FIXADDR_SIZE (__end_of_permanent_fixed_addresses << PAGE_SHIFT) > #define FIXADDR_START (FIXADDR_TOP - FIXADDR_SIZE) > > diff --git a/arch/x86/include/asm/pgtable_64_types.h b/arch/x86/include/asm/pgtable_64_types.h > index 3a264200c62f..de8bace10200 100644 > --- a/arch/x86/include/asm/pgtable_64_types.h > +++ b/arch/x86/include/asm/pgtable_64_types.h > @@ -66,9 +66,6 @@ typedef struct { pteval_t pte; } pte_t; > #define VMEMMAP_START __VMEMMAP_BASE > #endif /* CONFIG_RANDOMIZE_MEMORY */ > #define VMALLOC_END (VMALLOC_START + _AC((VMALLOC_SIZE_TB << 40) - 1, UL)) > -#define MODULES_VADDR (__START_KERNEL_map + KERNEL_IMAGE_SIZE) > -#define MODULES_END _AC(0xffffffffff000000, UL) How much of an ABI breakage would that be? See Documentation/x86/x86_64/mm.txt. With my .config MODULES_END becomes 0xffffffffff1fe000 and it'll remain dynamic depending on .config. No idea how much in userspace relies on MODULES_END being static 0xffffffffff000000... Hmm. diff --git a/arch/x86/include/asm/pgtable_64_types.h b/arch/x86/include/asm/pgtable_64_types.h index 3a264200c62f..eda7fa856fa9 100644 --- a/arch/x86/include/asm/pgtable_64_types.h +++ b/arch/x86/include/asm/pgtable_64_types.h @@ -67,7 +67,7 @@ typedef struct { pteval_t pte; } pte_t; #endif /* CONFIG_RANDOMIZE_MEMORY */ #define VMALLOC_END (VMALLOC_START + _AC((VMALLOC_SIZE_TB << 40) - 1, UL)) #define MODULES_VADDR (__START_KERNEL_map + KERNEL_IMAGE_SIZE) -#define MODULES_END _AC(0xffffffffff000000, UL) +#define MODULES_END __fix_to_virt(__end_of_fixed_addresses + 1) #define MODULES_LEN (MODULES_END - MODULES_VADDR) #define ESPFIX_PGD_ENTRY _AC(-2, UL) #define ESPFIX_BASE_ADDR (ESPFIX_PGD_ENTRY << PGDIR_SHIFT)