Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753879AbdHQSLC (ORCPT ); Thu, 17 Aug 2017 14:11:02 -0400 Received: from mail-cys01nam02on0048.outbound.protection.outlook.com ([104.47.37.48]:19706 "EHLO NAM02-CY1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753382AbdHQSK7 (ORCPT ); Thu, 17 Aug 2017 14:10:59 -0400 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Thomas.Lendacky@amd.com; Subject: Re: [RFC Part1 PATCH v3 07/17] x86/mm: Include SEV for encryption memory attribute changes To: Borislav Petkov , Brijesh Singh Cc: linux-kernel@vger.kernel.org, x86@kernel.org, linux-efi@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, kvm@vger.kernel.org, Thomas Gleixner , Ingo Molnar , "H . Peter Anvin" , Andy Lutomirski , Tony Luck , Piotr Luc , Fenghua Yu , Lu Baolu , Reza Arbab , David Howells , Matt Fleming , "Kirill A . Shutemov" , Laura Abbott , Ard Biesheuvel , Andrew Morton , Eric Biederman , Benjamin Herrenschmidt , Paul Mackerras , Konrad Rzeszutek Wilk , Jonathan Corbet , Dave Airlie , Kees Cook , Paolo Bonzini , =?UTF-8?B?UmFkaW0gS3LEjW3DocWZ?= , Arnd Bergmann , Tejun Heo , Christoph Lameter References: <20170724190757.11278-1-brijesh.singh@amd.com> <20170724190757.11278-8-brijesh.singh@amd.com> <20170727145841.GG28553@nazgul.tnic> From: Tom Lendacky Message-ID: Date: Thu, 17 Aug 2017 13:10:45 -0500 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: <20170727145841.GG28553@nazgul.tnic> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [165.204.78.1] X-ClientProxiedBy: MWHPR1701CA0021.namprd17.prod.outlook.com (10.172.58.31) To BN6PR12MB1140.namprd12.prod.outlook.com (10.168.226.142) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4f4f68fb-a2ee-418c-0b1a-08d4e59b4e60 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(2017030254152)(48565401081)(300000503095)(300135400095)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095);SRVR:BN6PR12MB1140; X-Microsoft-Exchange-Diagnostics: 1;BN6PR12MB1140;3:IzrLGlqCC7qcPo3d5Upg9lp0CD7eSwrmbxdFTeREkJXhOFBZ1mHu3q5zPWeBXWZHb+CXeFEegvY8dWRKO75HCRpF+WyukBiNisz8jIy9YidyR8yB19oNVYj9E0n8LPsfpfFR3na2p8z8q75dEPnw8T8/5pjZMVx1O2kz2KPeX4W7h+LnDV0mX1BSy4kn8LdiX5UGFBsiNSGyJ2jX+HSLKqWdPNS5A+hOjaQAGUzJHfPPwvbhJYozUCji2bMStF3a;25:Kh25kQy+2SBVMI+Gf4Oef1IeIJpst9b+LMY8MyoSw+mRDQKmdfcqWRT+QWFqak5ZIxJ+jtrkFBy9VqNC5lcZ8wIM4JNHDZj2BwB4j/m+A4jLuMDuichsC27dOsYs6zW0WPY7TnJ1vJr6Z6ZlCmktmXyX7Vo2M6fGW8wq54PwRQgwWLuFf9UiQW4zZtYkBjXcRw3vx0wrn5AdNKtuqbDYFXS3ol7GHLYXNH8Dsmyx+CL5gYcIs5GC4j8Hn/fy9oIS4+qnEb0AxsqrxoqtiG9Km1o8ZK/2Fvl1sxjgpZhB9rt87qvsaCnuQxaAQ+JnjyIDGbL+wnHJ/VKHwf7lnHCKxQ==;31:7d0MhvqYkmzZYzzA2JClSv/b/XtJtg+fiTZdB1fabdvt0LrTgegVSkCEhxcltFJSstzORXSkWQz+O8n6GAT/fujrAq3DoOz943Jfse3UZ4rnwrMefZKuRW5IczhZeec59t/wCIKOGsWpiE0//T0RjMKZ70AHdmwfTUZ+FRallqynMxoblAJFU0Q+SyZ1H64B51zsiNMeJ7jbgMv5PdbuE5NmLbk3tu+fmeCDCJEDLs8= X-MS-TrafficTypeDiagnostic: BN6PR12MB1140: X-Microsoft-Exchange-Diagnostics: 1;BN6PR12MB1140;20:ytlA3E4Z2c2bL/Pc5SQboiqB+6604Kt022dsB2i3gxaS0Kifl0umMYkKNSMCELB7QKzHk6FSQlPWgLSrTfmFj+BRM3I6JS+qUAo7A+TGiqdx/xpZD4MLLAZ/s9VUr9+Nr0Mrt+tPwwsXsIIIVaBiSsIgF8ISt2kMteh9Rb6PiLoRzC7jBpBzbV8Q9Il1VB3UcWhcZ/RBRz8sVK2gi5a7fYvjX2g3vj9ShRNjuGyxPFoChM0wDd3ETaAlWfH6AeddO+85arAVKxyVKGANJORj8aAYU1ruri3O1afIY22thdM++I9jJ7dZtGFoQUAvdnz8JaRr7U2cALVsDxeQLAcsOYFrxCozmbu9j3yyjysUDcKyDYi1paUuFW1kUM8r1wQ1K8MVKX0OxJE4+ZU67HIqbwek0BPcemz8dTIk/9I1HyuHyQ2CUsnEzGphJXoNqdNBmH13AQ0FJzPy5knOxK6OPk5Kykjq02B+HFqwyk2sMYAYNJGZYy/2ONqOFfwCcexC;4:Le98SL1aojx4nNnTX8ik8feGsg1hRnNn4iydfDy49Bm93IYDXMjW9A4WChtVtyR++NMGKzB3OZ4kehQQym02+2pJOAEvriOFhgGHg0A+JTZXZtcmkFWH0SKsJD6mA+zplEKa6PdEZLQRE3ILLvUFYUt5CbeOFW3bpWyZrDCEKTRAjLgysNN9h9UJja17NFi5SyIi8kW29NiyF6SfILiIAqiuk6vlTArpS4i0IondPCODjDkCkzAKJ+jQVe+i0p4mWt9rgY0u3Mb0/6cKSJC9hSEHG1M6ElMxq4emXxbY1CQ= X-Exchange-Antispam-Report-Test: UriScan:(767451399110); X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(8121501046)(5005006)(93006095)(93001095)(10201501046)(100000703101)(100105400095)(3002001)(6055026)(6041248)(20161123560025)(20161123562025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123558100)(20161123564025)(20161123555025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:BN6PR12MB1140;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:BN6PR12MB1140; X-Forefront-PRVS: 0402872DA1 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(4630300001)(7370300001)(6009001)(6049001)(39860400002)(76094002)(189002)(24454002)(377454003)(199003)(54094003)(54356999)(53936002)(6246003)(97736004)(68736007)(106356001)(76176999)(7416002)(7406005)(105586002)(5660300001)(65826007)(42186005)(7736002)(305945005)(189998001)(64126003)(72206003)(50466002)(81166006)(81156014)(8676002)(50986999)(4001350100001)(83506001)(3260700006)(25786009)(53546010)(4326008)(54906002)(478600001)(31686004)(77096006)(3846002)(6116002)(6486002)(230700001)(2906002)(229853002)(90366009)(7350300001)(66066001)(86362001)(31696002)(23676002)(2950100002)(6666003)(6636002)(36756003)(101416001)(33646002)(65806001)(65956001)(47776003);DIR:OUT;SFP:1101;SCL:1;SRVR:BN6PR12MB1140;H:[10.236.64.250];FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtCTjZQUjEyTUIxMTQwOzIzOmdHclFJWjdrN01maW42VzN1RE1WZ1FqMnda?= =?utf-8?B?ZkxPdVRmeDhsU2I3RlJ5MnJ1Sm1RZGRUM1FoOEQzcnZJWHArenVpeEx6a2Rv?= =?utf-8?B?MkxI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vWhM8WSahnxTkb0MWcI5OBR2dynuvqf7B13yIgeuFtBZ3PGlwNC2dFX5oKdTd12QNECyrHJoNjbp6MSrxn5O4= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;BN6PR12MB1140;20:HhCy064vpcDEmLgkfgg7vWBBWbBaD2KYdGxyQ83gmJb/XRT5hNSAV69T4GquroyQqf+tren01apdMbhWKTCoR9WhVi0llOgN4vjFxPl4WRLs24TFhuRCQW9MtB3nvaA6glCgkX+J5iTkiNZ9HQDYWUA9nerhIafkbH7rnBoZzylNk+P+3VpFEa9gLhAZwOF9pJ33x5AW5mLHyjrGfqJjlTDcqG4DtnMJCU2i0T2mLfEr5BupX7uq1fK4pqOFoWoX X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Aug 2017 18:10:50.9315 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR12MB1140 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1511 Lines: 47 On 7/27/2017 9:58 AM, Borislav Petkov wrote: > On Mon, Jul 24, 2017 at 02:07:47PM -0500, Brijesh Singh wrote: >> From: Tom Lendacky >> >> The current code checks only for sme_active() when determining whether >> to perform the encryption attribute change. Include sev_active() in this >> check so that memory attribute changes can occur under SME and SEV. >> >> Signed-off-by: Tom Lendacky >> Signed-off-by: Brijesh Singh >> --- >> arch/x86/mm/pageattr.c | 4 ++-- >> 1 file changed, 2 insertions(+), 2 deletions(-) >> >> diff --git a/arch/x86/mm/pageattr.c b/arch/x86/mm/pageattr.c >> index dfb7d65..b726b23 100644 >> --- a/arch/x86/mm/pageattr.c >> +++ b/arch/x86/mm/pageattr.c >> @@ -1781,8 +1781,8 @@ static int __set_memory_enc_dec(unsigned long addr, int numpages, bool enc) >> unsigned long start; >> int ret; >> >> - /* Nothing to do if the SME is not active */ >> - if (!sme_active()) >> + /* Nothing to do if SME and SEV are not active */ >> + if (!sme_active() && !sev_active()) > > This is the second place which does > > if (!SME && !SEV) > > I wonder if, instead of sprinking those, we should have a > > if (mem_enc_active()) > > or so which unifies all those memory encryption logic tests and makes > the code more straightforward for readers who don't have to pay > attention to SME vs SEV ... Yup, that will make things look cleaner and easier to understand. Thanks, Tom > > Just a thought. >