From mboxrd@z Thu Jan  1 00:00:00 1970
Received: from smtp-relay-internal-0.canonical.com (smtp-relay-internal-0.canonical.com [185.125.188.122])
 by mx.groups.io with SMTP id smtpd.web12.8704.1652800770856419991
 for <devel@edk2.groups.io>;
 Tue, 17 May 2022 08:19:31 -0700
Authentication-Results: mx.groups.io;
 dkim=pass header.i=@canonical.com header.s=20210705 header.b=kGNFt0Bh;
 spf=pass (domain: canonical.com, ip: 185.125.188.122, mailfrom: dann.frazier@canonical.com)
Received: from mail-io1-f70.google.com (mail-io1-f70.google.com [209.85.166.70])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256)
	(No client certificate requested)
	by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id B01513F32E
	for <devel@edk2.groups.io>; Tue, 17 May 2022 15:19:26 +0000 (UTC)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com;
	s=20210705; t=1652800766;
	bh=TM4bmB/bB4fNhP9MmSwh8FqL/IJGU8himJZDVP5+NUc=;
	h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version:
	 Content-Type:In-Reply-To;
	b=kGNFt0BhF+PY/SZjCOrp6kHMzB++4/kGXj2Q2wis75i+T4dcEBM/v1DFYAWySo+ZR
	 pQs58NWHL4ZQoah/X1Wvuf5s2LTUsoPc2HSWS3C+8v663QVByCqY9M0WGEvMi6QPy1
	 teJtniYPegotUvBYEdmUhc4WkOm6qYMTIAy0iWtpx2TlxICyg/JTeUqWa9Z8p9WlAV
	 0poh+9fHULa1UBERUqb9JM6J5Rd1HJWxhG9xmbxC6c6WkfZIxnGMvlI0mBJ4uHmXvk
	 dTfG8DqhQ9BZ7+neSQCvXcjS4GsDVU6hKKTL2u7Xfsuq9rt1MskW99Z8fEnGp7iHNQ
	 EAVnjzosJckeQ==
Received: by mail-io1-f70.google.com with SMTP id t1-20020a056602140100b0065393cc1dc3so12591425iov.5
        for <devel@edk2.groups.io>; Tue, 17 May 2022 08:19:26 -0700 (PDT)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20210112;
        h=x-gm-message-state:date:from:to:cc:subject:message-id:references
         :mime-version:content-disposition:in-reply-to;
        bh=TM4bmB/bB4fNhP9MmSwh8FqL/IJGU8himJZDVP5+NUc=;
        b=MZZVX/5AwtTf/HmrpZu2im8oFOWAEEwF0xSDclD6KmXrUBsGYvqbQG7lz3t5BGO21C
         vXfBZAhttpM58ov5F+7ieBRKA2ztdg1imspWRT4AOAsGgewGcOSU00VTpDiJ8RYkkp2c
         LBgeitDqKSFB+8HayXNpdXSBfdc81BnQZsGe0AQtLxfPDTQ8N2FK/5OqcWLK137bnqTc
         KCn71rA/GKKaIk3GLPULwUwWhvVOcyZjfTlJsiUFgY+Y/TYMqFSLCD0/fy+C/+qlj8DM
         5PGrcmCmqBHqFU8NdWORzhhfviM87q5hHsS4Q/za9bPrySkrRKE7w/lwbKTWkYHik0yp
         LFjw==
X-Gm-Message-State: AOAM533kAsS2ms2o0M5DGtfCLNoPnt6UPlrfKfam4tnqagpwylssO6eG
	KKuaMo58l5IxA339i6OtIf+rz0wbXeY10rEslRxLAAWJAjuz+MrF18DuLrU7UH1ik6V8hn1t+3h
	bxLbFh5JJxhkCF0cfZNE2GurD73NxHBY=
X-Received: by 2002:a92:cdae:0:b0:2cf:3d12:abdb with SMTP id g14-20020a92cdae000000b002cf3d12abdbmr11842409ild.162.1652800765273;
        Tue, 17 May 2022 08:19:25 -0700 (PDT)
X-Google-Smtp-Source: ABdhPJxOXBK+bB18sKwnQS7YZPp7Qxl5EiVgwtf4J7iDYaPs8ruFpvR+A3CIdWhZXh/akaQ90qJK0Q==
X-Received: by 2002:a92:cdae:0:b0:2cf:3d12:abdb with SMTP id g14-20020a92cdae000000b002cf3d12abdbmr11842399ild.162.1652800765022;
        Tue, 17 May 2022 08:19:25 -0700 (PDT)
Received: from xps13.dannf (c-73-14-97-161.hsd1.co.comcast.net. [73.14.97.161])
        by smtp.gmail.com with ESMTPSA id o11-20020a02220b000000b0032dd4094580sm3652991jao.49.2022.05.17.08.19.23
        (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
        Tue, 17 May 2022 08:19:23 -0700 (PDT)
Date: Tue, 17 May 2022 09:19:21 -0600
From: "dann frazier" <dann.frazier@canonical.com>
To: Min Xu <min.m.xu@intel.com>
Cc: devel@edk2.groups.io, Erdem Aktas <erdemaktas@google.com>,
	James Bottomley <jejb@linux.ibm.com>,
	Jiewen Yao <jiewen.yao@intel.com>,
	Tom Lendacky <thomas.lendacky@amd.com>
Subject: Re: [PATCH] OvmfPkg/OvmfPkgX64: Use different CcProbeLib when SMM is on or off
Message-ID: <YoO8+YPTdY85mXHT@xps13.dannf>
References: <20220517124314.1021-1-min.m.xu@intel.com>
MIME-Version: 1.0
In-Reply-To: <20220517124314.1021-1-min.m.xu@intel.com>
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

On Tue, May 17, 2022 at 08:43:14PM +0800, Min Xu wrote:
> CcProbeLib is designed to check the vm guest type. The OvmfPkg/CcProbeLib
> reads the OvmfWorkArea (0x80B000) to get the vm guest type which is
> written by each guest (SEV or TDX guest). But in SMM drivers the access
> to OvmfWorkArea is illegal. PiSmmCpuDxeSmm.inf is an example. It uses
> IoLib which in OvmfPkgX64 BaseIoLibIntrinsicSev.inf is included. The
> IoLib probes if the working guest is td guest by calling CcProbe().
> 
> So CcProbeLibNull will be included when SMM_REQUIRE is set. Currently
> only TDVF uses CcProbe to check the guest type, and TDVF doesn't
> support SMM, so this fix has no side-effect.

This is confirmed to fix the issue I reported, thanks!

Tested-by: dann frazier <dann.frazier@canonical.com>

  -dann

> Cc: dann frazier <dann.frazier@canonical.com>
> Cc: Erdem Aktas <erdemaktas@google.com>
> Cc: James Bottomley <jejb@linux.ibm.com>
> Cc: Jiewen Yao <jiewen.yao@intel.com>
> Cc: Tom Lendacky <thomas.lendacky@amd.com>
> Signed-off-by: Min Xu <min.m.xu@intel.com>
> ---
>  OvmfPkg/OvmfPkgX64.dsc | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc
> index 71526bba31..db7f4def7a 100644
> --- a/OvmfPkg/OvmfPkgX64.dsc
> +++ b/OvmfPkg/OvmfPkgX64.dsc
> @@ -171,7 +171,6 @@
>    PciCapLib|OvmfPkg/Library/BasePciCapLib/BasePciCapLib.inf
>    PciCapPciSegmentLib|OvmfPkg/Library/BasePciCapPciSegmentLib/BasePciCapPciSegmentLib.inf
>    PciCapPciIoLib|OvmfPkg/Library/UefiPciCapPciIoLib/UefiPciCapPciIoLib.inf
> -  CcProbeLib|OvmfPkg/Library/CcProbeLib/CcProbeLib.inf
>    IoLib|MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsicSev.inf
>    OemHookStatusCodeLib|MdeModulePkg/Library/OemHookStatusCodeLibNull/OemHookStatusCodeLibNull.inf
>    SerialPortLib|PcAtChipsetPkg/Library/SerialIoLib/SerialIoLib.inf
> @@ -198,6 +197,9 @@
>  
>  !if $(SMM_REQUIRE) == FALSE
>    LockBoxLib|OvmfPkg/Library/LockBoxLib/LockBoxBaseLib.inf
> +  CcProbeLib|OvmfPkg/Library/CcProbeLib/CcProbeLib.inf
> +!else
> +  CcProbeLib|MdePkg/Library/CcProbeLibNull/CcProbeLibNull.inf
>  !endif
>    CustomizedDisplayLib|MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLib.inf
>    FrameBufferBltLib|MdeModulePkg/Library/FrameBufferBltLib/FrameBufferBltLib.inf