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 09C2E7803D1 for ; Thu, 2 May 2024 17:13:08 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=tV5wXT2uVvrbllVx7ifeCLlscaNzzbCVRQb7oEJEbGE=; 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=1714669987; v=1; b=IC1HZqzRauRF79N8wH5nYtkGvqSvl8k4+2i5RuJ8TLho9O5UgYterHKiLbAaYfRvg8QwtEBR QETShXTT2R72uzbiZmOazAfcZ1gT3zULrOOddFnjxRCjT8nuNXm7dN7+VDQc+AmPjGzi8KNrvZm Oj16Di0aeaiK/t83VLsv/Vdt/xHI7wCzG3Rnvg/ADJHdw97vvcJldPLMLxfmjHyhGsOeNVC+V66 gHdS7LySHEpBzchtuteaaNaQuiTSsN/f+Z41bFWBWoWkYSbHaA2ubOmGF1EOmCvo8yykxSlHDHW fRaLwpG7zJiSssaEjilAyzrLgmmyhlqauS4YMO7g1AqhA== X-Received: by 127.0.0.2 with SMTP id RG7bYY7687511xCQFgzqjj2I; Thu, 02 May 2024 10:13:07 -0700 X-Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.14]) by mx.groups.io with SMTP id smtpd.web11.339.1714669986606267279 for ; Thu, 02 May 2024 10:13:06 -0700 X-CSE-ConnectionGUID: RNkdAsjQQBuFSD7GSEKF7w== X-CSE-MsgGUID: +S1a+RjeT1WMIebfeOXrnw== X-IronPort-AV: E=McAfee;i="6600,9927,11062"; a="10672150" X-IronPort-AV: E=Sophos;i="6.07,247,1708416000"; d="scan'208";a="10672150" X-Received: from orviesa005.jf.intel.com ([10.64.159.145]) by fmvoesa108.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 May 2024 10:13:04 -0700 X-CSE-ConnectionGUID: 9A/cTY8lTr2Y8V60DPYeLQ== X-CSE-MsgGUID: GyTGrSfwRm2vvzNuW8M/Pg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,247,1708416000"; d="scan'208";a="31998622" X-Received: from fmsmsx603.amr.corp.intel.com ([10.18.126.83]) by orviesa005.jf.intel.com with ESMTP/TLS/AES256-GCM-SHA384; 02 May 2024 10:13:04 -0700 X-Received: from fmsmsx603.amr.corp.intel.com (10.18.126.83) by fmsmsx603.amr.corp.intel.com (10.18.126.83) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Thu, 2 May 2024 10:13:04 -0700 X-Received: from fmsedg601.ED.cps.intel.com (10.1.192.135) by fmsmsx603.amr.corp.intel.com (10.18.126.83) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35 via Frontend Transport; Thu, 2 May 2024 10:13:04 -0700 X-Received: from NAM10-MW2-obe.outbound.protection.outlook.com (104.47.55.100) by edgegateway.intel.com (192.55.55.70) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.35; Thu, 2 May 2024 10:13:03 -0700 X-Received: from CO1PR11MB4929.namprd11.prod.outlook.com (2603:10b6:303:6d::19) by DS0PR11MB7650.namprd11.prod.outlook.com (2603:10b6:8:151::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7519.34; Thu, 2 May 2024 17:13:01 +0000 X-Received: from CO1PR11MB4929.namprd11.prod.outlook.com ([fe80::a886:6510:729d:f9d0]) by CO1PR11MB4929.namprd11.prod.outlook.com ([fe80::a886:6510:729d:f9d0%5]) with mapi id 15.20.7544.029; Thu, 2 May 2024 17:13:01 +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: AQHajvZRiISllRWn1UCU5p0YwvjzYrFo1moggAQASwCAAI/YUIAAIlQAgAARb6CACjWJEIAMef7g Date: Thu, 2 May 2024 17:13:00 +0000 Message-ID: References: <20240410061849.984-1-n.jayaprakash@intel.com> <17C4D6CE42E68D40.16800@groups.io> <17C74B724102AC1D.15491@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_|DS0PR11MB7650:EE_ x-ms-office365-filtering-correlation-id: 784f6222-b8fb-4b2a-450b-08dc6acb1efa x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam-message-info: =?us-ascii?Q?Aw8K8Xz7lQjiy8MEe2et0aVh9UWUTBB9GXMjc1L4UHIWLd3q+0qEcg63XovQ?= =?us-ascii?Q?zSIEl35t09Pz7Sa4SGy2ElYGeaDTDXLn5GLOnN0uqeabBdDcaAa+CDB63hHH?= =?us-ascii?Q?kFkFe60S8cn1Oi/SUblhTEZRmY1WskcCiloGDySDbTjLpKFzBJS9GtnSIrUl?= =?us-ascii?Q?ofHVmv62d4cW53I7Jnen+T5llEDyRV02eVw5z89v3tnIMy0JpEzQl4LlnH2D?= =?us-ascii?Q?6xI98tYGsNLiZ5A3I+fxncfgF1wpSPSo1Eaj/jcOVOICT+t4E0vhlGPWOEZY?= =?us-ascii?Q?i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ZPIACv+ljFoNecP51HcP?= =?us-ascii?Q?7Z3IOyllDnLjMnvfr0FYKtBukP/ifIObusUw3KziPYXwvQeNfOdGjvC5IZ5K?= =?us-ascii?Q?v1rzUzf03YHXn80UEropn8ShqWgcHn7+T8/NFByNFnBSpn8VkQxE4Q3Su5lZ?= =?us-ascii?Q?xrw=3D?= x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?dBMVOWWPPnmvNyeMlX7WRLruCVXdTfU5YAs8qBkyMSUaicRtGyYaC6bSTXcW?= =?us-ascii?Q?/1tN9xPc9eGJ9E2iKcQcJBWevre+NDgAIrURjvrNVnk8pdKspyAEjPCOwph3?= =?us-ascii?Q?MAPT7qXVNGRoMq2iX0SYjZE2heqCT66S83boDqtJCO8Zd/RDiJsu3a4+0tLJ?= =?us-ascii?Q?UK1yHd1Q8tff2fOjMgKEBU8gw8JHnMLxNFJxHsPOggT+ATJTnz1rGELnTwZ+?= =?us-ascii?Q?Fa95rjXNklX+dlFXpBdMMJNW/FhEO8cus0DL+XFuHAfpNW771XSNuZ9ao2Vt?= =?us-ascii?Q?+U1zIZghozyfkJpZtd8tDJCak62MCdBrFcoat2uXqVDm8iRL23EQEe6UCenx?= =?us-ascii?Q?D8vOSLeXXXBlRC67mtThCsVOshRyZp6C743oQt+hnjkLQU+pmvbdXpad+gME?= =?us-ascii?Q?cCwu+e9woYyAgoTjEYoX19cEu2c9maqSw9MYbecBXPemodt/ey52eVwuWn9n?= =?us-ascii?Q?FIB27FdQ4DdAVSMWScqJJsJkTR+hXwBpe3rdXpGRzztRhted64IgR4OMQXi1?= =?us-ascii?Q?HIwu+NPC2NjrLz5YSyId6BHqv1Tvi7oDPfj93luDLk6UFgdTVrSJrUnTzWra?= =?us-ascii?Q?fOhnQrHB7Qn1wTxv8FvTmg6rgo+kwpS5EDL1WMVydlWHudCYLkdF9rKGbU1V?= =?us-ascii?Q?UYPPH+5+ZF/VazatFswgCSWIpzYK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?= =?us-ascii?Q?9qx/aazCCIXt7oBp7jaKgnxpbPoYdWtYDVNWHAgGcfCK5qEFttcpk/Go7BXE?= =?us-ascii?Q?rw=3D=3D?= 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: 784f6222-b8fb-4b2a-450b-08dc6acb1efa X-MS-Exchange-CrossTenant-originalarrivaltime: 02 May 2024 17:13:00.9948 (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: gG02wsiRYW3jygTwc3LYOQc3N3Sye2d6X9XkuD6LEnVUSqAseTSqBy3ymGvpW301snV2zDKFeTqJWrtf5QP/NWh2GVZSq4Y9OLsKDJuJL8Q= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR11MB7650 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: Thu, 02 May 2024 10:13:06 -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: RdKm60a27CT7EMv89PRWR0fEx7686176AA= 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=IC1HZqzR; 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 Reviewed-by: Michael D Kinney Mike > -----Original Message----- > From: Jayaprakash, N > Sent: Wednesday, April 24, 2024 11:14 AM > To: devel@edk2.groups.io; Jayaprakash, N ; > Kinney, Michael D > 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 > Hi Mike, >=20 > I have sent an updated patch v2 for review which uses the MP Services > protocol API StarupThisAP() to read / write MSRs specific to CPU cores. > Please review and do the needful. >=20 > Regards, > JP >=20 > -----Original Message----- > From: devel@edk2.groups.io On Behalf Of > Jayaprakash, N > Sent: Thursday, April 18, 2024 11:49 AM > 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 > Thanks Mike. I shall make necessary changes and submit the PR again for > review. >=20 > Regards, > JP >=20 > -----Original Message----- > From: Kinney, Michael D > Sent: Thursday, April 18, 2024 10:46 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 > Please use MP Services Protocol APIs StartupAllAPs() or StarupThisAP() > to read/write MSRs on other logical processors. >=20 > There and many examples of this in the UefiCpuPkg to programming MSRs on > all the logical processors. >=20 > Mike >=20 > > -----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 > > > > 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. > > > > These APIs will be part of the edk2 module of the Python interpreter > > and will be used during the validation and debug scenarios only. > > > > This is not for switching the BSP for OS boot. This is only used > > during the validation and debug use cases. > > > > 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 > > > > Hi JP, > > > > 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. > > > > The MP Services can be used to execute a C function on APs to execute > > MSR related instructions. > > > > Mike > > > > > -----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 >=20 >=20 >=20 >=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 (#118536): https://edk2.groups.io/g/devel/message/118536 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-