Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp21348142rwd; Thu, 29 Jun 2023 14:55:06 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6ZJejns3u1GfQBuI7tec6Igmfxjnel29kB1PcLjsuHt8U6lLf5lpMmEHnzIIYgG5B/vEq2 X-Received: by 2002:a05:6a20:9146:b0:10c:ef7d:b0ca with SMTP id x6-20020a056a20914600b0010cef7db0camr1021763pzc.15.1688075705912; Thu, 29 Jun 2023 14:55:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688075705; cv=none; d=google.com; s=arc-20160816; b=WaQJxsHIb454EZbAqP2qH+SX6QJw53izKMCJmoKvr+Tkc8jBvajqb9MnukEp8EKCZq VayBJXkb7PKgCuAOwaRERZgA0ystUscCBlU0LubzG4L8Wl0E2HCvjZupdipUeDK3xdjt iZib56egI6K7tS44BOPb98AWMJF2FtvJFkIXkRtTuiLat4rAESda7tHQizQCREMeVrPl ycSyD5QJjcxGFVvCH/1T7wjl32Q6bd+8BFhkqa68vwzxe2Xambvw9LpHkTwy2B/k5cVu okr2RZ/4GCgzmY5dk9xgnjD5FQkNTrEHcVkaKk1JRymGilbq9czYdE6StK8yMSCPeVI4 DVpg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=MQ6gZ9/bAPPo0wSJO1J4eBSKAXXgqcsJWwChSPUwIRs=; fh=1dx3C7PHrxeo1d1YRVsD741ZRMm87woYONScInMPylk=; b=kdxZ/IaRk03QHBZ1jUC90fmVHwX55RU5LLDODsfGX+evKIkwQ6baLF8NOmdqMAcgFk X2ZtOQaM2GzMiFVUAHyWFNJtYNqjgnRH4PAUwGRPGr4WCESlLECYKdOB5oQ5WgLKTqMs 4FzDoMPHn07S/nEdIgn+MQDoRJIBZSJqU0+CRpjw6nPh/7M2mlVSWIFTdKnIYm4A5THd WWtIltE+cNp3IF4KxHuWzsBW0nuXz9yt5CUsoeF0ZowEfXIYO7AI0tP0YqYAuDKOqWuC RHgd0ykIFgOV8ot4HwjPBjAqTYJrha6wiv6g9kQkjrro/JeVlrWop/srY04GeH1n9Taw kBXQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=SLKKhpEO; 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=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k191-20020a6384c8000000b0055336060f9csi11605489pgd.376.2023.06.29.14.54.49; Thu, 29 Jun 2023 14:55:05 -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=@kernel.org header.s=k20201202 header.b=SLKKhpEO; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231724AbjF2VnG (ORCPT + 99 others); Thu, 29 Jun 2023 17:43:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58574 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229668AbjF2VnE (ORCPT ); Thu, 29 Jun 2023 17:43:04 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CFDEF2D71; Thu, 29 Jun 2023 14:43:03 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 5BF9761642; Thu, 29 Jun 2023 21:43:03 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B59FFC433C0; Thu, 29 Jun 2023 21:43:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1688074982; bh=VltSwcc04VIEITjXt/NoqelYoJMc18hddRllfhvqNbA=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=SLKKhpEOdL+nNwBaXludEJn2g9r8oRQ2lGNm2Xnvg+zOsdB6Btsia7rfXMxgAKOSA mo0H4ha2UJOsuxiF90A1hbrik66VyO+DB1NNvlk88jcoML4fxY0brSyOQ8FgL4Kvf7 fQfE2nfGnrStk1QB/T7s0dhEk51TIz2xqpIqn34/BClRGZukdtpydn81VXGhAl61qN UF5+QyKRd/pAKxAO9HpEl8d6AjdovTCFgEyStdOZpaYL1XrikHvRydH3strDSH+DsR MVxIfM/rXdNyuv9KHJlI6FehubILW1I29XJx38VdqdmDVSSAIZKRqpFaDMmn7YQTHq eK/DuLX/aXKDw== Received: by mail-lf1-f44.google.com with SMTP id 2adb3069b0e04-4fb7769f15aso1907950e87.0; Thu, 29 Jun 2023 14:43:02 -0700 (PDT) X-Gm-Message-State: ABy/qLauCmi+PS1HqJoJGvV/8wt6kZ/XW2dl6ga4TFtvJfm/E8FQef3m QzJKMJ6aNkREZEUVQuw0HelXp+ti+4sbt3LMfPs= X-Received: by 2002:a05:6512:2211:b0:4fb:8948:2b2b with SMTP id h17-20020a056512221100b004fb89482b2bmr1124867lfu.48.1688074980708; Thu, 29 Jun 2023 14:43:00 -0700 (PDT) MIME-Version: 1.0 References: <87jzvm12q0.ffs@tglx> In-Reply-To: <87jzvm12q0.ffs@tglx> From: Ard Biesheuvel Date: Thu, 29 Jun 2023 23:42:49 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: x86/efi: Make efi_set_virtual_address_map IBT safe To: Thomas Gleixner Cc: LKML , =?UTF-8?B?TmlrbMSBdnMgS2/EvGVzxYZpa292cw==?= , linux-efi@vger.kernel.org, x86@kernel.org, regressions@lists.linux.dev 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,DKIMWL_WL_HIGH, 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: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 29 Jun 2023 at 21:35, Thomas Gleixner wrote: > > Nikl=C4=81vs reported a boot regression on an Alderlake machine and bisec= ted 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=3Doff" on the kernel > command line cured the problem. > > Inspection of the involved calls in efi_enter_virtual_mode() unearthed th= at > efi_set_virtual_address_map() is the only place in the kernel which invok= es > an EFI call without the IBT safe wrapper. This went obviously unnoticed s= o > 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=C4=81vs Ko=C4=BCes=C5=86ikovs > Signed-off-by: Thomas Gleixner > Link: https://bugzilla.kernel.org/show_bug.cgi?id=3D217602 Reviewed-by: Ard Biesheuvel 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 =3D efi_call(efi.runtime->set_virtual_address_map, > - memory_map_size, descriptor_size, > - descriptor_version, virtual_map); > + status =3D arch_efi_call_virt(efi.runtime, set_virtual_address_ma= p, > + memory_map_size, descriptor_size, > + descriptor_version, virtual_map); > local_irq_restore(flags); > > efi_fpu_end();