Received: by 10.213.65.68 with SMTP id h4csp36377imn; Mon, 19 Mar 2018 18:43:37 -0700 (PDT) X-Google-Smtp-Source: AG47ELuNrxTm6BULXOxmPjC9tSFAlOHpPUbutrVM2SnRhHb+w20cG6SALgWF0j/L3ipPGhejNlTI X-Received: by 10.98.153.204 with SMTP id t73mr3065162pfk.121.1521510217254; Mon, 19 Mar 2018 18:43:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521510217; cv=none; d=google.com; s=arc-20160816; b=DaBh/obZJMAK7lEs6R+JhQELUFKACljR0o89RjElDu8eTWJL66a2i+Ch9r5q0eyyxh JktJzgL8zmWcVVA437OmM9132phNcVzbMotvsO6eK4LHPk8H99kFZKiv58qGBMKCp4N3 TiNugsjo6AM9mOp1qimKSSGNH1ZSkftZAR4VFQOSMAyXYvTbnSmvJ825UK9PeFUalEZ0 OwNj4jVF/HNgc4le6Ms/+B/E0JQcdtEOKctwPdE/kNoGouf/N/H5l94LyHJqoRt0sxTl wK9bqq63RDtotDMKY1B6PUEcGdR2AVojXiiCdoBwBQTYaTqpJhm0WDYKf/11UEc6wQOc Kh+Q== 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=AJlPsMAJRw1/CieF88d9OCESA4hO7uxNeCaOWz81zw8=; b=JTmba+ISpSQhoXNBVJb7vEgBItHv48whcXxexnXu76IDn56aVNrKQHU78gux8bosHV 7gMUwQjXzcyC0FJvEjMLeTV/dlJq6GPBsguqYzZIctc1H0HWhRGh3sdWj8UpxefB+m1C FJLdMptUUOmpzrZYAJB+CGUOLIuyLOsfN2WtsIMgaZock6mGstFFPw+pgRyX0DbHzCkO 5VWJuyBrgYkSul/qKG8NXfZP8XvLz4uaimdSIWDSsLC/OrfJJTEEn5sXjMWgJdZtgx5e EtBAxbtnl5JNuUrGMkgkSe+g4Ltd2tbRPJLDLxs9sJrrk2G5cWfp5wYnHn9X+KDeanam SRgg== 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 k6-v6si563371pln.103.2018.03.19.18.43.22; Mon, 19 Mar 2018 18:43:37 -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 S970037AbeCSS1f (ORCPT + 99 others); Mon, 19 Mar 2018 14:27:35 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:51250 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S970026AbeCSS12 (ORCPT ); Mon, 19 Mar 2018 14:27:28 -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 189101270; Mon, 19 Mar 2018 18:27:27 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jan Kiszka , Andy Lutomirski , Andy Shevchenko , Ard Biesheuvel , Boris Ostrovsky , Borislav Petkov , Brian Gerst , Denys Vlasenko , Josh Poimboeuf , Juergen Gross , Linus Torvalds , Matt Fleming , Peter Zijlstra , Thomas Garnier , Thomas Gleixner , linux-efi@vger.kernel.org, Ingo Molnar Subject: [PATCH 4.9 211/241] x86/boot/32: Fix UP boot on Quark and possibly other platforms Date: Mon, 19 Mar 2018 19:07:56 +0100 Message-Id: <20180319180759.909708500@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 commit d2b6dc61a8dd3c429609b993778cb54e75a5c5f0 upstream. This partially reverts commit: 23b2a4ddebdd17f ("x86/boot/32: Defer resyncing initial_page_table until per-cpu is set up") That commit had one definite bug and one potential bug. The definite bug is that setup_per_cpu_areas() uses a differnet generic implementation on UP kernels, so initial_page_table never got resynced. This was fine for access to percpu data (it's in the identity map on UP), but it breaks other users of initial_page_table. The potential bug is that helpers like efi_init() would be called before the tables were synced. Avoid both problems by just syncing the page tables in setup_arch() *and* setup_per_cpu_areas(). Reported-by: Jan Kiszka Signed-off-by: Andy Lutomirski Cc: Andy Shevchenko Cc: Ard Biesheuvel Cc: Boris Ostrovsky Cc: Borislav Petkov Cc: Brian Gerst Cc: Denys Vlasenko 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 Signed-off-by: Ingo Molnar Signed-off-by: Greg Kroah-Hartman --- arch/x86/kernel/setup.c | 15 +++++++++++++++ arch/x86/kernel/setup_percpu.c | 10 +++++----- 2 files changed, 20 insertions(+), 5 deletions(-) --- a/arch/x86/kernel/setup.c +++ b/arch/x86/kernel/setup.c @@ -1200,6 +1200,21 @@ 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 @@ -290,11 +290,11 @@ void __init setup_per_cpu_areas(void) #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. + * Sync back kernel address range again. We already did this in + * setup_arch(), but percpu data also needs to be 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,