From patchwork Fri Apr 29 20:17:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Fernandez X-Patchwork-Id: 12832721 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 27A76C433FE for ; Fri, 29 Apr 2022 20:18:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AA2496B007D; Fri, 29 Apr 2022 16:18:38 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A51BA6B007E; Fri, 29 Apr 2022 16:18:38 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 940336B0080; Fri, 29 Apr 2022 16:18:38 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.25]) by kanga.kvack.org (Postfix) with ESMTP id 8637F6B007D for ; Fri, 29 Apr 2022 16:18:38 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 5C9A7BD2 for ; Fri, 29 Apr 2022 20:18:38 +0000 (UTC) X-FDA: 79411029516.20.1112C0F Received: from mail-ot1-f49.google.com (mail-ot1-f49.google.com [209.85.210.49]) by imf17.hostedemail.com (Postfix) with ESMTP id 6ED6B40013 for ; Fri, 29 Apr 2022 20:18:28 +0000 (UTC) Received: by mail-ot1-f49.google.com with SMTP id l9-20020a056830268900b006054381dd35so5857986otu.4 for ; Fri, 29 Apr 2022 13:18:37 -0700 (PDT) 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=OkG/F7+kBMNIWCowVtEazmyHhBwO2DxtbJbfhKP712A=; b=CFVomb+9tyTJtBjEhdpiH1zhwooGhEZao10gTFdxqakjE50a70JiLTBnTH7LkExN+V oc+UNf8vfz0q7LVdjvbwtCy8BnniQSsjA83H+fwEwh99U6UXRuClAcfUpV3bpAAc9umN hs0O4wqgUFbbSCgB/tJAtF1o+ndijINfhWVCNdR3bBValgZ8Z1AMvT3jzPCO56a+EUVj eQw67Azpa5Iv4+Ywhr9kjCjFBO3QXN4+XwHcJopDuXewZTbZD9+wbmGww65HIywNbytB K9o9k/DmPxRb4TRXsls4NQStEslTiFL+j1mwuEZbxJ6bjwWQEk+zv+NX6GgbMX2SInsf YuNQ== 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=OkG/F7+kBMNIWCowVtEazmyHhBwO2DxtbJbfhKP712A=; b=ol48iDZi5S+V6wfijLEb8PGL/tpWDUFxLqRoHGdhdG1uHRGS+gUi8RLQFw2Nm71V7y RpDayVR0W38o9eqq9Qq6BuqCAXBC2FoG7mU/X8po1HRqrW0AJ8R/lKJk8sfRv2P1DKoX g9VnoTViLxmHvIFRVw0kTNSdL7adT7XlJHR2sqfJq3dkAgznTqq+yJf2qLJ8cCRu0djM y5sw6TAeLQ1AkL/JOT/D2VuhwNO0UKIZouppu4ZC1ruzvxYxww9fr+b+E+uueLPAqNX3 rSg28kfUcNIYxXr/y68blrU6G+s+mjG5z1uMCWgqXCxsApquGNQt+/ry+mfn3BO1Dzsl xDLQ== X-Gm-Message-State: AOAM531MuHW7E1J1ozhRsQX3SP9ETpLmTEO9pv0ddq2EJCKvHcFtua9J OSsrjBlWbnRdtNmfoJqKdm9X8w== X-Google-Smtp-Source: ABdhPJwfcMjRvkAXKIDIz9yJyzv/MGd9Qc+uZBZYcbTg+2X+d01VGqB1uGOCZg191g8uEunpkZerYw== X-Received: by 2002:a9d:37cb:0:b0:5cc:7a51:c984 with SMTP id x69-20020a9d37cb000000b005cc7a51c984mr409643otb.98.1651263517007; Fri, 29 Apr 2022 13:18:37 -0700 (PDT) Received: from localhost ([181.97.174.128]) by smtp.gmail.com with ESMTPSA id t13-20020a05683014cd00b0060603221245sm79060otq.21.2022.04.29.13.18.31 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 29 Apr 2022 13:18:36 -0700 (PDT) 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 v8 8/8] drivers/node: Show in sysfs node's crypto capabilities Date: Fri, 29 Apr 2022 17:17:17 -0300 Message-Id: <20220429201717.1946178-9-martin.fernandez@eclypsium.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220429201717.1946178-1-martin.fernandez@eclypsium.com> References: <20220429201717.1946178-1-martin.fernandez@eclypsium.com> MIME-Version: 1.0 X-Stat-Signature: gorddk9qpy5345aedz8jkejpprmio8tn Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=eclypsium.com header.s=google header.b=CFVomb+9; spf=pass (imf17.hostedemail.com: domain of martin.fernandez@eclypsium.com designates 209.85.210.49 as permitted sender) smtp.mailfrom=martin.fernandez@eclypsium.com; dmarc=pass (policy=quarantine) header.from=eclypsium.com X-Rspam-User: X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 6ED6B40013 X-HE-Tag: 1651263508-809755 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; on EFI systems: 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..0e95420bd7c5 --- /dev/null +++ b/Documentation/ABI/testing/sysfs-devices-node @@ -0,0 +1,10 @@ +What: /sys/devices/system/node/nodeX/crypto_capable +Date: April 2022 +Contact: Martin Fernandez +Users: fwupd (https://fwupd.org) +Description: + This value is 1 if all system memory in this node is + capable of being protected with the CPU's memory + cryptographic capabilities. It is 0 otherwise. + On EFI systems the node will be marked with + EFI_MEMORY_CPU_CRYPTO. \ No newline at end of file diff --git a/drivers/base/node.c b/drivers/base/node.c index ec8bb24a5a22..1df15ea03c27 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 };