From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-f45.google.com (mail-pj1-f45.google.com [209.85.216.45]) by mx.groups.io with SMTP id smtpd.web12.4524.1631585820934683601 for ; Mon, 13 Sep 2021 19:17:01 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@google.com header.s=20210112 header.b=hURIwUs8; spf=pass (domain: google.com, ip: 209.85.216.45, mailfrom: erdemaktas@google.com) Received: by mail-pj1-f45.google.com with SMTP id f11-20020a17090aa78b00b0018e98a7cddaso1545140pjq.4 for ; Mon, 13 Sep 2021 19:17:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Q/e3cNmYC/QmsFj9KzTrxgNTXEd7TeMWTJBsQAPhAZA=; b=hURIwUs86GggvPTIobM8UDsIC1YjnKf6N1MUzHN7/pwrs1/JfdZLTOIpiK0DMI1iSn vwG/Sr/YM71wnlULOjkfoKk50ze4E/U0pOnIHg3z0znm5K0sRZEGljSj5OVJiHnMUsaL QqBu+JRjMT1Ek1wb4uQhGfpM70W0K2kcL+i8ZpXv4sL3kZtBtG5yqaUKGEbUUzWxDqL/ /0p3zSmS9Lnv1OUmOiZXtz1KoeMw5nWS3NYRPmMJxTNyZKmr6nIHD8zXm1gjaB1l7Czw Id8fp6MJDDX3xazmrAB22ow7c6ixM67aPNwGhAoJIPb4kz3w8N26CwYOqPKMwG73ZuPH dhVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Q/e3cNmYC/QmsFj9KzTrxgNTXEd7TeMWTJBsQAPhAZA=; b=xxSyIvNpEA38bvG+bF0SVjpicGnpxr0sTTIpLXqKnvFjmWFUOycJID2DlDLgicUHe3 Y0jm+DeG+Rx94eHwntZcUqyOHWtAonUCR/J9e18UT80JoKkP717MU0negIldksA4pyf0 j/IkJBS6uidlgeoWR2PD5thwhmZpE8+gKkCawTfRhg2WzAIG02bTttkJzozrShxQ7cbC /wff57clH/Dw0u938hAkH5K7zx6rQ4O3pWh2m3kzt0MqPrI5PFKJG8aA5oO1zh6IQHBe xCOSGzmKfuFZ31oSTrRoXdnPNYJaUqiU6hHw2Vn1FIKsLdZJRtwb9xkMCjbteBRaGxzj AFvw== X-Gm-Message-State: AOAM531V0e8MqPnpX0jG/beXwMMOYnAq2K0nuPAhl9/xq6wPYPcx3SoU BSRqJ2KgydCbixgGtCm7mnmPfUWbB4RraSty8vouXg== X-Google-Smtp-Source: ABdhPJwq3B2HMN514bA36gPascbVv0Nzk4wZh4xpiKjTwfI4mRDDa6Gu5DBl9j+nfWTZFaynJDdSlnvzlaHitygACBA= X-Received: by 2002:a17:902:bb10:b0:13a:3cc4:8242 with SMTP id im16-20020a170902bb1000b0013a3cc48242mr13017181plb.58.1631585820097; Mon, 13 Sep 2021 19:17:00 -0700 (PDT) MIME-Version: 1.0 References: <31e974a9ef1ef191a1f76e81fa91047d12ee2169.1628767741.git.min.m.xu@intel.com> In-Reply-To: From: "Erdem Aktas" Date: Tue, 14 Sep 2021 05:16:48 +0300 Message-ID: Subject: Re: [PATCH 03/23] OvmfPkg/ResetVector: Enable Intel TDX in ResetVector of Ovmf To: "Xu, Min M" Cc: edk2-devel-groups-io , Ard Biesheuvel , "Justen, Jordan L" , Brijesh Singh , James Bottomley , "Yao, Jiewen" , Tom Lendacky Content-Type: text/plain; charset="UTF-8" On Mon, Sep 13, 2021 at 9:06 AM Xu, Min M wrote: > > > > +TdxApWait: > > > + cmp byte[TDX_WORK_AREA_PGTBL_READY], 0 > > > + je TdxApWait > > Don't we need memory fence before je TdxApWait. I did not check > > what the compiler generates for this loop. > Below is the code compiler generated for this loop. (VS2017/release) > 106 <1> TdxApWait: > 107 0000070B 803D04B0800000 <1> cmp byte[TDX_WORK_AREA_PGTBL_READY], 0 > 108 00000712 74F7 <1> je TdxApWait > 109 00000714 EB17 <1> jmp ExitInitTdxWorkarea > > This is the code lfence is added. > 106 <1> TdxApWait: > 107 0000070B 803D04B0800000 <1> cmp byte[TDX_WORK_AREA_PGTBL_READY], 0 > 108 00000712 0FAEE8 <1> lfence > 109 00000715 74F4 <1> je TdxApWait > 110 00000717 EB17 <1> jmp ExitInitTdxWorkarea > > I am not sure if lfence is needed. Thanks Min! You are right, I also checked it with GCC5 and saw the same output. Thanks for checking it. -Erdem