Received: by 10.192.165.148 with SMTP id m20csp1686759imm; Thu, 3 May 2018 03:52:35 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqC9hRKUw0n0ybfDuNtWpWmF+gaA2DHgc63KZPwXpWWmfR+nIQ+DX97SwX+/pdVb3dr5lEG X-Received: by 10.98.66.143 with SMTP id h15mr22612665pfd.156.1525344755932; Thu, 03 May 2018 03:52:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525344755; cv=none; d=google.com; s=arc-20160816; b=ya9aWeycMN6trP1lR9ILgBgXFU8iwYFDfUoHB/evbQCXZ0rTyBevBC5qzKkG+WITf4 Fj1GjGuxePoTaJ7k6ECZXupMRbi06fmLVSv+6ZWFIYeLx9eLFYSPe0QZ9HO8MhPzN9oN QFJ9KRMCaaYWJyE3FdeY1GrvcsAhOTxU6fhOJ/2BM6lPOTx0t6M7W5Hz/jznQNXJXT+x InUMPaETr5b7zZMUL+lwG4quOTPs+1rDrSSDmUPpz6967QGQ1we2jvbiGfTG0KFc0cDY B+hGAvwo/T0op52V7yZyNTgYmhp3WYSjYnwihjYlaFMKD/KDPZSROMT8fF8ZXW26k/4s 1bfA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=VhqoOQ3CxJN8aFNkiAZQzYa0r6LvL9skUN/U285fd/0=; b=cpb2pBQD0JfQcirb6zZREy98zaSMacLfChdSPCsn9aAmceE4m1/x058nAwwHxs3JGn KCdtcY3jXAAZcJpLneK2rkO3RG/vH+gqw1f/MGD2cyWrHfiwd6ALL0g34aGcI6HSIabX 6WRyfOkT9zjcj33ugQhBdDSBq5Z9PE2XBPfXubz10x4Omd3Ck3po2JvXQDpt8chv2pkr xRpFT/ap6EpJqbBZ0oz5zCnyc2Q6z5DJoAfe77fNHVFiyHhWSHeYtXFMgGIWr54NT+zv kCZxj575fvp9R3XIR/79yJAIPzM6gbLTIhyLZxjQpCOGS8xUvqYen/78aUAZiWdDK7FF k4fA== 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 v8-v6si13340003plg.68.2018.05.03.03.52.21; Thu, 03 May 2018 03:52:35 -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 S1751825AbeECKwK (ORCPT + 99 others); Thu, 3 May 2018 06:52:10 -0400 Received: from mga14.intel.com ([192.55.52.115]:38938 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751785AbeECKwJ (ORCPT ); Thu, 3 May 2018 06:52:09 -0400 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 03 May 2018 03:52:08 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,358,1520924400"; d="scan'208";a="221313183" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga005.jf.intel.com with ESMTP; 03 May 2018 03:52:06 -0700 Received: by black.fi.intel.com (Postfix, from userid 1000) id BC8F81687; Thu, 3 May 2018 13:52:05 +0300 (EEST) Date: Thu, 3 May 2018 13:52:05 +0300 From: "Kirill A. Shutemov" To: "Kirill A. Shutemov" Cc: Hugh Dickins , Ingo Molnar , Thomas Gleixner , "H. Peter Anvin" , Dave Hansen , linux-kernel@vger.kernel.org, x86@kernel.org Subject: Re: [PATCH] x86/boot/compressed: Exclude 'top_pgtable' from relocation Message-ID: <20180503105205.qmosbbbbp5jssehj@black.fi.intel.com> References: <20180502160816.35986-1-kirill.shutemov@linux.intel.com> <20180503083849.j42uzp6jjpauk475@kshutemo-mobl1> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180503083849.j42uzp6jjpauk475@kshutemo-mobl1> User-Agent: NeoMutt/20170714-126-deb55f (1.8.3) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, May 03, 2018 at 08:38:49AM +0000, Kirill A. Shutemov wrote: > The patch is bogus and I still don't understand what is going on. I think I found the issue. Could you check the patch below: diff --git a/arch/x86/boot/compressed/head_64.S b/arch/x86/boot/compressed/head_64.S index fca012baba19..86169ae1c536 100644 --- a/arch/x86/boot/compressed/head_64.S +++ b/arch/x86/boot/compressed/head_64.S @@ -370,10 +370,13 @@ trampoline_return: /* * cleanup_trampoline() would restore trampoline memory. * + * RDI is address of the page table to use (if required). + * * RSI holds real mode data and needs to be preserved across * this function call. */ pushq %rsi + leaq top_pgtable(%rbx), %rdi call cleanup_trampoline popq %rsi @@ -647,5 +650,14 @@ boot_stack_end: */ .section ".pgtable","a",@nobits .balign 4096 + .global pgtable 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..a362fa0b849c 100644 --- a/arch/x86/boot/compressed/pgtable_64.c +++ b/arch/x86/boot/compressed/pgtable_64.c @@ -22,14 +22,6 @@ struct paging_config { /* Buffer to preserve trampoline memory */ 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); - /* * Trampoline address will be printed by extract_kernel() for debugging * purposes. @@ -134,7 +126,7 @@ struct paging_config paging_prepare(void) return paging_config; } -void cleanup_trampoline(void) +void cleanup_trampoline(void *pgtable) { void *trampoline_pgtable; @@ -145,8 +137,8 @@ void cleanup_trampoline(void) * if it's there. */ if ((void *)__native_read_cr3() == trampoline_pgtable) { - memcpy(top_pgtable, trampoline_pgtable, PAGE_SIZE); - native_write_cr3((unsigned long)top_pgtable); + memcpy(pgtable, trampoline_pgtable, PAGE_SIZE); + native_write_cr3((unsigned long)pgtable); } /* Restore trampoline memory */ -- Kirill A. Shutemov