Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3528764pxf; Mon, 15 Mar 2021 11:34:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzLlV7gmHp9ZysEu9pQbmmfQMtLcI+h7uraPxE6AHbaNqi5IUX4eH0ytxs/9gydk9HGifWJ X-Received: by 2002:a17:907:3da3:: with SMTP id he35mr24824988ejc.148.1615833269945; Mon, 15 Mar 2021 11:34:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615833269; cv=none; d=google.com; s=arc-20160816; b=cZpy7kbVIELKnYwJR9vFESQoQW4VOrGWVN5WWJpndIQQF68/9+AT/wfj/ou4pdKDsb wnCx8l2d2URwxwIuhgHCt+gGfOepv7UXNKtXrpv/aZNO2LujEX2dYPC5d0mN8VY0Pokb 3MLoGEJ8jdCyezvZtNEScwIjD6qW8xSfbBQbHaqm+qHtSE5oU5lzMPjEGbE6uILnduE6 9EjCWXz7VfVjmwlzfe4VVXWtNM/wlTK7ek8o4g2MUceMJ3pw1eJ1nAQMg7xK5zpfKuIK KRVm28x8di8LJtoFxMQh6RpH767zzn651GV35ruiHvIkdRh2VI1KHChz+nMuV4YRxzu2 oLRw== 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=WXZv7BaXEkV2FbrTEE+Wxoo9MqdT6+1AwxutA2P4J3P6bhvz9vBxjnwKVW1EiIrdT5 BRxqKtjel2ZnhNO3Geb8y+d8TYfa6P7x1pNtuxeS+IHgU2lkPcJtqNM6cDEByuTZuO0A 9J+pXiEvzvkSBJ9CIvon/gTWuCP0ftSz4qnMqcIG4NoyXnS7YQLo4VlJfPSgnct+1zGU F6lmj37SEuuyA9gc0hhmHPEAtH/QXAAEsIsVFSGEcUWXf6HxpNpZGSf6aG7A4LuPGbul aYab6gstmeA7D57LNux5HFIQtl5mHb/ScvfIgN48JIG9vg5wKsKbwDGW22oOFUSRMPBX sFFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=a1Nuqb1N; 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 zd21si11663015ejb.634.2021.03.15.11.34.07; Mon, 15 Mar 2021 11:34: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=a1Nuqb1N; 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 S238173AbhCOOpd (ORCPT + 99 others); Mon, 15 Mar 2021 10:45:33 -0400 Received: from mail.kernel.org ([198.145.29.99]:51980 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234547AbhCOOER (ORCPT ); Mon, 15 Mar 2021 10:04:17 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 5803C64DAD; Mon, 15 Mar 2021 14:04:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615817057; bh=WpyuGGg4fLXOdll3DlmkFdMT8Yj29Ez8TxbVjZ3qKs0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=a1Nuqb1N6Bm7H0047eBXvMGhC2Pgpo3pG7Z1jVsH9d8Q75NbYySi9slZtkPJk/r37 L6W9dk2dNLo0KNZSnFTsgFXeeYfpuS/HtJ6JzraVxUCp+9qEtlxaUmKVu2j/aTi/dH MfWkcEJpSXCP2khFL7TWrtj9qoIiBZX2Mqm1iIHU= 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.11 279/306] efi: stub: omit SetVirtualAddressMap() if marked unsupported in RT_PROP table Date: Mon, 15 Mar 2021 14:55:42 +0100 Message-Id: <20210315135517.098808085@linuxfoundation.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210315135507.611436477@linuxfoundation.org> References: <20210315135507.611436477@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) { /*