From patchwork Thu Feb 3 16:43:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Fernandez X-Patchwork-Id: 12734324 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 3FEDCC433EF for ; Thu, 3 Feb 2022 16:44:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 814F86B03DB; Thu, 3 Feb 2022 11:44:02 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 79DC76B03DC; Thu, 3 Feb 2022 11:44:02 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 617F56B03DD; Thu, 3 Feb 2022 11:44:02 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0251.hostedemail.com [216.40.44.251]) by kanga.kvack.org (Postfix) with ESMTP id 53EAD6B03DB for ; Thu, 3 Feb 2022 11:44:02 -0500 (EST) Received: from smtpin15.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 0AC8395C9D for ; Thu, 3 Feb 2022 16:44:02 +0000 (UTC) X-FDA: 79102040724.15.FDC1BA8 Received: from mail-vk1-f181.google.com (mail-vk1-f181.google.com [209.85.221.181]) by imf15.hostedemail.com (Postfix) with ESMTP id 94521A0003 for ; Thu, 3 Feb 2022 16:44:01 +0000 (UTC) Received: by mail-vk1-f181.google.com with SMTP id j185so2090705vkc.1 for ; Thu, 03 Feb 2022 08:44:01 -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=dL7Kyw5R5uEJ5iFptCvOaKv8TqVxuhvnFOanF/ug8Oo=; b=MR8jXVkyACJhcck+4dcIScEcJjdlILboYDi4bqSv/6PZ8vBTWUY9vgbyWmkv4L/15Q FtimY0idlQDbZUTEV6rjD0xK50eicfInFXj/KAqbBZx+/tiI/11qsBWxJWE2MiAFXpOA /FNHgzWKuvmXWqOkq1muNBj+A2wx5HLtsHpFIY2ndlCa9hIDZgbgMK5TczXwoGmETExB FrOt7tpZowyB0etKJbSK6ojlEgVQ07mYW3A4TZTCmejaIh/8yLC+kSwulqt0/pn+MeM2 ciAwu3tFxEG46MI470mmhgPU7yW2gNwBIIAq3litWGQK53yT6iAypK5CNOL+cpubsYQr 5lpA== 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=dL7Kyw5R5uEJ5iFptCvOaKv8TqVxuhvnFOanF/ug8Oo=; b=iFzfmQz3muMp9FRazZ1pdUaFcD+jBelHGr/2rrGzarUVk+hbFf2JY2kfDIjzUMHXlZ L8YJygaC6lRirTGhJtRZ/Tdncg1bDhQ1XYzUNIJA9LkBdaFFHkPFAAuiNfagKc6VtLM7 oOkeYFNLafn8CXB5nG5NpaPmXEDTm5Bzv985w9rf/Hh0a/W/ih+fG+/rJYsiEkaH5Qrd i84199WbHy383y0Bsy/Mf74kaRwPebGVvmePm8bUb6KFVZr6hz99/EYyCSAJ2YpDpIT2 Fz6r1/B5QiTh6zRl0ePSeOd5/fVsSHdbfRgMWEFV6lT7R5bXa05tXYm1WZZe+7m8d/HI L6NA== X-Gm-Message-State: AOAM530XkPQYp7ux+Jjb9QXb2SlxSN9W7X8TnMfRT0gLxh1zW8SdzT3t EcuoPZadOC1DcGqplmTCIAuYRw== X-Google-Smtp-Source: ABdhPJxUoacAYoBRc2lU1MnrO2thZNWlOT7k9ldUA5Uo6JdpNTbP0+ss+QIEqv7t+aG2BNl+L+GRew== X-Received: by 2002:a1f:2d10:: with SMTP id t16mr15067999vkt.36.1643906640835; Thu, 03 Feb 2022 08:44:00 -0800 (PST) Received: from localhost (host8.190-224-49.telecom.net.ar. [190.224.49.8]) by smtp.gmail.com with ESMTPSA id k203sm6696515vka.56.2022.02.03.08.43.56 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 03 Feb 2022 08:44:00 -0800 (PST) From: Martin Fernandez To: linux-kernel@vger.kernel.org, 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, dave.hansen@linux.intel.com, x86@kernel.org, hpa@zytor.com, ardb@kernel.org, dvhart@infradead.org, andy@infradead.org, gregkh@linuxfoundation.org, rafael@kernel.org, rppt@kernel.org, akpm@linux-foundation.org, daniel.gutson@eclypsium.com, hughsient@gmail.com, alex.bazhaniuk@eclypsium.com, alison.schofield@intel.com, keescook@chromium.org, Martin Fernandez Subject: [PATCH v6 2/6] mm/mmzone: Tag pg_data_t with crypto capabilities Date: Thu, 3 Feb 2022 13:43:24 -0300 Message-Id: <20220203164328.203629-3-martin.fernandez@eclypsium.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220203164328.203629-1-martin.fernandez@eclypsium.com> References: <20220203164328.203629-1-martin.fernandez@eclypsium.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 94521A0003 X-Rspam-User: nil Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=eclypsium.com header.s=google header.b=MR8jXVky; dmarc=pass (policy=quarantine) header.from=eclypsium.com; spf=pass (imf15.hostedemail.com: domain of martin.fernandez@eclypsium.com designates 209.85.221.181 as permitted sender) smtp.mailfrom=martin.fernandez@eclypsium.com X-Stat-Signature: on8m9pww81dmjwi3xce1g7j8hnxmp5sb X-Rspamd-Server: rspam08 X-HE-Tag: 1643906641-771070 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 new member in the pg_data_t struct tell whether the node corresponding to that pg_data_t is able to do hardware memory encryption. This will be read from sysfs. Signed-off-by: Martin Fernandez Reviewed-by: Kees Cook --- include/linux/mmzone.h | 3 +++ mm/page_alloc.c | 1 + 2 files changed, 4 insertions(+) diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h index 936dc0b6c226..cec51e7a01d9 100644 --- a/include/linux/mmzone.h +++ b/include/linux/mmzone.h @@ -871,6 +871,9 @@ typedef struct pglist_data { struct task_struct *kcompactd; bool proactive_compact_trigger; #endif + + bool crypto_capable; + /* * This is a per-node reserve of pages that are not available * to userspace allocations. diff --git a/mm/page_alloc.c b/mm/page_alloc.c index c5952749ad40..8bcbd6fa0089 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -7592,6 +7592,7 @@ static void __init free_area_init_node(int nid) pgdat->node_id = nid; pgdat->node_start_pfn = start_pfn; pgdat->per_cpu_nodestats = NULL; + pgdat->crypto_capable = memblock_node_is_crypto_capable(nid); pr_info("Initmem setup node %d [mem %#018Lx-%#018Lx]\n", nid, (u64)start_pfn << PAGE_SHIFT,