Received: by 10.223.185.116 with SMTP id b49csp550486wrg; Wed, 14 Feb 2018 03:20:14 -0800 (PST) X-Google-Smtp-Source: AH8x225Fvr5hvferAiJoXYytGZiZaQmNuvNS/RuR5Y1ZSPwtk9MaCu2Kf6r6A80WtZrYj3M5qZ4d X-Received: by 10.99.124.85 with SMTP id l21mr3699405pgn.274.1518607214043; Wed, 14 Feb 2018 03:20:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518607214; cv=none; d=google.com; s=arc-20160816; b=oBO+UjiHnzYn3YPCv6dPKgyk5kJwawbeOMTyxupEq3yn0640yXG5uTkGkEvgx/wa36 qmcMnEAcm62s2Zg0RG20iB49vm3xN/y8hYcAnTYpzg7nemLM7Kobx4/nfmX4a2Sprh9I 5U39/WlLUk9GHRTTpaxPC8MZG4ibN2ouqCMVM8G9BEqdWOG28cjo7cxDqOA9IRXiTVW0 NIVx6jvtPSarnA7qDY5W3QdR8Qbr9VLG8GqvSxJZ/hVSMixkVj+kG1ZpmyhZ/RDatWpJ ngR/rr7ISkAdlNjDdZa5tjuf0TkuO6opecVn7cmxto+gbSbkyvSc2MbGjlToQ4zc2Rxp LHgw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=Yh6BA30NHE606z9fI8EOuvlv/oLEgQULBsRVrTkXyFc=; b=N5IPdHJJ5eanW04SkcGJl/5JtsWtTQ/dcO1PTsQKmyjnA3u+Xc0t5r4ZPIi6wPu5tr eKXxwMgN0mShDQwWUAbxm3356GghCab3Bf4LbrXzGYWYvFMDXDT3l/SNrjCcSl16/nO2 tqD2VHATIppJpFUkL8Btp23qArFmDonRm7M2HjhCpgQ7Ry4l6oMypX5ALtMofONihwrA gWbJezwSCu1W8N9eNFno7GqhQvPUHY7wiSQdqvyNMK8WQporrGEQZTNeDxsq1FZSHv+1 cTyckXe2IYr12Hx4C5dybivpjkVnaM44bjq4o32nO4w3eLIm9wRQHtdfWrIuh1x2Qi90 deLg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t193si879091pgc.38.2018.02.14.03.19.59; Wed, 14 Feb 2018 03:20:14 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S967478AbeBNLSU (ORCPT + 99 others); Wed, 14 Feb 2018 06:18:20 -0500 Received: from mga18.intel.com ([134.134.136.126]:46030 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S967374AbeBNLRQ (ORCPT ); Wed, 14 Feb 2018 06:17:16 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 14 Feb 2018 03:17:15 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,512,1511856000"; d="scan'208";a="17619924" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga007.fm.intel.com with ESMTP; 14 Feb 2018 03:17:12 -0800 Received: by black.fi.intel.com (Postfix, from userid 1000) id 8F25A23E; Wed, 14 Feb 2018 13:17:08 +0200 (EET) From: "Kirill A. Shutemov" To: Ingo Molnar , x86@kernel.org, Thomas Gleixner , "H. Peter Anvin" Cc: Linus Torvalds , Andy Lutomirski , Borislav Petkov , Andi Kleen , linux-mm@kvack.org, linux-kernel@vger.kernel.org, "Kirill A. Shutemov" Subject: [PATCH 5/9] x86/mm: Make LDT_BASE_ADDR dynamic Date: Wed, 14 Feb 2018 14:16:52 +0300 Message-Id: <20180214111656.88514-6-kirill.shutemov@linux.intel.com> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180214111656.88514-1-kirill.shutemov@linux.intel.com> References: <20180214111656.88514-1-kirill.shutemov@linux.intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org LDT_BASE_ADDR has different value in 4- and 5-level paging configurations. We need to make it dynamic in preparation for boot-time switching between paging modes. Signed-off-by: Kirill A. Shutemov --- arch/x86/include/asm/pgtable_64_types.h | 9 +++++---- arch/x86/mm/dump_pagetables.c | 5 ++++- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/arch/x86/include/asm/pgtable_64_types.h b/arch/x86/include/asm/pgtable_64_types.h index 5e2d724f8f47..903e4d054bcb 100644 --- a/arch/x86/include/asm/pgtable_64_types.h +++ b/arch/x86/include/asm/pgtable_64_types.h @@ -92,18 +92,19 @@ extern unsigned int pgtable_l5_enabled; */ #define MAXMEM _AC(__AC(1, UL) << MAX_PHYSMEM_BITS, UL) +#define LDT_PGD_ENTRY_L4 -3UL +#define LDT_PGD_ENTRY_L5 -112UL +#define LDT_PGD_ENTRY (pgtable_l5_enabled ? LDT_PGD_ENTRY_L5 : LDT_PGD_ENTRY_L4) +#define LDT_BASE_ADDR (LDT_PGD_ENTRY << PGDIR_SHIFT) + #ifdef CONFIG_X86_5LEVEL # define VMALLOC_SIZE_TB _AC(12800, UL) # define __VMALLOC_BASE _AC(0xffa0000000000000, UL) # define __VMEMMAP_BASE _AC(0xffd4000000000000, UL) -# define LDT_PGD_ENTRY _AC(-112, UL) -# define LDT_BASE_ADDR (LDT_PGD_ENTRY << PGDIR_SHIFT) #else # define VMALLOC_SIZE_TB _AC(32, UL) # define __VMALLOC_BASE _AC(0xffffc90000000000, UL) # define __VMEMMAP_BASE _AC(0xffffea0000000000, UL) -# define LDT_PGD_ENTRY _AC(-3, UL) -# define LDT_BASE_ADDR (LDT_PGD_ENTRY << PGDIR_SHIFT) #endif #ifdef CONFIG_DYNAMIC_MEMORY_LAYOUT diff --git a/arch/x86/mm/dump_pagetables.c b/arch/x86/mm/dump_pagetables.c index 2a4849e92831..a89f2dbc3531 100644 --- a/arch/x86/mm/dump_pagetables.c +++ b/arch/x86/mm/dump_pagetables.c @@ -89,7 +89,7 @@ static struct addr_marker address_markers[] = { [KASAN_SHADOW_END_NR] = { KASAN_SHADOW_END, "KASAN shadow end" }, #endif #ifdef CONFIG_MODIFY_LDT_SYSCALL - [LDT_NR] = { LDT_BASE_ADDR, "LDT remap" }, + [LDT_NR] = { 0UL, "LDT remap" }, #endif [CPU_ENTRY_AREA_NR] = { CPU_ENTRY_AREA_BASE,"CPU entry Area" }, #ifdef CONFIG_X86_ESPFIX64 @@ -570,6 +570,9 @@ static int __init pt_dump_init(void) address_markers[LOW_KERNEL_NR].start_address = PAGE_OFFSET; address_markers[VMALLOC_START_NR].start_address = VMALLOC_START; address_markers[VMEMMAP_START_NR].start_address = VMEMMAP_START; +#ifdef CONFIG_MODIFY_LDT_SYSCALL + address_markers[LDT_NR].start_address = LDT_BASE_ADDR; +#endif #endif #ifdef CONFIG_X86_32 address_markers[VMALLOC_START_NR].start_address = VMALLOC_START; -- 2.15.1