From patchwork Tue Jan 17 14:27:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 643893 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 87E75C678D7 for ; Tue, 17 Jan 2023 14:29:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230349AbjAQO3D (ORCPT ); Tue, 17 Jan 2023 09:29:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47698 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232707AbjAQO2d (ORCPT ); Tue, 17 Jan 2023 09:28:33 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 396FD305E7 for ; Tue, 17 Jan 2023 06:27:38 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id C9B5C6144E for ; Tue, 17 Jan 2023 14:27:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 93081C43392; Tue, 17 Jan 2023 14:27:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1673965657; bh=Wrp3SuN2sf33gurMiIx27fDLuT7yPVKXHH1EzZKlC4o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qO6UZKm85lxdidHzRIBlEmzabel00R6fT+epRLagkglI9c324eFQl24LKV6Ys7xr2 pxzMg0EXzd4Wh6S+apqPFFDf4RFzXM2/GF5pvorIzQ1aw5OUhMtRqvwcADmASrEpRI LVM4tgZdlnFUf+JAz/uaPVTfXBDbkIO/HVzaPE48oNKVc+JSif3YXg4p/59BDefRWy JZPp3193gnm4ox5QK/omEFu9PGsg3Hfuu+savxQGIHi76hjL4Qs8RWJUzepdWPaBOT d3VvO+3ophnb4v28xgTqzGsUdZli8ADalukiKkL5D16eXgRQWWGuSe2K9J2zdk4OWI XQwXFzv+ffPOw== From: Ard Biesheuvel To: linux-efi@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, Ard Biesheuvel , Johan Hovold , Maximilian Luz , Nathan Chancellor , Steev Klimaszewski , Shawn Guo Subject: [RFT PATCH 2/2] arm64: efi: Force use of SetVirtualAddressMap() on MS Surface Date: Tue, 17 Jan 2023 15:27:18 +0100 Message-Id: <20230117142718.564299-3-ardb@kernel.org> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230117142718.564299-1-ardb@kernel.org> References: <20230117142718.564299-1-ardb@kernel.org> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1374; i=ardb@kernel.org; h=from:subject; bh=Wrp3SuN2sf33gurMiIx27fDLuT7yPVKXHH1EzZKlC4o=; b=owEB7QES/pANAwAKAcNPIjmS2Y8kAcsmYgBjxrBFK4LKNEyKO1VtL2pr9bayyhVzwVhz3steIhq1 N9crJECJAbMEAAEKAB0WIQT72WJ8QGnJQhU3VynDTyI5ktmPJAUCY8awRQAKCRDDTyI5ktmPJD7wDA CtuOFuG44iYE/4fcehhVRuxvJyzfsCG8MPJP42IX+GpJ4W/3BdRV6nmp4H4y52itZcDQc13yDxrRuk tP/Xjhtt7bcIgdS88R4Uvv1tzjZnmKaAeW/I6xYuRmzPT70ka6hAbWe7cRSsrSLFXpf1MBqZk0uzho 1BKac/OLexVJWMZ4cZL2MqSnbzNQSfIcU367p7NKgbKjuTEPjNOzp+oB05tahotW7FOerYyN1PIw75 u1xtxfHxptcaEBHk2FPs2a9tvrqaoSK93b9cupSeGBPWNcC/RX2mKkZcIRzDNqVkmeogcRmIs4HC7B fpfvFCE8MJETCZuuQ/2KVO5qacEraQGmlTotiIYJnZSPinIOLTbJ8LVcw4hwO1Yepvfh9Wz9fkDASu NC+75IMnH6PP4sOZUDKeqUCIbMyEacKaXtbioSswxJPIg6FPLgevddQ+Rgbnt8YKwrWD/k7rSGDJjx AD56fzaj80Cx9FMZRQPlwglje0ejLXopO7qQkvKS7C/sY= X-Developer-Key: i=ardb@kernel.org; a=openpgp; fpr=F43D03328115A198C90016883D200E9CA6329909 Precedence: bulk List-ID: X-Mailing-List: linux-efi@vger.kernel.org Qualcomm Snapdragon based Surface machines crash in the ResetSystem() EFI runtime service if SetVirtualAddressMap() has not been called prior. Unfortunately, SetVirtualAddressMap() itself crashes at boot time unless the mapping being installed is a 1:1 mapping, as these firmware implementations violate the EFI spec by accessing the new mapping before SetVirtualAddressMap() completes. Now that we have worked around the latter issue by always using a 1:1 map when the size of the VA space permits it, we can safely call SetVirtualAddressMap() in such cases. Signed-off-by: Ard Biesheuvel --- drivers/firmware/efi/libstub/arm64.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/firmware/efi/libstub/arm64.c b/drivers/firmware/efi/libstub/arm64.c index ff2d18c42ee74979..cc3757fc29bdda24 100644 --- a/drivers/firmware/efi/libstub/arm64.c +++ b/drivers/firmware/efi/libstub/arm64.c @@ -22,7 +22,8 @@ static bool system_needs_vamap(void) * Ampere Altra machines crash in SetTime() if SetVirtualAddressMap() * has not been called prior. */ - if (!type1_family || strcmp(type1_family, "Altra")) + if (!type1_family || + (strcmp(type1_family, "Altra") && strcmp(type1_family, "Surface"))) return false; efi_warn("Working around broken SetVirtualAddressMap()\n");