From patchwork Thu Dec 16 19:22:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Martin Fernandez X-Patchwork-Id: 12682419 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 43FFBC433EF for ; Thu, 16 Dec 2021 19:25:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AE97E6B007E; Thu, 16 Dec 2021 14:24:00 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A98046B0080; Thu, 16 Dec 2021 14:24:00 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 961066B0081; Thu, 16 Dec 2021 14:24:00 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0182.hostedemail.com [216.40.44.182]) by kanga.kvack.org (Postfix) with ESMTP id 88BAC6B007E for ; Thu, 16 Dec 2021 14:24:00 -0500 (EST) Received: from smtpin15.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 344008907D for ; Thu, 16 Dec 2021 19:23:50 +0000 (UTC) X-FDA: 78924632220.15.E3B5450 Received: from mail-qk1-f169.google.com (mail-qk1-f169.google.com [209.85.222.169]) by imf17.hostedemail.com (Postfix) with ESMTP id A03E340005 for ; Thu, 16 Dec 2021 19:23:42 +0000 (UTC) Received: by mail-qk1-f169.google.com with SMTP id t83so24285987qke.8 for ; Thu, 16 Dec 2021 11:23:49 -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=AH5lWdN4aaOBeMJv18vhZagllhCdh1eRKSlcmjc8AEM=; b=cjK5uNREMFQogYWToQtq5d2khgn3l+ce6d3g5aREEMfU1ZmwxEw/1af6sNlR2wLzOz TUxWWdhhfiRbuozt+qIMTiJLYUf9z372ISx+k2osPtlkeESNRjfEoiiXLaPYZv85ru+w 8PIve9b0BjG5Xe3jTS0TFmvG2NSackUAlmKal9V8BiyKbCPV8vxpGXIN49CPiqCSlkpS UHZvB62wPguNqonI45MQH0UobDOlB7qDsmwDPWJY4JX53bRXA0Qba6SBInDdtLbI/RbF aa85KLS239ucyWjsEfTofovAasO/4v7SVC5HigIe0LuGUbbtRMOCHXErYGHB9fnRIAE7 EyHg== 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=AH5lWdN4aaOBeMJv18vhZagllhCdh1eRKSlcmjc8AEM=; b=7jR3anHOqDBJy3y6kcQY3CY4o3iHNZpFXInDtb0473Ye3a4DSpxt71EcZGyDdDtF+v tf8l57yw5jW7totQ7AjyxgsAdklP83KgNkwT4INSuZ5A0+04TGfL1r1RbqtggkBiHOdG bLVgdz/Yi0RvW/vcuDvG6tz0dqMvbXaMqg6BjYaWoDULMlKy1hxzpxyA/NkZ0qsbN40a cCabyu3ty5lncrP0JR+t4C16g1hg2DQMpoBeKkqWRq3/zJ/Jut0uJCfRGc0id/zb4L5/ aJQEoEOdrGcM3Xa3UlKjBICSuuzzgXBqSV7oeFw68R3mWph/ovu+nb2nPJ/gz0SbymqM 6LEg== X-Gm-Message-State: AOAM533Uyzk8aNEcKYkGZQb+nfFwBZoHfLjLD60Fy6UfxHOoXuoix1Gj II9pEijM6GwBl8wBiMsdrQekxw== X-Google-Smtp-Source: ABdhPJwERimh+QTigiLtfVxRjB1Ls3j6fyYxSp/4R1hD2IL5zeGaIumUANrS2pIGVkdIPc/04oqx+w== X-Received: by 2002:a05:620a:24ca:: with SMTP id m10mr13172979qkn.649.1639682629056; Thu, 16 Dec 2021 11:23:49 -0800 (PST) Received: from localhost (7-153-16-190.fibertel.com.ar. [190.16.153.7]) by smtp.gmail.com with ESMTPSA id o4sm3258510qkh.107.2021.12.16.11.23.44 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 16 Dec 2021 11:23:48 -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, Martin Fernandez Subject: [PATCH v4 5/5] drivers/node: Show in sysfs node's crypto capabilities Date: Thu, 16 Dec 2021 16:22:22 -0300 Message-Id: <20211216192222.127908-6-martin.fernandez@eclypsium.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211216192222.127908-1-martin.fernandez@eclypsium.com> References: <20211216192222.127908-1-martin.fernandez@eclypsium.com> MIME-Version: 1.0 Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=eclypsium.com header.s=google header.b=cjK5uNRE; spf=pass (imf17.hostedemail.com: domain of martin.fernandez@eclypsium.com designates 209.85.222.169 as permitted sender) smtp.mailfrom=martin.fernandez@eclypsium.com; dmarc=pass (policy=quarantine) header.from=eclypsium.com X-Rspamd-Queue-Id: A03E340005 X-Stat-Signature: uhf3dkfh8n4sx6y3kipxdhnckyystrcc X-Rspamd-Server: rspam04 X-HE-Tag: 1639682622-989600 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: 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..93581b31225e --- /dev/null +++ b/Documentation/ABI/testing/sysfs-devices-node @@ -0,0 +1,10 @@ +What: /sys/devices/system/node/nodeX/crypto_capable +Date: December 2021 +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 b5a4ba18f9f9..67b0e2fa93b1 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 };