From patchwork Thu Feb 3 16:43:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Martin Fernandez X-Patchwork-Id: 12734328 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 01D89C4332F for ; Thu, 3 Feb 2022 16:44:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9263A6B03E1; Thu, 3 Feb 2022 11:44:27 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 8D5936B03E2; Thu, 3 Feb 2022 11:44:27 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 776646B03E3; Thu, 3 Feb 2022 11:44:27 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.26]) by kanga.kvack.org (Postfix) with ESMTP id 6826A6B03E1 for ; Thu, 3 Feb 2022 11:44:27 -0500 (EST) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 39B8C210B5 for ; Thu, 3 Feb 2022 16:44:27 +0000 (UTC) X-FDA: 79102041774.03.D7C9D4E Received: from mail-ua1-f42.google.com (mail-ua1-f42.google.com [209.85.222.42]) by imf23.hostedemail.com (Postfix) with ESMTP id E5122140009 for ; Thu, 3 Feb 2022 16:44:26 +0000 (UTC) Received: by mail-ua1-f42.google.com with SMTP id r8so6360531uaj.0 for ; Thu, 03 Feb 2022 08:44:26 -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=/7hWGiKDX/+3TtHvDCLSMJlu4NmyHYy7nVm6Glu5jcs=; b=Eu44Mg8zNIVsl+UBg0lHCou2bGR731muhWBsGIFlH7Qlfig/tH9EjGG7LhYDeVUgL2 yBKfPclwTyg18UZrOiqfuJ89i8XybLNqTaYSX/a4KtBkhWzz5k8noCv5qKrQnf7pz9gC cU9EIuCV0fRK8UzYYfyJ83sxVUdyV2whm2zfukAd37PEkif+0OQrFVjVtJRfk/NpB5kF aTGPNskbxUyxI7LLEMPrnqlI95zdXOWkLpELHRbx4BnCz2oqk41Y/TO4YHXrNBFYCbhD etxqFqFShnXPHvrKvugW+xoT0rdqJ0frp0xn6PltLCnhV9Fkya4hBOscS61TtYtWobdj h4pQ== 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=/7hWGiKDX/+3TtHvDCLSMJlu4NmyHYy7nVm6Glu5jcs=; b=Usj4n5L0uXB5KERcZvMOyPsGnFcIPjGtxo5cOhVVPod1PJ0MCtNQklc2aDCDPUNo+E gWG+k8XJx98KteVB0lJQasZPbSZ6dmDr9RRc6XkQbtxEiQCbqx1CCpTL6TkbVEwy929o 0sxipw1cfVYwEtXjTFI+KnkCVHwImndcFErEzm/UFVmyVJ1UwKWUwbPXQ3qFCMs6vKDR 0TGAsn9LtCi+Ey5lOkd9RrV7Ci9SOmUB5ngw5n+VdAb9jV5/Pav1YJVK5yjosnAy4pws yYbzXP2oD3M15V89qp4wKmcxL8Jy5/tzAabMD054C46rrP6y9wddz50w57YAaznBnWYc LDWg== X-Gm-Message-State: AOAM532TkySPfZYt+GaiIGsx9BkVfsbfpDBypvw/NXYYrmSHyE1ynC6i jdQ5pF1d8KZFq8OtHAlUimNXxQ== X-Google-Smtp-Source: ABdhPJx2HB4OlovRK80h8tYU9Mdgc8buyu05GDejH1rOLWTHA+JswrW0YVKJpoDXnPTHBnmidcJ4GQ== X-Received: by 2002:a67:fd55:: with SMTP id g21mr14698421vsr.86.1643906666202; Thu, 03 Feb 2022 08:44:26 -0800 (PST) Received: from localhost (host8.190-224-49.telecom.net.ar. [190.224.49.8]) by smtp.gmail.com with ESMTPSA id m185sm6362545vke.30.2022.02.03.08.44.22 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 03 Feb 2022 08:44:26 -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 6/6] drivers/node: Show in sysfs node's crypto capabilities Date: Thu, 3 Feb 2022 13:43:28 -0300 Message-Id: <20220203164328.203629-7-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-Stat-Signature: y4i4khd4dw6jmd1rimf49miozm49i3z6 X-Rspam-User: nil Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=eclypsium.com header.s=google header.b=Eu44Mg8z; spf=pass (imf23.hostedemail.com: domain of martin.fernandez@eclypsium.com designates 209.85.222.42 as permitted sender) smtp.mailfrom=martin.fernandez@eclypsium.com; dmarc=pass (policy=quarantine) header.from=eclypsium.com X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: E5122140009 X-HE-Tag: 1643906666-975712 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000016, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Show in each node in sysfs if its memory is able to do be encrypted by the CPU, ie. if all its memory is marked with EFI_MEMORY_CPU_CRYPTO in the EFI memory map. Signed-off-by: Martin Fernandez --- Documentation/ABI/testing/sysfs-devices-node | 10 ++++++++++ drivers/base/node.c | 10 ++++++++++ 2 files changed, 20 insertions(+) create mode 100644 Documentation/ABI/testing/sysfs-devices-node diff --git a/Documentation/ABI/testing/sysfs-devices-node b/Documentation/ABI/testing/sysfs-devices-node new file mode 100644 index 000000000000..0d1fd86c9faf --- /dev/null +++ b/Documentation/ABI/testing/sysfs-devices-node @@ -0,0 +1,10 @@ +What: /sys/devices/system/node/nodeX/crypto_capable +Date: February 2022 +Contact: Martin Fernandez +Users: fwupd (https://fwupd.org) +Description: + This value is 1 if all system memory in this node is + marked with EFI_MEMORY_CPU_CRYPTO, indicating that the + system memory is capable of being protected with the + CPU’s memory cryptographic capabilities. It is 0 + otherwise. \ No newline at end of file diff --git a/drivers/base/node.c b/drivers/base/node.c index 87acc47e8951..dabaed997ecd 100644 --- a/drivers/base/node.c +++ b/drivers/base/node.c @@ -560,11 +560,21 @@ static ssize_t node_read_distance(struct device *dev, } static DEVICE_ATTR(distance, 0444, node_read_distance, NULL); +static ssize_t crypto_capable_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct pglist_data *pgdat = NODE_DATA(dev->id); + + return sysfs_emit(buf, "%d\n", pgdat->crypto_capable); +} +static DEVICE_ATTR_RO(crypto_capable); + static struct attribute *node_dev_attrs[] = { &dev_attr_meminfo.attr, &dev_attr_numastat.attr, &dev_attr_distance.attr, &dev_attr_vmstat.attr, + &dev_attr_crypto_capable.attr, NULL };