Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3529495pxf; Mon, 15 Mar 2021 11:35:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyBGQBPAf8U50OimvIyWy4cMivF5QRrVM1eMSKm+5lV2tRvi94MWMpBgn/KGFVxx4wW/FRI X-Received: by 2002:a17:907:7745:: with SMTP id kx5mr24955483ejc.3.1615833329884; Mon, 15 Mar 2021 11:35:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615833329; cv=none; d=google.com; s=arc-20160816; b=FZc9z8Ro9lIlFA2+Y/O4BBtiP809QArIw5Cd7lrELBZliGtrY2z95i9HxoQmrrYPwM bTbyi9CEHzsY9TnPcKWdz75ElIWwM1dENzxtOR51Szhp0O1ZJdBtQ11ADK/AJHyPeumk UXpnYfIgHxvEZvZlnMd8oua6rrgzvBD4HkGAVoKO/32+uqcV7aXtMJuL9rOGJ5can0RD hKNNSqu69cYlN+VQCXxQm+4NBzQFoR5ehsHfcCh6JUGsPFs34JauwEtoe2ViJuNmIRJJ 1SyouBiacAuPovw03uJqSEPQKubYh22FLL4QFYhRcB7ohQVQCQMTaGk3N4P/ZJ0US3LA V/SA== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=8F27NGz0Cjrt78I3zTFHqLlJRcfSM6IKvvedJl4j+qc=; b=gS0+Y5RWG1EHz7+ipcKYftLwJfNVi4PFlVaMR0cCMEEnFAlyj0yxtrOohkz6h0dukH gnFGDhosmKMOl3ODiZ5obV/Tx1UrEoyUSwaIdBUPCyQgJfDEUORgILaj5jkD/OMwE/+O 30HRIjfxyDa9p7F+jQK6XrR4DLfZ7uVLVBV2uPLtkGm4r/k8ZLVBGewqumguwQsX5cRD yDwSDb5FOFydWchiV+FKrJRUGzrYk5brikr7Lu/wiWkNX6BAAy6daI56ccI3mMski4tc 3Q0YXjXoMFtI1pWx7l0MUzCOru/sJQTC+XTpF7pHNB2dzTR0tWkt7x3JBKMAqKvE6Kxb zzfg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=gvfuZzg8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id de11si11819716edb.15.2021.03.15.11.35.07; Mon, 15 Mar 2021 11:35:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=gvfuZzg8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237411AbhCOOpP (ORCPT + 99 others); Mon, 15 Mar 2021 10:45:15 -0400 Received: from mail.kernel.org ([198.145.29.99]:51552 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234536AbhCOOEN (ORCPT ); Mon, 15 Mar 2021 10:04:13 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 3BBF264F17; Mon, 15 Mar 2021 14:04:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615817053; bh=WpyuGGg4fLXOdll3DlmkFdMT8Yj29Ez8TxbVjZ3qKs0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gvfuZzg8k+RfkG22cq+7KWj8DgpnnvNc2/x7rCnBC5Rqk0+F7Nn4spBpom2ccuvXn c493GMtSbx+Dnt3tYbEvkbipJ0Grl32sXnW2ujHA5Wm/zFvi7VLpezApPHdErfQx/Y Jc9ZjFKnZnLp5kHJQtLdoh9OCHDnq2qOOu4qz9CY= From: gregkh@linuxfoundation.org To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Shawn Guo , Ard Biesheuvel Subject: [PATCH 5.10 264/290] efi: stub: omit SetVirtualAddressMap() if marked unsupported in RT_PROP table Date: Mon, 15 Mar 2021 14:55:57 +0100 Message-Id: <20210315135550.939002740@linuxfoundation.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210315135541.921894249@linuxfoundation.org> References: <20210315135541.921894249@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Greg Kroah-Hartman From: Ard Biesheuvel commit 9e9888a0fe97b9501a40f717225d2bef7100a2c1 upstream. 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. Cc: # v5.10+ Tested-by: Shawn Guo Signed-off-by: Ard Biesheuvel Signed-off-by: Greg Kroah-Hartman --- drivers/firmware/efi/libstub/efi-stub.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) --- 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(voi 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_h (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) { /*