Received: by 10.223.185.116 with SMTP id b49csp548774wrg; Wed, 14 Feb 2018 03:18:20 -0800 (PST) X-Google-Smtp-Source: AH8x225CnvqMi1uv99co7xN1ZvMziQE2SYkDnEf51/bqecDVAVzHf/K8ukflXx0lxxRzzyKI7dSY X-Received: by 10.99.96.137 with SMTP id u131mr3710794pgb.103.1518607100702; Wed, 14 Feb 2018 03:18:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518607100; cv=none; d=google.com; s=arc-20160816; b=Fsx9W8rs5xOqveCDsmkaERdQN1Ua/jLXdJhI2exvxYMdQ5EWc5nA9gg3T9alJFJzMD R4VYJ5+LH7IrKe0w4tjv3I7H8a5ySCdyfG7iAGwWYlI+SYjaocmgVMYUrjzJq/0LWi6a c9rFs3ByoV7jHgQAoz3qyfTPLGS4Ntnty6np6LhSZRsXEpkC9aP7msqV9XRFPkg2aMUB CYZVMW3xhSBJvGAkfsb20HUAfjml0p8Xjb5cQzPu5cqJxZoC4DDQGozRupbxUlXPBbub Uupoz6HBB1UrsVNY5A1OSyiAP4UMW4a2Z437rCqmAIlJfoDPNv571/lEH2MtfG4OoMRS 3rjA== 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=hOPmXFaTOJEjwdu84XcPUYI5axngoqqxc3zChX0yspc=; b=weoMAOoJQBdrgLLW+a0296mfkpU1ClyirY20DPPirgnfGUmgFW9MT+tSm7+kx2NCIj 66WFkxUZM+x5L58dZs4M3jRUsnwlE49mK8jsjz4b2i9hNOvdFcKG9zkLcrs/t7/3RCR+ DVVXzcU4lPxgJ+7Pc58tnuBOx5QQIL5iIErr3dUBGIPipTK6Ew1ya2qZ+lpo9H5wrqt0 Xhe9QACT1zCmqv5Fsh3izGkM9nLZkZfSJoydw57Csd7FKIdKQdQOkMcmcM68ZvD+3YQi 8QnakbtH5L5KGfE7ity7h9oWQN4ZzCgglJt0LsuwEQ5SXE0T/tPqI7wyCsI8FtdcfRVy /Ceg== 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 k131si559207pgc.101.2018.02.14.03.18.05; Wed, 14 Feb 2018 03:18:20 -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 S967402AbeBNLRO (ORCPT + 99 others); Wed, 14 Feb 2018 06:17:14 -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 S967374AbeBNLRM (ORCPT ); Wed, 14 Feb 2018 06:17:12 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 14 Feb 2018 03:17:12 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,512,1511856000"; d="scan'208";a="29951844" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga004.fm.intel.com with ESMTP; 14 Feb 2018 03:17:09 -0800 Received: by black.fi.intel.com (Postfix, from userid 1000) id 78438166; 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 4/9] x86: Introduce pgtable_l5_enabled Date: Wed, 14 Feb 2018 14:16:51 +0300 Message-Id: <20180214111656.88514-5-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 The new flag would indicate what paging mode we are in. Signed-off-by: Kirill A. Shutemov --- arch/x86/boot/compressed/kaslr.c | 4 ++++ arch/x86/include/asm/pgtable_32_types.h | 2 ++ arch/x86/include/asm/pgtable_64_types.h | 6 ++++++ arch/x86/kernel/head64.c | 5 +++++ 4 files changed, 17 insertions(+) diff --git a/arch/x86/boot/compressed/kaslr.c b/arch/x86/boot/compressed/kaslr.c index 8199a6187251..bd69e1830fbe 100644 --- a/arch/x86/boot/compressed/kaslr.c +++ b/arch/x86/boot/compressed/kaslr.c @@ -46,6 +46,10 @@ #define STATIC #include +#ifdef CONFIG_X86_5LEVEL +unsigned int pgtable_l5_enabled __ro_after_init = 1; +#endif + extern unsigned long get_cmd_line_ptr(void); /* Simplified build-specific string for starting entropy. */ diff --git a/arch/x86/include/asm/pgtable_32_types.h b/arch/x86/include/asm/pgtable_32_types.h index 0777e18a1d23..e3225e83db7d 100644 --- a/arch/x86/include/asm/pgtable_32_types.h +++ b/arch/x86/include/asm/pgtable_32_types.h @@ -15,6 +15,8 @@ # include #endif +#define pgtable_l5_enabled 0 + #define PGDIR_SIZE (1UL << PGDIR_SHIFT) #define PGDIR_MASK (~(PGDIR_SIZE - 1)) diff --git a/arch/x86/include/asm/pgtable_64_types.h b/arch/x86/include/asm/pgtable_64_types.h index a0db91ab63b8..5e2d724f8f47 100644 --- a/arch/x86/include/asm/pgtable_64_types.h +++ b/arch/x86/include/asm/pgtable_64_types.h @@ -20,6 +20,12 @@ typedef unsigned long pgprotval_t; typedef struct { pteval_t pte; } pte_t; +#ifdef CONFIG_X86_5LEVEL +extern unsigned int pgtable_l5_enabled; +#else +#define pgtable_l5_enabled 0 +#endif + #endif /* !__ASSEMBLY__ */ #define SHARED_KERNEL_PMD 0 diff --git a/arch/x86/kernel/head64.c b/arch/x86/kernel/head64.c index bf5c9ba63ba1..17d00d1886de 100644 --- a/arch/x86/kernel/head64.c +++ b/arch/x86/kernel/head64.c @@ -39,6 +39,11 @@ extern pmd_t early_dynamic_pgts[EARLY_DYNAMIC_PAGE_TABLES][PTRS_PER_PMD]; static unsigned int __initdata next_early_pgt; pmdval_t early_pmd_flags = __PAGE_KERNEL_LARGE & ~(_PAGE_GLOBAL | _PAGE_NX); +#ifdef CONFIG_X86_5LEVEL +unsigned int pgtable_l5_enabled __ro_after_init = 1; +EXPORT_SYMBOL(pgtable_l5_enabled); +#endif + #ifdef CONFIG_DYNAMIC_MEMORY_LAYOUT unsigned long page_offset_base __ro_after_init = __PAGE_OFFSET_BASE; EXPORT_SYMBOL(page_offset_base); -- 2.15.1