From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (NAM12-MW2-obe.outbound.protection.outlook.com [40.107.244.86]) by mx.groups.io with SMTP id smtpd.web08.70722.1661780215769326053 for ; Mon, 29 Aug 2022 06:36:56 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@amd.com header.s=selector1 header.b=Dpq+t88y; 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.244.86, mailfrom: thomas.lendacky@amd.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dRYWs/9xyaSZZqdBiD2SLTxy+39lLDSNW0fx2YLNlEa5Egbd2fKlr/Q2joKDiKkfDmWIZBANAQPCJ/XRSUydYxAfqt2cAOtgVYcCwWzb0zLc59++p4Kwu4XYfVQOiVU2ShyZSDEOhU2MSiV16XmsjxbWBSrcB+rc9z7IusACt5H+HAEuVNkd5dAiyUto3MTlOW8QrZ4LST9y9pOkf+tKUd5MkYSCjimCB4zU9s+soc0wqkecNHNq4MXtZxdwOXxEB4cj6UU1oMqYex8rIa2hXeq3QVPLJtBAQV7cZpeyaxz15Zco+Wd6QNsdo2E+klkISpCC2wOcVe1RhWVB15ky6w== 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=5r75aL6EDFUMMFSRYn4wNeosSWDhJpi1T5ACH38bdBk=; b=cyOL7ndwKHhnKAdG/avPwttiljxkjiOe8KJ4MgS3bSqvcCU/Cl/m6Ixj2yXgpXnRiBZob4njrBjf4xHzbOI0SFe/VZCC6OFJDiU0X6VKqZzwBwHImLjIbvpTOb1leAFpbH8CA2SDyhJkxnR6jRow19O9Bm4dpoS8wWuNIJXATYt46H1Qyy2h78gYjPOMS8bLZwc1ySfAoBnrjveV/DNwX5qGxfAqhmGqjVP4rkoYUnd6Pzy/RuUejbdzCImp/Xknns6Q/SogboFJciov43Jhgzq3dlZo78RI/XOM8wnmIzf/J1zXrc/jgaEbUJXAxcIQ+OGK1RquzxjkSjuQ+1Tr1g== 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=5r75aL6EDFUMMFSRYn4wNeosSWDhJpi1T5ACH38bdBk=; b=Dpq+t88yNADYv4lnwT2OIRhib/kTlEcrF7YCekYd+K80yr5X4aQYrJq1tKoIXofAWqmFci7K4foI0xcRY6qX8bo16E/88Qjqi+h7aVwsOrmILXoXMBG+4U7bf9xfcyuAbIblajtlZQARwPm9l+n9HQ8qlojhHSzUfwFQERebquI= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com; Received: from DM4PR12MB5229.namprd12.prod.outlook.com (2603:10b6:5:398::12) by CH0PR12MB5028.namprd12.prod.outlook.com (2603:10b6:610:e3::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5566.15; Mon, 29 Aug 2022 13:36:53 +0000 Received: from DM4PR12MB5229.namprd12.prod.outlook.com ([fe80::c175:4c:c0d:1396]) by DM4PR12MB5229.namprd12.prod.outlook.com ([fe80::c175:4c:c0d:1396%4]) with mapi id 15.20.5566.021; Mon, 29 Aug 2022 13:36:53 +0000 Message-ID: Date: Mon, 29 Aug 2022 08:36:51 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Subject: Re: [PATCH V4 2/2] OvmfPkg: Update CcProbeLib to DxeCcProbeLib To: Min Xu , devel@edk2.groups.io Cc: Gerd Hoffmann , Erdem Aktas , James Bottomley , Jiewen Yao References: From: "Lendacky, Thomas" In-Reply-To: X-ClientProxiedBy: BL1P221CA0012.NAMP221.PROD.OUTLOOK.COM (2603:10b6:208:2c5::6) To DM4PR12MB5229.namprd12.prod.outlook.com (2603:10b6:5:398::12) Return-Path: Thomas.Lendacky@amd.com MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: abbefbd6-228a-4d6a-b131-08da89c38900 X-MS-TrafficTypeDiagnostic: CH0PR12MB5028:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: S1dU8QawMkLybjkcVo0jlqvscP0bg9T0nxK4UM/wuThN9xDRnZqHOq2YYFsBFtqW+Ma5aVnSC2nmmw9y+SamneFfOx+jGcdzylRiY8yGd09VFyNZ5t2XiXANr/WPRDO/IrOWyEuaWk0TpZB/TwH8sXGGEnE/SI490MyJS9ugeFKFgfBt4jxsPJZ3SZGgIIaA01jFMhUdbRuFybTNsJzY4P5DzcKdT1Ynoj+luXjHezJoQvwd3g7u/EZQxfX3AwTvx6Xv9WeZLqNXxcrR5TnN1B+aMYUOg49dsYDtWqNm/Molf1bnjKoMg/Wjx9SJfpNuH9xSTz8Ici5ZS1sz4Ttqamr8ctKijpGPhDCqUnTw/GJ4Cj9VxWrNu09uWyMENPz6g404Tff3MH3hrAtKoP11ID0pHFrGdyQ8ri4ob3AvbhpLkXTb+3N63yaE7Nn/5aXuq/mDPD6dVYrkB+2zpNYOGJT6L/jeqRPDkbV8Utz+by8lNnCmYXs/TZrUhRGNXm8DuByxVEIgRXE+Ehe8L2rpqDFTTRoVzGITLyBNN4TtMDstcLDxZna96Cg8kgnp9LYTypTxmL8VMEvLwFBCIP4Nrr92MGOgR1byWwXiRyROqzVKMElUxfCzwrfT39U5Y3yZcj1TzJX0ACkyGt9Z08BgUI+y0qi7ZkyP9U47OLPS4baYdTF5cL+IjxXWs23OiCIi4lSNGgXruvnRrcQMEAfpLr/A1VI5CqXwSz3qiHc/JmyvodyU0OXY3Ikpx/SIE7ooXeFyt5qdmqxwepykFXm+VjvVJBrnnaWKUm/699lrMrnotlMFPEqh5JfLvLw+iLg73U3ujPwOUa4VMsTBT+oo5w== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM4PR12MB5229.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230016)(6029001)(4636009)(346002)(366004)(396003)(39860400002)(376002)(136003)(6506007)(38100700002)(53546011)(83380400001)(2906002)(2616005)(6512007)(186003)(8676002)(6486002)(4326008)(86362001)(66476007)(66556008)(31696002)(66946007)(316002)(31686004)(26005)(966005)(54906003)(36756003)(41300700001)(8936002)(478600001)(5660300002)(43740500002)(45980500001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?dFNYUnNUQUdqUDlKNHczamVBaHZmOVp5eitFaU16VzRKOHFLTWpLTUpOZ0JC?= =?utf-8?B?aTVDcDNody9raG91U2NnL3N1ejlHcW9SalVMYnNFc3ozSzFQMm84MUZFdTBK?= =?utf-8?B?MTJSTWNLR1I0b25GSDE3MGx5Z3BIU0VBb0k0YldrTG1HQW1VSC9iVm9reVJB?= =?utf-8?B?cmJsNkNvdFRWcWdSc3hFKzZtcGM0ZlE0NXdheUl1UTNGbTdQbFM3dHJxUWJ5?= =?utf-8?B?SmRGVFZiUTBGMlJ3K2ZjVHJ5Vk02QmZYM1NKRjdxMmgyQU52ejlCRTFHS0x0?= =?utf-8?B?dUlkbFE3R1IwQTFHRVJNbFpOL0JPbDdFKzhOUjdKdVFIOUcvbzkwendZbDNL?= =?utf-8?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d.com X-MS-Exchange-CrossTenant-Network-Message-Id: abbefbd6-228a-4d6a-b131-08da89c38900 X-MS-Exchange-CrossTenant-AuthSource: DM4PR12MB5229.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Aug 2022 13:36:53.8060 (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: ivB9zvEg1ceoY//UF3aBLp6S6EO0wGreJ7ekPJ+UUtB5aOWFiI+beP3GsC1SKhM+/+U1rpKtNAO4rhbUzOThjw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR12MB5028 Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 8/26/22 18:07, Min Xu wrote: > From: Min M Xu > > BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3974 > > CcProbeLib once was designed to probe the Confidential Computing guest > type by checking the PcdOvmfWorkArea. But this memory is allocated with > either EfiACPIMemoryNVS or EfiBootServicesData. It cannot be accessed > after ExitBootService. Please see the detailed analysis in BZ#3974. > > To fix this issue, CcProbeLib is redesigned as 2 implementation: > - SecPeiCcProbeLib > - DxeCcProbeLib > > In SecPeiCcProbeLib we check the CC guest type by reading the > PcdOvmfWorkArea. Because it is used in SEC / PEI and we don't worry about > the issues in BZ#3974. > > In DxeCcProbeLib we cache the GuestType in Ovmf work area in a variable. > After that the Guest type is returned with the cached value. So that we > don't need to worry about the access to Ovmf work area after > ExitBootService. > > To gurantee the GuestType is cached, we read the value in both s/gurantee/guarantee/ > constructor and CcProbe. Because in some corner case, the constructor > may be called after CcProbe. For example in MdeModulePkg/Core/Dxe/DxeMain, > BaseDebugLibSerialPortConstructor is called before > DxeCcProbeLibConstructor. While CcProbe () is called in > BaseDebugLibSerialPortConstructor. Is there a way to put some kind of ordering in place so that CcProbe's constructor is called before BaseDebugLibSerialPortConstructor? > > The reason why we probe CC guest type in 2 different ways is the global > varialbe. Global variable cannot be used in SEC/PEI and CcProbe is called s/varialbe/variable/ Thanks, Tom > very frequently. > > Cc: Gerd Hoffmann > Cc: Erdem Aktas > Cc: James Bottomley > Cc: Jiewen Yao > Cc: Tom Lendacky > Signed-off-by: Min Xu > ---