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 87647740045 for ; Wed, 24 Apr 2024 18:14:16 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=oVdx4EwMk7ANfzed73xpzbN1HsWyg9lT1awI3EaXjZE=; 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=1713982454; v=1; b=NnEdImPEn39kRPOBLBTWwkGX3h+bEF07dxR7Jv55la3PuJMTVqLr8UhUQZCBZfWo8sfw/x9Q 3LycJhn0mPSdA7Y35eYK9As8fTLh84XRQ23Mj8mHGdoQZxeftta4sGkqsbWxtKmVAEMLHMsAhKW 6+ChfS2YGlXknpRumyjucr4OyKroeWaDdBlcsjrU0qwi1swT/QimU3pvW5XLMb4UeWZL3iSfYCF f9iGAKhRfQkxUZAWzYzietcnBUzn2EqvoJIa/Srt8DN7gaW+18AIDj7MrnoHS5g2nxEcJNdgUjQ zwwvImYwCJ/QacPq8skBhA9lfZnIT+v1ZhYHdHMATOK4g== X-Received: by 127.0.0.2 with SMTP id Uj5OYY7687511xsqhehRJHJP; Wed, 24 Apr 2024 11:14:14 -0700 X-Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.8]) by mx.groups.io with SMTP id smtpd.web10.3902.1713982454100099052 for ; Wed, 24 Apr 2024 11:14:14 -0700 X-CSE-ConnectionGUID: 86Xuhh9WSP245O60YO5P2A== X-CSE-MsgGUID: d+7z7+k/ROWEIng/FK3N6g== X-IronPort-AV: E=McAfee;i="6600,9927,11054"; a="27148570" X-IronPort-AV: E=Sophos;i="6.07,226,1708416000"; d="scan'208";a="27148570" X-Received: from fmviesa009.fm.intel.com ([10.60.135.149]) by fmvoesa102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Apr 2024 11:14:14 -0700 X-CSE-ConnectionGUID: O+QMpYCpSaiJsdagrSZMvA== X-CSE-MsgGUID: gwWApE6pRB+YltHe0UCTzw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,226,1708416000"; d="scan'208";a="24799727" X-Received: from orsmsx602.amr.corp.intel.com ([10.22.229.15]) by fmviesa009.fm.intel.com with ESMTP/TLS/AES256-GCM-SHA384; 24 Apr 2024 11:14:13 -0700 X-Received: from orsmsx612.amr.corp.intel.com (10.22.229.25) by ORSMSX602.amr.corp.intel.com (10.22.229.15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Wed, 24 Apr 2024 11:14:13 -0700 X-Received: from orsmsx611.amr.corp.intel.com (10.22.229.24) by ORSMSX612.amr.corp.intel.com (10.22.229.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Wed, 24 Apr 2024 11:14:13 -0700 X-Received: from ORSEDG601.ED.cps.intel.com (10.7.248.6) by orsmsx611.amr.corp.intel.com (10.22.229.24) 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, 24 Apr 2024 11:14:13 -0700 X-Received: from NAM11-CO1-obe.outbound.protection.outlook.com (104.47.56.168) by edgegateway.intel.com (134.134.137.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.35; Wed, 24 Apr 2024 11:13:55 -0700 X-Received: from PH7PR11MB5943.namprd11.prod.outlook.com (2603:10b6:510:13f::19) by IA0PR11MB8418.namprd11.prod.outlook.com (2603:10b6:208:487::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7519.22; Wed, 24 Apr 2024 18:13:50 +0000 X-Received: from PH7PR11MB5943.namprd11.prod.outlook.com ([fe80::20f5:8535:1838:9d4e]) by PH7PR11MB5943.namprd11.prod.outlook.com ([fe80::20f5:8535:1838:9d4e%4]) with mapi id 15.20.7519.021; Wed, 24 Apr 2024 18:13:50 +0000 From: "Jayaprakash, N" 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 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: AQHaiw9vOsT7KodHAE2KeTJCgUKwfbFo1moggAQASwCAAI/YUIAAIlQAgAARb6CACjWJEA== Date: Wed, 24 Apr 2024 18:13:50 +0000 Message-ID: References: <20240410061849.984-1-n.jayaprakash@intel.com> <17C4D6CE42E68D40.16800@groups.io> <17C74B724102AC1D.15491@groups.io> In-Reply-To: <17C74B724102AC1D.15491@groups.io> Accept-Language: en-IN, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-ms-traffictypediagnostic: PH7PR11MB5943:EE_|IA0PR11MB8418:EE_ x-ms-office365-filtering-correlation-id: 473b2744-4a7b-4599-3eb0-08dc648a4abe x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam-message-info: =?us-ascii?Q?iVMKaioeNAERCo6NTqPSVJe9RAvJYV11t67/uJO8xl15UmLRc8V6DF0/LbdU?= =?us-ascii?Q?SSbl5ZPDw0eKqI6BdA29KUhxCHm96TcxuHzyYEWJtc8/fsev2BEL89DAP3bl?= =?us-ascii?Q?8g62If9Jkx1KOAVUkoVlBvQH6bA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ZuQT/Plv7+dmTOPPHccN4z2rBubMUVQ4GS3difWGMbnhsQhVQaBB0?= =?us-ascii?Q?HfUpAucL8B4E1mxlIPuAciB8pqy3U3e5sMdO6x3iuqVlUZ6i1f0kf+04NHIZ?= =?us-ascii?Q?U6hx8qXcSzEai69a80yjelfMqr2GPk48JENh4CuUuMbBDlYHdw3mFB1zXYHO?= =?us-ascii?Q?y/R+MpbyOvFRlkeQ60U6bu2U7FzQbmAFiAWW6LbW9wxKNVw0o7yZPXcYQk1w?= =?us-ascii?Q?MsoCetQpwrobjp8mhHqtdg6A9ZK4WjHZlhvq+ysuNArVxetl52auefNmz33D?= =?us-ascii?Q?MkU=3D?= x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?gjkWnpIvuvFUoz3CRo0zalb5cZfbV9tvB148dEdFWAOu+RkelKXBFbRHH1UF?= =?us-ascii?Q?JT6FKnKt1UjkXFCa5ELGazgVuGSzJUlnICR+mS2LFdKk7lZfaYarC+6tCoS2?= =?us-ascii?Q?2LIZ9itTyafb4X3JpdSeUelny9+yjDFbEb5KrsJvP3vVhIvNT3R1wW24Ox04?= =?us-ascii?Q?g9dA6viXg59uSjK1sz9DLspLx5DIBHe8mNBOHhLB1jRkiTL7em+96OahrH/u?= =?us-ascii?Q?p05boi2HiYsZA0bMfeW+zuMYDA798dxkkN+ggZaKkbhssmxpRVNygjoHQtSd?= =?us-ascii?Q?fWWHBmx16UDQaovF+0PIe4cT2SXy8EwL+WBPsbvGVDj+1xbOcgX1Qge1WNT6?= =?us-ascii?Q?xga7hJO6dyLT8vZ8R5sBFPnw/0LPje3wryH0qC1zmv+/oMVTFyt8XMZBx4Uj?= =?us-ascii?Q?M1egtajjdP5wJz3VLnsGWSHEhBONSPyDLzPOM/nFtXNB9GS2nxxRky0GCT4l?= =?us-ascii?Q?8CgvQfM1JdfhPDcLmvyxo+N34yzRuEoAybQvWBBZ7HHLyPBDHwlTaeSrl3nY?= =?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eyhEfH1UxbYYfXTMku1Fnv3o?= =?us-ascii?Q?QJ+9P306WnzuPP6dOI7mQxWe4E2Ib5stxw9yhe4pbwWSfWDruax0cHi8AJxK?= =?us-ascii?Q?jF4exMv55HZyvG3uz1wNKIIE99EziK9BXppmTY9JrLRxTOlIQ6IFJqTOX4kE?= =?us-ascii?Q?3TXT0ifjYbgcWS4fQIgOF1n3d5dhKMga06IeaGHh?= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: PH7PR11MB5943.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 473b2744-4a7b-4599-3eb0-08dc648a4abe X-MS-Exchange-CrossTenant-originalarrivaltime: 24 Apr 2024 18:13:50.1669 (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: jBlraTbBqqDF+mp9eIPXpZrHUXkv+fJjdYaFWHIktnuqE+cIC+0Or6k/TH7oWQyXpEM1Ugx8Fm0fvLCKer82Fg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR11MB8418 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, 24 Apr 2024 11:14:14 -0700 Resent-From: n.jayaprakash@intel.com Reply-To: devel@edk2.groups.io,n.jayaprakash@intel.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: ZajtfaZPgmJKXfsOSWNtQFv6x7686176AA= 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=NnEdImPE; 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 Hi Mike, I have sent an updated patch v2 for review which uses the MP Services proto= col API StarupThisAP() to read / write MSRs specific to CPU cores. Please review and do the needful. Regards, JP -----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 & wr= msr_ex functions to read/write cpu specific msrs Thanks Mike. I shall make necessary changes and submit the PR again for rev= iew. Regards, JP -----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 & wr= msr_ex functions to read/write cpu specific msrs Please use MP Services Protocol APIs StartupAllAPs() or StarupThisAP() to r= ead/write MSRs on other logical processors. There and many examples of this in the UefiCpuPkg to programming MSRs on al= l the logical processors. Mike > -----Original Message----- > From: Jayaprakash, N > Sent: Wednesday, April 17, 2024 8:16 PM > To: Kinney, Michael D ;=20 > devel@edk2.groups.io > Cc: Rebecca Cran > Subject: RE: [edk2-devel] [edk2-libc Patch 1/1] edk2-libc:add rdmsr_ex=20 > & wrmsr_ex functions to read/write cpu specific msrs >=20 > In the validation and debug scenarios, engineers tend to read MSRs and=20 > write to MSRs of different CPUs. > So we are providing a simple mechanism through these APIs to enable=20 > them to do these operations. >=20 > These APIs will be part of the edk2 module of the Python interpreter=20 > 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=20 > 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=20 > > Subject: RE: [edk2-devel] [edk2-libc Patch 1/1] edk2-libc:add rdmsr_ex=20 > & 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=20 > operation and is typically used if the current BSP is not stable or=20 > 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=20 > 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=20 > > > > 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=20 > > Jayaprakash, N > > Sent: Wednesday, April 10, 2024 11:49 AM > > To: devel@edk2.groups.io > > Cc: Jayaprakash, N ; Rebecca Cran=20 > > ; Kinney, Michael D > > Subject: [edk2-devel] [edk2-libc Patch 1/1] edk2-libc:add rdmsr_ex &=20 > > 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=20 > > APIs supported in edk2 module. These extension APIs makes it > possible > > to read / write MSRs from specific processors and fills an existing=20 > > 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=20 > > + 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=20 > > rax_value, unsigned int rbx_value, unsigned int rcx_value, unsigned=20 > > 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=20 > > */ #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,=20 > > +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=20 > > */ extern char **environ; @@ -3865,6 +3901,56 @@ > edk2_rdmsr(PyObject > > *self, PyObject *args) > > return Py_BuildValue("(II)", (unsigned long)veax, (unsigned=20 > > 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\=20 > > +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=20 > > +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 {=20 > > 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 (#118232): https://edk2.groups.io/g/devel/message/118232 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-