From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.158.5]) by mx.groups.io with SMTP id smtpd.web11.5812.1649854532890845735 for ; Wed, 13 Apr 2022 05:55:33 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@ibm.com header.s=pp1 header.b=WfXzTuuA; spf=pass (domain: linux.ibm.com, ip: 148.163.158.5, mailfrom: jejb@linux.ibm.com) Received: from pps.filterd (m0098419.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 23DCODMi004463; Wed, 13 Apr 2022 12:55:11 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=message-id : subject : from : reply-to : to : cc : date : in-reply-to : references : content-type : content-transfer-encoding : mime-version; s=pp1; bh=4gzPwN/Si/FwkhQULHjvpxhESYSwLYT1C9koNG3Gv5E=; b=WfXzTuuAHJzMQVLVuxCYKingQM1kFah93tKF3IV9pih72fF3V8NOYIlF+vrNUI7rbxm2 LJxB7feZUegUwLFOoeNnUA3nXdZkqtGuxbBD6L4YmB4VbiJhYavCQtZxYpRz2nAFjrWp y0VSFllWjluSGpuSIUd3PQUcnrVF4eW+NyoONEqJ9YRqvSvoO9SabewsHlN2BB8SuR+P //RjEehYwfYvWLLZ8HPNCtrpFJ8JZvffGHtXQes1JLtYx+wJ+AjscAEjFEknL3W7yD0O YHWD6P0irNY0aNo8+XEiUZQtACI5dGegLG2cdwn/a0Vv9QCyCpmubyofuhuzp2lKjhDQ jA== Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com with ESMTP id 3fdxg0gm28-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 13 Apr 2022 12:55:10 +0000 Received: from m0098419.ppops.net (m0098419.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 23DCtA65018438; Wed, 13 Apr 2022 12:55:10 GMT Received: from ppma03dal.us.ibm.com (b.bd.3ea9.ip4.static.sl-reverse.com [169.62.189.11]) by mx0b-001b2d01.pphosted.com with ESMTP id 3fdxg0gm1s-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 13 Apr 2022 12:55:10 +0000 Received: from pps.filterd (ppma03dal.us.ibm.com [127.0.0.1]) by ppma03dal.us.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 23DCq6kn031489; Wed, 13 Apr 2022 12:55:09 GMT Received: from b03cxnp08026.gho.boulder.ibm.com (b03cxnp08026.gho.boulder.ibm.com [9.17.130.18]) by ppma03dal.us.ibm.com with ESMTP id 3fb1sa7x9w-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 13 Apr 2022 12:55:09 +0000 Received: from b03ledav004.gho.boulder.ibm.com (b03ledav004.gho.boulder.ibm.com [9.17.130.235]) by b03cxnp08026.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 23DCt8NT24510758 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 13 Apr 2022 12:55:08 GMT Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6DEFA78067; Wed, 13 Apr 2022 12:55:08 +0000 (GMT) Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 324AE78070; Wed, 13 Apr 2022 12:55:07 +0000 (GMT) Received: from lingrow.int.hansenpartnership.com (unknown [9.163.10.46]) by b03ledav004.gho.boulder.ibm.com (Postfix) with ESMTP; Wed, 13 Apr 2022 12:55:07 +0000 (GMT) Message-ID: Subject: Re: [PATCH 0/4] Introduce TdProbe in MdePkg From: "James Bottomley" Reply-To: jejb@linux.ibm.com To: Min Xu , devel@edk2.groups.io Cc: Michael D Kinney , Liming Gao , Zhiguang Liu , Jiewen Yao , Gerd Hoffmann , Brijesh Singh , Erdem Aktas , Tom Lendacky Date: Wed, 13 Apr 2022 08:55:06 -0400 In-Reply-To: References: User-Agent: Evolution 3.34.4 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: 0ztEakujD6GsyMwZe6UrdNNQoucl9Pkt X-Proofpoint-GUID: eXFSLJtFb-kY9bOAwc22iXVgYgasbXSk X-Proofpoint-UnRewURL: 0 URL was un-rewritten MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.858,Hydra:6.0.486,FMLib:17.11.64.514 definitions=2022-04-13_01,2022-04-13_01,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 adultscore=0 malwarescore=0 impostorscore=0 phishscore=0 suspectscore=0 mlxlogscore=999 priorityscore=1501 clxscore=1011 spamscore=0 mlxscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2204130067 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit On Wed, 2022-04-13 at 17:08 +0800, Min Xu wrote: > BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3902 > > Bad IO performance in SEC phase is observed after TDX features was > introduced. (after commit b6b2de884864 - "MdePkg: Support mmio for > Tdx guest in BaseIoLibIntrinsic"). > > This is because IsTdxGuest() will be called in each MMIO operation. > It is trying to cache the result of the probe in the efi data > segment. However, that doesn't work in SEC, because the data segment > is read only (so the write seems to succeed but a read will always > return the original value), leading to us calling TdIsEnabled() check > for every mmio we do, which is causing the slowdown because it's very > expensive. > > TdProbe is introduced in this patch-set. It is called in > BaseIoLibIntrinsicSev instead of IsTdxGuest. There are 2 versions of > the TdProbeLib. Null instance of TdProbe always returns TD_PROBE_NON. > Its OvmfPkg version checks the Ovmf work area to determine the Td > guest type. I tested this out with the TPM code: it restores pretty much all of the lost performance, thanks! Tested-by: James Bottomley James