Received: by 10.192.165.148 with SMTP id m20csp1374199imm; Wed, 2 May 2018 20:44:19 -0700 (PDT) X-Google-Smtp-Source: AB8JxZq8d0It5v2RiVLoHhQ5aoR4ZblPVrUFMF7zL9t7JMyyh/Bo+bv5qStgPigfB++j/3biI+5e X-Received: by 2002:a17:902:7b86:: with SMTP id w6-v6mr571557pll.183.1525319059926; Wed, 02 May 2018 20:44:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525319059; cv=none; d=google.com; s=arc-20160816; b=CACQbuhNfWmjWlMElKswn9t/B0tbB8GDM2v4WWFYsxsx1DyGMkw2FMpmAf/6Z4176z bdBj9zewKTTbpJu3MtZQRc0CC+cni0x4AN52jXDOtOZurnSd65vXE5CbgKnjJP4Q+jZq 5pp+gnTcFrrD/1dIae7Ep3gKNH6zcqe4y/OQ+arRJKdqk2QLgFSOSsUerJ0Rj+5+WPkq zYPQbUql1FgxXDwuwm2yOAHLegBqebM9cMmBXO7vb3YGCaW9oNdjwnRowj37ONbS/GIG Lp91uR2BFX7gr5dmztYuD7JAcAC+6bHsHar62KAQf8dahJgq1z/1uSNswZYsZzskMhXw Tj2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date:dkim-signature :arc-authentication-results; bh=0uucTAbuByTFCUxcG6noFhcvc94eA1b5CT7BuA4NzEQ=; b=MZHk9mgf5oNJQBkgPuUSy8Cd1s0rbwvha8+PfSoHpeD6panmq5hY+T9mPm5FByHD6F iPuxxC90Lo9v+5EZmvFhtUbV2h+T0sn326B6jvvl4e5OI67UEc5swSmnw/4ENtBunke5 mahztq6wIk58nMt4g9rKQufW3ALGKCnnF79C+XS/ewlrmg+Ccav3CIwWWGO6AF4IEWCN cZr/AMJEbT3XCBocAnvA2iRC91IIVYC15gusdtucS6HdodIAfXLt1kIA72j7VSCyEsBl pM0ju9u4PJychCdZeZwZMU+Dc8jviIwtohd6BpbNOSygdjoZUpJ2h7zvDPbHJivUa+CE 75WQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=L/1KZA7G; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n59-v6si12676256plb.198.2018.05.02.20.44.04; Wed, 02 May 2018 20:44:19 -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; dkim=pass header.i=@google.com header.s=20161025 header.b=L/1KZA7G; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752094AbeECDml (ORCPT + 99 others); Wed, 2 May 2018 23:42:41 -0400 Received: from mail-pf0-f193.google.com ([209.85.192.193]:38732 "EHLO mail-pf0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751993AbeECDmj (ORCPT ); Wed, 2 May 2018 23:42:39 -0400 Received: by mail-pf0-f193.google.com with SMTP id o76so13555524pfi.5 for ; Wed, 02 May 2018 20:42:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:in-reply-to:message-id:references :user-agent:mime-version; bh=0uucTAbuByTFCUxcG6noFhcvc94eA1b5CT7BuA4NzEQ=; b=L/1KZA7G7a0G+ConWFJsIqqHppRZu6HtNblT9Biu2PjduCcttcl2BZ5AoLjKxdNuWr h03lV/pxR2+Seyw+Nyn1dXGrBRg7YV8w68f1cqi3VBpkmXB11FTKl+GS8dv6abwjCNUV zPXnTtaLpwY8DUFkaZmlOHCefPzfr6pgLR05G97qEhmljNdWaVvybfrFJRnNTQjnNvRi k7UykVtPIu+poIqMfgO/ncQUbnUIBXwktAdG1X/5NaTF7UoZKUgrSnpqYDGvC6a/EdU1 ppszcy0GZH7xjQkuPhlWLoBaJnzYLy9AeNYXz1WRnFvRjb/gv8ohku7iA53TPCh/61Ap qI2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:in-reply-to:message-id :references:user-agent:mime-version; bh=0uucTAbuByTFCUxcG6noFhcvc94eA1b5CT7BuA4NzEQ=; b=pCwVGTfuvFBSSTOeqqdlaz25E0knNfOKq7NgA8gXkY/cQfx3aW6IJoMRsDOZXe5y/z zVbYaDIxNbhDBwXE7xiORciJwrZPlTll/E/Oyl0IgmoT/XVvimX0DxuQdeSoOOsaxqWi npffEl7t4osApO8ToStSJQEY6s71Qj4GDhgJRjtr7xCUwWP9/8/WEg0hvyPaFRuysl0C w0uqdeHB+YKEzx2he60buz/+szpXxEGl6/K/RyHkwy5XWZRw7UDkg1D0vfooS4id3CNK 8WE7wab1CAWNmbulaexN62xoyWpzNg1PfSny/vMR+wzSqwdNx9NCYzULfi7pWxyBHfzV 2INg== X-Gm-Message-State: ALQs6tCer3wZXz0zMHzInaOy0EXBSG2ehCuzSwXR3OCwKSwgvWTc/l7w lWCRaDLdHbi9OAPMntcKGlM3DQ== X-Received: by 2002:a17:902:8f94:: with SMTP id z20-v6mr8041419plo.391.1525318958610; Wed, 02 May 2018 20:42:38 -0700 (PDT) Received: from [100.112.95.218] ([104.133.9.106]) by smtp.gmail.com with ESMTPSA id g207sm24209313pfb.18.2018.05.02.20.42.37 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 02 May 2018 20:42:37 -0700 (PDT) Date: Wed, 2 May 2018 20:42:30 -0700 (PDT) From: Hugh Dickins X-X-Sender: hugh@eggly.anvils To: "Kirill A. Shutemov" cc: Ingo Molnar , Thomas Gleixner , "H. Peter Anvin" , Hugh Dickins , Dave Hansen , linux-kernel@vger.kernel.org, x86@kernel.org Subject: Re: [PATCH] x86/boot/compressed: Exclude 'top_pgtable' from relocation In-Reply-To: <20180502160816.35986-1-kirill.shutemov@linux.intel.com> Message-ID: References: <20180502160816.35986-1-kirill.shutemov@linux.intel.com> User-Agent: Alpine 2.11 (LSU 23 2013-08-11) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 2 May 2018, Kirill A. Shutemov wrote: > 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") Thanks for the Cc, Kirill, which I presume was because I'd mentioned to you that I was unable to boot 4.17-rc on laptop or workstation. Which is still so with 4.17-rc3, and I'm sorry to say still so with this patch: even if I add the fix which I think this patch needs, see below. I did bisect on Monday, and the first bad was your commit 194a9749c73d "x86/boot/compressed/64: Handle 5-level paging boot if kernel is above 4G". (Cc'ing Dave since his PTI Global work was my other suspect, but that's off the hook - if I revert just 194a9749c73d then I have no trouble.) Am I really the only one getting immediate reboot on x86_64? Perhaps everyone else has machines with 5-level page tables now ?-) I've looked at the changes a little, and tried a few things (hoping to avoid a long back and forth describing and trying things for you); but no success yet, and rather out of my depth with these changes - I've not had to delve into boot/compressed before. (I did briefly get excited by the trampoline_32bit + TRAMPOLINE_32BIT_PGTABLE_OFFSET in cleanup_trampoline(), which lacks a "/ sizeof(unsigned long)"; but since ...PGTABLE_OFFSET is 0 anyway, that's nothing but cosmetic.) Hugh > --- > 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; Doesn't that need to be extern char top_pgtable[] ? > > /* > * Trampoline address will be printed by extract_kernel() for debugging > -- > 2.17.0