Received: by 10.213.65.68 with SMTP id h4csp1771972imn; Mon, 19 Mar 2018 12:51:01 -0700 (PDT) X-Google-Smtp-Source: AG47ELv+VvbTF7l2jtaH6CTqpqYXFs8ioZxMh8YuO0GYq7JfAvMO+EFV3oDB7AGsLs17zHytZ/AU X-Received: by 2002:a17:902:2d24:: with SMTP id o33-v6mr16814plb.143.1521489061102; Mon, 19 Mar 2018 12:51:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521489061; cv=none; d=google.com; s=arc-20160816; b=QMt3Ys7sAXJzpZMwYanRu0kNQzZxLtJ4UUYSyyh5+SMVa8uyo7LaSN/84iXKSrzDQW m5kfO8EqVwPxyLJtrQYgUAHN4d5ocv5THxzhq/Xwz1kFEj8KszE/4yNvrw4QCh6KMNYe 7PfpH3zfYRAtBMsGpFK6U5Dbqg0RSmWai2bwOom5YW45+2yY/yr6K/YNL0y5N/TL2YiV Ic7zKZybffrM+kCwguTrYU8YgqHlYFDUw5mBOqRnT6WdzC1pHTfz2u9Dv6lFp7Rj0ofi pLtZpv8RJLy6SfSL0BUDWRNWYVkmWpD3IYXH88aHmT1T+JrNhFvDvF8OMIjWhIX7IJO8 LzDw== 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 :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=IBaW3QMCg0d02GOZ1t6kdxTFs1jR/vLx0CTbAzPoTZo=; b=UZAQ8ANgahPADC4mIEoBMQ/pYlphwmXdI5bT45VkoHa6YNJ5wD/5Kcdns5UPXUdqQ9 tsV4eeVEjC8IJlNK+a9RFvtHtYMDkSAcK3eGlTLFrbf+NMqb2T2xw64/35JU3zGk0qfh t6WN/kSZCGWHAk6DdGIBBLa2kU+3IdSUTXQB+ji+d/Jel7/mgBwN9O1eiPW+gtjxwsl7 /+WLHvGQcCDvFdm3Lqwdfw0T+XpvzLK4qqpe8raKtM+kiavuKPnzgvn18bMpzW9MNH7c iV5tFH0d1szLjdBKBFa/wTwuI6EBISapAoJd3xO6Teb9r19ZKirOqQAOUF5HeEG8jL5y V6Qg== 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 u86si468437pfa.69.2018.03.19.12.50.47; Mon, 19 Mar 2018 12:51:01 -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 S969912AbeCSTs5 (ORCPT + 99 others); Mon, 19 Mar 2018 15:48:57 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:47550 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S969148AbeCSSUN (ORCPT ); Mon, 19 Mar 2018 14:20:13 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 719212F; Mon, 19 Mar 2018 18:20:12 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Andy Lutomirski , Ard Biesheuvel , Boris Ostrovsky , Borislav Petkov , Brian Gerst , Denys Vlasenko , "H. Peter Anvin" , Josh Poimboeuf , Juergen Gross , Linus Torvalds , Matt Fleming , Peter Zijlstra , Thomas Garnier , Thomas Gleixner , linux-efi@vger.kernel.org, Ingo Molnar , Sasha Levin Subject: [PATCH 4.9 052/241] x86/boot/32: Defer resyncing initial_page_table until per-cpu is set up Date: Mon, 19 Mar 2018 19:05:17 +0100 Message-Id: <20180319180753.377148577@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180319180751.172155436@linuxfoundation.org> References: <20180319180751.172155436@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Andy Lutomirski [ Upstream commit 23b2a4ddebdd17fad265b4bb77256c2e4ec37dee ] The x86 smpboot trampoline expects initial_page_table to have the GDT mapped. If the GDT ends up in a virtually mapped per-cpu page, then it won't be in the page tables at all until perc-pu areas are set up. The result will be a triple fault the first time that the CPU attempts to access the GDT after LGDT loads the perc-pu GDT. This appears to be an old bug, but somehow the GDT fixmap rework is triggering it. This seems to have something to do with the memory layout. Signed-off-by: Andy Lutomirski Cc: Ard Biesheuvel Cc: Boris Ostrovsky Cc: Borislav Petkov Cc: Brian Gerst Cc: Denys Vlasenko Cc: H. Peter Anvin Cc: Josh Poimboeuf Cc: Juergen Gross Cc: Linus Torvalds Cc: Matt Fleming Cc: Peter Zijlstra Cc: Thomas Garnier Cc: Thomas Gleixner Cc: linux-efi@vger.kernel.org Link: http://lkml.kernel.org/r/a553264a5972c6a86f9b5caac237470a0c74a720.1490218061.git.luto@kernel.org Signed-off-by: Ingo Molnar Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- arch/x86/kernel/setup.c | 15 --------------- arch/x86/kernel/setup_percpu.c | 21 +++++++++++++++++++++ 2 files changed, 21 insertions(+), 15 deletions(-) --- a/arch/x86/kernel/setup.c +++ b/arch/x86/kernel/setup.c @@ -1200,21 +1200,6 @@ void __init setup_arch(char **cmdline_p) kasan_init(); -#ifdef CONFIG_X86_32 - /* sync back kernel address range */ - clone_pgd_range(initial_page_table + KERNEL_PGD_BOUNDARY, - swapper_pg_dir + KERNEL_PGD_BOUNDARY, - KERNEL_PGD_PTRS); - - /* - * sync back low identity map too. It is used for example - * in the 32-bit EFI stub. - */ - clone_pgd_range(initial_page_table, - swapper_pg_dir + KERNEL_PGD_BOUNDARY, - min(KERNEL_PGD_PTRS, KERNEL_PGD_BOUNDARY)); -#endif - tboot_probe(); map_vsyscall(); --- a/arch/x86/kernel/setup_percpu.c +++ b/arch/x86/kernel/setup_percpu.c @@ -287,4 +287,25 @@ void __init setup_per_cpu_areas(void) /* Setup cpu initialized, callin, callout masks */ setup_cpu_local_masks(); + +#ifdef CONFIG_X86_32 + /* + * Sync back kernel address range. We want to make sure that + * all kernel mappings, including percpu mappings, are available + * in the smpboot asm. We can't reliably pick up percpu + * mappings using vmalloc_fault(), because exception dispatch + * needs percpu data. + */ + clone_pgd_range(initial_page_table + KERNEL_PGD_BOUNDARY, + swapper_pg_dir + KERNEL_PGD_BOUNDARY, + KERNEL_PGD_PTRS); + + /* + * sync back low identity map too. It is used for example + * in the 32-bit EFI stub. + */ + clone_pgd_range(initial_page_table, + swapper_pg_dir + KERNEL_PGD_BOUNDARY, + min(KERNEL_PGD_PTRS, KERNEL_PGD_BOUNDARY)); +#endif }