* [edk2-devel] [edk2-libc Patch 0/1] wrmsr function is not working as expected. @ 2024-04-04 9:44 Jayaprakash, N 2024-04-04 9:44 ` [edk2-devel] [edk2-libc Patch 1/1] edk2-libc: wrmsr function available in edk2module " Jayaprakash, N [not found] ` <17C30A8D5FBBA882.4513@groups.io> 0 siblings, 2 replies; 4+ messages in thread From: Jayaprakash, N @ 2024-04-04 9:44 UTC (permalink / raw) To: devel; +Cc: Jayaprakash N The wrmsr function always writes 0s to the higher 32 bits of the msr register. This issue has been fixed by this PR. Jayaprakash N (1): edk2-libc: wrmsr function available in edk2module is not working as expected .../Python/Python-3.6.8/PyMod-3.6.8/Modules/edk2module.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.40.0.windows.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#117420): https://edk2.groups.io/g/devel/message/117420 Mute This Topic: https://groups.io/mt/105325842/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=- ^ permalink raw reply [flat|nested] 4+ messages in thread
* [edk2-devel] [edk2-libc Patch 1/1] edk2-libc: wrmsr function available in edk2module is not working as expected 2024-04-04 9:44 [edk2-devel] [edk2-libc Patch 0/1] wrmsr function is not working as expected Jayaprakash, N @ 2024-04-04 9:44 ` Jayaprakash, N [not found] ` <17C30A8D5FBBA882.4513@groups.io> 1 sibling, 0 replies; 4+ messages in thread From: Jayaprakash, N @ 2024-04-04 9:44 UTC (permalink / raw) To: devel; +Cc: Jayaprakash N, Rebecca Cran, Michael D Kinney REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4745 This commit fixes the issue reported in the BZ4745. The wrmsr function 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 to a 64 bit value. Problematic statement in the function edk2_wrmsr code: data = vedx << 32 | veax; Where the vedx 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 statement has been modified as below: data = (((UINT64)vedx) << 32) | veax; Verified the function by making this change and could see that the wrmsr is working as expected. 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..cec4332 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 = (((UINT64)vedx) << 32) | veax; Py_BEGIN_ALLOW_THREADS AsmWriteMsr64(vecx, data); Py_END_ALLOW_THREADS -- 2.40.0.windows.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#117421): https://edk2.groups.io/g/devel/message/117421 Mute This Topic: https://groups.io/mt/105325843/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=- ^ permalink raw reply related [flat|nested] 4+ messages in thread
[parent not found: <17C30A8D5FBBA882.4513@groups.io>]
* Re: [edk2-devel] [edk2-libc Patch 1/1] edk2-libc: wrmsr function available in edk2module is not working as expected [not found] ` <17C30A8D5FBBA882.4513@groups.io> @ 2024-04-10 6:08 ` Jayaprakash, N 2024-04-17 18:34 ` Michael D Kinney 0 siblings, 1 reply; 4+ messages in thread From: Jayaprakash, N @ 2024-04-10 6:08 UTC (permalink / raw) To: devel@edk2.groups.io, Jayaprakash, N; +Cc: Rebecca Cran, Kinney, Michael D Reviewed-by : Jayaprakash N -----Original Message----- From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Jayaprakash, N Sent: Thursday, April 4, 2024 3:14 PM To: devel@edk2.groups.io Cc: Jayaprakash, N <n.jayaprakash@intel.com>; Rebecca Cran <rebecca@bsdio.com>; Kinney, Michael D <michael.d.kinney@intel.com> Subject: [edk2-devel] [edk2-libc Patch 1/1] edk2-libc: wrmsr function available in edk2module is not working as expected REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4745 This commit fixes the issue reported in the BZ4745. The wrmsr function 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 to a 64 bit value. Problematic statement in the function edk2_wrmsr code: data = vedx << 32 | veax; Where the vedx 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 statement has been modified as below: data = (((UINT64)vedx) << 32) | veax; Verified the function by making this change and could see that the wrmsr is working as expected. 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..cec4332 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/edk2mo +++ dule.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 = (((UINT64)vedx) << 32) | veax; Py_BEGIN_ALLOW_THREADS AsmWriteMsr64(vecx, data); Py_END_ALLOW_THREADS -- 2.40.0.windows.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#117568): https://edk2.groups.io/g/devel/message/117568 Mute This Topic: https://groups.io/mt/105437258/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=- ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [edk2-devel] [edk2-libc Patch 1/1] edk2-libc: wrmsr function available in edk2module is not working as expected 2024-04-10 6:08 ` Jayaprakash, N @ 2024-04-17 18:34 ` Michael D Kinney 0 siblings, 0 replies; 4+ messages in thread From: Michael D Kinney @ 2024-04-17 18:34 UTC (permalink / raw) To: Jayaprakash, N, devel@edk2.groups.io; +Cc: Rebecca Cran, Kinney, Michael D > -----Original Message----- > From: Jayaprakash, N <n.jayaprakash@intel.com> > Sent: Tuesday, April 9, 2024 11:09 PM > To: devel@edk2.groups.io; Jayaprakash, N <n.jayaprakash@intel.com> > Cc: Rebecca Cran <rebecca@bsdio.com>; Kinney, Michael D > <michael.d.kinney@intel.com> > Subject: RE: [edk2-devel] [edk2-libc Patch 1/1] edk2-libc: wrmsr > function available in edk2module is not working as expected > > Reviewed-by : Jayaprakash N > > -----Original Message----- > From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of > Jayaprakash, N > Sent: Thursday, April 4, 2024 3:14 PM > To: devel@edk2.groups.io > Cc: Jayaprakash, N <n.jayaprakash@intel.com>; Rebecca Cran > <rebecca@bsdio.com>; Kinney, Michael D <michael.d.kinney@intel.com> > Subject: [edk2-devel] [edk2-libc Patch 1/1] edk2-libc: wrmsr function > available in edk2module is not working as expected > > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4745 > > This commit fixes the issue reported in the BZ4745. > The wrmsr function 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 to a 64 bit value. > > Problematic statement in the function edk2_wrmsr code: > data = vedx << 32 | veax; > Where the vedx 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 statement has been modified as below: > data = (((UINT64)vedx) << 32) | veax; > Verified the function by making this change and could see that the > wrmsr is working as expected. > > 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..cec4332 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/edk2mo > +++ dule.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 = (((UINT64)vedx) << 32) | veax; On 32-bit builds, this will use an intrinsic. Is BaseLib LShiftU64() available here? > Py_BEGIN_ALLOW_THREADS > AsmWriteMsr64(vecx, data); > Py_END_ALLOW_THREADS > -- > 2.40.0.windows.1 > > > > > -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#117929): https://edk2.groups.io/g/devel/message/117929 Mute This Topic: https://groups.io/mt/105437258/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=- ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-04-17 18:35 UTC | newest] Thread overview: 4+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2024-04-04 9:44 [edk2-devel] [edk2-libc Patch 0/1] wrmsr function is not working as expected Jayaprakash, N 2024-04-04 9:44 ` [edk2-devel] [edk2-libc Patch 1/1] edk2-libc: wrmsr function available in edk2module " Jayaprakash, N [not found] ` <17C30A8D5FBBA882.4513@groups.io> 2024-04-10 6:08 ` Jayaprakash, N 2024-04-17 18:34 ` Michael D Kinney
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox