From patchwork Wed Nov 24 20:34:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Fernandez X-Patchwork-Id: 12637767 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 37BB8C433F5 for ; Wed, 24 Nov 2021 20:37:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0E6236B007E; Wed, 24 Nov 2021 15:36:27 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 06C406B0080; Wed, 24 Nov 2021 15:36:27 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E00776B0081; Wed, 24 Nov 2021 15:36:26 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0055.hostedemail.com [216.40.44.55]) by kanga.kvack.org (Postfix) with ESMTP id CE7C66B007E for ; Wed, 24 Nov 2021 15:36:26 -0500 (EST) Received: from smtpin13.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 93032184967C1 for ; Wed, 24 Nov 2021 20:36:16 +0000 (UTC) X-FDA: 78844981152.13.F63F8F4 Received: from mail-vk1-f176.google.com (mail-vk1-f176.google.com [209.85.221.176]) by imf29.hostedemail.com (Postfix) with ESMTP id 69EC29000266 for ; Wed, 24 Nov 2021 20:36:13 +0000 (UTC) Received: by mail-vk1-f176.google.com with SMTP id 84so2407572vkc.6 for ; Wed, 24 Nov 2021 12:36:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=eclypsium.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=jY0dy/d5c8YPxh7NXvxGcRPu0/DQhp2j75dR0lO6H7o=; b=YKP1iGwN3dXHjgMjYuAi+DHERVJy5yD4KnnKwrrB8Vw3N9k95iuo+Uf6w1JpvVRCKO ypKQBdwzMGajAa/dYvxHesztyscRflbsqWDCEEDVSvuk3jaiGSCyU7Ndc3B9oVGs8KVL oJuaCHLwPOAtE4iy7/Rwet/lvfXVqiwfXn84SrBZTMEgDrzrfVjRejCi9zFZAHjBrAv/ p43qJ+VwLr2gPe5XzhN5cqiqGcvM1QqM5h38aFAyI17GjiItGVs+l4IteLsLN+q6DHWM 026avAx6elQMgxDoM+7TO2JzlYy567x3+N8gxH0MRR5EFU9UVTgrourfXEYlL7XZxMDA ZKpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=jY0dy/d5c8YPxh7NXvxGcRPu0/DQhp2j75dR0lO6H7o=; b=f2+hV68P9sNV3evnPz+61DicXxDic/5w6WuSLVh7RIQwpnXX6/3jdZ9csWAuqeLpvp 5ej/JD+UOng8yW6Xh/lOiZUDCU8Hmif2i79zD7gi3VUzMzXPF0hOmVoXBz5wFZczX7LB cInPN9XesmjozSDzw28Bn66/uaSu4sI7tcI/wN+FZOfxDh0mr61qSdhoaqAYAz9MZF1Q uMNfgdA/7HT4MiLrSg0Pr9prObjgFR1Ryb9i0wYZKQJEiSQvi1mzDTu9GlYKsYIg2BVw qy/W3toDxxytWcRVF626dTY+arpME7ewLflp843DGAi2yixO4z6AwIj+O03jmwHhWTGs dbXg== X-Gm-Message-State: AOAM530rFOAOIB9yehbHA9XxAgPfH5NH0nKwDu9MKiG0q597LWFev2xP wZ2g32z+SHD7SiG1AJSaq8rUeg== X-Google-Smtp-Source: ABdhPJzR0bwHzxnrsklT2ho3w5z0D589l6rvGmOY2zbPVUFKORG+kRx9hLglmOnTJtr7RU8cnD8Qdg== X-Received: by 2002:a1f:9f04:: with SMTP id i4mr4918531vke.33.1637786175500; Wed, 24 Nov 2021 12:36:15 -0800 (PST) Received: from localhost (7-153-16-190.fibertel.com.ar. [190.16.153.7]) by smtp.gmail.com with ESMTPSA id c9sm601971uaf.12.2021.11.24.12.36.10 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 24 Nov 2021 12:36:15 -0800 (PST) From: Martin Fernandez To: linux-efi@vger.kernel.org, platform-driver-x86@vger.kernel.org, linux-mm@kvack.org Cc: tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, x86@kernel.org, hpa@zytor.com, dave.hansen@linux.intel.com, luto@kernel.org, peterz@infradead.org, ardb@kernel.org, dvhart@infradead.org, andy@infradead.org, gregkh@linuxfoundation.org, rafael@kernel.org, daniel.gutson@eclypsium.com, hughsient@gmail.com, alison.schofield@intel.com, Martin Fernandez Subject: [PATCH v2 4/5] x86/efi: Tag e820_entries as crypto capable from EFI memmap Date: Wed, 24 Nov 2021 17:34:58 -0300 Message-Id: <20211124203459.4578-5-martin.fernandez@eclypsium.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211124203459.4578-1-martin.fernandez@eclypsium.com> References: <20211124203459.4578-1-martin.fernandez@eclypsium.com> MIME-Version: 1.0 X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 69EC29000266 Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=eclypsium.com header.s=google header.b=YKP1iGwN; dmarc=pass (policy=quarantine) header.from=eclypsium.com; spf=pass (imf29.hostedemail.com: domain of martin.fernandez@eclypsium.com designates 209.85.221.176 as permitted sender) smtp.mailfrom=martin.fernandez@eclypsium.com X-Stat-Signature: h8tgn4oui5wr4q4nsnjubmp6iaefz5xh X-HE-Tag: 1637786173-704586 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Add a function to iterate over the EFI Memory Map and mark the regions tagged with EFI_MEMORY_CPU_CRYPTO in the e820_table; and call it from efi_init if add_efi_memmap is disabled. Also modify do_add_efi_memmap to mark the regions there. Signed-off-by: Martin Fernandez --- arch/x86/platform/efi/efi.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/arch/x86/platform/efi/efi.c b/arch/x86/platform/efi/efi.c index 147c30a81f15..8f52cde61688 100644 --- a/arch/x86/platform/efi/efi.c +++ b/arch/x86/platform/efi/efi.c @@ -184,6 +184,8 @@ static void __init do_add_efi_memmap(void) } e820__range_add(start, size, e820_type); + if (md->attribute & EFI_MEMORY_CPU_CRYPTO) + e820__range_mark_as_crypto(start, size); } e820__update_table(e820_table); } @@ -441,6 +443,22 @@ static int __init efi_config_init(const efi_config_table_type_t *arch_tables) return ret; } +static void __init efi_mark_e820_regions_as_crypto_capable(void) +{ + efi_memory_desc_t *md; + + for_each_efi_memory_desc(md) { + if (md->attribute & EFI_MEMORY_CPU_CRYPTO) + e820__range_mark_as_crypto(md->phys_addr, md->num_pages << EFI_PAGE_SHIFT); + } + + /* + * We added and modified regions so it's good to update the + * table to merge/sort + */ + e820__update_table(e820_table); +} + void __init efi_init(void) { if (IS_ENABLED(CONFIG_X86_32) && @@ -494,6 +512,13 @@ void __init efi_init(void) set_bit(EFI_RUNTIME_SERVICES, &efi.flags); efi_clean_memmap(); + /* + * If add_efi_memmap then there is no need to mark the regions + * again + */ + if (!add_efi_memmap) + efi_mark_e820_regions_as_crypto_capable(); + if (efi_enabled(EFI_DBG)) efi_print_memmap(); }