Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp2606916pxb; Thu, 3 Feb 2022 10:01:56 -0800 (PST) X-Google-Smtp-Source: ABdhPJyTrZBXOLbgrdu6ECYMs7Px67GwTyvMpV20JLjPU3pATnjfjEmq+cE950kaVhWW3uMhgYpC X-Received: by 2002:a17:902:c941:: with SMTP id i1mr13329427pla.81.1643911315493; Thu, 03 Feb 2022 10:01:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643911315; cv=none; d=google.com; s=arc-20160816; b=ixRe+fu4TY7uwd7qV6PelLP0OJtI8jLXWbY5Jg61Txk1K3BivrsLCM6K0mDsHXGVad ADJOtQPTx3o6bkFmOiRNAOzeD/9E7Ty9iSXWINMobROQxqEYhV3axQMF6LTFK7UwzLGy W7QC/MMMyPWpGyxHZ5rY54LymnM3nIlkKab1pLxtPhQglsdNfPGXFseB9OyDkzOHdsxo bCY0pFJrCX4+5p8umC3xkxk5p04Kdyy22L3rv+/Pq9BzZpHCIWwB+vSx5dQJvyqCMDnW TZZR1KC42PyS8gXGcZrq+fBHNxa/zNIZolylvxfFAwgI0O5+2f6PzYapUGE25Rpreovu B1EQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=/7hWGiKDX/+3TtHvDCLSMJlu4NmyHYy7nVm6Glu5jcs=; b=n0DC9mISCAq3e/bkXMi/7zRD8eVH+M01G2bfRBo0Sc8yjmsqoIf5qNt9/eq6dSfTLP /yyZWtWbv8ohbjRnhpc/h1J/Y3az8QpJdm8s8NfLF3frjyto48gEU5/3bG5tOKlQ/cOz 7Ypmtcy0dHGBmVAtOKfR9sO0X0SZAhmclVMYVdaMIIJCRGtfcs8etkJ++ERJT7sifPe3 GVcxepgRuyZeazrftjFE0ZhzH2QYbhp9R5FhQTfcJkOVa7h4Bk64dhqhaIMpDmqfAFAo 5GAenxedD1Pa+IwaEpW3fQ3hHUrNz9jZBnxqKILU9eyKI3sUHcjWAtcE4qXNyH//A/+L Rs6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@eclypsium.com header.s=google header.b=Eu44Mg8z; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=eclypsium.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gz13si8066034pjb.0.2022.02.03.10.01.42; Thu, 03 Feb 2022 10:01:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@eclypsium.com header.s=google header.b=Eu44Mg8z; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=eclypsium.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229967AbiBCQob (ORCPT + 99 others); Thu, 3 Feb 2022 11:44:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60740 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352379AbiBCQo1 (ORCPT ); Thu, 3 Feb 2022 11:44:27 -0500 Received: from mail-ua1-x936.google.com (mail-ua1-x936.google.com [IPv6:2607:f8b0:4864:20::936]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 43125C06173D for ; Thu, 3 Feb 2022 08:44:27 -0800 (PST) Received: by mail-ua1-x936.google.com with SMTP id a24so6167503uat.10 for ; Thu, 03 Feb 2022 08:44:27 -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=45PS7qrBzUkkItOzyf/BfNZy1pZmK9BgA82vJd3quiSE/D6yEm4AqJxeWvjF1yMZxY LDpoApJOmJ18XxGcrfrVkawOekzZ6X9yw+whGSjb5b5K6diTyJqXycSLoEKMxb2RgS2k DcU6JcutenCESOtkNmPeRofiCUVflY09K+Xj41Nlh8TwHg5fGHMhHtv31U+kpcTiZuAu UEnSqz5NDTsQEyyg/9/gV8+7FgSyFlLOmToA5+Y3pc5zZJAvMO0vy/mu1Hu0vdsP1LpJ fy2ORC2X5/2iYPdM3MFRXE9x4nZnsXrVbfFDcHiqFf0SjBgmjq+NwkfnylKOJeci1kQ9 Sk3Q== X-Gm-Message-State: AOAM5308MbIiUm9lDQkMy7fR9W9misNgh9OwXbnBGCX5SpJmbk2B5q7x d8vsyqg9OGYXwKesNC14mOKGalyy80w81AuWxChbNKh6JSH/nlTbkuF03eUYwR6xGGF7fSMV57o K1ibnwtTZ4o6lQBmjjq26SzvGKAfvy/CK3yHXKuE9ZS2k0zfxQx3z49q5mITvdawX5pZRZNsIy1 oFFh9rd79txpLpKgP5 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 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 }; -- 2.30.2