From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.groups.io with SMTP id smtpd.web11.186.1635862108160388577 for ; Tue, 02 Nov 2021 07:08:28 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=WcHAV6Lk; spf=pass (domain: redhat.com, ip: 216.205.24.124, mailfrom: kraxel@redhat.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1635862107; 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=b7+clQJAY+Go7kdpEOJPYWJhg12r4XzhpSFGo5NMPOM=; b=WcHAV6LkeD3vrxua1zk3dwKcitknQs6x3fvLLBYgYB1LBKSoaEVeW7RwfdpLshMawPlCsK oONH+W2ahyORBVeYENYTl4bnk1pVnJl8lqKbLbjSSp7e3P/8QhQfoP59IpW7s3OMC6YL0M yVSMTXHpTPWUFwzzEpjygwkfopKYI6Q= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-587-RG07Qr3cNe2OmfPh6FYVxg-1; Tue, 02 Nov 2021 10:08:24 -0400 X-MC-Unique: RG07Qr3cNe2OmfPh6FYVxg-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B0B7019200C0; Tue, 2 Nov 2021 14:06:46 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.194.99]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1AB0A6C8F7; Tue, 2 Nov 2021 14:06:46 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 27463180092D; Tue, 2 Nov 2021 15:06:43 +0100 (CET) Date: Tue, 2 Nov 2021 15:06:43 +0100 From: "Gerd Hoffmann" To: Min Xu Cc: devel@edk2.groups.io, Michael D Kinney , Liming Gao , Zhiguang Liu , Brijesh Singh , Erdem Aktas , James Bottomley , Jiewen Yao , Tom Lendacky Subject: Re: [PATCH V3 02/29] MdePkg: Add TdxLib to wrap Tdx operations Message-ID: <20211102140643.7ok6qaidrau7cn6e@sirius.home.kraxel.org> References: <232162e8ee92888f7ac9795ee9baa331ea39c613.1635769996.git.min.m.xu@intel.com> MIME-Version: 1.0 In-Reply-To: <232162e8ee92888f7ac9795ee9baa331ea39c613.1635769996.git.min.m.xu@intel.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kraxel@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Hi, > +UINT64 mTdSharedPageMask = 0; > +UINT32 mTdMaxVCpuNum = 0; > +UINT32 mTdVCpuNum = 0; > +UINT64 > +EFIAPI > +TdSharedPageMask ( > + VOID > + ) > +{ > + UINT64 Status; > + UINT8 Gpaw; > + TD_RETURN_DATA TdReturnData; > + > + if (mTdSharedPageMask != 0) { > + return mTdSharedPageMask; > + } Small possible optimization: you can cache the whole TD_RETURN_DATA struct instead of the three extracted values, then ... > + Status = TdCall (TDCALL_TDINFO, 0, 0, 0, &TdReturnData); > + ASSERT (Status == TDX_EXIT_REASON_SUCCESS); ... you need a single TDCALL_TDINFO call only. > + tdcall > + > + ; Panic if TDCALL reports failure. > + test rax, rax > + jnz .no_return_data > +.panic: > + ud2 Comment doesn't match code. jnz .panic ? take care, Gerd