Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751932AbdINLZ1 (ORCPT ); Thu, 14 Sep 2017 07:25:27 -0400 Received: from mail-dm3nam03on0066.outbound.protection.outlook.com ([104.47.41.66]:7625 "EHLO NAM03-DM3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751500AbdINLZZ (ORCPT ); Thu, 14 Sep 2017 07:25:25 -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 Subject: Re: [RFC Part2 PATCH v3 19/26] KVM: svm: Add support for SEV GUEST_STATUS command To: Borislav Petkov References: <20170724200303.12197-1-brijesh.singh@amd.com> <20170724200303.12197-20-brijesh.singh@amd.com> <20170914103539.6q3clh3qcynkwgeo@pd.tnic> From: Brijesh Singh Message-ID: <79013520-363b-c180-4169-d77f4f493518@amd.com> Date: Thu, 14 Sep 2017 06:25:17 -0500 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 In-Reply-To: <20170914103539.6q3clh3qcynkwgeo@pd.tnic> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Content-Language: en-US X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: MWHPR10CA0051.namprd10.prod.outlook.com (10.169.238.13) To CY1PR12MB0152.namprd12.prod.outlook.com (10.161.173.22) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 149c6316-19d1-4691-9ef5-08d4fb634a2f 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)(2017052603199)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095);SRVR:CY1PR12MB0152; X-Microsoft-Exchange-Diagnostics: 1;CY1PR12MB0152;3:zCzIuGHoMZgR7x2kX7KqpQ9DHA45XiVGnJmGNwrmdVYCalN8evafh69gVmE5bPj5av9G7NC+hkMquxOa2RZAi5yBvk2Fxny4W26Uqs+C58+as7Na+AALiovYTpLy8lVKSN3LWyoPhjcwtjWjH0PVMdQW/Y9fi26MGVLfu04qQt4cD+ewX7skLZKa9M9OWeATGqQUVLVNUO10xA/oT2o/asQa2pE/so1zWnm00UAdzdUWekk9ND4oH1unbraQ7V6d;25:jsQlkulaQV3wXpQU4ZpgYzgjfQ7DDqN9RlTC5pmwSOW7wRVaV3lBZN8lQhE4lU72yYSJzKQpGMdOSOYVt7aExfUk3PAt/RML+FivU9WfahLGCQOyiMlJUt1pEvVXfLA5JBd/cU/GHDpIkcKOsXu9acqrQcDWmIY0ZiT/7lNSg3Jb790w+2bF9PhI21aPwWNAFTyZRrRyRkVi5xXC8Ju/0Z18tRvP1aEj1MX+AajTnnFLVOl6A1z5Hh0R3JsXok8Xig1RoxWQyzfNEsvZ9Rh9HcL3mnEfznYp7vBv+9BCoOyzZ2DyALRjFgkygCMSS0Ksur0RPL2jWj7zLwZn9tiXwg==;31:LVZEROAaVtjoQEAHfV2Dm3kur4xWz7VpGFxKZwG2hvXR8hpf2D5FVDqJves1KEt1ySVCIMmVPqNHnW+L/Yi/fuuXQye4SKpJof2DpoELzr9xsCVK1vnmQ+NDVXev+hqeLLqismExSKVTUFlvEtbxJu8h43+g/Xj0VmfP6jj6bdIE497NNzlScgm3iqk0TJSq3Q0czVdScZpb33n2i6bzhmUHaRl5kKGE0VJFOmQ0wHU= X-MS-TrafficTypeDiagnostic: CY1PR12MB0152: X-Microsoft-Exchange-Diagnostics: 1;CY1PR12MB0152;20:fzKvE83u0WWJ5GkhwZT2GdmcEVcNE7bzujwL8DjGbtBcgTm+Qb/S2I//TY5NjtDFj2cgXxhkhc0gQ7a6AH/wrXgILOFu6aQ2O8kuT23Zu5YxGO+Mhm1FcEplfoSROz4hG5ow3hfpwStG11eq5pBODUq0/NtM9YPjNEnNTZ0Y/Au4I/joR0TdWoxER2wy6V8SgXaZlBWl1kq20ZqS3IVeF2OK3VYPjHbqwaP1p+FjPh1GWAp2d7Sx8OLV6669OPX3ZhAF8sK9/9UWV9fczuqMCxDRGIHt1mqd8MPCLg4qy3kNkAxSz3fwMOQq2POSAbEwvDf8W/30owntBjgofSZqJdUt1trDxXmZfuPulvELDYuq8H84naes+5JXVxQXrTMVrkKW7bstRQWJdideiH411xu2EIA8XfeBKmOUFFPIrFRdQ1Er1TPLAJU16q6NIhWhSr4JQzOYzLmksbl0F7bS3eHSRB7OeEUlntO4ktdNRrk41DCDipEdMyjcFLSud3Zi;4:YArmbT4xuBL/VFE+qc/NoBZiJfItAx7WKP008vr2noFoso26OAWr3chgoafMGBk2x56DJdeJkCE1sJarLkbQaJPfAqhCwn5TpDHIQPEnnMkYYLfR/+WA21f/L8rpMTjFkDa0UFPMuYhfB8Hw825aWK5Cop/ylBW/oTgYnq91jslh3y+sM29lOwN2x8ZysPDUJjj4R9UxTl+UedjWpS9FVYFJ8O0Dp+k5kn5WGSEqhoIrDafxRoPAIvPewylzXoEX 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)(10201501046)(100000703101)(100105400095)(6055026)(6041248)(20161123555025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123560025)(20161123562025)(20161123558100)(20161123564025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:CY1PR12MB0152;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:CY1PR12MB0152; X-Forefront-PRVS: 0430FA5CB7 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(6009001)(346002)(376002)(377454003)(199003)(24454002)(189002)(305945005)(6246003)(4326008)(110136004)(97736004)(54356999)(76176999)(50986999)(2870700001)(25786009)(53936002)(31686004)(65826007)(189998001)(101416001)(4001350100001)(478600001)(68736007)(2906002)(65806001)(33646002)(65956001)(5660300001)(66066001)(3846002)(47776003)(53416004)(23676002)(54906002)(6116002)(36756003)(105586002)(229853002)(83506001)(53546010)(6486002)(8676002)(7736002)(86362001)(64126003)(6916009)(50466002)(16526017)(316002)(6666003)(106356001)(31696002)(2950100002)(81166006)(8936002)(81156014);DIR:OUT;SFP:1101;SCL:1;SRVR:CY1PR12MB0152;H:wsp094498wss.amd.com;FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtDWTFQUjEyTUIwMTUyOzIzOkJGNGthTytTVG03cjZjQXlTb3lMdVlCdm0y?= =?utf-8?B?c1FqcCt5NTN3d0ZFZTg5UUhKQ0lnbnVDMXdiYTJya3NYenJYaTNjMU9IY3lD?= =?utf-8?B?NENmYUZacmVFOXdhWUNtRnpZOUNqaHhyMkt2QzMrRTRKQnZORkRwb2ZwY2k0?= =?utf-8?B?ZkR6amVKSUtEamlyUFhKdFZZZDExQ3VDeW5YamhIRWQ5Nko3OFIzSkpMT2RX?= =?utf-8?B?TXhOUVUrTU1YNHpyWm1iaStrZG9BWWU2NkliNHZ5bjY3WVFkZml5cUowclUv?= =?utf-8?B?OG51U3dqV2RzeVRaODd6akl1a0ZRMU1zV2xoemJ4ZUd4MVhNVGZUNUdNN1Ey?= =?utf-8?B?YlZXY2tFcTFPOEluYm9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g==;5:W7QfYS6cZPO8NfQEdpX1wh8x48c0zsukwc9hTxvFaSQX3sIs/IyZ7AGXf2oCgzRN2XUpE48NIyELgKJru2yQJ5sHE/v5A6jZUBHI59Gns/x15Vx918J4YeWgfrz3FKCQOqig9cO4Puo08emWzOM9RA==;24:pLdcNboUBcdx8RdKrh+2/gVSkrjGnwPI21MLhn4mQEUHIJzQJE/2v52sxm5Ahkp72fakt2pYUZk95A68xTLQlg0rXIHh2E7Ip2n5HZQJnPM=;7:9hZGK0LTr6p8ff0kWKIDircuJMPUYQ+RxxccNSrGUMgv2iqxddKL1B3NWYKw8IkQkEfftf658GKhhXg8tSkhQ5wia1qfjOWt+sRuUT4Skz6mzymaWqNrsWgbcchbBiP6RbsUCvFcfHFyI2jbGzxEJmvvgGKQeiaagDk31mAuBkvdGW3lTglbPGzN6VM18XnYswaOXCqtdqkeyJPWI/Rv6u+V2DT0Jlkgg9loXen3E5g= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;CY1PR12MB0152;20:cjHcXahOp4gsaLjJ7MmNZAivKrkV6IX3GdBt7L8HNpTffOjj8rA4ZFAVSqf7BMaSD45IcC8civQYEvj32ZWE2MHR7GdXGdfqBzFEMbjKsuDx/y86vmTgVvYqeDeUJfHmNp1L1wuSowf3/2p8fexFsLHvST+f2g++rrROL9G2SEm+s73PM+t1s/KU+6azEgR9qY04yUNGkA45cHqQL5r+Hq3s6Eb/LMaadidkJQTubLu/oB7A6wb8srh+u2qN9pEa X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Sep 2017 11:25:21.6832 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR12MB0152 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1448 Lines: 46 On 9/14/17 5:35 AM, Borislav Petkov wrote: ... > + >> + if (copy_from_user(¶ms, (void *) argp->data, >> + sizeof(struct kvm_sev_guest_status))) > Let me try to understand what's going on here. You copy user data into > params... This is wrong -- since all the parameters in GET_STATUS is "OUT" hence we don't need to perform copy_from_user. I will fix it. thanks > >> + return -EFAULT; >> + >> + data = kzalloc(sizeof(*data), GFP_KERNEL); >> + if (!data) >> + return -ENOMEM; >> + >> + data->handle = sev_get_handle(kvm); >> + ret = sev_issue_cmd(kvm, SEV_CMD_GUEST_STATUS, data, &argp->error); >> + if (ret) >> + goto e_free; >> + >> + params.policy = data->policy; >> + params.state = data->state; >> + params.handle = data->handle; > ... *overwrite* the copied data which means, the copy meant *absolutely* > *nothing* at all! ... > > Also, why does userspace need to know the firmware ->handle? SEV firmware supports key-sharing, if guest policy allows sharing the key between VMs then we need the firmware->handle. If key-sharing feature is used then firmware->handle of the 1st VM will be passed into the LAUNCH_START of  2nd VM.  I still have not coded up anything in qemu for key-sharing and also I am using GET_STATUS command in qemu yet. But wanted to make sure that if we decide to add "info sev-status" command in qemu-monitor to retrieve the SEV state information and then all the information is available to us.