From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (NAM11-CO1-obe.outbound.protection.outlook.com [40.107.220.60]) by mx.groups.io with SMTP id smtpd.web10.629.1631731837292370163 for ; Wed, 15 Sep 2021 11:50:37 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@amd.com header.s=selector1 header.b=CzR12IcJ; spf=permerror, err=parse error for token &{10 18 %{i}._ip.%{h}._ehlo.%{d}._spf.vali.email}: invalid domain name (domain: amd.com, ip: 40.107.220.60, mailfrom: brijesh.singh@amd.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=C9w7v1InuEhtpj0unzuiNbiexDl7rzDcPnYR9WOBSjons9skKcNlMdiJ33eQnyBBqPLzx5VAsrDZOj3gHVazbXwvScbZlZ59TX2xLI6AKfNreoynxxJv+s9UeGLtWELAmtiGeedIukmcHTK1VuBYcgICDjhj6y3ZNbzZ75R50gllFqkjWeu4MgPEHGL2SrEIRpj9OPp0Zh151TMHWRZGkd0BvXbK7WN9lKJsyW8U4TnXXpD5cUWm1k0f0h5W6FmTCCz25Bw04obFzebGnlDGUggjpKaBZkh8y6WG64axNcZ7ounX7P9LZ5uMES+2s/Rz7Ljo7JYPmlh4dcw4CAK2tA== 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=5q9nGzP3f8l4/ZoRDEdpQjDKe2UNyHXrEYAu7eROMQY=; b=YqXoG3cZQsOQ1QlXQvJjA0xk1ZGzRdVQKLMQ1F2PMm67FEbzDPcPouincL2ZgszyxUhr0g0JHn4gD1zqtqfyjQ7hBCgPwamsZOqQcJj5Smf19RTtxoLeKTmJFNRp7V4fXDHBR0TliovZIu/SACcEf62JgRgRJxkgW7n08hFIB7/bNJ+BGsqAr3F4UYESor48/UCNvI2Y2aaReX12GY4eNg2rwd0PBcKwqaU6h65up1T8UsTiGMCx6TuE7QnBK4di5Ror0yNTpDmCW75+rd6e6Shdo+vMG3u9JvOEzI1dehAq1KJl2pzSxDzB1YkSvLG1H0D2y6YxkF9AEBxA0eOvTQ== 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=5q9nGzP3f8l4/ZoRDEdpQjDKe2UNyHXrEYAu7eROMQY=; b=CzR12IcJ8XmhBrpe+LgYrfspjrFOWTuHr5BzSpqnkzNnMwNOlGWGvgo01L9cc68xQCvE2YPMQyel2CZbk1FKRUQ5N6ahDxbbqJuYrs+oeIRnn1qMdo59RKOcw3NUgFFyM8uPskv6Rf7yUHn1JhiCSrKCZZoXbFyhXglfAcGHksk= Authentication-Results: redhat.com; dkim=none (message not signed) header.d=none;redhat.com; dmarc=none action=none header.from=amd.com; Received: from SN6PR12MB2718.namprd12.prod.outlook.com (2603:10b6:805:6f::22) by SN6PR12MB2687.namprd12.prod.outlook.com (2603:10b6:805:73::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4500.18; Wed, 15 Sep 2021 18:50:35 +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.4500.019; Wed, 15 Sep 2021 18:50:35 +0000 Cc: brijesh.singh@amd.com, edk2-devel-groups-io , James Bottomley , Min Xu , Jiewen Yao , Tom Lendacky , Jordan Justen , Ard Biesheuvel , Michael Roth , Gerd Hoffmann Subject: Re: [PATCH v7 09/31] OvmfPkg/SecMain: register GHCB gpa for the SEV-SNP guest To: Erdem Aktas References: <20210913181941.23405-1-brijesh.singh@amd.com> <20210913181941.23405-10-brijesh.singh@amd.com> From: "Brijesh Singh" Message-ID: <700b230a-88d0-2174-7235-6c633f2affac@amd.com> Date: Wed, 15 Sep 2021 13:50:34 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 In-Reply-To: X-ClientProxiedBy: SN6PR08CA0004.namprd08.prod.outlook.com (2603:10b6:805:66::17) To SN6PR12MB2718.namprd12.prod.outlook.com (2603:10b6:805:6f::22) Return-Path: brijesh.singh@amd.com MIME-Version: 1.0 Received: from [10.236.31.95] (165.204.77.1) by SN6PR08CA0004.namprd08.prod.outlook.com (2603:10b6:805:66::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4523.14 via Frontend Transport; Wed, 15 Sep 2021 18:50:34 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 0b28ca05-ebfa-4e94-deca-08d97879b3d1 X-MS-TrafficTypeDiagnostic: SN6PR12MB2687: 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: 4J0uhv6IeSBTMZYORvhz26Bee8VIE5pL8V0HQzdTlqoVPkVNFsr+5fk+vihkl1f9DvBLOBQbNHhIofzrJpG0usFyDtmN9kKDBlElpPSMGG/DkDF4YLeJNzHl8u0Jt3eJI290KsYn6UB426RGWC01Cu+DNDw8iprgqVUhh+05y2mkP4mau6ho12V+zft0zxahXyNgnsN7ZZgi0Z/RPpwRWvEzEmGzPphBgEraIt7MxtKUbLjA4n1r4F8Z5P2jqiE/u5u9jUWoTVKS+p3KX3NPzfkEVNgN98jmXKwVsX3AVvkpkODOOexdxH7X3auI5I+IMYjhBxcFLlcmcXvlI1qPB/XfcwvcjtKCsC0cYGvHg5puWR+s9VFhIKWSDziV5qf9lAhULm35x2K+Jficbms6oIiquTSb197+A8MCj0XLtCICQc0HWRuTDWJ0c4+Bi5xGNLZRu8yneIuNIBUiBmmYndGzVYkhNK4vBgNw8c3CXtoV53GhkvdOWCavzcWIy9MJkXRtZP+F75isXNxdv02wl/Nj1QSVUDy4cBtnOApYY0/X/UQNsOGoAFQxsis4iYbyohdrjwhdDutZN2i2+8VVDIbndgj4BuuaVSOtDv8sOHFdZKuvg4moV1CAGqWNrzt2+UMpi1tOKswLDBUVAsnbsicTDDdNjKJbRIv0JYX/MeW2qBIFwpojNMBNfVnuseQENOG4yIEkqP8nAekEwlXiPlU+ByYNhD76uqydFycfpCidjeiSQiryubt00q6QtvPbzgZpgCTZ6JyaZ/wgR9L+MA== 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)(346002)(366004)(376002)(136003)(396003)(39860400002)(53546011)(52116002)(2906002)(478600001)(31686004)(44832011)(186003)(38350700002)(54906003)(6916009)(31696002)(2616005)(956004)(4326008)(8936002)(86362001)(8676002)(66476007)(36756003)(6486002)(66556008)(83380400001)(26005)(16576012)(66946007)(5660300002)(316002)(38100700002)(45980500001)(43740500002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?SjN1WG1QMnd4b0FuQll1MFRORFVSdUhsUDVyUDBKS1B1cVBpa1d0WmZDWXd2?= =?utf-8?B?NVh5ZEJicnVuQWtmNDQ2MnBZTDVxQk5ibEhNT0VlM1BaMnVUVWluZmoxbk5z?= =?utf-8?B?TVg1c2RSOUVsTit2emljOHBERHRBYnJ1b3pmdEFBVXRvQkR6d3RaS1FsL3F1?= =?utf-8?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?utf-8?B?WDM5NGUwbkdQVGxHdW4zQWs5Mis2OGwxbTQvaFBPNWE0dWlORDArdlFzUjRh?= =?utf-8?B?a2lGR2xybnNYTUFqdHRobHE4THJjd3NwV2x5L1JNdUFRWk14bldSVUVrVDhx?= =?utf-8?B?NVdoMnhObGhVQzhPbmtZWW1wd05DalFXYWpnOHQvd1VuS0NBN2hYcWNsdFBT?= =?utf-8?B?b1ZWQnI4Y1Y1S2VHL2RsS21EUWF5Ulh1UUlsbU9RZ2J5dDhuKzV5dFNubDNL?= =?utf-8?B?ditiTVB5WVdEMStuVmpraHEvaUtBNGVMdkVIUldjUnNzT0hIbmM0SVZ0UU5L?= =?utf-8?B?SGplUm43UFpGZ2t0eE94WTVBV0ZyVmY0TFc4ckxwTE4rZWdQSmJRYXJ2QkUz?= =?utf-8?B?bXZOMkozUmZmOTdRei81aCtGcXF4dmFuZ0pFSERqV3hFdDlVZC9lZU1tTjZp?= =?utf-8?B?eVNNRDRVRUtScjNGR0RiTUdpcVNid0d6cHVyeTA2TWF1dGNyeVByMnE4VzNl?= =?utf-8?B?dWtPS0c1K0tPeDd0VmlKeHhndFhkUlFrZTIxNXhOWndMbUdRU0g3QW4xWEU2?= =?utf-8?B?RmVJaUdhK0lCVndpcGlBUG5mZzBRWHhrZ0Frc0dic1ppVEp3ZnpxaTI2NjZI?= =?utf-8?B?SkIxSzlzT1hZNW9nd0hoanRRRWQ1dkZFTFpVZHV2VU1QWitrOEVPa2c4UW1B?= =?utf-8?Q?P/2HzW7V1qVrtGMmMrthb+znvqd5Fgr01izxbQG?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0b28ca05-ebfa-4e94-deca-08d97879b3d1 X-MS-Exchange-CrossTenant-AuthSource: SN6PR12MB2718.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Sep 2021 18:50:35.4656 (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: 3I5//WomunGeHxiQ7JB7zZNVHXGbCOwatlpmYoii9tJE7adfz4F+F8ZR0PjqZMPx98mSHVKBJgOzWk47YFq5JA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR12MB2687 Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit On 9/15/21 12:08 PM, Erdem Aktas wrote: > On Mon, Sep 13, 2021 at 9:20 PM Brijesh Singh wrote: >> +*/ >> +STATIC >> +VOID >> +SevSnpGhcbRegister ( >> + UINTN Address >> + ) >> +{ >> + MSR_SEV_ES_GHCB_REGISTER Msr; >> + MSR_SEV_ES_GHCB_REGISTER CurrentMsr; >> + EFI_PHYSICAL_ADDRESS GuestFrameNumber; >> + >> + GuestFrameNumber = Address >> EFI_PAGE_SHIFT; >> + >> + // >> + // Save the current MSR Value >> + // >> + CurrentMsr.GhcbPhysicalAddress = AsmReadMsr64 (MSR_SEV_ES_GHCB); > > We are backing the current MSR value but when was it initialized > before ? Also is not this function supposed to set the Address as the > GHCB address? If it is, do we care about the old value? > Good point, there is no reason to read and restore the old GHCB, I will remove it in next version. The function does not set this as a GHCB address, it send request to hypervisor saying that it would like to use this address. If hypervisor is not okay with the address then it may recommend something else. We don't support working with the hypervisor preferred address. Setting the GHCB address code is common between Snp and Es but checking with hypervisor whether its okay to use is new in the GHCBv2 and is SNP specific. > >> + // Restore the MSR >> + // >> + AsmWriteMsr64 (MSR_SEV_ES_GHCB, CurrentMsr.GhcbPhysicalAddress); > > Why are we restoring the old value? I may have misunderstood but I > thought this function will set Address as the new GHCB address? > > Thanks > -Erdem >