From patchwork Wed Nov 9 17:27:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 13037812 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A3A8BC433FE for ; Wed, 9 Nov 2022 17:28:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=6i3yheMfI8KVp5hBirPqS3iP9fuu0SB5tUU1pkSDCxw=; b=qj8yzStaLxyec6 8ebyYxW+J26jskuudw66T6JJ0zbkrxDDVYJ/LUdvgSVfKlwGbsxMpUt6aJHZCyKOblo1KKFEMHpg2 +1YGJEno5Gv3uRNf27P+/Q+recHENmuDrU7dJIOdt/ARLl9iDJPK1KJd2qMcMevst5Ulq+bmGKPnv 8Ix2FsXrR6dvyP5S9xDplfuueYzjApvbmo4qL8M0wlfx93MbRL0WjMij7lG+ynb8OsDGjux151viO 863iyqXyvGr2l3oXNMGIgpE1z7CjezR52dnkXk2kY+XaUEngCb1bI8u93QeLETfq4fiM6DNudQfrY fN6OQlT97DMVxVRuLBwQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1osoro-00FXPZ-Ca; Wed, 09 Nov 2022 17:28:00 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1osorl-00FXMp-Fj for linux-arm-kernel@lists.infradead.org; Wed, 09 Nov 2022 17:27:58 +0000 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 DD0F361C01; Wed, 9 Nov 2022 17:27:56 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3B272C433C1; Wed, 9 Nov 2022 17:27:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1668014876; bh=+qAX0WCvBvt2ZAO/ZEiX9R0/faeC3FYXr+Bab8yJpgc=; h=From:To:Cc:Subject:Date:From; b=jO+Y4K3gJ4veSjvsiZi/HzZJ0acSEXeVQ1VnAof5HQw+aD6eWUWe7bLkMcrouWPt/ jyAoTIqYKcR8bjPsnuzcvJRQWJMx4Qggl0tWFmvoPUwc21ymyGWXoco83BRRq/ey3+ Va9qK7e2TSCY/+H134d048Iu22+ixFsglJVK/2sLvu3HyQsNf8MS5Mtql52tM9HQTZ Rf7YzAk8w/sYECJvHy4Do9tHCTQZ45ScxUKVR5XmhLsY1b1XL8KvbE4+iuqIPy4fTB mPw0Y8Hf+Bil0mSjMTcSDU6QB3eZrqjo5xOiWz+LmNjxdWwhYkWotlFGEd060+bwzL EoSW3JFKvg4wg== From: Ard Biesheuvel To: linux-efi@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, alexandru.elisei@arm.com, Ard Biesheuvel Subject: [PATCH] efi: Override runtime supported mask from a EFI variable if present Date: Wed, 9 Nov 2022 18:27:50 +0100 Message-Id: <20221109172750.2823891-1-ardb@kernel.org> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1427; i=ardb@kernel.org; h=from:subject; bh=+qAX0WCvBvt2ZAO/ZEiX9R0/faeC3FYXr+Bab8yJpgc=; b=owEB7QES/pANAwAKAcNPIjmS2Y8kAcsmYgBja+MV/zaQ/eSZ2P2yAsMJlaau9JYjgexMxcsv3yjW a10qOGuJAbMEAAEKAB0WIQT72WJ8QGnJQhU3VynDTyI5ktmPJAUCY2vjFQAKCRDDTyI5ktmPJCBzC/ 9wf8y4W6QdO7otQdDy4IflhzXmGDZBOzJRjUiRDfFIcgeYuAmWKiJDT/3SzFtjTiLQWhRn3Q2ptt1j WDa3zHM9tS7ISAmkYX6P29TeapwVrKGB+actatY9DftWRMm6cUNdTNuLkXrV+F2qX0mp9jzVj3RehJ 7rMhknupRYXr5QS+rFvUhIYXxn2uAmsARVmC7z9n7ARnutfs186bhEUDwcA4nx2kgXb5XvCJJyNuax 6WUZXlbcioYdlYI91XR8ddZR/8hyABgTajQeVq3ZENmBY4XBRVBuF/DHccz8QnIrMRsW+Acm2NZHV8 KiEbDFbeXTDMmMNliFemJgXB8206OTR8KBxUak0gXewYhj/hF0hPDQnM12Tmo5cOcDzMoIpB6UoF3q dY5SP6XqkFiBWkONTkcTfJJ41nvWoZZaX2X8HWoOzSMJ3lCHPlCpcHYlC51UhL1uusNEoXUj1glgsg 7rViqw+NszT3rq7405JOEsL3zhaXvz4ubAM+NmqVA2Ulg= X-Developer-Key: i=ardb@kernel.org; a=openpgp; fpr=F43D03328115A198C90016883D200E9CA6329909 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221109_092757_579351_A0E12BC9 X-CRM114-Status: GOOD ( 13.63 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org For debugging purposes, allow the runtime override mask to be set from a EFI variable if one exists. For instance, the RT supported mask can be set to 0xfffd to disable the SetTime() runtime service, and enable all others: echo -ne "\x7\0\0\0\xfd\xff" \ > /sys/firmware/efi/efivars/LinuxRtMaskOverride-eb66918a-7eef-402a-842e-931d21c38ae9 Signed-off-by: Ard Biesheuvel --- drivers/firmware/efi/efi.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c index a46df5d1d0942751..faed1ef78c044924 100644 --- a/drivers/firmware/efi/efi.c +++ b/drivers/firmware/efi/efi.c @@ -367,7 +367,17 @@ static int __init efisubsys_init(void) } } - if (efi_rt_services_supported(EFI_RT_SUPPORTED_TIME_SERVICES)) + if (efi_rt_services_supported(EFI_RT_SUPPORTED_GET_VARIABLE)) { + unsigned long size = sizeof(efi.runtime_supported_mask); + + if (efi.get_variable(L"LinuxRtMaskOverride", + &EFI_RT_PROPERTIES_TABLE_GUID, NULL, &size, + &efi.runtime_supported_mask) == EFI_SUCCESS) + pr_info("Overriding runtime_supported_mask to 0x%x\n", + efi.runtime_supported_mask); + } + + if (efi_rt_services_supported(EFI_RT_SUPPORTED_GET_TIME)) platform_device_register_simple("rtc-efi", 0, NULL, 0); /* We register the efi directory at /sys/firmware/efi */