From patchwork Thu Jan 13 21:30:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Fernandez X-Patchwork-Id: 531835 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C29B8C433EF for ; Thu, 13 Jan 2022 21:30:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233173AbiAMVat (ORCPT ); Thu, 13 Jan 2022 16:30:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47138 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235614AbiAMVas (ORCPT ); Thu, 13 Jan 2022 16:30:48 -0500 Received: from mail-ot1-x32d.google.com (mail-ot1-x32d.google.com [IPv6:2607:f8b0:4864:20::32d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 76493C06173E for ; Thu, 13 Jan 2022 13:30:48 -0800 (PST) Received: by mail-ot1-x32d.google.com with SMTP id 60-20020a9d0142000000b0059103eb18d4so7892756otu.2 for ; Thu, 13 Jan 2022 13:30:48 -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=7RqfR1RKHyt56B3HaINQqKrkUmepffSj3WABI23dqNA=; b=DXOplbCa3rlaTR1lzXo0syR+d0dk0Ki3jfBTsW21qNTvRNb67a7rQFafgRjnsDG0xl IMRYzB1c3zKfRhmQ4H/ZAWy6s7cnRvC7aZSZn2Pv4CNgOjM/N2zri/+3hOHGnv5FBdDE T6EdwD/rbF7IK9lKa0gCFgot6HuowyV2kGQ49C28bv7WWSLmDkXMbIf89xOzCJQfqfsx ukB78kPc4izKs5xECbE7mKdDOAj9JbkAO0IUOhMkikVSrhoW61a4HvH4TTTN0HXr8kwt sqAldQmHRJIB6ys53jbqjMR534CpJY9uOp+L5ed+jr1HukdwMAvLFVNzka/GtcGQpD+b 686Q== 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=7RqfR1RKHyt56B3HaINQqKrkUmepffSj3WABI23dqNA=; b=eACwt+w79WFEZcfDItD6gCybAe/duHDDMzpYhTWNJTXGyVZI3xI9Qg+KSImmN9Cg1q L2qfs6nyGmEFAiudLSmaZGEdGB7CfWD8s1LcLTG8gK6kgvo2KkPHt31WJ68y1qcFUEYi MPpv7kuVpjviR3i/L29MYVqz+UFeMxzXMyUwnD2BLWfnqrTLxfbNR5Y3+ljgsP2AzVI7 DCj5yRkGbZbyN5OpnTxq8QchY8/GqVpnH4xyMGvzCh8gE0U9abHrEkbYdFFMPNMiU4qq M9SIgQVDH1Jb1f270hm86+xL/Et8eDGtJ8PZg0AP7rvx6TH0wnbWsC96qfPyrpQ9V3zt +f1g== X-Gm-Message-State: AOAM531EYgtTRHNwcuKdKb5a/8V2TeLzdjiOPiSm9XcZ9wvXFD4dhlQW jJl+dvy3okg1yRkW5cygp1VruQ== X-Google-Smtp-Source: ABdhPJxohhMZ86BwQjPzKMMIL7CIogMV+YYOB+Qz4+6WClsKEC8ODPW1XtId8mIcWO0OAl/kvVANfg== X-Received: by 2002:a9d:7e84:: with SMTP id m4mr1134058otp.269.1642109447444; Thu, 13 Jan 2022 13:30:47 -0800 (PST) Received: from localhost (115-127-16-190.fibertel.com.ar. [190.16.127.115]) by smtp.gmail.com with ESMTPSA id s124sm971747ooa.1.2022.01.13.13.30.42 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 13 Jan 2022 13:30:47 -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 v5 1/5] mm/memblock: Tag memblocks with crypto capabilities Date: Thu, 13 Jan 2022 18:30:23 -0300 Message-Id: <20220113213027.457282-2-martin.fernandez@eclypsium.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220113213027.457282-1-martin.fernandez@eclypsium.com> References: <20220113213027.457282-1-martin.fernandez@eclypsium.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-efi@vger.kernel.org Add the capability to mark regions of the memory memory_type able of hardware memory encryption. Also add the capability to query if all regions of a memory node are able to do hardware memory encryption to call it when initializing the nodes. Signed-off-by: Martin Fernandez --- include/linux/memblock.h | 5 ++++ mm/memblock.c | 49 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+) diff --git a/include/linux/memblock.h b/include/linux/memblock.h index 9dc7cb239d21..374c03e10b2e 100644 --- a/include/linux/memblock.h +++ b/include/linux/memblock.h @@ -41,6 +41,7 @@ extern unsigned long long max_possible_pfn; * via a driver, and never indicated in the firmware-provided memory map as * system RAM. This corresponds to IORESOURCE_SYSRAM_DRIVER_MANAGED in the * kernel resource tree. + * @MEMBLOCK_CRYPTO_CAPABLE: capable of hardware encryption */ enum memblock_flags { MEMBLOCK_NONE = 0x0, /* No special request */ @@ -48,6 +49,7 @@ enum memblock_flags { MEMBLOCK_MIRROR = 0x2, /* mirrored region */ MEMBLOCK_NOMAP = 0x4, /* don't add to kernel direct mapping */ MEMBLOCK_DRIVER_MANAGED = 0x8, /* always detected via a driver */ + MEMBLOCK_CRYPTO_CAPABLE = 0x10, /* capable of hardware encryption */ }; /** @@ -121,6 +123,9 @@ int memblock_physmem_add(phys_addr_t base, phys_addr_t size); void memblock_trim_memory(phys_addr_t align); bool memblock_overlaps_region(struct memblock_type *type, phys_addr_t base, phys_addr_t size); +bool memblock_node_is_crypto_capable(int nid); +int memblock_mark_crypto_capable(phys_addr_t base, phys_addr_t size); +int memblock_clear_crypto_capable(phys_addr_t base, phys_addr_t size); int memblock_mark_hotplug(phys_addr_t base, phys_addr_t size); int memblock_clear_hotplug(phys_addr_t base, phys_addr_t size); int memblock_mark_mirror(phys_addr_t base, phys_addr_t size); diff --git a/mm/memblock.c b/mm/memblock.c index 1018e50566f3..61ec50647469 100644 --- a/mm/memblock.c +++ b/mm/memblock.c @@ -191,6 +191,27 @@ bool __init_memblock memblock_overlaps_region(struct memblock_type *type, return i < type->cnt; } +/** + * memblock_node_is_crypto_capable - get if whole node is capable + * of encryption + * @nid: number of node + * + * Iterate over all memory memblock_type and find if all regions under + * node @nid are capable of hardware encryption. + */ +bool __init_memblock memblock_node_is_crypto_capable(int nid) +{ + struct memblock_region *region; + + for_each_mem_region(region) { + if ((memblock_get_region_node(region) == nid) && + !(region->flags & MEMBLOCK_CRYPTO_CAPABLE)) + return false; + } + + return true; +} + /** * __memblock_find_range_bottom_up - find free area utility in bottom-up * @start: start of candidate range @@ -885,6 +906,34 @@ static int __init_memblock memblock_setclr_flag(phys_addr_t base, return 0; } +/** + * memblock_mark_crypto_capable - Mark memory regions capable of hardware + * encryption with flag MEMBLOCK_CRYPTO_CAPABLE. + * @base: the base phys addr of the region + * @size: the size of the region + * + * Return: 0 on success, -errno on failure. + */ +int __init_memblock memblock_mark_crypto_capable(phys_addr_t base, + phys_addr_t size) +{ + return memblock_setclr_flag(base, size, 1, MEMBLOCK_CRYPTO_CAPABLE); +} + +/** + * memblock_clear_crypto_capable - Clear flag MEMBLOCK_CRYPTO for a + * specified region. + * @base: the base phys addr of the region + * @size: the size of the region + * + * Return: 0 on success, -errno on failure. + */ +int __init_memblock memblock_clear_crypto_capable(phys_addr_t base, + phys_addr_t size) +{ + return memblock_setclr_flag(base, size, 0, MEMBLOCK_CRYPTO_CAPABLE); +} + /** * memblock_mark_hotplug - Mark hotpluggable memory with flag MEMBLOCK_HOTPLUG. * @base: the base phys addr of the region From patchwork Thu Jan 13 21:30: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: 532370 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8A3F3C433EF for ; Thu, 13 Jan 2022 21:30:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235784AbiAMVa4 (ORCPT ); Thu, 13 Jan 2022 16:30:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47174 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235615AbiAMVaz (ORCPT ); Thu, 13 Jan 2022 16:30:55 -0500 Received: from mail-oi1-x22f.google.com (mail-oi1-x22f.google.com [IPv6:2607:f8b0:4864:20::22f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7EE60C06173E for ; Thu, 13 Jan 2022 13:30:55 -0800 (PST) Received: by mail-oi1-x22f.google.com with SMTP id q186so9650101oih.8 for ; Thu, 13 Jan 2022 13:30:55 -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=hTJNWfpBwWHBXmDAw3gLRIR3djfB+sK2GlFOBYJqrMUl/HiEOQGTQoo9yPe+EWanj8 09iUccyveauB4v3d65kz1O/ho3Hm/bg/9JXoxX/39geyyvUSYl7Inx2ynNhG0bWLzbpn EhhJY776tO9ns0OiI1tOeBENLXIyLkzA684P1WLxGNGqws0uGjPbRBPU5veXOLw9SsuS sn3lT/ZzP9jS25qxkumsln1WApOkQJktI9Dttaw8+F4U2YuMu9KuwzQXeQD5eStbo8be jFu7gWvEVQSC3a7lZHb8H3fUXEgA5MBfzyC3EvB7UVpfZhnFE+7z3A1haLlxBc5tRlw/ 2s0w== 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=xC7aJ1/Yce1GUEkLyY84d+f+0TF3nUtBDqgnutEDVcFZhtHJxJc2jV7DIP1uDzuZXA RAXa8Vb2gV1/nB+s3ruFMAU/fsoDG7tT7vBOjLjK5AMShykqDPaqn38sAlbUE5Jcls4/ Mh084NDi33Yf5Ebu4112sL/fBKK4ukfLMgiicyjPkUbT5klMb5q/87Ryx11Y3Vc5KTzx sJnXu8h9Frrl13Ehl15JNtVohDsQf2Qfw3lSCTRI1x2Lx9RroXUOXec87v7JEJErH65N Zizlp4d2gM2cB8dZa1AopM+ogusBQc6TV8xrpMojoZzQvyrbRqSYQwUVaMouTOmZxvt3 1buA== X-Gm-Message-State: AOAM531HkvhQm6Rg/7AJcxioIHH6wx9K8GTskN2syPCVM+3bop0ax//d os6+Z6j2P4yaNe3UvTAYtrz2+w== X-Google-Smtp-Source: ABdhPJzDN1onylDe2EOdadMwtWVnznDi7osDVKOSlKgZ23uvQiFvC/0MpSn76QDva8qLZ5/xZMp8EQ== X-Received: by 2002:aca:a80d:: with SMTP id r13mr8142853oie.21.1642109454826; Thu, 13 Jan 2022 13:30:54 -0800 (PST) Received: from localhost (115-127-16-190.fibertel.com.ar. [190.16.127.115]) by smtp.gmail.com with ESMTPSA id i18sm626212oob.41.2022.01.13.13.30.49 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 13 Jan 2022 13:30:54 -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 v5 2/5] mm/mmzone: Tag pg_data_t with crypto capabilities Date: Thu, 13 Jan 2022 18:30:24 -0300 Message-Id: <20220113213027.457282-3-martin.fernandez@eclypsium.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220113213027.457282-1-martin.fernandez@eclypsium.com> References: <20220113213027.457282-1-martin.fernandez@eclypsium.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-efi@vger.kernel.org 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 --- 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, From patchwork Thu Jan 13 21:30:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Fernandez X-Patchwork-Id: 531834 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 60E0CC433EF for ; Thu, 13 Jan 2022 21:31:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235752AbiAMVbD (ORCPT ); Thu, 13 Jan 2022 16:31:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47216 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235732AbiAMVbD (ORCPT ); Thu, 13 Jan 2022 16:31:03 -0500 Received: from mail-ot1-x331.google.com (mail-ot1-x331.google.com [IPv6:2607:f8b0:4864:20::331]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 07865C06161C for ; Thu, 13 Jan 2022 13:31:03 -0800 (PST) Received: by mail-ot1-x331.google.com with SMTP id i7-20020a9d68c7000000b0059396529af8so1195518oto.4 for ; Thu, 13 Jan 2022 13:31:03 -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=VAoRDHUwm1eMqcpMENH9/PXAOANb+EVYwXPhK3cnDlE=; b=WyLcYtkIoEuLzTKFelzWIIRxp2otZLIQNxuK8bOnSYN8hupRQ5twgB0y0nOgm9LYFa LkAoZE1KMLj54jhKyrRJKAQqIJA14pYL74bk98T29Vh+BnfHFUucPEVK4w3iyY7ZdvGK pGjvFfLkY6pwUTtTZtUzLbQ5gMtDz5tIjSoHomVEsuwyR7v2K8XmkZ9C8zVC1fGigot+ 4W8pYmormQTKPOxQmpnBLhCcUUx0NNvVXMqYr2klyHUUjvnr4A7pWc0tPammCG0NePdk FwdYdvLw9/t+tdwWfW+77N9PncJIuQ3Q3L5hWbr//+w2wzULi2HBhfkJE1Wty1NZrfgE bi0g== 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=VAoRDHUwm1eMqcpMENH9/PXAOANb+EVYwXPhK3cnDlE=; b=08rDuH8AVAsmA6hb+0qSws4IA62dl40S3S6+/uLr5ZMIWzgoJLmnbIgLxoSPA8rUhQ Jnx1tgHRQg2f3FjI+UwVaatKDkWdlPPAI5r0zvy44OWKAKLk5zpGznrECawzryoopLnD bRw8tw6OY8YmaKpwBZOdkRAoBhG0rDmSLo8pjkyJCpQWeYY1t2fOVAlYSeDDwG/2rL/c O7+ONUF/fdH11JS332ClTP4iVB9RwPtFSuzqUhha+dOdDpQcDR6pzCFxtZWMvrJD3tG9 M5Syu7XpiF1vVPjqG8lT9h3y8guxN4d6OcDfTL9QkuIeZENK1+tjYNwc1Wn8jwxk4L8A 0+dA== X-Gm-Message-State: AOAM533FWrhZni0Ct5F1lgN5GUlXvNwGhXCwjqLeuCSEU6C1lxPV6kTs LSyb5alvz+LwkyuWIm80qzevbSu7zCmLkree X-Google-Smtp-Source: ABdhPJzPsE5o2ZryrBn+0ysWSz+aUIEFzgLWkqw12mZ95CWeEziw/kOfErJzDUXmn2mxu4nyuUtYMg== X-Received: by 2002:a05:6830:2694:: with SMTP id l20mr4819858otu.242.1642109462316; Thu, 13 Jan 2022 13:31:02 -0800 (PST) Received: from localhost (115-127-16-190.fibertel.com.ar. [190.16.127.115]) by smtp.gmail.com with ESMTPSA id i25sm880263otl.8.2022.01.13.13.30.57 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 13 Jan 2022 13:31:01 -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 v5 3/5] x86/e820: Tag e820_entry with crypto capabilities Date: Thu, 13 Jan 2022 18:30:25 -0300 Message-Id: <20220113213027.457282-4-martin.fernandez@eclypsium.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220113213027.457282-1-martin.fernandez@eclypsium.com> References: <20220113213027.457282-1-martin.fernandez@eclypsium.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-efi@vger.kernel.org Add a new enum for crypto capabilities. Add a new member in e820_entry to hold whether an entry is able to do hardware memory encryption or not. Add a new function __e820__range_update_crypto similar to __e820__range_update but to update crypto capabilities. Change e820__update_table to handle merging and overlap problems taking into account crypto_capable. Add a function to mark a range as crypto, using __e820__range_update_crypto in the background. This will be called when initializing EFI. Signed-off-by: Martin Fernandez --- arch/x86/include/asm/e820/api.h | 1 + arch/x86/include/asm/e820/types.h | 12 +++- arch/x86/kernel/e820.c | 112 ++++++++++++++++++++++++++++-- 3 files changed, 115 insertions(+), 10 deletions(-) diff --git a/arch/x86/include/asm/e820/api.h b/arch/x86/include/asm/e820/api.h index e8f58ddd06d9..677dcbabcc8b 100644 --- a/arch/x86/include/asm/e820/api.h +++ b/arch/x86/include/asm/e820/api.h @@ -17,6 +17,7 @@ extern bool e820__mapped_all(u64 start, u64 end, enum e820_type type); extern void e820__range_add (u64 start, u64 size, enum e820_type type); extern u64 e820__range_update(u64 start, u64 size, enum e820_type old_type, enum e820_type new_type); extern u64 e820__range_remove(u64 start, u64 size, enum e820_type old_type, bool check_type); +extern u64 e820__range_mark_as_crypto_capable(u64 start, u64 size); extern void e820__print_table(char *who); extern int e820__update_table(struct e820_table *table); diff --git a/arch/x86/include/asm/e820/types.h b/arch/x86/include/asm/e820/types.h index 314f75d886d0..aef03c665f5e 100644 --- a/arch/x86/include/asm/e820/types.h +++ b/arch/x86/include/asm/e820/types.h @@ -46,6 +46,11 @@ enum e820_type { E820_TYPE_RESERVED_KERN = 128, }; +enum e820_crypto_capabilities { + E820_NOT_CRYPTO_CAPABLE = 0, + E820_CRYPTO_CAPABLE = 1, +}; + /* * A single E820 map entry, describing a memory range of [addr...addr+size-1], * of 'type' memory type: @@ -53,9 +58,10 @@ enum e820_type { * (We pack it because there can be thousands of them on large systems.) */ struct e820_entry { - u64 addr; - u64 size; - enum e820_type type; + u64 addr; + u64 size; + enum e820_type type; + enum e820_crypto_capabilities crypto_capable; } __attribute__((packed)); /* diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c index bc0657f0deed..bbf67b77bd18 100644 --- a/arch/x86/kernel/e820.c +++ b/arch/x86/kernel/e820.c @@ -163,7 +163,9 @@ int e820__get_entry_type(u64 start, u64 end) /* * Add a memory region to the kernel E820 map. */ -static void __init __e820__range_add(struct e820_table *table, u64 start, u64 size, enum e820_type type) +static void __init __e820__range_add(struct e820_table *table, u64 start, + u64 size, enum e820_type type, + enum e820_crypto_capabilities crypto_capable) { int x = table->nr_entries; @@ -176,12 +178,13 @@ static void __init __e820__range_add(struct e820_table *table, u64 start, u64 si table->entries[x].addr = start; table->entries[x].size = size; table->entries[x].type = type; + table->entries[x].crypto_capable = crypto_capable; table->nr_entries++; } void __init e820__range_add(u64 start, u64 size, enum e820_type type) { - __e820__range_add(e820_table, start, size, type); + __e820__range_add(e820_table, start, size, type, E820_NOT_CRYPTO_CAPABLE); } static void __init e820_print_type(enum e820_type type) @@ -211,6 +214,8 @@ void __init e820__print_table(char *who) e820_table->entries[i].addr + e820_table->entries[i].size - 1); e820_print_type(e820_table->entries[i].type); + if (e820_table->entries[i].crypto_capable == E820_CRYPTO_CAPABLE) + pr_cont("; crypto-capable"); pr_cont("\n"); } } @@ -327,6 +332,7 @@ int __init e820__update_table(struct e820_table *table) unsigned long long last_addr; u32 new_nr_entries, overlap_entries; u32 i, chg_idx, chg_nr; + enum e820_crypto_capabilities current_crypto, last_crypto; /* If there's only one memory region, don't bother: */ if (table->nr_entries < 2) @@ -367,6 +373,7 @@ int __init e820__update_table(struct e820_table *table) new_nr_entries = 0; /* Index for creating new map entries */ last_type = 0; /* Start with undefined memory type */ last_addr = 0; /* Start with 0 as last starting address */ + last_crypto = E820_NOT_CRYPTO_CAPABLE; /* Loop through change-points, determining effect on the new map: */ for (chg_idx = 0; chg_idx < chg_nr; chg_idx++) { @@ -388,13 +395,19 @@ int __init e820__update_table(struct e820_table *table) * 1=usable, 2,3,4,4+=unusable) */ current_type = 0; + current_crypto = E820_CRYPTO_CAPABLE; for (i = 0; i < overlap_entries; i++) { + if (overlap_list[i]->crypto_capable < current_crypto) + current_crypto = overlap_list[i]->crypto_capable; + if (overlap_list[i]->type > current_type) current_type = overlap_list[i]->type; } /* Continue building up new map based on this information: */ - if (current_type != last_type || e820_nomerge(current_type)) { + if (current_type != last_type || + current_crypto != last_crypto || + e820_nomerge(current_type)) { if (last_type != 0) { new_entries[new_nr_entries].size = change_point[chg_idx]->addr - last_addr; /* Move forward only if the new size was non-zero: */ @@ -406,9 +419,12 @@ int __init e820__update_table(struct e820_table *table) if (current_type != 0) { new_entries[new_nr_entries].addr = change_point[chg_idx]->addr; new_entries[new_nr_entries].type = current_type; + new_entries[new_nr_entries].crypto_capable = current_crypto; + last_addr = change_point[chg_idx]->addr; } last_type = current_type; + last_crypto = current_crypto; } } @@ -497,8 +513,80 @@ __e820__range_update(struct e820_table *table, u64 start, u64 size, enum e820_ty /* New range is completely covered? */ if (entry->addr < start && entry_end > end) { - __e820__range_add(table, start, size, new_type); - __e820__range_add(table, end, entry_end - end, entry->type); + __e820__range_add(table, start, size, new_type, entry->crypto_capable); + __e820__range_add(table, end, entry_end - end, entry->type, entry->crypto_capable); + entry->size = start - entry->addr; + real_updated_size += size; + continue; + } + + /* Partially covered: */ + final_start = max(start, entry->addr); + final_end = min(end, entry_end); + if (final_start >= final_end) + continue; + + __e820__range_add(table, final_start, final_end - final_start, + new_type, entry->crypto_capable); + + real_updated_size += final_end - final_start; + + /* + * Left range could be head or tail, so need to update + * its size first: + */ + entry->size -= final_end - final_start; + if (entry->addr < final_start) + continue; + + entry->addr = final_end; + } + return real_updated_size; +} + +/* + * Update crypto capabilities in a range + */ +static u64 __init __e820__range_update_crypto(struct e820_table *table, + u64 start, u64 size, + enum e820_crypto_capabilities crypto_capable) +{ + u64 end; + unsigned int i; + u64 real_updated_size = 0; + + if (size > (ULLONG_MAX - start)) + size = ULLONG_MAX - start; + + end = start + size; + printk(KERN_DEBUG "e820: update crypto capabilities [mem %#018Lx-%#018Lx] ", start, end - 1); + pr_cont(" ==> "); + if (crypto_capable == E820_CRYPTO_CAPABLE) + pr_cont("crypto capable"); + else + pr_cont("not crypto capable"); + pr_cont("\n"); + + for (i = 0; i < table->nr_entries; i++) { + struct e820_entry *entry = &table->entries[i]; + u64 final_start, final_end; + u64 entry_end; + enum e820_type type = entry->type; + + entry_end = entry->addr + entry->size; + + /* Completely covered by new range? */ + if (entry->addr >= start && entry_end <= end) { + entry->crypto_capable = crypto_capable; + real_updated_size += entry->size; + continue; + } + + /* New range is completely covered? */ + if (entry->addr < start && entry_end > end) { + __e820__range_add(table, start, size, type, crypto_capable); + __e820__range_add(table, end, entry_end - end, + type, entry->crypto_capable); entry->size = start - entry->addr; real_updated_size += size; continue; @@ -510,7 +598,8 @@ __e820__range_update(struct e820_table *table, u64 start, u64 size, enum e820_ty if (final_start >= final_end) continue; - __e820__range_add(table, final_start, final_end - final_start, new_type); + __e820__range_add(table, final_start, final_end - final_start, + type, crypto_capable); real_updated_size += final_end - final_start; @@ -527,6 +616,11 @@ __e820__range_update(struct e820_table *table, u64 start, u64 size, enum e820_ty return real_updated_size; } +u64 __init e820__range_mark_as_crypto_capable(u64 start, u64 size) +{ + return __e820__range_update_crypto(e820_table, start, size, E820_CRYPTO_CAPABLE); +} + u64 __init e820__range_update(u64 start, u64 size, enum e820_type old_type, enum e820_type new_type) { return __e820__range_update(e820_table, start, size, old_type, new_type); @@ -572,7 +666,9 @@ u64 __init e820__range_remove(u64 start, u64 size, enum e820_type old_type, bool /* Is the new range completely covered? */ if (entry->addr < start && entry_end > end) { - e820__range_add(end, entry_end - end, entry->type); + __e820__range_add(e820_table, end, entry_end - end, + entry->type, entry->crypto_capable); + entry->size = start - entry->addr; real_removed_size += size; continue; @@ -1322,6 +1418,8 @@ void __init e820__memblock_setup(void) continue; memblock_add(entry->addr, entry->size); + if (entry->crypto_capable == E820_CRYPTO_CAPABLE) + memblock_mark_crypto_capable(entry->addr, entry->size); } /* Throw away partial pages: */ From patchwork Thu Jan 13 21:30:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Fernandez X-Patchwork-Id: 532369 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6C952C433FE for ; Thu, 13 Jan 2022 21:31:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235124AbiAMVbL (ORCPT ); Thu, 13 Jan 2022 16:31:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47254 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235906AbiAMVbK (ORCPT ); Thu, 13 Jan 2022 16:31:10 -0500 Received: from mail-oi1-x232.google.com (mail-oi1-x232.google.com [IPv6:2607:f8b0:4864:20::232]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 45DF6C061574 for ; Thu, 13 Jan 2022 13:31:10 -0800 (PST) Received: by mail-oi1-x232.google.com with SMTP id t9so9601929oie.12 for ; Thu, 13 Jan 2022 13:31:10 -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=AYRnV1Ist1vARSPSnF2rw/yrtuWCrI0ayDUHb4fDzqo=; b=SMckg/nzX83RUT38HDVqXqL/+USSoRNwE2qeb9u2fYcDf+eHn88PcolAkaromVaRG0 X9VARu1HxmUUQ+XnYnc8deAHrPHJMxBP/1z8wreMqEXwVx/hvMJmU06GCgHeA/6VOm2Y dat7Xi9MT9cyH7FmNRqX48xelGVsT2QmygWkut/XwSUtbg3La7lqRzsF+VomJc0W+1ja CsLbpSGOM33Rx28bmwbanQ7ojQNPBvOh4uIVreW2qM+AdaszzP/K5bFlUU6f8JEjuI6c XMeDY4gmsPzxHxeKqh3QO/CCvk8naON6KAe+OyK3/iV/j4dl+Pd8xNw2MeZyWFUfGxOT f4fQ== 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=AYRnV1Ist1vARSPSnF2rw/yrtuWCrI0ayDUHb4fDzqo=; b=L0X3jcP2Ez1RQLYEpavy6/90nn7vuE6CJK+ztFP+Z+JnwPY449kE60z/Y8mjDXF/Sp OexCzbSiNdtIh2CMywsFYN5VkOAVONU+BCnis8hdJyAATSE7Fa+m0SdiWnGs++YD7SID klkbbkbJVOg1KuBhzdXxKZiR/9cAZ6obd27gtnU30Naxb1gGz5AST9YAVUWbUbgAo/GE dhPDXuetwuSpS4ucxUb5XvhoqbWUxSeGkTTSL2krEGf1pAx3KwqF/fnBSs2F9amOxJ+x fVqJoMafpcldBqpyCS0spAYN0rDBaH6j7rgKMMelV1uaxdrPIJaHS4NxhonDa5h7VGFM 8EYQ== X-Gm-Message-State: AOAM532OiGwxtmSqbqHmqppIH/VQRdKFUyHuzHlCcSBzfaETuGhep0C4 yLb7rFvnlrC8y/j0BcePIfQPmg== X-Google-Smtp-Source: ABdhPJwEYr2CLO1fRtR6rM6IJUk2OdrzSIfOZW8PCuyuo97iz5DyT8grICu19f+pXA46UCcnMK86AQ== X-Received: by 2002:a05:6808:2382:: with SMTP id bp2mr5091455oib.164.1642109469690; Thu, 13 Jan 2022 13:31:09 -0800 (PST) Received: from localhost (115-127-16-190.fibertel.com.ar. [190.16.127.115]) by smtp.gmail.com with ESMTPSA id i7sm908931oot.17.2022.01.13.13.31.04 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 13 Jan 2022 13:31:09 -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 v5 4/5] x86/efi: Tag e820_entries as crypto capable from EFI memmap Date: Thu, 13 Jan 2022 18:30:26 -0300 Message-Id: <20220113213027.457282-5-martin.fernandez@eclypsium.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220113213027.457282-1-martin.fernandez@eclypsium.com> References: <20220113213027.457282-1-martin.fernandez@eclypsium.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-efi@vger.kernel.org Add a function to iterate over the EFI Memory Map and mark the regions tagged with EFI_MEMORY_CPU_CRYPTO in the e820_table; and call it from efi_init if add_efi_memmap is disabled. Also modify do_add_efi_memmap to mark the regions there. Signed-off-by: Martin Fernandez --- arch/x86/platform/efi/efi.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/arch/x86/platform/efi/efi.c b/arch/x86/platform/efi/efi.c index 147c30a81f15..ce2f9d38fe36 100644 --- a/arch/x86/platform/efi/efi.c +++ b/arch/x86/platform/efi/efi.c @@ -184,6 +184,8 @@ static void __init do_add_efi_memmap(void) } e820__range_add(start, size, e820_type); + if (md->attribute & EFI_MEMORY_CPU_CRYPTO) + e820__range_mark_as_crypto_capable(start, size); } e820__update_table(e820_table); } @@ -441,6 +443,23 @@ static int __init efi_config_init(const efi_config_table_type_t *arch_tables) return ret; } +static void __init efi_mark_e820_regions_as_crypto_capable(void) +{ + efi_memory_desc_t *md; + + for_each_efi_memory_desc(md) { + if (md->attribute & EFI_MEMORY_CPU_CRYPTO) + e820__range_mark_as_crypto_capable(md->phys_addr, + md->num_pages << EFI_PAGE_SHIFT); + } + + /* + * We added and modified regions so it's good to update the + * table to merge/sort + */ + e820__update_table(e820_table); +} + void __init efi_init(void) { if (IS_ENABLED(CONFIG_X86_32) && @@ -494,6 +513,13 @@ void __init efi_init(void) set_bit(EFI_RUNTIME_SERVICES, &efi.flags); efi_clean_memmap(); + /* + * If add_efi_memmap then there is no need to mark the regions + * again + */ + if (!add_efi_memmap) + efi_mark_e820_regions_as_crypto_capable(); + if (efi_enabled(EFI_DBG)) efi_print_memmap(); } From patchwork Thu Jan 13 21:30:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Martin Fernandez X-Patchwork-Id: 531833 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0F6B2C433F5 for ; Thu, 13 Jan 2022 21:31:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235906AbiAMVbb (ORCPT ); Thu, 13 Jan 2022 16:31:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47292 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236060AbiAMVbR (ORCPT ); Thu, 13 Jan 2022 16:31:17 -0500 Received: from mail-oi1-x236.google.com (mail-oi1-x236.google.com [IPv6:2607:f8b0:4864:20::236]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 55EB2C06161C for ; Thu, 13 Jan 2022 13:31:17 -0800 (PST) Received: by mail-oi1-x236.google.com with SMTP id i9so9675588oih.4 for ; Thu, 13 Jan 2022 13:31:17 -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=yVN27if4TLsRCEMhCF/aqw8r/7THOayqDLYA7IAtavc=; b=cl/0zLZFJiGx8sFR5y9ZQu0me7yAE4sNXzqAJwzAbdsxRpWRMgUShOFWYq8N1hPJY2 48lcCYaUXpUWBAmmXMep3197PfpmGKcgBMTygUt3HNfyP7uOOgBxNz99RILKcZoRYfqs Zt/3R6UjOLJefC5vcjn7sL1MXjc3KjmC+NQjSymVxGXKyYrGFTRPKZcRuLkkEg6NPefk U12lx/o3FRe8+qmMzea5DJ5DLvKXyzTANaRZcV9oVsgPU8w8f/XvJ3Tac1oXIB+RUkGf hwj4x2EZC7kxNZHRPe0QXebw4HB5BaulW7Esu1JdDEw+fpJCtRbhSQoxMNwuGdoSTe3I L08Q== 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=yVN27if4TLsRCEMhCF/aqw8r/7THOayqDLYA7IAtavc=; b=h/6RNEMe5WTbnnThWnvSo4sy7ofQ/1PrnPPJ8nF5FTce0FonhDHErLT6q14W0NA5dm 0sNbMsN09Fws8SX1mMw4orjF85uhNd4sutshWe5UrBqni0SWL8oFsXzLFMTdXV+v+4eb Fi4RSC+Ndd/vn9YMegtvLDNyfN3w52bqiUVpUbHpWXxmQTCoER77inpp6+lUsDhAnZ+N jkxQzKBCTZOf/7x/r0N4qKpI/QjOqcYouu9VImyKFc05yOatI7nC02p/p9qD98YApsS+ DCUGKup2mwphmfCbNM78CfYs9yWxxVq6blZ5A5/rWheypla2RAdZk/1dcUDbH+EJTt8+ dX8w== X-Gm-Message-State: AOAM531WGMvAmh20Ji5/EizfCjLleNVuLoU34vDb77fdhjhIi/Am9oK9 d6jYxoHT5XZN9sPcW9CCTJaFRg== X-Google-Smtp-Source: ABdhPJxJcXPnlOWnI9M6Jnqh9i6KsB4TBvlTnQrIc/FadDEsjuKYa97ar6lwUiV86vnw2DEkK9FwHA== X-Received: by 2002:a05:6808:1a83:: with SMTP id bm3mr3785579oib.53.1642109476722; Thu, 13 Jan 2022 13:31:16 -0800 (PST) Received: from localhost (115-127-16-190.fibertel.com.ar. [190.16.127.115]) by smtp.gmail.com with ESMTPSA id o130sm1040829oig.26.2022.01.13.13.31.11 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 13 Jan 2022 13:31:16 -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 v5 5/5] drivers/node: Show in sysfs node's crypto capabilities Date: Thu, 13 Jan 2022 18:30:27 -0300 Message-Id: <20220113213027.457282-6-martin.fernandez@eclypsium.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220113213027.457282-1-martin.fernandez@eclypsium.com> References: <20220113213027.457282-1-martin.fernandez@eclypsium.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-efi@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..7c0480580670 --- /dev/null +++ b/Documentation/ABI/testing/sysfs-devices-node @@ -0,0 +1,10 @@ +What: /sys/devices/system/node/nodeX/crypto_capable +Date: January 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 };