Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp3092988pxb; Fri, 4 Feb 2022 00:46:33 -0800 (PST) X-Google-Smtp-Source: ABdhPJyzARvajBSg4AnNuUsw+jNLs3AZ0oKgTezZcUMwJzwa4NrIMfJpJcQk0MCUsqV6veman30J X-Received: by 2002:a17:902:c213:: with SMTP id 19mr2200599pll.133.1643964393325; Fri, 04 Feb 2022 00:46:33 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1643964393; cv=pass; d=google.com; s=arc-20160816; b=WOPR5XmCFo5IyT0hqRiSJVWjEo67Ny3ZQlvcSLPgnZS4341lC4nb3XDsZjyf6wEeCR iCLI2pDFwokBdx2Ut1MVXDjnFhQga+a1xHyxvIMCLXlQArflDdUS2/tHSv9Y9zfaIbxl G44eGhYWhwC5BWTRkibOvoiYG/HgP2NZYn7usxvbc+27xGcRhBPiAVYf+0+e+gcxFwA/ vkD51aaPytk1xXY1+SKNzhfyVp4u1skjXczR5RONgdhcc0Mzous1XXj46Nm7A9Xq6/Ui 0qwP86PXUIhCft1oFkgh8UIagdmsTSmAXyc0lKdgeYnhR5ILG/bLPRUwxd7+aeMauYoc Dgvg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :in-reply-to:from:references:cc:to:content-language:subject :user-agent:date:message-id:dkim-signature; bh=a2uG1D3QVrHsVl4D88DeXg3OThfJ2MtOcC7T1EM1NN4=; b=nkoNJy+6G8pwKOxKhBOb4F7bXp14GcspeqXlqT12Q27/x0veGO9cUo757ty454Bm/Q 7cqJ+u88KqlLMnddfkRbZPm/gGft6VVmLDNwGzPFwifY6hDmJH4dOBKtXAqmogX5qHbs tDIyYRB1/+upSbnfsOKrKudT0W4RXbcmxHZb6ZYCvhT8eehdoKw5AuZJosPdpFXWSq9L A/o+kNEiUscyUp9mXQglgw7Sr3BJX8Cl4TDU7hqj6AcXtX91rcLxaTmlXhrGMS8Ymc8K bI03e5cF8Vq7l5E49C0ftHQmeIcWib0sxrmAr2Shn/FmCo/j2epUAxYVFJQ3ut9eWvw/ SGxw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=zJXDisXw; arc=pass (i=1); 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=amd.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 144si1234409pga.249.2022.02.04.00.46.21; Fri, 04 Feb 2022 00:46:33 -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=@amd.com header.s=selector1 header.b=zJXDisXw; arc=pass (i=1); 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=amd.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1356852AbiBDDrM (ORCPT + 99 others); Thu, 3 Feb 2022 22:47:12 -0500 Received: from mail-bn8nam11on2074.outbound.protection.outlook.com ([40.107.236.74]:11712 "EHLO NAM11-BN8-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S232345AbiBDDrK (ORCPT ); Thu, 3 Feb 2022 22:47:10 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nS6uY7f0OPTkIhqyf3vc/O3f0WUve59j/esDWvzVjXeF7MmAdp168PXs038o6jFrSu61RtX/qrGpp16Q07uLvmgSNQ+mGKli7XLi2vI3YZkHVomxXZpSVK+vFloWleLSuiA+rjf2wO5p3SOgNOEPxU7tAuprDgkvy+sDmKeNQP7fy4VN0v8G9opf134hVVmD3xlRwd4Un9sx8ZzIRliUgHJWWT/sl8RJAixVUXpd4ZXS26ubK+bjQGG4PXp8DXCaNiOBgmqxbyMAplpeZrivK+S38ZJ60QG5LjjrT8PT57scqQ5p6g/RpQXWECsx8NL/HdKpOLLWfLHw/YdvFfmBFw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=a2uG1D3QVrHsVl4D88DeXg3OThfJ2MtOcC7T1EM1NN4=; b=eY+2pd54FugjtDI8rDDnlJg+IJ6Xg8Yyk4wAYmUZREI2HXPTuVNbOI3PwEXulMBhMmQxnWlsY66AgPTKg3uxysKTZr4GWzxKp+C2Gxha86kT48ppTAHIe4RybWAnqJZkX4xMWWUGNwntj/YY1E6oZSipSDlCI570sn+5P56IvkcMLQYEnzFaIHp3uY/TTCUiCRWCVfaI8dNKjjjDorVrQ14uzJIIeKxCXsCLnieWp7a9ayX3wf18BXqjEhfQbcBgNDlnmjh2V9Ga0d/3oqJQibwTynq/QYWZqMwHPZNLyuvEjtGWat1mcovQf0lwpE8BAMbjTnuoJx3NkFWU6BGP9g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=a2uG1D3QVrHsVl4D88DeXg3OThfJ2MtOcC7T1EM1NN4=; b=zJXDisXwHC6VX0qlJPYRj0JUVuM55u2d14o6iPx7kaTDq3GcktLQAIGy3mILwdTc4OrWO08t06w2TOLLvOkZU6TbFTZdLJpaIIjE2UmKq2iXFSbckSdDcqMA8ugm0DdgI9wC13htJODPtgL7r2GZE2kckB2io5DWLdHRcxKyyfQ= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com; Received: from BL1PR12MB5157.namprd12.prod.outlook.com (2603:10b6:208:308::15) by DM6PR12MB3481.namprd12.prod.outlook.com (2603:10b6:5:11a::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.15; Fri, 4 Feb 2022 03:47:07 +0000 Received: from BL1PR12MB5157.namprd12.prod.outlook.com ([fe80::42f:534d:e82:b59f]) by BL1PR12MB5157.namprd12.prod.outlook.com ([fe80::42f:534d:e82:b59f%4]) with mapi id 15.20.4951.014; Fri, 4 Feb 2022 03:47:07 +0000 Message-ID: <67d2711b-200c-0894-4ff7-beb3eb304399@amd.com> Date: Thu, 3 Feb 2022 21:47:02 -0600 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.5.1 Subject: Re: [PATCH v6 6/6] drivers/node: Show in sysfs node's crypto capabilities Content-Language: en-US To: Martin Fernandez , 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, "Lendacky, Thomas" References: <20220203164328.203629-1-martin.fernandez@eclypsium.com> <20220203164328.203629-7-martin.fernandez@eclypsium.com> From: "Limonciello, Mario" In-Reply-To: <20220203164328.203629-7-martin.fernandez@eclypsium.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-ClientProxiedBy: MN2PR03CA0018.namprd03.prod.outlook.com (2603:10b6:208:23a::23) To BL1PR12MB5157.namprd12.prod.outlook.com (2603:10b6:208:308::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e8a41fd5-332b-4eb3-b52d-08d9e79103a8 X-MS-TrafficTypeDiagnostic: DM6PR12MB3481:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:9508; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 07yO1vs9Q0Je7qU9JV/kzlacML+LZ4Th8Qm2FRsBHonGdKfOWvlwdkhgTDrkzLWHdnlQaanlP9Lm4r+mARNHQBW3k9qdw3LYLzldbZOV8wUQLzlwjVG4WSeSJyN//vRbJhAcK4ff2/vqJ5DrTfegU4MUaBqPqfpvaUBJNm+DGXS70tzMV7GIjJdeTeHETpCgIQDNehZYPXxapdTO/tTQxw1pDm8KCcVqn8eL4dP4IuUdDKyt/kYNaLfas8CyZ+iGdkEtYeltqXlD+Yot6PyA5V0eU7+/PtxlvZdZIB6aScxALmukDjZrln8KYUr1JmPuI/BaBVyYtkU7AM+rLFkpKjjgqgW5U5Frz9UcaXTYq6gnIZuDpmialWdhjQIzLTb8XTc2uknLuQ7k8rX8nqRU0OOo5Y1EJubz+2MkFh84Z08JxyYfRFUcLryzGu4qQG5asxAQVZmCCwRWDi3HCWvLyhtgth1FYcvyasOfJv6ZcMBPDi7K7qCDF6871JtT9mFDP8aa8lsLIBjlX3Nr998tdyO1mR1f8GJCRZT8pGYLwgrK1+YG3nTVz/vfdJ6vrni6dXJ4nXJvoQd/T3msjIc9mWvZ3e79kCkCqhwWk1XWom6lJTbGZy4PuNmsydUsHJtsVZ+XlC5lWIlc0PXqeTbuIXrfsjSlFweeV63CHCZVh8rFwwxnjZxTNbQF3OmdTaxIFDkw1AHR6Jx/Xbyz98sXV4Da9W/YW31QmiTmusokR3OCjl0PtAzS4JLT3x0y1il0rFVgbJGTICN4fhGQzuc0Sfx3hib5M6XitZSrYLOKhbXDtwxNxplLsP9WyEN1TaOW X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BL1PR12MB5157.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(4636009)(366004)(66556008)(38100700002)(4326008)(2906002)(8676002)(36756003)(66476007)(31686004)(6506007)(66946007)(6512007)(83380400001)(316002)(86362001)(8936002)(2616005)(31696002)(186003)(6486002)(508600001)(26005)(53546011)(5660300002)(6666004)(7416002)(43740500002)(45980500001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?a2tZK2lDZWJqbzkzQnlhOHNVNFlvTU50M0JTVlY5aEhINGxObkZjaGI2Z1dJ?= =?utf-8?B?S3JRZXVObjJmTENwbXg0dG1QU2RSOTFKMGE4TzQ4QUNOay9TRWFQTkxvMDRN?= =?utf-8?B?UVRWVjhFVTZGcUoxVURjTVNiM2c2V0R6RWZ5alVzQWZrOXpMQk1aMytpdkw2?= =?utf-8?B?OTdpNFhRaU1YTFNKakc2Ym9NSEtwYktJMTVpa3dQcHl2WEZVMVlyekt2dnc4?= =?utf-8?B?OXhRVXIxZFI4U21mTTFqNVQ2c2tLK05RTlJSeU16aGhMWm14SkVGVjYrek9i?= =?utf-8?B?amtKd0l4NXBlMFphdmVzV1F6UFVIYXMyN1BZL1VYeFF5emNBaEpHSlh4SlVH?= =?utf-8?B?ek81aDlwUWkwa0JWKzM5a1NQNkJwZHI3eFZkNW5McXpNVFRoVHFoVGRacEda?= =?utf-8?B?cFAway8reWJXcWY2SGNCYWdJQjdLb1c1QnQ1OHFTVFRCcW9TMGpaZmh2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4eb3-b52d-08d9e79103a8 X-MS-Exchange-CrossTenant-AuthSource: BL1PR12MB5157.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Feb 2022 03:47:07.1672 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: iAE+tjRTMZGPXTFt6+HOdZQ9hH+Txopxk1v3I63t6YVhHYvfMHvxbZ2oI9vuJ2lGUacnbNF+Y2e746NWdhkCew== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB3481 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2/3/2022 10:43, Martin Fernandez wrote: > 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); As there is interest in seeing these capabilities from userspace, it seems like a logical time to also expose a `crypto_active` attribute. Then userspace can make a judgement call if the system supports crypto memory (`crypto_capable`) and then also whether or not it's been turned on (`crypto_active`). `crypto_active` could be detected with some existing support in the kernel of `mem_encrypt_active()`. This will then work for a variety of architectures too that offer `mem_encrypt_active()`. As it stands today the only reliable way to tell from userspace (at least for AMD's x86 implementation) is by grepping the system log for the line "AMD Memory Encryption Features active". > +} > +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 > }; >