From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.groups.io with SMTP id smtpd.web09.68456.1661765659885709722 for ; Mon, 29 Aug 2022 02:34:20 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Sgb7dJOW; spf=pass (domain: redhat.com, ip: 170.10.133.124, mailfrom: kraxel@redhat.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1661765658; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=nsgKO9sJJYA/ehXDc4lIaeJOiZfQU2Qv/6fXQXLZ6y4=; b=Sgb7dJOWhis4R2nFiL6ZzyvCflosb/s8W8mRMX67/Goqr5yTF15ZHtmkRW4S2o5ZzSdU/m 1ctRA0CxGoilFimjd0WoTsrUn23EjpO+oWilbMI7Y7fRlQNAXgBZd08YXJP7Kotl99a+gq HyLbPnK2dk1pifyU4OU/Fxcqz0YPhAQ= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-14-GkuuR9LoMGaII1zL5UvJYQ-1; Mon, 29 Aug 2022 05:34:15 -0400 X-MC-Unique: GkuuR9LoMGaII1zL5UvJYQ-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id DB1D43C10140; Mon, 29 Aug 2022 09:34:14 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.195.70]) by smtp.corp.redhat.com (Postfix) with ESMTPS id AB68740B40C7; Mon, 29 Aug 2022 09:34:14 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 4DDEC18000B3; Mon, 29 Aug 2022 11:34:13 +0200 (CEST) Date: Mon, 29 Aug 2022 11:34:13 +0200 From: "Gerd Hoffmann" To: Min Xu Cc: devel@edk2.groups.io, Erdem Aktas , James Bottomley , Jiewen Yao , Tom Lendacky , Yuan Yu Subject: Re: [PATCH V4 0/2] Re-design CcProbeLib Message-ID: <20220829093413.62723ertuipqh3zy@sirius.home.kraxel.org> References: MIME-Version: 1.0 In-Reply-To: X-Scanned-By: MIMEDefang 2.84 on 10.11.54.1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Sat, Aug 27, 2022 at 07:07:06AM +0800, Min Xu wrote: > 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 re-designed 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 global > 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. > > 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 > very frequently. > > Code: https://github.com/mxu9/edk2/tree/CcProbeLib.BZ3974.v4 > > v4 changes: > - Read Cc guest type in both DxeCcProbeLib's constructor and CcProbe. So > that we guarantee the Cc guest type is read early enough. Acked-by: Gerd Hoffmann take care, Gerd