From nobody Thu May 2 08:26:36 2024 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+73963+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+73963+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1618240093; cv=none; d=zohomail.com; s=zohoarc; b=nUnM/I6+9HQK4BJlkvUkcUEynwRnSLTcewma9xDdqzgE0RKXvNRYscmT46PRfxVW/YpLN7nvBOkn/S9WgnGluh9/ptQ87vX9mj+H0X4uxpW6JLD+BJ7Y0enNnyM1DsfxwJvWVBkITPr/lO+m6w7EkItItBAx53ObACtx9f2HyYY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618240093; 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=WWFOjZFE0H33ExojAi4Vdl46iVYxp6Q3t8r0AuOJHZg=; b=SzUhtm3jmxVmXQrCXS4yE5wSk4Q9dBUpEbGItpVtgdjJlNmgM8D2zAOMdf0OWVwK6ctewoLuCDrsTRV19xtKSooIuTO9k0W3nEP0Yio7nnAmPRV9c3OtdTRM3/sAsCwBJiWKT/GOPCjZ0MAZny5IDX5fowHgIE8BSSDSli8ohAU= 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+73963+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1618240093534939.9035707760862; Mon, 12 Apr 2021 08:08:13 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id xd7pYY1788612xI7YOM5uMqJ; Mon, 12 Apr 2021 08:08:12 -0700 X-Received: from mail-pg1-f171.google.com (mail-pg1-f171.google.com [209.85.215.171]) by mx.groups.io with SMTP id smtpd.web12.34203.1618240092141753130 for ; Mon, 12 Apr 2021 08:08:12 -0700 X-Received: by mail-pg1-f171.google.com with SMTP id w10so9614866pgh.5 for ; Mon, 12 Apr 2021 08:08:12 -0700 (PDT) X-Gm-Message-State: tJLnca4SyjU8QaavkR6zp7yOx1787277AA= X-Google-Smtp-Source: ABdhPJxjGiR8QS3G5ddBA7oCJ2LA7zAKX59/PO0KESCJ9tn7+Tr/Q07yS4jLtGhr/WF+KUmKCH9/sw== X-Received: by 2002:a65:6483:: with SMTP id e3mr27726009pgv.208.1618240091315; Mon, 12 Apr 2021 08:08:11 -0700 (PDT) X-Received: from localhost.localdomain ([240d:1e:84:2c00:f834:96b1:5066:781d]) by smtp.googlemail.com with ESMTPSA id i10sm267479pjm.1.2021.04.12.08.08.09 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 12 Apr 2021 08:08:10 -0700 (PDT) From: "Takuto Naito" To: devel@edk2.groups.io Cc: Takuto Naito , Michael D Kinney , Liming Gao , Zhiguang Liu Subject: [edk2-devel] [PATCH v1 1/1] Fix AsmReadMsr64() and AsmWriteMsr64() with GCC toolchain Date: Tue, 13 Apr 2021 00:07:18 +0900 Message-Id: <20210412150718.71002-2-naitaku@gmail.com> In-Reply-To: <20210412150718.71002-1-naitaku@gmail.com> References: <20210412150718.71002-1-naitaku@gmail.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,naitaku@gmail.com Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1618240092; bh=OqFxgjZ2Y2NDFEZMSrffSjJgkUPY6eM+knV47s68ro0=; h=Cc:Date:From:Reply-To:Subject:To; b=vmzY345lXGS/woCXYIPtKzjqPYHt5rSQMO0yQIHlH7BBT8Gq7TMJbZS7pIwZFh0wCcm XcuusjcC7HvRL0XN4ynjmOj1tRf8oPLbE0lyLbkWhdH+n2jf07z+2HaaJ08g3TEk2w+HH YjQslJMiQI5pDdU+ssZor1uLXuA7qQuh5fU= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3325 1. AsmReadMsr64() in X64/GccInlinePriv.c AsmReadMsr64 can return uninitialized value if FilterBeforeMsrRead returns False. This causes build error with the CLANG toolchain. 2. AsmWriteMsr64() in X64/GccInlinePriv.c In the case that FilterBeforeMsrWrite changes Value and returns True, The original Value, not the changed Value, is written to the MSR. This behavior is different from the one of AsmWriteMsr64() in X64/WriteMsr64.c for the MSFT toolchain. Signed-off-by: Takuto Naito Cc: Michael D Kinney Cc: Liming Gao Cc: Zhiguang Liu --- MdePkg/Library/BaseLib/X64/GccInlinePriv.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/MdePkg/Library/BaseLib/X64/GccInlinePriv.c b/MdePkg/Library/Ba= seLib/X64/GccInlinePriv.c index e4920f2116..244bd62ee6 100644 --- a/MdePkg/Library/BaseLib/X64/GccInlinePriv.c +++ b/MdePkg/Library/BaseLib/X64/GccInlinePriv.c @@ -80,7 +80,7 @@ AsmReadMsr64 ( } FilterAfterMsrRead (Index, &Value); =20 - return (((UINT64)HighData) << 32) | LowData; + return Value; } =20 /** @@ -111,11 +111,10 @@ AsmWriteMsr64 ( UINT32 HighData; BOOLEAN Flag; =20 - LowData =3D (UINT32)(Value); - HighData =3D (UINT32)(Value >> 32); - Flag =3D FilterBeforeMsrWrite (Index, &Value); if (Flag) { + LowData =3D (UINT32)(Value); + HighData =3D (UINT32)(Value >> 32); __asm__ __volatile__ ( "wrmsr" : --=20 2.31.1 -=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 (#73963): https://edk2.groups.io/g/devel/message/73963 Mute This Topic: https://groups.io/mt/82040470/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-