Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752444AbdIMQXh (ORCPT ); Wed, 13 Sep 2017 12:23:37 -0400 Received: from mail-sn1nam02on0061.outbound.protection.outlook.com ([104.47.36.61]:22946 "EHLO NAM02-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751607AbdIMQXe (ORCPT ); Wed, 13 Sep 2017 12:23:34 -0400 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 Subject: Re: [RFC Part2 PATCH v3 13/26] KVM: SVM: Add KVM_SEV_INIT command To: Borislav Petkov References: <20170724200303.12197-1-brijesh.singh@amd.com> <20170724200303.12197-14-brijesh.singh@amd.com> <20170913150636.fcjhbg7wdf2whmy2@pd.tnic> From: Brijesh Singh Message-ID: Date: Wed, 13 Sep 2017 11:23:26 -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: <20170913150636.fcjhbg7wdf2whmy2@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: SN4PR0201CA0004.namprd02.prod.outlook.com (10.161.238.142) To BY2PR12MB0148.namprd12.prod.outlook.com (10.162.82.21) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4f19066d-a5ec-425d-b725-08d4fac3c63f X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(300000502095)(300135100095)(22001)(2017030254152)(300000503095)(300135400095)(48565401081)(2017052603199)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095);SRVR:BY2PR12MB0148; X-Microsoft-Exchange-Diagnostics: 1;BY2PR12MB0148;3:k3X3KTWQMp8FXXpGKzg/DMVAdR/leUQWCFcR43DR7nmKBiyz38ZXYHdvcYq+U50cAN7cE5Zj5J6NSf2I/oQ2EnAMVf09XkQicRP8KJn6NKTAMc2CmxewPuTXMdQIj3dIUC2f43IaSmyPsmFAckzSSuh6nbB55uB2C70ZbPYw+MZuVNh8QkyckRxGHVyB8hktlO8TG0vdZsKgX1xrJL21J2hvcg1QPY/o3bUzU2CFkCo8ZcHu61wbIAQ6wG5kP3h0;25:SUqc/ZPjTqVY96kpHkUMJlKxTBs0KZxL0+c/7oslDOUxtNm3evbyraWRGWan3BebSRtklGSSc9SJ5OUtUReVJFgwuub+Xcp0c3hHPVYvPKwmBSse1i1LS5vG+RxvmB47AUASJ6kvIXtWP5F41qxXXVRc87hSrYTZVPH6dM/OgurU5ja3snks13wnWXmQGca8NgKJRX1a8aQove6KIvNxCF1vbN0Nzy1mb4IZRSr7BoX3HJZaFT6CW7qhcwEUzwM1I4ZeXYDn8PChOT33TnxfAhkTJSFpegHw/qbqlZ6e7ICWI7uWWM3CgXH+nh10JC6qAtOgAdPy0e5sLe8XQKpkgw==;31:f6rkryjT0MQJooYaju3eg9+cszvZJKS/GtHGUOzbLa3HsV7NFZFf2JUyJkX5i+zfcgumHEgJWM8wHewtWELn12P9txE/WvyWqamrBQ1wKmDNIfwQ3wFWsJ5wC/+sK71nraIDadT7dR/4MUsJ/bWJoPQB6qkSub8/XCPUBhfiEELsDRvAL9i5ZyXYJCSonJkYZIOx9ll+ofDxc3r3XRLUoEk+2DQjrWRQV2bc8Ueaasw= X-MS-TrafficTypeDiagnostic: BY2PR12MB0148: Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=brijesh.singh@amd.com; X-Microsoft-Exchange-Diagnostics: 1;BY2PR12MB0148;20:v9fZMzlax4QAuq0sMQQaVn4EEhHpSTZPoDSMwHPa6XDqsA0Ie0qRON8H/6SzRJXJGlXNwZepZjoKj1V7LW5ZRUAdIjnvrVLJGPpZ/1mcFV0t6Dp1I0uDneYnhRfHqX2L+eviVCZwpgHc114FbPuuhWlNinERK1XyR03Zu8cz69Upre56yiZYMp2H83kv2N6L0X8xmIn7dMkCGC+1bGcxTDfChZQTjWUJonXJB5tcDlGKMYlkEr1idyYUwkH0oAgZD6rYTT8FAA3uW8sCN+IxONJ8Gexnj6cH6O/8Z0jekOQ9JrIQa5R7bC+7wWZVEkf6+iDYz+zd+lYo6OnU5Li2+vOTwE4JN8LPY91qKA8HvZd8JkLq2b2OrP3cvB6pndBQ0Ht/2JT5TnE4gO+3pChpcb7BU5920pFLqtGhvECPx+i85FK7PTcskColR4nZ9EoZdNjrBK7yiCHT1VVggtVgtCuVy5rcFfprl4y4Vq9uihIwBvuSNGgha89DltA9ZTu/;4:wLZNtej3TiPJUPC8vh1111qFiv7qLVWWJp9OwBdywyzNzHEtCnW1H/Lt0vUXo9iwJ7FSwBItPdD324/6EIr824W4TLjDzZMI8BIEnXuN0YOdpHPcQmxzDTkglRdxKy6trYGHpSOfRk/TyneDxP5phWkrMW7BiHp6PkjsKC9LLp5OFLCBp4srZ5CXUmyVT0F5SKWQltFQ/RDkBV+uxbZ4W3WyCWJv2nUGMa30wUqgALofo1abCv8F0QzwCCkm4vrS 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)(5005006)(8121501046)(93006095)(93001095)(3002001)(100000703101)(100105400095)(10201501046)(6055026)(6041248)(20161123555025)(20161123562025)(20161123558100)(20161123564025)(20161123560025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:BY2PR12MB0148;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:BY2PR12MB0148; X-Forefront-PRVS: 042957ACD7 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(6009001)(6049001)(376002)(366002)(346002)(39860400002)(199003)(24454002)(189002)(377454003)(51914003)(6666003)(5660300001)(110136004)(4326008)(229853002)(77096006)(6486002)(53546010)(6246003)(2950100002)(6916009)(68736007)(47776003)(316002)(65826007)(31686004)(66066001)(53936002)(65956001)(4001350100001)(33646002)(90366009)(65806001)(189998001)(230700001)(86362001)(106356001)(54356999)(36756003)(54906002)(64126003)(8676002)(2906002)(8936002)(31696002)(81166006)(81156014)(50986999)(83506001)(7736002)(305945005)(25786009)(101416001)(50466002)(478600001)(97736004)(23676002)(3846002)(105586002)(16526017)(76176999)(16576012)(6116002);DIR:OUT;SFP:1101;SCL:1;SRVR:BY2PR12MB0148;H:[10.236.136.62];FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtCWTJQUjEyTUIwMTQ4OzIzOlFRelZwZTV0c1pZWllqbi9meWJON25KbEZz?= =?utf-8?B?WTUyVktQZUlVcmtFVkVjWVlMaUR0M0lNbFZ5MFRQN1o4Nzdoa0lJVjdUaEN2?= =?utf-8?B?U1pnWThheXRvWVVzNWhCUjZoRFZjRmlFUFlSOUhuZ1JqQ2c0Sm9iZmN2am9H?= =?utf-8?B?RlE2Q0QxTlpTSTk3Ym8xWFNQZXE1WGZMamtwamErRk95bTYvbCsxd3hhcWR6?= =?utf-8?B?NGYvU2VVTm51WGJBaWR2bSt5MzhNZ251QzgyNUU1TTl4SGhCY2hrMExYdTNi?= =?utf-8?B?L0hzZXdPSEZ0WVNkRjl2cG8rUXVIcXpGQXVpeGpjRDAxYm02Q2dLaUVETGJs?= =?utf-8?B?SG1Qb29JRjIvMlRyVk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WahlA7UKsBa3Qh8xi4TrFzZdnrSNGN2S12Pe4765weZmHRiGrWSUSdwT36MeZ2FMvZPyQgyRzexV3rjGebA6jRbh+2my3ve3CiX8/lrLnQd++ks6N2Er+9yP1TpyDGKXAzM3XYLtX4/S844Ob3EUCdA3T7t5lT6QPKcs04PtWKwaxZesqGkeZquiWp4iANXBYsN+QJSEuFKoA==;5:FSWKvWi1LDzdI/Iyh1Y5TQneoFl2FBPD4rBL44aFU/ah3Q0Nb++RBPOV03hLxc+zz+OiugbugzIgM2rI1JcennOJGcUkoqhGEPW0ACu3Nie4ZGHxGhf3/qckAxhvcr2rUbp16s4WTS3H16XOtMW3ow==;24:f7ozNI1CmczfQ/aJkxKZTlY5UDaMcAcaZgN5QSVXqca3L2wvFrDPiGLnDllvqgH1LrhRhFDhUAXsYU/hJcq27ZWz5cF/paeBvB08wAyZzv4=;7:lQlTXPyJ9v9Y766fknVCrD7/Gx+haWzIxBQfNeAHkuPjjZva8vft1URkmhjQFGRIOYElFYuY8jcPd4oKN1KuvarDxB54HUHiwRhunNZIuQe+FJl7o3SdSAXJ2nHeH1gCe1/BeOJ3fnzz8mu376keQYOhwc+rUUEu/hAjDybeXE6buN9Xr+XgFMANETF66t2uUIe9Ztp61JD4f0OKN9h3nD0Dv/yRf+NfyFnTjJ++trw= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;BY2PR12MB0148;20:VDoGYeLvfVvs+svGCg9jLyuY3+B2VBQU1OpgoKGGAdZHXcHdpUljB11vLvkmpCg/zED4uqubuQcTIKcUskTPgIDrV+J/FLiGHcEDPF4YKUAztVkPkaAMDosHmaZtmkBD7mnCdpRB6fIds91Jju1uvWXomgl0X1T4+y8+cqJiQ6O+O4ygDx6AwuYIuWalPYG/6wlbecbHzrtpFz1Nf1QB3MRJB42S6MYXU3GNLy6ZTM1gkxctYDCYlUH6pFAZ9mMH X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Sep 2017 16:23:31.0057 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY2PR12MB0148 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 744 Lines: 24 Hi Boris, thanks for the detail review. On 09/13/2017 10:06 AM, Borislav Petkov wrote: ... >> +static int sev_platform_get_state(int *state, int *error) >> +{ >> + int ret; >> + struct sev_data_status *data; >> + >> + data = kzalloc(sizeof(*data), GFP_KERNEL); > > It's a bit silly to do the allocation only for the duration of > sev_platform_status() - just allocate "data" on the stack. > I am okay with moving it on the stack but just to give context why I went in this way. The physical address of data is given to the device (in this case SEV FW). I was not sure if its okay to pass the stack address to the device. Additionally, the FW spec requires us to zero all the fields -- so we need to memset if we allocate it on the stack.