From nobody Mon Feb 9 10:58:34 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+87968+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+87968+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1648080744; cv=none; d=zohomail.com; s=zohoarc; b=a2UKBIBDYlSgKxR39eKpKQF5fvz0Fq6fTF3VUwmZKs6ZcWKpUrFmTQNGYSHikFyJ5imQq51wpYWUiQd/PndWOPEn8Bq3mM+23xF5fO1L4t/8JPivmlpWDx1oYpFOUgHdNPda+dxaqfiK+kyQF5tTv8XMMkfsQFOFp40NuyB3oBQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1648080744; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=C0PHyFWm1K2mF4T4IBAyD38rMvLBtgxedbTB1KtOkN4=; b=EiUAMAHEjWawQ7K/035JrIm3C0l+UjKH7Gi4izeOZfz11CgW5OGt7FBsgXi6B9rvmHmXL5Z6UUVULgLvAgP9bVj3wAfpv64kcKpEYUSbWoYeiMbMrjw0d399cJlfPzwPNubGZhi7Ev29QYDnyLKzQzQchligu1i0PVzRB4MspvI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+87968+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1648080744507389.6924996842314; Wed, 23 Mar 2022 17:12:24 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id zM7RYY1788612x8sghapz4bO; Wed, 23 Mar 2022 17:12:24 -0700 X-Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by mx.groups.io with SMTP id smtpd.web09.4779.1648080680578717265 for ; Wed, 23 Mar 2022 17:12:23 -0700 X-IronPort-AV: E=McAfee;i="6200,9189,10295"; a="258207674" X-IronPort-AV: E=Sophos;i="5.90,205,1643702400"; d="scan'208";a="258207674" X-Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Mar 2022 17:12:23 -0700 X-IronPort-AV: E=Sophos;i="5.90,205,1643702400"; d="scan'208";a="649651434" X-Received: from mxu9-mobl1.ccr.corp.intel.com ([10.255.31.90]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Mar 2022 17:12:20 -0700 From: "Min Xu" To: devel@edk2.groups.io Cc: Min Xu , Ard Biesheuvel , Jordan Justen , Brijesh Singh , Erdem Aktas , James Bottomley , Jiewen Yao , Tom Lendacky , Gerd Hoffmann Subject: [edk2-devel] [PATCH V10 32/47] OvmfPkg/Sec: Declare local variable as volatile in SecCoreStartupWithStack Date: Thu, 24 Mar 2022 08:10:18 +0800 Message-Id: <20220324001033.1169-33-min.m.xu@intel.com> In-Reply-To: <20220324001033.1169-1-min.m.xu@intel.com> References: <20220324001033.1169-1-min.m.xu@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,min.m.xu@intel.com X-Gm-Message-State: hB6ikzwmmDW3xrcdKHtzoC6Px1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1648080744; bh=qvjYUOcIE+qz97yPCa0D2ZLZKuaOU9u6r1mSuNjs9tU=; h=Cc:Date:From:Reply-To:Subject:To; b=r1qY/vl3qwIsfbYNKGPM4mhV6ca7oygefgkNOVK/tu7/qxKE5JsERkHFLNbVUBzk6d4 XlEGqoqZDRYn+FNgsoerEOcSPKgyd2W6ZI7RDwtDKMiuWnwOcUKsKawMSqmGEd+QENtEm VwFJPVjjhdYJdkEiBnu9MApUdyJC1bBmkaY= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1648080746185100012 Content-Type: text/plain; charset="utf-8" RFC: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3429 Declare the local variables in SecCoreStartupWithStack that actually move the data elements as volatile to prevent the optimizer from replacing this function with the intrinsic memcpy(). Cc: Ard Biesheuvel Cc: Jordan Justen Cc: Brijesh Singh Cc: Erdem Aktas Cc: James Bottomley Cc: Jiewen Yao Cc: Tom Lendacky Cc: Gerd Hoffmann Acked-by: Gerd Hoffmann Signed-off-by: Min Xu --- OvmfPkg/Sec/SecMain.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/OvmfPkg/Sec/SecMain.c b/OvmfPkg/Sec/SecMain.c index 2c5561661ef3..02520e25ab9a 100644 --- a/OvmfPkg/Sec/SecMain.c +++ b/OvmfPkg/Sec/SecMain.c @@ -757,12 +757,17 @@ SecCoreStartupWithStack ( // IdtTableInStack.PeiService =3D NULL; for (Index =3D 0; Index < SEC_IDT_ENTRY_COUNT; Index++) { - UINT8 *Src; - UINT8 *Dst; - UINTN Byte; + // + // Declare the local variables that actually move the data elements as + // volatile to prevent the optimizer from replacing this function with + // the intrinsic memcpy() + // + CONST UINT8 *Src; + volatile UINT8 *Dst; + UINTN Byte; =20 - Src =3D (UINT8 *)&mIdtEntryTemplate; - Dst =3D (UINT8 *)&IdtTableInStack.IdtTable[Index]; + Src =3D (CONST UINT8 *)&mIdtEntryTemplate; + Dst =3D (volatile UINT8 *)&IdtTableInStack.IdtTable[Index]; for (Byte =3D 0; Byte < sizeof (mIdtEntryTemplate); Byte++) { Dst[Byte] =3D Src[Byte]; } --=20 2.29.2.windows.2 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#87968): https://edk2.groups.io/g/devel/message/87968 Mute This Topic: https://groups.io/mt/89989268/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-