Message ID | 87jzvm12q0.ffs@tglx |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp9873658vqr; Thu, 29 Jun 2023 12:50:57 -0700 (PDT) X-Google-Smtp-Source: APBJJlGy+cw3jzF77skPQhOiyh6tvkROnmRzGZpoluPdGR2zJqQvNlkoERAD/hcX2W2pAUHrDGQJ X-Received: by 2002:a05:6a00:1a8b:b0:66f:7076:a5b8 with SMTP id e11-20020a056a001a8b00b0066f7076a5b8mr887256pfv.29.1688068256858; Thu, 29 Jun 2023 12:50:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688068256; cv=none; d=google.com; s=arc-20160816; b=IdF8gv7VTUJ/hWwRF/yRRX+3WJEbwDlzjxD2mw8YKcNQB3VfC9wU6BD98ybDZli5NH KuKwuUFXaBmRlYjtYaLLffA3FsYZtLAJlr08aDie4KbCTLVXu9ow+NDaaMV1yFoCvFbA XcWmJT80/HDpQ0TnXOj2AiYwajHH5aVqOhhLYP51MN2caVC8YirnFEFU+HrBP6HrArgM D1eRQv+K85zq/ejZIACRhdFjD5/gibyksnABTMEe3nSo7oR1RQoWuZYITCCvhAA24ujQ V4f0VFlr9C2ahcwwW6jJozAnWxBIf4HRVlhnnyQ7+WED8WHlxKLBkPu8nFsAFwW210XK TcXg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:dkim-signature:dkim-signature:from; bh=cQWrepqeMi4qIeVTOHeQAMFD514b/C3xCiVp4otJIcA=; fh=1hRrtnvrVzMzNH2hbXUUeJfIdhXMLefgrlzob8tJOiE=; b=sLnbnyAdFkZu0+M0l/6bk3KWr0MK/okR0o0OITeLBYOmXDgwsbF7Wfsl4CtIqhQr2H W0TKQD+1O/olNWBHvDweEG6m3ncYFWMxx+6MJy2LhS3H2NJtiP7y8vtODVJhp6KTs6BZ ox963Gv+kE3MZGEZnVFC3vLjUkKjscxM34e/sMBEOlsBXTDTpPn6+J/XusBf7ZBJT99U XDmrqfNW+h5+BdZWWa+dR64CuBi5MreSYHv3dNjPr6jNZ29qH/YzWePzP7CDujwEiDbL pXHPKLHbB5fdxTg4vu2XRpk1ehYOgnyxYIW7QtTEr8bPSkZtWn5ZKBw0D6DOlM6WZsT5 H5ew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=sPLqChFM; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o18-20020a056a0015d200b00668717a964fsi7255364pfu.33.2023.06.29.12.50.42; Thu, 29 Jun 2023 12:50:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=sPLqChFM; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231849AbjF2TfY (ORCPT <rfc822;adanhawthorn@gmail.com> + 99 others); Thu, 29 Jun 2023 15:35:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56426 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230187AbjF2TfX (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 29 Jun 2023 15:35:23 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3A73D12F; Thu, 29 Jun 2023 12:35:22 -0700 (PDT) From: Thomas Gleixner <tglx@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1688067320; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=cQWrepqeMi4qIeVTOHeQAMFD514b/C3xCiVp4otJIcA=; b=sPLqChFMbwkv7gUwFdIZmNr84XHb6D2mjdmp+jV6yLK0gpjf/1guCqRCQXf3UuVN9a1jhT KV2/t0r8g9bIum79RRipBqOw8tSsmID2evmWe5Bf/B0gEHDub6hMjp+uUll2VUR1cWO8bg BkmH3PrRndazrmGkcskfGUfZlOGtfgU21Br07TmLqvpoOFozC8HI/WgmBqaCYLwNNjec/D Q2uuxVUXXwia0M6QZyAxA9IqMq2VimbUC+HcdcUmSw7+y+MAegwR75iG5owSN6mHloiKCe qxoIqSvBguJlLmCEJZuAcspj69ITLqBOhHL26Lz8ealCLhDPK6f7C9wBEoy1zA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1688067320; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=cQWrepqeMi4qIeVTOHeQAMFD514b/C3xCiVp4otJIcA=; b=3nR0ix5L1Oxfruv0U7AwkFzNl5SLb/elXiT6FzigX3+qvl5ejSZN8rglwscHPwqtjlK2zI pQaEZybL3uj4hxDA== To: LKML <linux-kernel@vger.kernel.org> Cc: =?utf-8?b?TmlrbMSBdnMgS2/EvGVzxYZpa292cw==?= <pinkflames.linux@gmail.com>, Ard Biesheuvel <ardb@kernel.org>, linux-efi@vger.kernel.org, x86@kernel.org, regressions@lists.linux.dev Subject: x86/efi: Make efi_set_virtual_address_map IBT safe Date: Thu, 29 Jun 2023 21:35:19 +0200 Message-ID: <87jzvm12q0.ffs@tglx> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1770067860554361577?= X-GMAIL-MSGID: =?utf-8?q?1770067860554361577?= |
Series |
x86/efi: Make efi_set_virtual_address_map IBT safe
|
|
Commit Message
Thomas Gleixner
June 29, 2023, 7:35 p.m. UTC
Niklāvs reported a boot regression on an Alderlake machine and bisected it
to commit 9df9d2f0471b ("init: Invoke arch_cpu_finalize_init() earlier").
By moving the invocation of arch_cpu_finalize_init() further down he
identified that efi_enter_virtual_mode() is the function which causes
the boot hang.
The main difference of the earlier invocation is that the boot CPU is
already fully initialized and mitigations and alternatives are applied.
But the only really interesting change turned out to be IBT, which is
now enabled before efi_enter_virtual_mode(). "ibt=off" on the kernel
command line cured the problem.
Inspection of the involved calls in efi_enter_virtual_mode() unearthed that
efi_set_virtual_address_map() is the only place in the kernel which invokes
an EFI call without the IBT safe wrapper. This went obviously unnoticed so
far as IBT was enabled later.
Use arch_efi_call_virt() instead of efi_call() to cure that.
Fixes: fe379fa4d199 ("x86/ibt: Disable IBT around firmware")
Fixes: 9df9d2f0471b ("init: Invoke arch_cpu_finalize_init() earlier")
Reported-by: Niklāvs Koļesņikovs <pinkflames.linux@gmail.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://bugzilla.kernel.org/show_bug.cgi?id=217602
---
I put two fixes tags in as the IBT one missed that and the earlier
invocation unearthed it and made it observable.
---
arch/x86/platform/efi/efi_64.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
Comments
On Thu, 29 Jun 2023 at 21:35, Thomas Gleixner <tglx@linutronix.de> wrote: > > Niklāvs reported a boot regression on an Alderlake machine and bisected it > to commit 9df9d2f0471b ("init: Invoke arch_cpu_finalize_init() earlier"). > > By moving the invocation of arch_cpu_finalize_init() further down he > identified that efi_enter_virtual_mode() is the function which causes > the boot hang. > > The main difference of the earlier invocation is that the boot CPU is > already fully initialized and mitigations and alternatives are applied. > > But the only really interesting change turned out to be IBT, which is > now enabled before efi_enter_virtual_mode(). "ibt=off" on the kernel > command line cured the problem. > > Inspection of the involved calls in efi_enter_virtual_mode() unearthed that > efi_set_virtual_address_map() is the only place in the kernel which invokes > an EFI call without the IBT safe wrapper. This went obviously unnoticed so > far as IBT was enabled later. > > Use arch_efi_call_virt() instead of efi_call() to cure that. > > Fixes: fe379fa4d199 ("x86/ibt: Disable IBT around firmware") > Fixes: 9df9d2f0471b ("init: Invoke arch_cpu_finalize_init() earlier") > Reported-by: Niklāvs Koļesņikovs <pinkflames.linux@gmail.com> > Signed-off-by: Thomas Gleixner <tglx@linutronix.de> > Link: https://bugzilla.kernel.org/show_bug.cgi?id=217602 Reviewed-by: Ard Biesheuvel <ardb@kernel.org> I take it you'll send this straight to Linus? > --- > I put two fixes tags in as the IBT one missed that and the earlier > invocation unearthed it and made it observable. > --- > arch/x86/platform/efi/efi_64.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > --- a/arch/x86/platform/efi/efi_64.c > +++ b/arch/x86/platform/efi/efi_64.c > @@ -853,9 +853,9 @@ efi_set_virtual_address_map(unsigned lon > > /* Disable interrupts around EFI calls: */ > local_irq_save(flags); > - status = efi_call(efi.runtime->set_virtual_address_map, > - memory_map_size, descriptor_size, > - descriptor_version, virtual_map); > + status = arch_efi_call_virt(efi.runtime, set_virtual_address_map, > + memory_map_size, descriptor_size, > + descriptor_version, virtual_map); > local_irq_restore(flags); > > efi_fpu_end();
On Thu, Jun 29 2023 at 23:42, Ard Biesheuvel wrote: > On Thu, 29 Jun 2023 at 21:35, Thomas Gleixner <tglx@linutronix.de> wrote: >> Niklāvs reported a boot regression on an Alderlake machine and bisected it >> to commit 9df9d2f0471b ("init: Invoke arch_cpu_finalize_init() earlier"). >> >> By moving the invocation of arch_cpu_finalize_init() further down he >> identified that efi_enter_virtual_mode() is the function which causes >> the boot hang. >> >> The main difference of the earlier invocation is that the boot CPU is >> already fully initialized and mitigations and alternatives are applied. >> >> But the only really interesting change turned out to be IBT, which is >> now enabled before efi_enter_virtual_mode(). "ibt=off" on the kernel >> command line cured the problem. >> >> Inspection of the involved calls in efi_enter_virtual_mode() unearthed that >> efi_set_virtual_address_map() is the only place in the kernel which invokes >> an EFI call without the IBT safe wrapper. This went obviously unnoticed so >> far as IBT was enabled later. >> >> Use arch_efi_call_virt() instead of efi_call() to cure that. >> >> Fixes: fe379fa4d199 ("x86/ibt: Disable IBT around firmware") >> Fixes: 9df9d2f0471b ("init: Invoke arch_cpu_finalize_init() earlier") >> Reported-by: Niklāvs Koļesņikovs <pinkflames.linux@gmail.com> >> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> >> Link: https://bugzilla.kernel.org/show_bug.cgi?id=217602 > > Reviewed-by: Ard Biesheuvel <ardb@kernel.org> > > I take it you'll send this straight to Linus? I can do that. Thanks, tglx
--- a/arch/x86/platform/efi/efi_64.c +++ b/arch/x86/platform/efi/efi_64.c @@ -853,9 +853,9 @@ efi_set_virtual_address_map(unsigned lon /* Disable interrupts around EFI calls: */ local_irq_save(flags); - status = efi_call(efi.runtime->set_virtual_address_map, - memory_map_size, descriptor_size, - descriptor_version, virtual_map); + status = arch_efi_call_virt(efi.runtime, set_virtual_address_map, + memory_map_size, descriptor_size, + descriptor_version, virtual_map); local_irq_restore(flags); efi_fpu_end();