Received: by 10.192.165.148 with SMTP id m20csp811965imm; Wed, 2 May 2018 09:09:25 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpo8z5NENPFvgAWRdZBVS8tq9k/unf0xjEReS3juuViFz+/980Zj5CmatOlCltrB/jvv3Uu X-Received: by 2002:a63:6ec7:: with SMTP id j190-v6mr16342580pgc.71.1525277365640; Wed, 02 May 2018 09:09:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525277365; cv=none; d=google.com; s=arc-20160816; b=bJKxklrXhnHQTZLQwXR3J6obQncFaS406P9cCgMKAIraNJRO8qduY97hHme2CW/ylC jXprfoF4NJXQmGbynoSPQwO8eAPoalQoMuRMbtyOq9FW6XXwuqSqVTWzkHrkvMrMIdf4 PGO1nZ2ea+j5/3DEoA5yA+8HEOeFxzu4rTtcpiq3aO+dfm+oOXbecA5ozk+Xz4U1u6q9 orkoW5no28prqliPwZHt1FvDNydMtKDF6/4lnBMn0DcEpUc7v0MRfLzzaai/isbTCCgW lWtI+Y9TzDs5TOP72vKvRWbNZIdOzCwS381CncnWJRkg4TLX6McWOfJrbnZ5ELlsh8DJ uYTA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=CH/w/JlZyA1NyIe9MV4AL9eZ/3VOablBME4PorLQU8A=; b=YwEF03+35Vstr3dQCiRNjWdvEKR4Sgb4asBw0J7TwPvgVgNOOkWSTHH3oIqsEoGibI GdWbQMRtPkdf4LetUozvesjyOVxRihGGbH/6Zl23L4xJcCBv6fh9wzBh0PH8Nx7QLSme PULZY8ehw/c/8dtlkAoIQh9HEtc/rjAAaImotzQlxlZfEKauHx9n0WDAobFavaDW9uYs FoUXRYJV0kflpSXlTuf5Iaoh9/qN7J25KnrqMLCoI4B1miQTUUaL/ikaacROzinywCn7 9e8aVNu1LZfZdLxY3RUTtVQgnz8tYrPNdCTv8OYBC21oMj5M8OO8cYc1U3RuKvxWllIj e2NQ== 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 p13-v6si11886367pll.416.2018.05.02.09.09.11; Wed, 02 May 2018 09:09:25 -0700 (PDT) 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 S1751880AbeEBQI2 (ORCPT + 99 others); Wed, 2 May 2018 12:08:28 -0400 Received: from mga12.intel.com ([192.55.52.136]:22478 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751525AbeEBQI1 (ORCPT ); Wed, 2 May 2018 12:08:27 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 02 May 2018 09:08:22 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,354,1520924400"; d="scan'208";a="38728085" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga006.jf.intel.com with ESMTP; 02 May 2018 09:08:20 -0700 Received: by black.fi.intel.com (Postfix, from userid 1000) id 751C7161F; Wed, 2 May 2018 19:08:19 +0300 (EEST) From: "Kirill A. Shutemov" To: Ingo Molnar , x86@kernel.org, Thomas Gleixner , "H. Peter Anvin" Cc: Hugh Dickins , linux-kernel@vger.kernel.org, "Kirill A. Shutemov" Subject: [PATCH] x86/boot/compressed: Exclude 'top_pgtable' from relocation Date: Wed, 2 May 2018 19:08:16 +0300 Message-Id: <20180502160816.35986-1-kirill.shutemov@linux.intel.com> X-Mailer: git-send-email 2.17.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org startup_64() copies kernel (including .data section) to the new place. It's required for safe in-place decompression. This is a problem if the original place is referenced: by mistake I've put 'top_pgtable' into .data section and the address is loaded into CR3. If the original place gets overwritten during image decompression the kernel will crash and the machine will be rebooted. Move 'top_pgtable' into .pgtable section where the rest of page tables are. This section is not subject for relocation. Signed-off-by: Kirill A. Shutemov Fixes: e9d0e6330eb8 ("x86/boot/compressed/64: Prepare new top-level page table for trampoline") --- arch/x86/boot/compressed/head_64.S | 8 ++++++++ arch/x86/boot/compressed/pgtable_64.c | 4 +--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/arch/x86/boot/compressed/head_64.S b/arch/x86/boot/compressed/head_64.S index fca012baba19..c433c21703e6 100644 --- a/arch/x86/boot/compressed/head_64.S +++ b/arch/x86/boot/compressed/head_64.S @@ -649,3 +649,11 @@ boot_stack_end: .balign 4096 pgtable: .fill BOOT_PGT_SIZE, 1, 0 + +/* + * The page table is going to be used instead of page table in the trampoline + * memory. + */ + .global top_pgtable +top_pgtable: + .fill PAGE_SIZE, 1, 0 diff --git a/arch/x86/boot/compressed/pgtable_64.c b/arch/x86/boot/compressed/pgtable_64.c index 32af1cbcd903..3a0578f54550 100644 --- a/arch/x86/boot/compressed/pgtable_64.c +++ b/arch/x86/boot/compressed/pgtable_64.c @@ -25,10 +25,8 @@ static char trampoline_save[TRAMPOLINE_32BIT_SIZE]; /* * The page table is going to be used instead of page table in the trampoline * memory. - * - * It must not be in BSS as BSS is cleared after cleanup_trampoline(). */ -static char top_pgtable[PAGE_SIZE] __aligned(PAGE_SIZE) __section(.data); +extern char *top_pgtable; /* * Trampoline address will be printed by extract_kernel() for debugging -- 2.17.0