From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail05.groups.io (mail05.groups.io [45.79.224.7]) by spool.mail.gandi.net (Postfix) with ESMTPS id F0535740034 for ; Thu, 18 Apr 2024 05:16:06 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=eaBvr+Ng0EZiShKg2KmE0dhU+laBVA1HIT8vDl8M2kA=; c=relaxed/simple; d=groups.io; h=From:To:CC:Subject:Thread-Topic:Thread-Index:Date:Message-ID:References:In-Reply-To:Accept-Language:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Resent-Date:Resent-From:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Language:Content-Type:Content-Transfer-Encoding; s=20240206; t=1713417365; v=1; b=G4yjveJztPd3Bvvu8WKv4v7m29QAyslk/pl68pEd1Amz9yufkGovYg3/gUq8RnigXR1pjEgy rfWKV8e9ts2ZP5KWfNxlTJHzkW2brSS1mPnVnjQt0nCuI1Un+1tVcYf8SR7VEEwqwGKx2z+erf8 22354zE1kItp7CdCeBuHZgOlvmSGylfiOUZgaV8juajDqOWY5jB8AwCIk+5eVdHVcRMABHKvZID rl/teuvA7E89V8Ni1AnPd1skV4KgYiDE4vnDtS497v+DQHFBM44qOHVDYQRT8nZCB9Jm192rlTm 7GZjksUif638XtlwQKb5s07N33Wu9j1Ik1mUKUPYqHWYQ== X-Received: by 127.0.0.2 with SMTP id Jq1OYY7687511xQXjj1UoZf3; Wed, 17 Apr 2024 22:16:05 -0700 X-Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.15]) by mx.groups.io with SMTP id smtpd.web11.5761.1713417364423840837 for ; Wed, 17 Apr 2024 22:16:04 -0700 X-CSE-ConnectionGUID: GUr6FlszQISTPjO9X7LzuQ== X-CSE-MsgGUID: 4qbQgs1cRLiuWJLy0zF9vQ== X-IronPort-AV: E=McAfee;i="6600,9927,11047"; a="12727279" X-IronPort-AV: E=Sophos;i="6.07,211,1708416000"; d="scan'208";a="12727279" X-Received: from orviesa009.jf.intel.com ([10.64.159.149]) by orvoesa107.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Apr 2024 22:16:04 -0700 X-CSE-ConnectionGUID: b8Qs2x9OTA6iocpBQmYEFQ== X-CSE-MsgGUID: /q02MCD3TzOWLc7kmk8e5A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,211,1708416000"; d="scan'208";a="22848448" X-Received: from fmsmsx601.amr.corp.intel.com ([10.18.126.81]) by orviesa009.jf.intel.com with ESMTP/TLS/AES256-GCM-SHA384; 17 Apr 2024 22:16:04 -0700 X-Received: from fmsmsx602.amr.corp.intel.com (10.18.126.82) by fmsmsx601.amr.corp.intel.com (10.18.126.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Wed, 17 Apr 2024 22:16:03 -0700 X-Received: from fmsedg602.ED.cps.intel.com (10.1.192.136) by fmsmsx602.amr.corp.intel.com (10.18.126.82) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35 via Frontend Transport; Wed, 17 Apr 2024 22:16:03 -0700 X-Received: from NAM11-BN8-obe.outbound.protection.outlook.com (104.47.58.172) by edgegateway.intel.com (192.55.55.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.35; Wed, 17 Apr 2024 22:16:02 -0700 X-Received: from CO1PR11MB4929.namprd11.prod.outlook.com (2603:10b6:303:6d::19) by LV2PR11MB5998.namprd11.prod.outlook.com (2603:10b6:408:17e::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7472.28; Thu, 18 Apr 2024 05:16:00 +0000 X-Received: from CO1PR11MB4929.namprd11.prod.outlook.com ([fe80::e34e:4d18:b93e:c368]) by CO1PR11MB4929.namprd11.prod.outlook.com ([fe80::e34e:4d18:b93e:c368%5]) with mapi id 15.20.7472.027; Thu, 18 Apr 2024 05:16:00 +0000 From: "Michael D Kinney" To: "Jayaprakash, N" , "devel@edk2.groups.io" CC: Rebecca Cran , "Kinney, Michael D" Subject: Re: [edk2-devel] [edk2-libc Patch 1/1] edk2-libc:add rdmsr_ex & wrmsr_ex functions to read/write cpu specific msrs Thread-Topic: [edk2-devel] [edk2-libc Patch 1/1] edk2-libc:add rdmsr_ex & wrmsr_ex functions to read/write cpu specific msrs Thread-Index: AQHajvZRiISllRWn1UCU5p0YwvjzYrFszlFQgACRS4CAACCaAA== Date: Thu, 18 Apr 2024 05:16:00 +0000 Message-ID: References: <20240410061849.984-1-n.jayaprakash@intel.com> <17C4D6CE42E68D40.16800@groups.io> In-Reply-To: Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-ms-traffictypediagnostic: CO1PR11MB4929:EE_|LV2PR11MB5998:EE_ x-ms-office365-filtering-correlation-id: 88e5ba86-c76d-4e33-c3fe-08dc5f66a2f0 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam-message-info: mfNHRKmSfa2J/vTnEzi3vFEoox0e7YfZA48beOqUrDPtg2CvJ/87qA9x9JstPpZACsychqnlzLMhoKwGrzYnnQP9TEl2Z77hz9E82QNGJdukNubRPLl/QiWglkRT7LcYwGMbB7lqNKRuZVqZvS2YhsGThZblqNG1JkrduI9gBqe8498lUahsbiyatKKgGAG8SiNW0Y4tCW3HReac/k98c7dzTorRcfQgbluRQfSSDqJR4diKI1FotbmdlQWzzacNDd+s+5RgqinHmqcLMas11DX3eAebDwz/nJ6mJsf1uKJ6MXtEN0ChdmZApP+2fD/bMULAWs211f1Rqxs8/AQczf4EGK3ZSCBIkQOFA0Sk/eXGgvt0YzQm8yDqGhGbIxzX3+cMZLau1o9DSyTwerj/GCg2HI3bPOTS7OiWl0MLiPGT3e5xOZEDulJT5qvqrf6fEfMk9ieYCkA+NAgbHspcGhTSIlBPNTtIdSf93aqlOZ9KBzQK8jJbl3fVuq0/f8sfUqFn8Pe9QPuBdl5M3Ycbx0Ya2F2mINqTiXe7n0khfNjmh4nbc7PFDmQNP4fKZQVIpbe1jEY1ZgNF3jEWAykgLr+1ByxvL21jQD59z1i3vLXbCpxSjEVsuALgq9rTvvSvByaWPsYG469mP2wiUUjmJUG1k7MKKY50NbxkwDqoEdOhkDilDNTZNdCRlB3bs6hc x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?GQjHZ8i1CYsJpAWKQj2yrfIwWMZbbXZOm7x3BW2QpyRoZNdSXw7juThkdmkq?= =?us-ascii?Q?b3fIkdJJT01bM9oNNSIN6MtjdOf8xvWIOS+T7F0o9ZL1oudDZKMgGCoOdRyC?= =?us-ascii?Q?6pObfEHDjE8+7HJveA5njDy6tjx58NKWxthMbSJf1dzBauqjhoRj9qUWRZPQ?= =?us-ascii?Q?lhZh0G5XwwfUnH8pOM9MaPB0jxjtpBF7fMFSy11CGI9uakhaEGmuXNejH/7b?= =?us-ascii?Q?lz1Iq3/NaqWD+GSsyXK5sXheThup/LtTE0txRZM7tAUGhlED0IWzg6lIzsh/?= =?us-ascii?Q?zJsSYpArEPV6fc3J8X1ogWTnY1/+tVs7+J/df6WkCvHS0CGaL4Q2ccY2vXaA?= =?us-ascii?Q?NMfgWTHygGJpgiif6R9gqU6NqXIVOPgpXH+Tovi2xyxOuAuO44tKKaZTMSeW?= =?us-ascii?Q?+/zr9T1TPDgJteKPrI7Shnm4iODTR0rP1EkV8oyhUyT55bj3SKetjwFX2uMR?= =?us-ascii?Q?9VHmBTk43xgRs8cVQ6kzUS5soo01GSb1NoeQlViCKIfvgqGRQmYFkzCIwwZ+?= =?us-ascii?Q?fG/BYDZTQ+C7iP8G04kbrjXsA8b4j5FI2qoiLzLkHzh0ox0js+yA5TUyWsaD?= =?us-ascii?Q?K/D1XUVULTD9U94h7S46IKf/DEstqPS8hMA3BirJfuisH7Hr0jJQNMKlaDfG?= =?us-ascii?Q?MYeqJ/RDYGE7MngKJYnHTuLi956Pu2S7BdvbUSK3SYWPoU3AxmS/HNDjAjCR?= =?us-ascii?Q?QLubUgV4ySGBYLxl0bY0Vw++6MrIBUTIbZ0rngCvp1e79oG338RGHTM72Xj4?= =?us-ascii?Q?Ji2Dz5FkHrUntgrz7zW3puYwGGvuQmojLpAGHt3ZZqd96zDLA3JH48phYx6B?= =?us-ascii?Q?SzMMOXsRB30uOeLOw8B1U7mbvsVPGvGaGQfh4SB6ePoTeJmH9h23pJBOXjmo?= =?us-ascii?Q?mSDAeR+BjJn9H/Id7828K+yO/x4SFsfG7jMhdShLGFx8lc9TNl9T//xDPl17?= =?us-ascii?Q?acKfh5puknndgweG5+YXozlg9TR+yVQF/4pd/QmdHNASLq7wuzhGjKCNOJyy?= =?us-ascii?Q?Pmex0Qq/SrK71RwmvwkdOJbw4y71/sLO/U+vosoZQGOzsW1YUGkwURO50FXj?= =?us-ascii?Q?moQwe4MWppDApH6KVW3vQ6UZtG2vMrLBXtvrobqLkI0l9bQWe+lV+EZ0rEBX?= =?us-ascii?Q?K+7o4vJL+F9YCs7JYzgVaTVWqXJ1H1TYdNdxDQ3HWbRz+Gro0Lc9bNajvfF+?= =?us-ascii?Q?5tImca1eG0PUP5EWMOOGA234bHuYDj4yZaA+fVVzU2beP7C5Uxxmoi7gpBQP?= =?us-ascii?Q?C7jV7pJ53cLLkhlf1sbTngLqCPo5DWCyOzCzVVnz/7IpBB/HXMrA1R944KAt?= =?us-ascii?Q?4rNTiesPpenBPXkVB7FdAXEcilPUFIj1QNaz2SHH2nL5T29X5XF5R5h6nRD7?= =?us-ascii?Q?IK/XmVgaiNNmzhHjHY0PsOllPvq1PZ1ugp9YEoXtfxHNsut0Ns/7BNoG2W78?= =?us-ascii?Q?D7uqQWRyAST4RVvs1wFDSx0udl2jWA7/RKWXKY5sow2o7IO3TShI4oawA6jZ?= =?us-ascii?Q?5wYY/o3izofpZYChzv0vIL0cbOJ+Tf5gvPFj4aaSTGo32t+2OkWDPKvIrWQg?= =?us-ascii?Q?DI1biSQX+TMydOS9SSnExjb9eZPlnd0loCIWJiwk?= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: CO1PR11MB4929.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 88e5ba86-c76d-4e33-c3fe-08dc5f66a2f0 X-MS-Exchange-CrossTenant-originalarrivaltime: 18 Apr 2024 05:16:00.4331 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: ID3Wud7t4UEdbJMaSmBsd60kpGWpkhxmwbcjMR7d1Q/0phVtaagqiGfJQaEpJbOtdMBtffoyb7DilrU0oZdHD7j/5hyS8wSS0BSgQid12U8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV2PR11MB5998 X-OriginatorOrg: intel.com Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Resent-Date: Wed, 17 Apr 2024 22:16:04 -0700 Resent-From: michael.d.kinney@intel.com Reply-To: devel@edk2.groups.io,michael.d.kinney@intel.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: 0TbCtcWs5buPgcOxrfYgphLNx7686176AA= Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20240206 header.b=G4yjveJz; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=intel.com (policy=none); spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 45.79.224.7 as permitted sender) smtp.mailfrom=bounce@groups.io Please use MP Services Protocol APIs StartupAllAPs() or StarupThisAP()=20 to read/write MSRs on other logical processors. There and many examples of this in the UefiCpuPkg to programming MSRs on all the logical processors. Mike > -----Original Message----- > From: Jayaprakash, N > Sent: Wednesday, April 17, 2024 8:16 PM > To: Kinney, Michael D ; > devel@edk2.groups.io > Cc: Rebecca Cran > Subject: RE: [edk2-devel] [edk2-libc Patch 1/1] edk2-libc:add rdmsr_ex > & wrmsr_ex functions to read/write cpu specific msrs >=20 > In the validation and debug scenarios, engineers tend to read MSRs and > write to MSRs of different CPUs. > So we are providing a simple mechanism through these APIs to enable > them to do these operations. >=20 > These APIs will be part of the edk2 module of the Python interpreter > and will be used during the validation and debug scenarios only. >=20 > This is not for switching the BSP for OS boot. This is only used > during the validation and debug use cases. >=20 > Regards, > JP > -----Original Message----- > From: Kinney, Michael D > Sent: Thursday, April 18, 2024 12:08 AM > To: Jayaprakash, N ; devel@edk2.groups.io > Cc: Rebecca Cran ; Kinney, Michael D > > Subject: RE: [edk2-devel] [edk2-libc Patch 1/1] edk2-libc:add rdmsr_ex > & wrmsr_ex functions to read/write cpu specific msrs >=20 > Hi JP, >=20 > Is there a reason switch BSP is being used. That is not a common > operation and is typically used if the current BSP is not stable or > there is a good reason to switch the BSP for OS boot. >=20 > The MP Services can be used to execute a C function on APs to execute > MSR related instructions. >=20 > Mike >=20 > > -----Original Message----- > > From: Jayaprakash, N > > Sent: Sunday, April 14, 2024 10:33 PM > > To: devel@edk2.groups.io; Jayaprakash, N > > Cc: Rebecca Cran ; Kinney, Michael D > > > > Subject: RE: [edk2-devel] [edk2-libc Patch 1/1] edk2-libc:add > rdmsr_ex > > & wrmsr_ex functions to read/write cpu specific msrs > > > > + Rebecca and Mike, > > > > Would you be able to review this PR? > > > > Regards, > > JP > > > > -----Original Message----- > > From: devel@edk2.groups.io On Behalf Of > > Jayaprakash, N > > Sent: Wednesday, April 10, 2024 11:49 AM > > To: devel@edk2.groups.io > > Cc: Jayaprakash, N ; Rebecca Cran > > ; Kinney, Michael D > > Subject: [edk2-devel] [edk2-libc Patch 1/1] edk2-libc:add rdmsr_ex & > > wrmsr_ex functions to read/write cpu specific msrs > > > > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D4746 > > > > The rdmsr_ex and wrmsr_ex are extension APIs to the rdmsr and wrmsr > > APIs supported in edk2 module. These extension APIs makes it > possible > > to read / write MSRs from specific processors and fills an existing > > gap in this area. > > > > Cc: Rebecca Cran > > Cc: Michael D Kinney > > Cc: Jayaprakash N > > Signed-off-by: Jayaprakash N > > --- > > .../PyMod-3.6.8/Modules/edk2module.c | 159 > > +++++++++++++++++- > > .../Python/Python-3.6.8/Python368.inf | 3 + > > 2 files changed, 158 insertions(+), 4 deletions(-) > > > > 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..f1b13a6 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 > > @@ -3,7 +3,7 @@ > > Derived from posixmodule.c in Python 2.7.2. > > > > Copyright (c) 2015, Daryl McDaniel. All rights reserved.
> > - Copyright (c) 2011 - 2023, Intel Corporation. All rights > > reserved.
> > + Copyright (c) 2011 - 2024, Intel Corporation. All rights > > + reserved.
> > This program and the accompanying materials are licensed and > made > > available under > > the terms and conditions of the BSD License that accompanies > this > > distribution. > > The full text of the license may be found at @@ -22,16 +22,23 > @@ > > #include #include #include > > +#include // Needed for the definition of > > EFI_AP_PROCEDURE > > #include > > #include > > #include > > #include > > +#include > > +#include > > > > #ifdef __cplusplus > > extern "C" { > > #endif > > > > PyTypeObject EfiGuidType; > > +EFI_MP_SERVICES_PROTOCOL *gpMpService =3D NULL; > > +UINTN gBSPProcessorNumber =3D 0; > > +UINTN gNumberOfProcessors =3D 0; > > +UINTN gNumberOfEnabledProcessors =3D 0; > > > > extern void _swsmi( unsigned int smi_code_data, unsigned int > > rax_value, unsigned int rbx_value, unsigned int rcx_value, unsigned > > int rdx_value, unsigned int rsi_value, unsigned int rdi_value ); // > - > > - Support routines @@ -169,6 +176,35 @@ PyDoc_STRVAR(edk2__doc__, > > /* dummy version. _PyVerify_fd() is already defined in fileobject.h > > */ #define _PyVerify_fd_dup2(A, B) (1) > > > > +static EFI_STATUS > > +MpServicesWhoAmI ( > > + IN EFI_MP_SERVICES_PROTOCOL *pMpService, > > + OUT UINTN *pProcessorNumber > > + ) > > +{ > > + return pMpService->WhoAmI (pMpService, pProcessorNumber); } > > + > > +static EFI_STATUS > > +MpServicesGetNumberOfProcessors ( > > + IN EFI_MP_SERVICES_PROTOCOL *pMpService, > > + OUT UINTN *pNumberOfProcessors, > > + OUT UINTN *pNumberOfEnabledProcessors > > + > > + ) > > +{ > > + return pMpService->GetNumberOfProcessors (pMpService, > > +pNumberOfProcessors, pNumberOfEnabledProcessors); } > > + > > +static EFI_STATUS > > +MpServicesSwitchBSP ( > > + IN EFI_MP_SERVICES_PROTOCOL *pMpService, > > + IN UINTN ProcessorNumber > > + ) > > +{ > > + return pMpService->SwitchBSP(pMpService, ProcessorNumber, TRUE); > } > > + > > #ifndef UEFI_C_SOURCE > > /* Return a dictionary corresponding to the POSIX environment table > > */ extern char **environ; @@ -3865,6 +3901,56 @@ > edk2_rdmsr(PyObject > > *self, PyObject *args) > > return Py_BuildValue("(II)", (unsigned long)veax, (unsigned > > long)vedx); } > > > > +PyDoc_STRVAR(efi_rdmsr_ex__doc__, > > +"rdmsr_ex(cpu, msr) -> (lower_32bits, higher_32bits)\n\ \n\ Read > the > > +given msr by switching to cpu and return the data as tuple.\n\ \n\ > > +Parameters:\n\ > > + cpu - The cpu number in hex or int format\n\ > > + msr - The msr in hex or int format\n\ \n\ Return Value:\n\ > > + a tuple with lower and higher 32 bit values read from the > msr\n\ > > +"); > > + > > +static PyObject * > > +edk2_rdmsr_ex(PyObject *self, PyObject *args) { > > + unsigned int cpu, vecx, veax, vedx; > > + unsigned int bsp_switched =3D 0; > > + EFI_STATUS status =3D 0; > > + UINT64 data =3D 0; > > + > > + if (!PyArg_ParseTuple(args, "II", &cpu, &vecx)) > > + return NULL; > > + > > + Py_BEGIN_ALLOW_THREADS > > + if (cpu !=3D gBSPProcessorNumber && cpu < gNumberOfProcessors) { > > + //switch the BSP to the cpu > > + status =3D MpServicesSwitchBSP(gpMpService, cpu); > > + if (!EFI_ERROR(status)) > > + { > > + bsp_switched =3D 1; > > + } > > + } > > + > > + data =3D AsmReadMsr64(vecx); > > + > > + if (bsp_switched) > > + { > > + // switch BSP to the saved BSP processor > > + MpServicesSwitchBSP(gpMpService, gBSPProcessorNumber); > > + // update the saved BSP processor > > + MpServicesWhoAmI(gpMpService, &gBSPProcessorNumber); > > + } > > + Py_END_ALLOW_THREADS > > + veax =3D (UINT32)data; > > + vedx =3D (UINT64)data >> 32; > > + return Py_BuildValue("(II)", (unsigned long)veax, (unsigned > > +long)vedx); } > > + > > PyDoc_STRVAR(efi_wrmsr__doc__, > > "wrmsr(msr, lower_32bits, higher_32bits) -> None\n\ \n\ @@ -3889,6 > > +3975,58 @@ edk2_wrmsr(PyObject *self, PyObject *args) > > data =3D vedx << 32 | veax; > > Py_BEGIN_ALLOW_THREADS > > AsmWriteMsr64(vecx, data); > > + Py_END_ALLOW_THREADS > > + Py_INCREF(Py_None); > > + return Py_None; > > +} > > + > > +PyDoc_STRVAR(efi_wrmsr_ex__doc__, > > +"wrmsr_ex(cpu, msr, lower_32bits, higher_32bits) -> None\n\ \n\ > > Writes > > +higher_32bits:lower_32bits to the given msr.\n\ \n\ Parameters:\n\ > > + cpu - The cpu number in hex or int format\n\ > > + msr - The msr in hex or int format\n\ > > + lower_32bits - The lower 32 bit data for the msr\n\ > > + higher_32bits - The higher 32 bit data for the msr\n\ \n\ > Return > > +Value:\n\ > > + None\n\ > > +"); > > + > > +static PyObject * > > +edk2_wrmsr_ex(PyObject *self, PyObject *args) { > > + unsigned int cpu, msr, veax, vedx; > > + unsigned int bsp_switched =3D 0; > > + EFI_STATUS status =3D 0; > > + UINT64 data =3D 0; > > + > > + if (!PyArg_ParseTuple(args, "IIII", &cpu, &msr, &veax, &vedx)) > > + return NULL; > > + data =3D (((UINT64)vedx) << 32) | veax; > > + > > + Py_BEGIN_ALLOW_THREADS > > + if (cpu !=3D gBSPProcessorNumber && cpu < gNumberOfProcessors) { > > + //switch the BSP to the cpu > > + status =3D MpServicesSwitchBSP(gpMpService, cpu); > > + if (!EFI_ERROR(status)) > > + { > > + bsp_switched =3D 1; > > + } > > + } > > + // write to MSR > > + AsmWriteMsr64(msr, data); > > + > > + if (bsp_switched) > > + { > > + // switch BSP to the saved BSP processor > > + MpServicesSwitchBSP(gpMpService, gBSPProcessorNumber); > > + // update the saved BSP processor > > + MpServicesWhoAmI(gpMpService, &gBSPProcessorNumber); } > > Py_END_ALLOW_THREADS > > Py_INCREF(Py_None); > > return Py_None; > > @@ -4576,7 +4714,9 @@ static PyMethodDef edk2_methods[] =3D { #endif > > {"abort", edk2_abort, METH_NOARGS, > > edk2_abort__doc__}, > > {"rdmsr", edk2_rdmsr, > METH_VARARGS, > > efi_rdmsr__doc__}, > > + {"rdmsr_ex", edk2_rdmsr_ex, > METH_VARARGS, > > efi_rdmsr_ex__doc__}, > > {"wrmsr", edk2_wrmsr, > METH_VARARGS, > > efi_wrmsr__doc__}, > > + {"wrmsr_ex", edk2_wrmsr_ex, > METH_VARARGS, > > efi_wrmsr_ex__doc__}, > > {"readpci", edk2_readpci, > METH_VARARGS, > > efi_readpci__doc__}, > > {"writepci", edk2_writepci, > METH_VARARGS, > > efi_writepci__doc__}, > > {"readmem", posix_readmem, > > METH_VARARGS, efi_readmem__doc__}, > > @@ -4813,13 +4953,24 @@ static struct PyModuleDef edk2module =3D { > > PyMODINIT_FUNC > > PyEdk2__Init(void) > > { > > - PyObject *m; > > + PyObject *m; > > + EFI_STATUS Status =3D 0; > > > > #ifndef UEFI_C_SOURCE > > PyObject *v; > > #endif > > + Status =3D gBS->LocateProtocol(&gEfiMpServiceProtocolGuid, NULL, > > &gpMpService); > > + if (EFI_ERROR(Status)) > > + { > > + printf("Unable to locate the Protocol MpServices protocol: > > %r\n", Status); > > + return NULL; > > + } > > + // Get the current BSP processor number > > + MpServicesWhoAmI(gpMpService, &gBSPProcessorNumber); > > + // Get the number of processors > > + MpServicesGetNumberOfProcessors(gpMpService, > > &gNumberOfProcessors, > > + &gNumberOfEnabledProcessors); > > > > - m =3D PyModule_Create(&edk2module); > > + m =3D PyModule_Create(&edk2module); > > if (m =3D=3D NULL) > > return m; > > > > @@ -4870,7 +5021,7 @@ PyEdk2__Init(void) > > //PyModule_AddObject(m, "statvfs_result", > > // (PyObject*) &StatVFSResultType); > > initialized =3D 1; > > - return m; > > + return m; > > > > } > > > > diff --git a/AppPkg/Applications/Python/Python-3.6.8/Python368.inf > > b/AppPkg/Applications/Python/Python-3.6.8/Python368.inf > > index 8b7f677..eca98b5 100644 > > --- a/AppPkg/Applications/Python/Python-3.6.8/Python368.inf > > +++ b/AppPkg/Applications/Python/Python-3.6.8/Python368.inf > > @@ -46,6 +46,9 @@ > > #BsdSocketLib > > #EfiSocketLib > > > > +[Protocols] > > + gEfiMpServiceProtocolGuid ## CONSUMES > > + > > [FixedPcd] > > gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0x0F > > gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel|0x80000040 > > -- > > 2.40.0.windows.1 > > > > > > > >=20 > > -=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 (#117943): https://edk2.groups.io/g/devel/message/117943 Mute This Topic: https://groups.io/mt/105530360/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-