Received: by 2002:a05:6358:700f:b0:131:369:b2a3 with SMTP id 15csp548735rwo; Tue, 1 Aug 2023 23:35:17 -0700 (PDT) X-Google-Smtp-Source: APBJJlFzYYXKHBrE0PNtBEDSX3E9WptleiivsOw/R5ifV5UoRXa5eGveav3OcG6c3CBoC6n6xQah X-Received: by 2002:a05:6a21:488b:b0:134:7364:a59f with SMTP id av11-20020a056a21488b00b001347364a59fmr16463435pzc.29.1690958116863; Tue, 01 Aug 2023 23:35:16 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1690958116; cv=pass; d=google.com; s=arc-20160816; b=m3U9F383d+eGisvKvurFeLPx5pkAHJsoc8t1AxVXW2tFq+Lqnb+ethzwXfQYvQv0tL hPngKP0SR38Q2PiubXq4Rk9r/6waCFkdgRKQypuywEMbRIFjcplpT+2BUSkeh0+GWp7f NJbp8RVn03Patz2aXuCrzorgr78dgV+zA0TPiHgiyWq2OWZyW8IlFfToaYDzPtxHhXuZ yp5Ghr3EH/BfneEDDlymLf5fExrAM3+7NT/iMMuC2TlppZuQoezLG5K9YyTfJd780zAw z7xyvXbJUOAfEumRIGCK0c0c8SdjO3JRzmXQRxNvNoqN6H1J9OZoPWNX/ErBdS9YpY6V udPg== 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 :in-reply-to:from:references:cc:to:content-language:subject:reply-to :user-agent:date:message-id:dkim-signature; bh=r45NYATVK7KYaXBTwMJ2IYlOAdgYzW+weYoKuvCrwbk=; fh=ARP9F+VCM6FjILGdMZlHkPooWSt8ujhTYBaEU95lEWc=; b=iSx2IJOs39NtaO8Oj1IfqGHusE7+eWlMVlQAIC/+gmA9FgFTyQz+dHp9lmSIuIPy1v 0MIXV8oos3TeIx8sBK78YmcDeIuoR9n4cK2fG1oC6ituDmlFaaX85cxYYLVjQXFq6A4R n5l3frS3XIdQxVAfvmaE8FbcY0L9OdFyda36lWVi9VOHQs3MC5zs1duSps6mQwT1Xs21 OOiTFMSch9kyc/fhciH3Il6YpJk5rAPi2GH+jzcCJfWAqIPjQNId89bQY1Lou0AMNdRW We4g1bRH8+AJohOU/joqOf3+nkrrSSQAAYqD+GVl8E5vagZBHwMAXdcvmJ6PPTB8rbJ/ IqFw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=kw6VCWpq; 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-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b4-20020a056a000a8400b0067de347ee12si10554347pfl.164.2023.08.01.23.35.04; Tue, 01 Aug 2023 23:35:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=kw6VCWpq; 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-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-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 S231387AbjHBEMx (ORCPT + 99 others); Wed, 2 Aug 2023 00:12:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46426 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231766AbjHBEMq (ORCPT ); Wed, 2 Aug 2023 00:12:46 -0400 Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam02on2054.outbound.protection.outlook.com [40.107.95.54]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0A368269A for ; Tue, 1 Aug 2023 21:12:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EzUNIK01L2f4V5sLP1XwkTCERovS6fI15ZekpW85o21PJdMgA+TM/ZPRS1J92vJAANr6t7xG7N2MnkkVXoZ8f72Uu/ayguWtA8gDS1r/SHIV1pM1rcbNoInsjwii7wyi05vAaYUNs9OAx9s5zzN8OXRCZtG+BclDynJ+VUC1DwRLBfBOC7mK61sG6X9AJbLSvqzr5Hy5QjAyKYDQjhDwx7aRrf0obfC0Lht9lqwNPFEX8IZaK6BlFPCt5jOr51YVlTA0kK7i+LCFDNc1Y+d3E7LgR7RiZqG48xiLGMnhENpp65TV4ryL/XgGWxd+dPskNP3jPg+MZbZhaejuaMqBNA== 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:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=r45NYATVK7KYaXBTwMJ2IYlOAdgYzW+weYoKuvCrwbk=; b=H9OzQMg+ZjSx7qjr4T5atpxFNmwy4kW2ts0OBhvXzK005iId3de4c2Xqn5TFQ0soIWuiRLo0rHSdmgLO5NerTq7Z8wflwHzqYU0i/5xXadPgbUIXIm0VunwIp4e664Z2XEK+V+ZUZJl+io5c5cYt9wGl9ajYgBc6ESp+2NMb/Yvs0KzV4HlS43LSN/ZRq3ZrDLmHubJJSwBpuUAI/a9bWd6KJkdUS2O68fhjkVWD8N+0EkT4PcZf1A8zPT2ZqsN/J6GkHVz2wV/cCDifJwHyIvqNnUyOH0bcOa8pj5XlmmI5qiWTIn2TYQXnxIXBidfWQOF/AyYEbEYPAAJDG5iVVA== 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=r45NYATVK7KYaXBTwMJ2IYlOAdgYzW+weYoKuvCrwbk=; b=kw6VCWpqTOF8xdhdaxwM2n1s1W5rqnBfMtzeCtaGtOH0CSYq1PkT7YOh+5GGerWto0S8TtY4Awaj1W0aaD1/64D1czaLf6FQk7litORq6HJ0piHdAl0Q5LLFWC0VH4BsxUIp2mSlLoQQtxR9deBXQqmH0oaYfGh2s7SG+wsGLWI= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com; Received: from DS7PR12MB6309.namprd12.prod.outlook.com (2603:10b6:8:96::19) by CY5PR12MB6059.namprd12.prod.outlook.com (2603:10b6:930:2c::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6631.45; Wed, 2 Aug 2023 04:12:35 +0000 Received: from DS7PR12MB6309.namprd12.prod.outlook.com ([fe80::9ade:451:96c3:7b54]) by DS7PR12MB6309.namprd12.prod.outlook.com ([fe80::9ade:451:96c3:7b54%3]) with mapi id 15.20.6631.042; Wed, 2 Aug 2023 04:12:35 +0000 Message-ID: <100d7145-7307-20fc-2cc9-0c2edd08f3ef@amd.com> Date: Wed, 2 Aug 2023 09:42:22 +0530 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Reply-To: nikunj@amd.com Subject: Re: [PATCH v3 05/14] virt: sev-guest: Add vmpck_id to snp_guest_dev struct Content-Language: en-US To: Tom Lendacky , linux-kernel@vger.kernel.org, x86@kernel.org Cc: bp@alien8.de, dionnaglaze@google.com, pgonda@google.com, seanjc@google.com, pbonzini@redhat.com References: <20230722111909.15166-1-nikunj@amd.com> <20230722111909.15166-6-nikunj@amd.com> <1a4e6652-2e24-955c-5332-da84cced68e4@amd.com> From: "Nikunj A. Dadhania" In-Reply-To: <1a4e6652-2e24-955c-5332-da84cced68e4@amd.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-ClientProxiedBy: PN3PR01CA0137.INDPRD01.PROD.OUTLOOK.COM (2603:1096:c01:bf::14) To DS7PR12MB6309.namprd12.prod.outlook.com (2603:10b6:8:96::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS7PR12MB6309:EE_|CY5PR12MB6059:EE_ X-MS-Office365-Filtering-Correlation-Id: bbfcc3b8-56cc-4372-7206-08db930eb36d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: BBCUC0AGTTIuypaX3Py+b8YKzE44rIfRcZXUVWZq1Xmr8bTqRSm+oRohTcuG51vsu6pQr5n9FIMGmOJw3T/Yxj01g6XfoGjIo9bsY+D3bWMt6z/M+7+Pn06Y4ieZ+bp6rpMTKC1Ov1SGMCYFEID3qUWoyKvZFWTlwylJ3dCuNHlzIu7ay44O+UyBebHMM8VrXkLfgalvxI5orDyfu65H51qNZDLIr1EVcZM25qcGD1zSnhwMpF25dDqu7LlLWd0moISg2S0TOxkQlGWKi0eSgM8R8MhEV0RxDdewJe9UsKNKj7yAc2eqZB7LqA3EHD15o1VWN0wDah4pWjh1VNtmqy+sWn8pGw5brG/M7dHESE0rfGLuH6GIsvfSK6nQqCaD1BltfzdQqFEn3jpSN4cT02rv8ZgC4EdMz5JGNSxQEAIZ9eJhC93/TtPu4Zh5exm1JQmAt1pKwCigxmuwcJTaQPysOBH5jl76JoWLF/jhDsoPVp74RHNP4LKHhaicTvs204Q5wTz/yD8jKrypQmsFV+BNty9yvp/uhFxRB2Pl2qtAsRaYh9EQqdFF/K6NG7CFq213NZWfh091lg8dadlFJtzYYl2Ai8dHOxYr5YlG6uBDAV+8djMxnsPDgrVgCw5/aNmmTs3N8Er7F/QGeCpBKw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DS7PR12MB6309.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(39860400002)(376002)(366004)(136003)(396003)(346002)(451199021)(2616005)(186003)(6512007)(316002)(478600001)(38100700002)(66946007)(66556008)(66476007)(6666004)(6486002)(4326008)(31696002)(6506007)(53546011)(36756003)(41300700001)(26005)(8676002)(5660300002)(3450700001)(8936002)(2906002)(83380400001)(31686004)(43740500002)(45980500001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?Qi9NQSttZFJ2Qng4SEpwMHN5ZjdCdlZtQm1LakZweHpvb2NUTGlybWdjMUJI?= =?utf-8?B?VjFaNVJuMTdzU09CT2pvU01lbmtGSTB5eUZXVVNYYnB2d1RGRFkvTHNieno5?= =?utf-8?B?NGNzdEdCWDQzNjc1SXJTTnMwTmZUdDhCVlhQZkRXdm1kdGxBa3Q1dUtuWWRo?= =?utf-8?B?N2JmYTR6SisxMW9nWlE1VFdHazZvZ2d0S0FmQkVIN2Y4anBSNVNXRFZUM3hL?= =?utf-8?B?cCt2YjFyeTdYWnJtOEZoc2tTd3NFemNQeXIrc3V5TnpSV1ZkMEpodlRkTkJh?= =?utf-8?B?aVdDNi8yWHhObFRhKytVVHpWMGM2dFZrYVMxeFk5OFVkNUtqM0VXaUxxc3Z4?= =?utf-8?B?SWxZZ2p4eHJCalJvMXhUVllMREpVbEwzNFFWYUg1dUpWTVZBZEVRT1IrRDJt?= =?utf-8?B?N0NKcUFRMzZhUEloSUFGcmlwM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12MB6309.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Aug 2023 04:12:35.5954 (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: 2hYiNby4bUi5osPIx71XzU/gkJTKdXvwc5810EYwfYpHFtw8BVBCjOoOvsoN71p02nyFmjGQ1li5+Gkv9vm9Xg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY5PR12MB6059 X-Spam-Status: No, score=-1.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO,NICE_REPLY_A, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 8/1/2023 10:00 PM, Tom Lendacky wrote: > On 7/22/23 06:19, Nikunj A Dadhania wrote: >> Drop vmpck and os_area_msg_seqno pointers so that secret page layout >> does not need to be exposed to the sev-guest driver after the rework. >> Instead, add helper APIs to access vmpck and os_area_msg_seqno when >> needed. >> >> Signed-off-by: Nikunj A Dadhania >> --- >>   drivers/virt/coco/sev-guest/sev-guest.c | 84 +++++++++++++------------ >>   1 file changed, 43 insertions(+), 41 deletions(-) >> >> diff --git a/drivers/virt/coco/sev-guest/sev-guest.c b/drivers/virt/coco/sev-guest/sev-guest.c >> index d4241048b397..8ad43e007d3b 100644 >> --- a/drivers/virt/coco/sev-guest/sev-guest.c >> +++ b/drivers/virt/coco/sev-guest/sev-guest.c >> @@ -50,8 +50,7 @@ struct snp_guest_dev { >>         struct snp_secrets_page_layout *layout; >>       struct snp_req_data input; >> -    u32 *os_area_msg_seqno; >> -    u8 *vmpck; >> +    unsigned int vmpck_id; >>   }; >>     static u32 vmpck_id; >> @@ -67,12 +66,23 @@ static inline unsigned int get_ctx_authsize(struct snp_guest_dev *snp_dev) >>       return 0; >>   } >>   -static bool is_vmpck_empty(struct snp_guest_dev *snp_dev) >> +static inline u8 *snp_get_vmpck(struct snp_guest_dev *snp_dev) >> +{ >> +    return snp_dev->layout->vmpck0 + snp_dev->vmpck_id * VMPCK_KEY_LEN; >> +} >> + >> +static inline u32 *snp_get_os_area_msg_seqno(struct snp_guest_dev *snp_dev) >> +{ >> +    return &snp_dev->layout->os_area.msg_seqno_0 + snp_dev->vmpck_id; >> +} >> + >> +static bool snp_is_vmpck_empty(struct snp_guest_dev *snp_dev) > > I noticed this name change from is_vmpck_empty() to snp_is_vmpck_empty(). Is that in prep for moving, too? Is so, maybe call that out in the commit message. Yes, will add to the commit. > >>   { >>       char zero_key[VMPCK_KEY_LEN] = {0}; >> +    u8 *key = snp_get_vmpck(snp_dev); >>   -    if (snp_dev->vmpck) >> -        return !memcmp(snp_dev->vmpck, zero_key, VMPCK_KEY_LEN); >> +    if (key) >> +        return !memcmp(key, zero_key, VMPCK_KEY_LEN); > > I believe key can't be NULL, so this check isn't required. Sure, will update. Regards Nikunj