public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Jayaprakash, N" <n.jayaprakash@intel.com>
To: devel@edk2.groups.io
Cc: Jayaprakash N <n.jayaprakash@intel.com>,
	Rebecca Cran <rebecca@bsdio.com>,
	Michael D Kinney <michael.d.kinney@intel.com>
Subject: [edk2-devel] [edk2-libc Patch v3 1/1] ek2-libc: wrmsr function available in edk2module is not working as expected
Date: Fri, 19 Apr 2024 14:31:02 +0530	[thread overview]
Message-ID: <20240419090319.660-2-n.jayaprakash@intel.com> (raw)
In-Reply-To: <20240419090319.660-1-n.jayaprakash@intel.com>

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4745

This commit fixes the issue reported in the BZ4745.
The wrmsr was always writing 0 to the higher 32 bits of the msr register.
This was due to a logical flaw in the code, where the input variable of
type unsigned int was left shitted by 32 bits without explicitly
converting it to a 64 bit value.

The issue is with the below statement.
data = vedx << 32 | veax;
Where the vedx which is an unsigned int, after left shifting by 32 bits
its value will be set to 0. Because of this the higher 32 bits of the MSR
are always set to 0. This has been fixed by this commit.

Cc: Rebecca Cran <rebecca@bsdio.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Jayaprakash N <n.jayaprakash@intel.com>
Signed-off-by: Jayaprakash N <n.jayaprakash@intel.com>
---
 .../Python/Python-3.6.8/PyMod-3.6.8/Modules/edk2module.c        | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/AppPkg/Applications/Python/Python-3.6.8/PyMod-3.6.8/Modules/edk2module.c b/AppPkg/Applications/Python/Python-3.6.8/PyMod-3.6.8/Modules/edk2module.c
index d6af8da..f688b51 100644
--- a/AppPkg/Applications/Python/Python-3.6.8/PyMod-3.6.8/Modules/edk2module.c
+++ b/AppPkg/Applications/Python/Python-3.6.8/PyMod-3.6.8/Modules/edk2module.c
@@ -3886,7 +3886,7 @@ edk2_wrmsr(PyObject *self, PyObject *args)
   UINT64       data = 0;
   if (!PyArg_ParseTuple(args, "III", &vecx, &veax, &vedx))
     return NULL;
-  data = vedx << 32 | veax;
+  data = LShiftU64(vedx, 32) | veax;
   Py_BEGIN_ALLOW_THREADS
   AsmWriteMsr64(vecx, data);
   Py_END_ALLOW_THREADS
-- 
2.44.0.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#118012): https://edk2.groups.io/g/devel/message/118012
Mute This Topic: https://groups.io/mt/105614477/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



  reply	other threads:[~2024-04-19  9:03 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-19  9:01 [edk2-devel] [edk2-libc Patch v3 0/1] wrmsr function is not working as expected Jayaprakash, N
2024-04-19  9:01 ` Jayaprakash, N [this message]
2024-04-19 16:47   ` [edk2-devel] [edk2-libc Patch v3 1/1] ek2-libc: wrmsr function available in edk2module " Michael D Kinney

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240419090319.660-2-n.jayaprakash@intel.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox