Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751533AbdILPcY (ORCPT ); Tue, 12 Sep 2017 11:32:24 -0400 Received: from mail-by2nam03on0048.outbound.protection.outlook.com ([104.47.42.48]:51454 "EHLO NAM03-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751404AbdILPcT (ORCPT ); Tue, 12 Sep 2017 11:32:19 -0400 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=brijesh.singh@amd.com; Cc: brijesh.singh@amd.com, linux-kernel@vger.kernel.org, x86@kernel.org, kvm@vger.kernel.org, Thomas Gleixner , Joerg Roedel , "Michael S . Tsirkin" , Paolo Bonzini , =?UTF-8?B?XCJSYWRpbSBLcsSNbcOhxZlcIg==?= , Tom Lendacky , Herbert Xu , "David S . Miller" , Gary Hook , linux-crypto@vger.kernel.org Subject: Re: [RFC Part2 PATCH v3 03/26] crypto: ccp: Add Secure Encrypted Virtualization (SEV) device support To: Borislav Petkov References: <20170724200303.12197-1-brijesh.singh@amd.com> <20170724200303.12197-4-brijesh.singh@amd.com> <20170912140249.f26w5xedbrqu52i4@pd.tnic> From: Brijesh Singh Message-ID: <855be17c-382e-4e7d-7300-ca19cc50c625@amd.com> Date: Tue, 12 Sep 2017 10:32:13 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: <20170912140249.f26w5xedbrqu52i4@pd.tnic> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: DM5PR20CA0002.namprd20.prod.outlook.com (2603:10b6:3:93::12) To DM2PR12MB0154.namprd12.prod.outlook.com (2a01:111:e400:50ce::17) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 72782a22-d1e4-4bea-2d7d-08d4f9f3730a X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(300000502095)(300135100095)(22001)(2017030254152)(48565401081)(300000503095)(300135400095)(2017052603199)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095);SRVR:DM2PR12MB0154; X-Microsoft-Exchange-Diagnostics: 1;DM2PR12MB0154;3:QDAP4AwPAaMzC2ZFavdpNE4H6l5kmeF5AtRk+kVbnyfpiKeZzZIO1D84NTH1YTvL0E7r0qChdwNa12YojaRJu6G8kPIyJoSE7ApBVDLJQ+yGCATe31HlC3XlL9GiYlw/tx8w9P3+3pLDRLaAdOGG9pe3NNJqG5wsWV5Gs9wLnM9Szaq82dunpJTHBCfmlnBQactIrHyoaUfI6KCVLELs6pXeIgEuNmz8j9pDOK6JwDTRfmxGIrQPzxKoBm8yCixq;25:fno/M5eqMRh/mB29W5YqrV7MymUxTKsFAXgZeO7JoGc14rv3IqR4Z+WjYsMULl2JpdOId0bls7cLFU6LiBIyy4lsq1IqBVJXKa49Nep6MY+oFSWHIMI4603zbp7WKCuSoUSYCKXkhi0ymMlRufOnlAxM6BiDdkx3sn/l0mNqnsc48lHWK7xSHhQgRZyHzFePGfqP3c7h0OgLt8SCe6RmtUrhtZl9rDc7Nm6JmbUswQ0PLWhNz+dF7x1B9gjW118tri7MtG+z6OW6zGqKoxCih1vjbzHz97Q0YLnQHzBPnHtC2si6P+kVMhdvrhUwjnoUie+91mN0ay/y8DLiI6rIyw==;31:MEvIp4e9em3aU6qTvQdHTmxRhfzsCcQLVULACbbDt9sE4a61gqE8EqQrMAHtJCajEA9PWj4e5Vvg0k1qSa8KvJfZsHCLy2jrkaJQQsioOCjVJhTYnASNHFyMiZ/C9RhmHkBqPNLCOA2jzXlnmK6CFUToMBkVBg8i2M8kBE+FbMlmD8IypZQ3rMrYnZAX+0A4GPnXc6K7p295W3SbMDp7tIQ7SFeZZT1VblINswP0Yp8= X-MS-TrafficTypeDiagnostic: DM2PR12MB0154: X-Microsoft-Exchange-Diagnostics: 1;DM2PR12MB0154;20:ZCO2C0MoBN3dRJ381ug2elOa1nhohTopwVJ7Iqo0tCG99qZm8rM5BlaXulVEezq0RqD2ticMppI+11pNcw7PLCPhcxXO6zskuXHWZ8+37ma+pBo0v8JIRQ0axSc9b/0YnkgNoY0t7z6W9YCQbG93GPnFPHcaD+Ml/eeZSnRhbnCh0psNA6f3a2YEyfQqdx4mfD/laEf8cknNuimJdhuGrjDZS12F3ciFo7qehavzz55H7ee1JFwzW5hoekLtx9QxiXGigGJZ6HotW851++7ZYVqHaCx3b5NMzSmDheAkqiVF2nG9kzmkBSBUc2q14DeUdyxT0eZnJENUoAu9TKg5o1EHTUfZjDdWmGomJcypP3aZTT04dv+56zYPNcVBxTjB7W49arcLBvVpAqGaaQBnuzu+O44BCH8E4FUuKFqQGZPEYeX/wQ6f3O160JalT1lAG7Bu8ekprwSNNIyoADdliRanTEDf/A3pe8GBZ1gwTPzxCnhjt4auDhtC+4umBBgD;4:63sPQQwA9rlRXqTEHmMLZWLFo8Yqair0mqo8KMIPAcQ0cStEHnuBjH9hbeZD7Sc/icka1GBW8WIs5YmNUaQkcCVrGpkXSnvuY+9Zwx+k5oXjf8pYuAsv2to105u/+yDpEObNK7fe3YPx893ppgLZyi4N69Vh0DGGILq/g+SwVbgPxDz9Kk9c1UMYr9UVFwSpGrMoIV5w0pfS+2U0B5c9STHgCLsHl+ErkQB+N7oZwub0r5gdiT48TOsMLHJiPgpI X-Exchange-Antispam-Report-Test: UriScan:; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(2401047)(8121501046)(5005006)(3002001)(93006095)(93001095)(100000703101)(100105400095)(10201501046)(6055026)(6041248)(20161123555025)(20161123564025)(20161123558100)(20161123560025)(20161123562025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:DM2PR12MB0154;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:DM2PR12MB0154; X-Forefront-PRVS: 042857DBB5 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(6049001)(6009001)(39860400002)(199003)(377454003)(24454002)(189002)(68736007)(81166006)(65826007)(64126003)(305945005)(229853002)(77096006)(86362001)(7416002)(7736002)(6246003)(31696002)(47776003)(50986999)(4326008)(50466002)(76176999)(6486002)(23676002)(54356999)(25786009)(101416001)(5660300001)(36756003)(110136004)(478600001)(65806001)(6666003)(8676002)(189998001)(66066001)(81156014)(65956001)(83506001)(97736004)(8936002)(106356001)(53936002)(42186005)(54906002)(53546010)(31686004)(6916009)(33646002)(2950100002)(105586002)(4001350100001)(230700001)(2906002)(6116002)(316002)(3846002);DIR:OUT;SFP:1101;SCL:1;SRVR:DM2PR12MB0154;H:[10.236.136.62];FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtETTJQUjEyTUIwMTU0OzIzOmFmbWU3MG9pc3gvNTlEU2dsY2cvcTlOMlMy?= =?utf-8?B?SzE5R29hTWtHN3Q2QnZtWmJKS1JTelE4YW9FNmYxQ29yRXg1WDAxMnZJUldy?= =?utf-8?B?eTNjMFRiVFBXTm9KODdsdW5KZVRRY0RIcmZaYzU3UnJaSDdBck5TRDNNZExD?= =?utf-8?B?bjgxSytqVkNJUkh2czVoYzV1M1hvOSthWjFhcVZ6aU1pWEFvTmxDK1BWZU9C?= =?utf-8?B?Zjdtc1JTK3lxWTdLemJTaGVRR3Vvc0R0N1VCRzRpUUFaSVdFdDZTeXJrWmwr?= =?utf-8?B?akpLTCtReXM1UnpHOTMwbE5mS3VzRzdqTWl2N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Lqgw2I2q2InHHVDAzTI0SiUMk22drzpKPanxfu153A40NX7DdSnuu6YhjxonHVwAuG9CvRMiFJURtY2YKYZ77LA==;5:mqmSZlyHhJay48SSwfs2qagMOShwntpwJEiNglofb6i4JIVhxAe8oeI/ZnH9DMcjH1xlzkTn+HcSIMCshad2Dqj+SZp2EO79XROGU6+0eoLjq4BoIXtq2AFGBBHIUVCgkBJ2fl1TVcG8ihB/NBx/Yw==;24:6GogCfhK14TZGUaTahAZSRE1BOrtb5odrutvuMw0EjdPScyhhfkpRIJ8KR6vR1siFD6H/XXojX7QOL9eYav1AKeetlfE7TgHDlcpqP7duuY=;7:KXQY+MHijesnSRshS4vbnqn4e2QS692TdJibdowlERgsrVTlXXsgJUu5DTmA14e80xY7bCTru6wpGPICVhX3X1pK7GpGlykjfI4gdo8vW4F8jMueGmZ2w+QmCiQN2gJa1tyugfklIf9fiAMt4P8beLli4IDcz1PzXdqDjqVoOrT25EHUscbO5NkMCVwxAMq4OzEItDZnaUfr9nHDI6pfg2IsJxhgnWY/8T0Ar5/6bUU= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;DM2PR12MB0154;20:JMWUC8k7lxfeZA1w8qMqXgzIfaP2Qq3rP0MXk7EAeuj8Cj/MqX3lBHMUFZeFEWiHox0SG6O0PUSm8vr+xy3dWeusr46Hpxe1Gr7KZqT4WGDQL2j6ZdiFTaMKxW4fu8MEAyk2dfhZSpWDvQ5W8ajNaOYedbXDgywv5heI3GPavS1MaGsYDresxj+a889nxhASn/zuMeKyUMg1d38rY9jtX5wZlxBwi8AdUMOZBztNoHdvJNesMtDxqvdKHDMqUS05 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Sep 2017 15:32:16.0842 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM2PR12MB0154 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2019 Lines: 57 Hi Boris, I will address all your feedback in next rev. On 09/12/2017 09:02 AM, Borislav Petkov wrote: ... > > You could make that more tabular like this: > > case SEV_CMD_INIT: return sizeof(struct sev_data_init); > case SEV_CMD_PLATFORM_STATUS: return sizeof(struct sev_data_status); > case SEV_CMD_PEK_CSR: return sizeof(struct sev_data_pek_csr); > ... > > which should make it more readable. > > But looking at this more, this is a static mapping between the commands > and the corresponding struct sizes and you use it in > > print_hex_dump_debug("(in): ", DUMP_PREFIX_OFFSET, 16, 2, data, > sev_cmd_buffer_len(cmd), false); > > But then, I don't see what that brings you because you're not dumping > the actual @data length but the *expected* data length based on the > command type. > > And *that* you can look up in the manual and do not need it in code, > enlarging the driver unnecessarily. > > ... The debug statement is very helpful during development, it gives me the full view of what command we send to PSP, data dump of command buffer before and after the request completion. e.g when dyndbg is enabled the output looks like this: [392035.621308] ccp 0000:02:00.2: sev command id 0x4 buffer 0x000080146d232820 [392035.621312] (in): 00000000: 0000 0000 0000 0000 0000 0000 [392035.624725] (out): 00000000: 0e00 0000 0000 0b00 0000 0000 The first debug line prints command ID, second line prints memory dump of the command structure and third line prints memory dump of command structure after PSP processed the command. The caller will use sev_issue_cmd() to issue PSP command. At this time we know the command id and a opaque pointer (this points to command structure for command id). Caller does not give us length of the command structure hence we need to derive it from the command id using sev_cmd_buffer_len(). The command structure length is fixed for a given command id. Thanks Brijesh