Received: by 2002:a05:6a10:eb17:0:0:0:0 with SMTP id hx23csp921890pxb; Thu, 9 Sep 2021 15:27:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxE08jz7J6K3iErfTPoCng1aQFrGE5lxmzvQfa8ffqP9xIm64U0lpyPnv7ht7TGiBe3Lnay X-Received: by 2002:a92:c0d2:: with SMTP id t18mr4074809ilf.80.1631226444371; Thu, 09 Sep 2021 15:27:24 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1631226444; cv=pass; d=google.com; s=arc-20160816; b=ZYgOMz4/0DGfIi7hxk/4tN7aNvf4FJO9W+weoSg+r2cR8+6tamKwhKNyytihlzsZs5 mzAkYVFEgMagR5EJ+2eC4No+SM0gVGOfl1NfTPkL2pkq+KUytMosSDBaJlE7QYcDSnLP ap0vN9C2erKtaSjB1oyPOXQGKUHcHtDdvKw7/Jv8pSEyyfwJsp330KcR6XmZr8l9EQN0 kENHSKdUYKg6JQ3ZDqoM+x6zqIFcoO67OXfinj8ooIqPvTnZ/q2KJclQ5RDFfK4ZCGqO yenuWA8Cpwc9SRGOJD7uTf2Jn4o1vm48k8V0p7zR7GS5yqcSMdCowIWFrzOucjI9sKe3 zmgA== 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 :content-language:in-reply-to:user-agent:date:message-id:from :references:to:subject:cc:dkim-signature; bh=uhOMDWA+zWGkB7kXYdg1YT7vRYSiz4iRK7fJt9U9sU4=; b=SF5m64Glm/CA8+kEguqp/gxCtCnWU6Q3GjLZGN6hsYkVHR/O3GZT/jgZZWdtDwCh78 pGkdwyHyY35MN9lgiczyGOkfzjRXhOPme1h6WHZF6T8eZTzRPQqWWcB5ZT0WhIeEbDs2 He0OsBH8sXauliBDn61BxhuDCrBNMV30susEAqUHm9O/32UrHo3+bFtTfsAW6qARcQX+ Q6+PoV4Sy0TZZ1YSoIHy3nqmbz1P2wRHJBZ/Ipbrxd6hRJP/sTZ+k4yfeH0YT4vh+VlG XpJ9tYjnlOIsJAu8DOGx9IKC7H2IAdtUVsu0bkj+0wLS40Xg7Dzp6yOdzgCa5b5Yq7Di aAQA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=QYsiZWWV; arc=pass (i=1 spf=pass spfdomain=amd.com dkim=pass dkdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l15si3774535ios.94.2021.09.09.15.27.02; Thu, 09 Sep 2021 15:27:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=QYsiZWWV; arc=pass (i=1 spf=pass spfdomain=amd.com dkim=pass dkdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-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 S1347523AbhIIW0s (ORCPT + 99 others); Thu, 9 Sep 2021 18:26:48 -0400 Received: from mail-dm6nam12on2089.outbound.protection.outlook.com ([40.107.243.89]:53569 "EHLO NAM12-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1346095AbhIIW0l (ORCPT ); Thu, 9 Sep 2021 18:26:41 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IZVbE51TYj0Dht1VBRcJhjkGaKD4mQnvAJFTXcWxq++KQF0ZptD93/rZGL9Q10IBLAvNy7HpkqNxYVbJWPlIhpe4fOr+6qdMq61nHre+NFuHi21bAtCb0EjPM6W8Q899LhNLlKHKDET1+dd4Vw4KptVhAh8jWap8AVuYdlBtRCtxS51d+y5U3LiX28ZmDOS6eFD3ibTnibcjiUzE4jPgQVNkyTCKiDnvmE6Y6uoWywBZUk2DPIQ7ERRk8ve+mCOVvGwHIebX88lP6L/ZECzsQCO2UJEZblX2zHdA261r6WYHI0wOVD+GnZtija2u39NLFbf9W/v8Gg+tCcgONGtR0Q== 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; bh=uhOMDWA+zWGkB7kXYdg1YT7vRYSiz4iRK7fJt9U9sU4=; b=QF0k0A4wFzt75FKD56rpX3uwQvSdYastW5qzIuA8/MVCmpdUbJ611tDDQpXmox8zbQioncZ142/zXOZ+I8hSYjYDTaViwosftA8Qsez/0aAFBwK3ol7hKBn7l97of1AhDFygrR0pzYlSfVaz/3jkN3pkFJWssAw1uhfh4fdhZoot+GRgzyqNxijmT8H/OtSTss8tyS8D1mcEBKjLa3Y+64DcjYY/lJI291fP/OzO6qRg62fpN4AX6GpTsROWIUF+U2angjz32SmKFB3u2H0G0nVlEVN/CjyubUDqebFYTorsnEdDUsBEJph78FkpL187WBtXkak0ZlPD5j4hJ9ujsw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; 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=uhOMDWA+zWGkB7kXYdg1YT7vRYSiz4iRK7fJt9U9sU4=; b=QYsiZWWVl2JxGNprG2Mh980/TGV1PiEwfLRWZ49iSOEPwmDb1/Hb2DmXwAFvB/NRfBJzoRjWQqnq+C4+9h+FQ4cxLeP0PgW6Z3P2x15crxvTXYGZfFUF8Yfi7nPU2bUEBOBLbQI4CaqJ8C5iWDTu54+DZMlov8EwM8BAtslceyw= Received: from SN6PR12MB2718.namprd12.prod.outlook.com (2603:10b6:805:6f::22) by SA0PR12MB4446.namprd12.prod.outlook.com (2603:10b6:806:71::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4500.14; Thu, 9 Sep 2021 22:25:27 +0000 Received: from SN6PR12MB2718.namprd12.prod.outlook.com ([fe80::78b7:7336:d363:9be3]) by SN6PR12MB2718.namprd12.prod.outlook.com ([fe80::78b7:7336:d363:9be3%6]) with mapi id 15.20.4478.027; Thu, 9 Sep 2021 22:25:27 +0000 Cc: brijesh.singh@amd.com, Paolo Bonzini , Tom Lendacky , John Allen , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , kvm , linux-crypto@vger.kernel.org, LKML , Alper Gun , Borislav Petkov , David Rienjes , Marc Orr , Peter Gonda , Vipin Sharma Subject: Re: [PATCH v2 3/4] KVM: SVM: move sev_bind_asid to psp To: Mingwei Zhang , Sean Christopherson References: <20210818053908.1907051-1-mizhang@google.com> <20210818053908.1907051-4-mizhang@google.com> <8421f104-34e8-cc68-1066-be95254af625@amd.com> From: Brijesh Singh Message-ID: <48af420f-20e3-719a-cf5c-e651a176e7c2@amd.com> Date: Thu, 9 Sep 2021 17:25:25 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-ClientProxiedBy: SA9P221CA0007.NAMP221.PROD.OUTLOOK.COM (2603:10b6:806:25::12) To SN6PR12MB2718.namprd12.prod.outlook.com (2603:10b6:805:6f::22) MIME-Version: 1.0 Received: from [10.236.31.95] (165.204.77.1) by SA9P221CA0007.NAMP221.PROD.OUTLOOK.COM (2603:10b6:806:25::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4500.14 via Frontend Transport; Thu, 9 Sep 2021 22:25:26 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 81768016-e884-4e2b-e9a7-08d973e0b979 X-MS-TrafficTypeDiagnostic: SA0PR12MB4446: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:10000; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: dfcZ4quuyysqOFb5MkTDVqkUIgHQw0tASz3dXKGuVdZ/LBhN+vS4eRI03wlBF+sIzEY5K0YHHLjm5vpcF/42KZaEC1WjYN6XSAqQtDKZDBhj5FMGuxWVjxoeCU0cWx9i/iBp98E/0pkcplidWA7ZkcKlyx5OjRJ+SfpfL9+xOJFCm63sVJaw4esiOwkoMNRNA93HVto8yP/56peZRDTFYYi+2iHMVEpR491hHCOhVpK9ghmFU0LSQqGskQLgewlVt1nlF85qju1o41hcy2rC4YH1PYbBPNhHcgLeDLM7dq+yru96vlz9kIHXv1vQ4cZ7c44zqs53p27yp5OPRcFT55bVB937hsKtHXtPuSVj/Uczivk9WoLbJZ99M4SZjs3Irfj5dwNdeWpLMSyAjUaaxD2xqB0SykDf3I+pu+6YLNuLhM6jDT+kd2Uq4BfF2HWx1v0w7k+posfTPCcd5B2DeZewNOagGYNgZ4H7sSR6g5tQ2NHtKGQ0e5vMXTPjfG26O/hRGz8Efe5yW0d60lYeZrSY42VDFcniETlup6re8wC9FtpoUdOnsRRv4D2ihieV6HwP6EipwsED6HPJRHTFmBJKqAR8ckhQVelNLUExPSLqb5mxUDS7VU4F6cYJiAICUFTlLxFIQrb7WcYu+hM8XrCFAtcvONVIqFJShXzjC0lk3gFaGCaEUi+vQHjr/tRFqN3HD1ol8mJQqn/uwciUI55Z6Uez5dlJYfq9bDqPM1JcRo+sBDJAws+m6TxYaFuao6Qfn0bVnGrl6M/dsn/PUQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SN6PR12MB2718.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(136003)(376002)(346002)(39860400002)(366004)(396003)(110136005)(38350700002)(38100700002)(2906002)(31686004)(54906003)(186003)(316002)(16576012)(26005)(44832011)(5660300002)(31696002)(53546011)(66946007)(6486002)(86362001)(8936002)(478600001)(83380400001)(956004)(66556008)(2616005)(66476007)(36756003)(8676002)(4326008)(7416002)(52116002)(45980500001)(43740500002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?Slc1cEtHK1ZQRlZaR1dJV2NEdU56ME5Sem1wR2Z5VjVlWmF6b3J1S2lDTld2?= =?utf-8?B?bGNQOWFFdVRMRHhVSWIrZVQzVW9Db2poM3I1cXZhZDkxb2d1cnVHQ0RDNWFY?= =?utf-8?B?MVVyd09iTjRUYmQxNHpnYW1lLzVFdklNa2dZSzlpU0hOcDR0RGJJRUhtSHkw?= =?utf-8?B?OUt5RUUveUVjU1ZqVDNST09WUFYwQm03cHJ5Y2JiTE1BTUlneFRQcEo5L25r?= =?utf-8?B?cytCQ3gwWWZZVHo3SU5tTEtXd3lOSW13blo4ZW9OUGVtOG5DOWNjVUc4ZWQw?= =?utf-8?B?VmpBMFRULzBhOHFFcGUzLzFWWjNQRWpkTG9NNTNCeExiZWp3OHp4czVxeVBy?= =?utf-8?B?YVNDMnZHMkFDSVRySFVzYm1SYXNGcm80clBkazNsS2N1OC9XWnUxOEUrNDhO?= =?utf-8?B?W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xPMmp6WTEwMWpSc2NV?= =?utf-8?B?dWs1WFc5andBU29xd3QrY1VkV1FVUERxQUQwUk1Pd3RaSEtnS2N2R0lLYUx1?= =?utf-8?B?MXlaYi9SekRyQ3BtclUzaDgxN29EcHhCOW9pQlJXSjVRN1UyNTZyNGwvOGpw?= =?utf-8?B?RE1rRGUvZllLK0d4Y0kvZlcxeHJBVU83ZklTdlcvdzl5VVFOejRlejJnSjNF?= =?utf-8?B?SVhMUWgyaGNoV1dvbnozTC9UQVJtQ0M0RlFZTG1Xd3JFdjVIN3RaQ214NE5h?= =?utf-8?B?U2xLYzFHeTZTejFtOFNiWkZGV2Y4TmVzS3NnZDRaOE56SGI3VjFxajJNcjB2?= =?utf-8?B?czhkZ0QzTXVyS1pOR3FjMWMyYkRqQWhvRUxiY3BHYm1WT1JSY09jMHlmUnRJ?= =?utf-8?B?SHBMN3AyNFNrenY5RCt0UVYvOHZ5MUFBWXhuMmFNUzNqK3ZlOWt3YWhmUUJE?= =?utf-8?Q?ZhGxxmT6yr4/GMCwQD2J6ByUTpWXEkszKGXAzMY?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 81768016-e884-4e2b-e9a7-08d973e0b979 X-MS-Exchange-CrossTenant-AuthSource: SN6PR12MB2718.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Sep 2021 22:25:27.3038 (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: 754I79nke7pkGpLAK51InqJUEwC83wncspoyPo2kyKIKyxpXU3Yx1A3jCOFDkNLydCU3apqRYuQ8JypOjodtSw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR12MB4446 Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org On 9/9/21 4:18 PM, Mingwei Zhang wrote: >>> Most of the address field in the "struct sev_data_*" are physical >>> addressess. The userspace will not be able to populate those fields. >> >> Yeah, that's my biggest hesitation to using struct sev_data_* in the API, it's >> both confusing and gross. But it's also why I think these helpers belong in the >> PSP driver, KVM should not need to know the "on-the-wire" format for communicating >> with the PSP. >> > > Did a simple checking for all struct sev_data_* fields defined in psp-sev.h: thank you for compiling the list, let me add few more at the end of your list (they are part of spec but PSP/KVM does not have support for it). I am also adding SNP specific so that we get a full picture. > > The average argument is roughly 4 (103/27), detailed data appended at > last. In addition, I believe the most used commands would be the > following? > > #data structure name: number of meaningful fields > sev_data_launch_start: 6 > sev_data_activate: 2 > sev_data_decommission: 1 > sev_data_receive_update_data: 7 > sev_data_send_update_vmsa: 7 > sev_data_launch_measure: 3 > sev_data_launch_finish: 1 > sev_data_deactivate: 1 > Once the page copy, and swap in/out is implemented then it will also be frequently used. sev_data_copy: 4 sev_swap_out: 12 sev_swap_in: 7 snp_data_gctx_create: 1 snp_data_activate: 2 snp_data_deactivate: 2 snp_data_decommission: 1 snp_data_launch_start: 6 snp_data_launch_update: 8 snp_data_launch_finish: 6 snp_data_page_move: 4 snp_data_page_swap_out: 8 snp_data_page_swap_in: 8 snp_data_page_reclaim: 2 snp_guest_request: 3 snp_guest_request_ext: 5 > For the above frequently-used command set, the average argument length > is also around 3-4 (28/8) on average, 2.5 as the median. > It averages around 4-5 (51/11) without snp. The good news is with snp the avg is still 4-5 (107/24). Additionally, we also need to pass the sev->fd in each of these functions, which will increase avg to 5-6. > So, from that perspective, I think we should just remove those > sev_data data structures in KVM, since it is more clear to read each > argument. > I believe once we are done with it, will have 5 functions that will need >=8 arguments. I don't know if its acceptable. > In addition, having to construct each sev_data_* structure in KVM code > is also a pain and consumes a lot of irrelevant lines as well. > Maybe I am missing something, aren't those lines will be moved from KVM to PSP driver? I am in full support for restructuring, but lets look at full set of PSP APIs before making the final decision. thanks > #data structure name: number of meaningful fields > sev_data_deactivate: 1 > sev_data_decommission: 1 > sev_data_launch_finish: 1 > sev_data_receive_finish: 1 > sev_data_send_cancel: 1 > sev_data_send_finish: 1 > sev_data_activate: 2 > sev_data_download_firmware: 2 > sev_data_get_id: 2 > sev_data_pek_csr: 2 > sev_data_init: 3 > sev_data_launch_measure: 3 > sev_data_launch_update_data: 3 > sev_data_launch_update_vmsa: 3 > sev_data_attestation_report: 4 > sev_data_dbg: 4 > sev_data_guest_status: 4 > sev_data_pdh_cert_export: 4 > sev_data_pek_cert_import: 4 > sev_data_launch_start: 6 > sev_data_receive_start: 6 > sev_data_launch_secret: 7 > sev_data_receive_update_data: 7 > sev_data_receive_update_vmsa: 7 > sev_data_send_update_data: 7 > sev_data_send_update_vmsa: 7 > sev_data_send_start: 10 >