Received: by 10.223.185.116 with SMTP id b49csp1112847wrg; Sat, 3 Mar 2018 15:58:05 -0800 (PST) X-Google-Smtp-Source: AG47ELuLrOeBRXZ+F2KvvakMyOpCkycBKpy4nLz6/HLyW0ZfOEEeiGhZ6s77/ceyfuH0XLCaY/ea X-Received: by 10.99.141.200 with SMTP id z191mr8279926pgd.418.1520121485278; Sat, 03 Mar 2018 15:58:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520121485; cv=none; d=google.com; s=arc-20160816; b=VHLR6Iz8lfZQXicoDi4aAj356hPiaFVjZ2kjHXcbXtx2ImZX2RV24y+JPYDcWUjJvj pNHZGzmFHmPzglRRhwat1bdYy3Ihg01EmnAc4X87mSjs7TUpXwdWV9ESzy/v4/GkOk84 rw6bGITkSfTA+GsXwYwl8SsToAQ5ET17Aswz3U0hm/K1nptFofVhSCR1BpnHqm8VlhRM URm06dle9UpfITGvoOFzEqGwFLM90gsn5acumK8mPA+Ber/G7Hd6fkihsRZqGX+/SOwb Mg7PLJeU+paosK/sZCqjFc35ze++i/xy1a4uwXWjWVuOk4NRPxh261sRFSE1ngqfq6Dl mo3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :spamdiagnosticmetadata:spamdiagnosticoutput:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=KXwlKWRxXiqQTLPD7FZpJCCzBnKDhW05JVNmFj1zN58=; b=U+EAggSlS79bmjLcgHwKI3jP+sODnNuk52DBwm0VLcyMhcCdfW3ZDLLtS406pSCyhD JIz/fYmLc5BodT3hhXrB+r+AV0jDT4u/chGozim2bwMhcrsth6aG3gvgfixM52XKljkZ nMK7tkcZ+Qjot+pgZxHxhatj6MgKN8w1/TvGhGF8wAN+XTZl7Sml/iazFeZEFMAo+XNI 1GVqRat0Nq+fb27saxzs5ePGIMWgxcPZBzF8VvqAtFubI2I0rTjEsIFWeVy2zp0sShvy SoV9bE/e1CULgwOJ/40Y427NWqYkObo3KIYjoHP1btoeZK8w/P7ofE/X2y9XaffNx+m0 37Dg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=kS6wBpMD; 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=microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c23-v6si6761037plz.794.2018.03.03.15.57.51; Sat, 03 Mar 2018 15:58:05 -0800 (PST) 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=@microsoft.com header.s=selector1 header.b=kS6wBpMD; 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=microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752524AbeCCX5D (ORCPT + 99 others); Sat, 3 Mar 2018 18:57:03 -0500 Received: from mail-by2nam01on0120.outbound.protection.outlook.com ([104.47.34.120]:24496 "EHLO NAM01-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S933839AbeCCWc0 (ORCPT ); Sat, 3 Mar 2018 17:32:26 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=KXwlKWRxXiqQTLPD7FZpJCCzBnKDhW05JVNmFj1zN58=; b=kS6wBpMDHh/uGaUWTpluYgpAmDVvwYsaBnaOcuVufH/aXh9Tz9ddSskFI1/6oNjuZwKvDmFxjoyCMbCWq0nNe7cJL5fUcf8s0IPXUBBEkBfM7120Qr+SaQyHQ3v5s5ih1X+lDsn/vWBejnxlnEopa1fhv7LrAdDkCQfxqAF4cas= Received: from MW2PR2101MB1034.namprd21.prod.outlook.com (52.132.149.10) by MW2PR2101MB1036.namprd21.prod.outlook.com (52.132.149.12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.567.3; Sat, 3 Mar 2018 22:32:15 +0000 Received: from MW2PR2101MB1034.namprd21.prod.outlook.com ([fe80::1d56:338f:e2b:cec0]) by MW2PR2101MB1034.namprd21.prod.outlook.com ([fe80::1d56:338f:e2b:cec0%3]) with mapi id 15.20.0567.006; Sat, 3 Mar 2018 22:32:15 +0000 From: Sasha Levin To: "linux-kernel@vger.kernel.org" , "stable@vger.kernel.org" CC: 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 AUTOSEL for 4.9 054/219] x86/boot/32: Defer resyncing initial_page_table until per-cpu is set up Thread-Topic: [PATCH AUTOSEL for 4.9 054/219] x86/boot/32: Defer resyncing initial_page_table until per-cpu is set up Thread-Index: AQHTsz7zZSY5b43B+0GK0/OfwsSe5Q== Date: Sat, 3 Mar 2018 22:28:27 +0000 Message-ID: <20180303222716.26640-54-alexander.levin@microsoft.com> References: <20180303222716.26640-1-alexander.levin@microsoft.com> In-Reply-To: <20180303222716.26640-1-alexander.levin@microsoft.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [52.168.54.252] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;MW2PR2101MB1036;6:Lyu4LqFE+ed3TbHACpkLcGXSGJmSEHmIGJaykFKE5a+gj/gv+s9XE5L4f7DHStAOq/fLMOAm7BDPm201yTpEnF3pxrO4fOp5cOc02uYlwNdgrvcSBgrCXuk1JY15L6197ml0dh5rzPYSOI+6l2Jd//bSRbQaT6H/E6hoqLCF97YK1yucJEekCgQN9wMgqWuqlXJNqXMVe02fFJmsULqhxzLPOg2mTz0NZAZbb0PwgrozwktLOEdWuI576FRNF0ohLI3pX8qYrhVAc9b49MjHLQHxGN/GIJIk35By/xgRGPQNF1dZ6OX1TQQ5c8kMOZr+JsMOuHP5L5IXZYLe5pUPoUA+IhOJ7bDNP9wjCMI8u/Auo1RoGpty/IuBWBA/TheT;5:HsRt/7PtcjS9MFIwx7w3ObNlOtGa3pxHgpPBprHzccn36kUYiGajA8DBib5nJ6Qdou8PCooYn2l3f3uOJf01G0QMMthE9auoJhXsJRKBPOGCnhR24FeBZK7J/E9A2mKri8QeUilItaooKseaiToCZzRC+XDhiVfMbH0dkcEuLXI=;24:2gNOSUDCvuk76YF9kA1VUZSXAdaSnUzR0p9yGmp6Nnqtc1q3IZFkA/PvOrWwusz9TRKPul5sde8eiXIoRG/L/3jfoMhANzan2KfYvuluIi0=;7:Wsvxs0xqoFa/pMFeYziXBJZB7dmDf8CIp+zHycxe5pqMHKkYRWkt7bxLbb3oaMgajdZobGDsA+Ccy7o2FYIjgfe61Fpo8tL2F4fKstJkKCHuY0oTC9MiU66ONCXioP9EG3s8qkALd6oPIIj4H3PcuvVySjFXlfIsfGOpSUccqgVsYJwCCv9rYvNf2CZGnO0mQoopVIZbAMw7+yMAKEqjMlaCiZeIVjhIkkmE7rAiV1yXag8SzGh6lRVM+py3zSU4 x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: a0e4a795-8f8a-45c0-a792-08d581569d83 x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(4534165)(4627221)(201703031133081)(201702281549075)(48565401081)(5600026)(4604075)(3008032)(2017052603307)(7193020);SRVR:MW2PR2101MB1036; x-ms-traffictypediagnostic: MW2PR2101MB1036: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alexander.Levin@microsoft.com; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(28532068793085)(89211679590171)(9452136761055)(85827821059158)(211936372134217)(42068640409301)(153496737603132)(146099531331640); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(8211001083)(61425038)(6040501)(2401047)(8121501046)(5005006)(93006095)(93001095)(3231220)(944501244)(52105095)(3002001)(10201501046)(6055026)(61426038)(61427038)(6041288)(20161123562045)(20161123564045)(20161123558120)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011);SRVR:MW2PR2101MB1036;BCL:0;PCL:0;RULEID:;SRVR:MW2PR2101MB1036; x-forefront-prvs: 0600F93FE1 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(396003)(366004)(39380400002)(346002)(376002)(39860400002)(199004)(189003)(10290500003)(81166006)(5660300001)(107886003)(8936002)(39060400002)(81156014)(3846002)(6506007)(2906002)(8676002)(3280700002)(59450400001)(72206003)(76176011)(4326008)(478600001)(6116002)(6486002)(53936002)(1076002)(68736007)(6512007)(102836004)(6306002)(2501003)(966005)(66066001)(3660700001)(5250100002)(6436002)(105586002)(86612001)(36756003)(316002)(7736002)(97736004)(26005)(186003)(110136005)(305945005)(22452003)(575784001)(86362001)(99286004)(7416002)(6666003)(25786009)(106356001)(2900100001)(14454004)(54906003)(10090500001)(2950100002)(22906009)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:MW2PR2101MB1036;H:MW2PR2101MB1034.namprd21.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: 0ydCqdyBTTqe/ZJ0ROesfl9X6zKVO9sDGM64GAepNtj9G6iVTcwsoI/4zDUw0FrMiW2EftLORkusIoEWT3cyPpM6PxjBl3GZS2Rr9B2FzifOYMxV3/NUfgXgmN9fNaOLZJmBFGNBeRILeYjPUWfptd7N40Ej8oN2WZXGvCJPktA= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: a0e4a795-8f8a-45c0-a792-08d581569d83 X-MS-Exchange-CrossTenant-originalarrivaltime: 03 Mar 2018 22:28:27.6975 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW2PR2101MB1036 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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.149= 0218061.git.luto@kernel.org Signed-off-by: Ingo Molnar Signed-off-by: Sasha Levin --- arch/x86/kernel/setup.c | 15 --------------- arch/x86/kernel/setup_percpu.c | 21 +++++++++++++++++++++ 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c index 6b55012d02a3..d1a214287fe3 100644 --- a/arch/x86/kernel/setup.c +++ b/arch/x86/kernel/setup.c @@ -1200,21 +1200,6 @@ void __init setup_arch(char **cmdline_p) =20 kasan_init(); =20 -#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(); =20 map_vsyscall(); diff --git a/arch/x86/kernel/setup_percpu.c b/arch/x86/kernel/setup_percpu.= c index 2bbd27f89802..bbba27269fdd 100644 --- 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) =20 /* 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 } --=20 2.14.1