From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 47893C433E6 for ; Fri, 5 Mar 2021 09:42:18 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B360A64E5F for ; Fri, 5 Mar 2021 09:42:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B360A64E5F Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: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:List-Owner; bh=Vy2KuGr7dsY0tdmu5EIQ8ScFa4GyTe69WnrBAAqgpgQ=; b=G35Ph+95Gh4YHOJDrk/jWz6uO OEXixOaIpIEPvWYnECsqIOt4t83Z+ilx9iP0E2/LUJoCe8zt04uiuMF7JoN7QHlgRZS8yln1h0BvN HIBj7bdS3y4q+ctfOpF2StZ/JwXezP3/isllMk2hb7NcYgdW+UNBIc4/BBGwSNlzyePpeOD54Nv4j WEVkZUudCTow1obJoc8JLiDacNL5aRmfXLP6TUAdtdISog4Y68KUP5IHJJ9If1/MO5+4ZFChX+zIy i2/Fux9nAO+JRfmLi3MMvgTtrTAr7UpM9qyWQjC+UmU74fvVYYL3eMqoQjBexcWDiY8swSPxD7/IM Co9m2a5cA==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lI6x2-00EKAk-NI; Fri, 05 Mar 2021 09:40:52 +0000 Received: from mail.kernel.org ([198.145.29.99]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lI6wt-00EK8Z-LW for linux-arm-kernel@lists.infradead.org; Fri, 05 Mar 2021 09:40:45 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id BC38B64FCF; Fri, 5 Mar 2021 09:40:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1614937242; bh=OcgW7e5dsEfOiRnPlNxRnIX9X+KmlG1lTi/jpkrhSNI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=B8xpM+GnavnRS83VsT7VFrY32MlID3xQPi/RTLWj61Rh1Qw3R1yxDE86jDyaHAixw U6l/fhwNmbtVU9cgqnqDFXadsRy+5/NfRM+/B8zpBk4XdqM9IVQ09VOfc33WyR+8B7 juZTjIoAWDhQhE6Ra4ehSc5J/nfSZI+6AfsVxun3H2t9pdIOdPNpiCBSIXgbOQS477 XhR32jG3Bq4rFUDYXOw0D/RJ4jN31lWMOj9HDVbzTs2LfI0F66OW1NFXiUfJjXWAUN NCEZotyLCloVy44Ee6z1VQWuT3patKnQf67LcfGtUomVA7tGfOQHDxuvCHZORBebSP w1rDf1jHIkBrw== From: Ard Biesheuvel To: linux-efi@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, Ard Biesheuvel , Jeffrey Hugo , Bjorn Andersson , Shawn Guo , Rob Clark , Leif Lindholm , linux-arm-msm@vger.kernel.org Subject: [PATCH 1/1] efi: stub: omit SetVirtualAddressMap() if marked unsupported in RT_PROP table Date: Fri, 5 Mar 2021 10:39:58 +0100 Message-Id: <20210305093958.187358-2-ardb@kernel.org> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210305093958.187358-1-ardb@kernel.org> References: <20210305093958.187358-1-ardb@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210305_094043_965370_881E1B3F X-CRM114-Status: GOOD ( 14.39 ) 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: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The EFI_RT_PROPERTIES_TABLE contains a mask of runtime services that are available after ExitBootServices(). This mostly does not concern the EFI stub at all, given that it runs before that. However, there is one call that is made at runtime, which is the call to SetVirtualAddressMap() (which is not even callable at boot time to begin with) So add the missing handling of the RT_PROP table to ensure that we only call SetVirtualAddressMap() if it is not being advertised as unsupported by the firmware. Signed-off-by: Ard Biesheuvel --- drivers/firmware/efi/libstub/efi-stub.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/drivers/firmware/efi/libstub/efi-stub.c b/drivers/firmware/efi/libstub/efi-stub.c index ec2f3985bef3..26e69788f27a 100644 --- a/drivers/firmware/efi/libstub/efi-stub.c +++ b/drivers/firmware/efi/libstub/efi-stub.c @@ -96,6 +96,18 @@ static void install_memreserve_table(void) efi_err("Failed to install memreserve config table!\n"); } +static u32 get_supported_rt_services(void) +{ + const efi_rt_properties_table_t *rt_prop_table; + u32 supported = EFI_RT_SUPPORTED_ALL; + + rt_prop_table = get_efi_config_table(EFI_RT_PROPERTIES_TABLE_GUID); + if (rt_prop_table) + supported &= rt_prop_table->runtime_services_supported; + + return supported; +} + /* * EFI entry point for the arm/arm64 EFI stubs. This is the entrypoint * that is described in the PE/COFF header. Most of the code is the same @@ -250,6 +262,10 @@ efi_status_t __efiapi efi_pe_entry(efi_handle_t handle, (prop_tbl->memory_protection_attribute & EFI_PROPERTIES_RUNTIME_MEMORY_PROTECTION_NON_EXECUTABLE_PE_DATA); + /* force efi_novamap if SetVirtualAddressMap() is unsupported */ + efi_novamap |= !(get_supported_rt_services() & + EFI_RT_SUPPORTED_SET_VIRTUAL_ADDRESS_MAP); + /* hibernation expects the runtime regions to stay in the same place */ if (!IS_ENABLED(CONFIG_HIBERNATION) && !efi_nokaslr && !flat_va_mapping) { /* -- 2.30.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel