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 672EE7803CE for ; Thu, 18 Apr 2024 03:16:23 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=mBidW9jOkmQjavKJfBn4DlEx4J56zzCBI0Rr5Dwu5Io=; 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=1713410181; v=1; b=vqLOq96B7gb7dJKUa3M0t3rqxiXQYWpFdzGin8AIGpA6A57NKxHL1prMa5hPIz/A4+AsS483 9PKNL1MreY7ke57SJ5TAx24xZQ7vc1QNq67j7QWLn3E/xZEl4jw5pZ6FVXv50Y8+sXN+W5hWCRv Tf/356ZIqOT5S+OfbgEAXgsWUoCMYo7LiCgTfghHGZVY7Re2rYhT+CaOi07eLPJsOsXoYt9rDlW K+okKS+7ahJ0o3zBDkAJ9/lDpCj8CC1UoW+ycyjz6RVVDQIPrlOWqCwHDwtB49IeGcpnWl71dg3 tIlwReQoyy3eoIuwb6sF+PRNup9A5nAXGcysYj08mUUmg== X-Received: by 127.0.0.2 with SMTP id rLFuYY7687511xtsWmLZp5KC; Wed, 17 Apr 2024 20:16:21 -0700 X-Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.19]) by mx.groups.io with SMTP id smtpd.web11.4265.1713410180971025190 for ; Wed, 17 Apr 2024 20:16:21 -0700 X-CSE-ConnectionGUID: pKXp50vKSxiWW8VCuYaCNQ== X-CSE-MsgGUID: Rt6KM2l7RVORRB8KWo6MAQ== X-IronPort-AV: E=McAfee;i="6600,9927,11047"; a="8797429" X-IronPort-AV: E=Sophos;i="6.07,210,1708416000"; d="scan'208";a="8797429" X-Received: from fmviesa001.fm.intel.com ([10.60.135.141]) by fmvoesa113.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Apr 2024 20:16:20 -0700 X-CSE-ConnectionGUID: Fbs5idIpRcq59eDqUwtUjA== X-CSE-MsgGUID: RvOjhVxjQsWAWb7Xk5TfUA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,210,1708416000"; d="scan'208";a="54040150" X-Received: from fmsmsx601.amr.corp.intel.com ([10.18.126.81]) by fmviesa001.fm.intel.com with ESMTP/TLS/AES256-GCM-SHA384; 17 Apr 2024 20:16:20 -0700 X-Received: from fmsmsx610.amr.corp.intel.com (10.18.126.90) 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 20:16:20 -0700 X-Received: from FMSEDG603.ED.cps.intel.com (10.1.192.133) by fmsmsx610.amr.corp.intel.com (10.18.126.90) 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 20:16:20 -0700 X-Received: from NAM12-DM6-obe.outbound.protection.outlook.com (104.47.59.168) by edgegateway.intel.com (192.55.55.68) 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 20:16:16 -0700 X-Received: from PH7PR11MB5943.namprd11.prod.outlook.com (2603:10b6:510:13f::19) by PH7PR11MB7962.namprd11.prod.outlook.com (2603:10b6:510:245::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7452.50; Thu, 18 Apr 2024 03:16:13 +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.7452.050; Thu, 18 Apr 2024 03:16:13 +0000 From: "Jayaprakash, N" 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 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/YUA== Date: Thu, 18 Apr 2024 03:16:13 +0000 Message-ID: References: <20240410061849.984-1-n.jayaprakash@intel.com> <17C4D6CE42E68D40.16800@groups.io> In-Reply-To: Accept-Language: en-IN, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-ms-traffictypediagnostic: PH7PR11MB5943:EE_|PH7PR11MB7962:EE_ x-ms-office365-filtering-correlation-id: 9a28e8ba-bd02-4700-b812-08dc5f55e6ec x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam-message-info: 6loQdyzALeB3bbOAPdxBTwaTo9AVSSU96G5wlnpIaN1SRy4GWLy4WbuZtoY+NwKgaSkAOdn1BYSo0U6wpFCamoaictYH6ORxQAn0ATSk5QSAhJpafEb8ovtSHvlPZYd6M1hLVU7ZXBW3UjLKkJrdFR2doEiMZnBWL2LWEK0Nt+6txj1ycO0sR8kPbNZs/46yW/Q4lgI8f0V05cpr2OMHTxmtqGVVvOwcVFMmqBgA38AtNfYe0Q+/GOECEVa1Nj/SSF5UmKjVLkkFfQrpirpvHHGtzlT4YmfY4JDSwhzhupc9qFZTaIohPrYYeEOf8ewzwr6TMeDOTMEGqN9pqm3wGq5z5szvLKZa1+uapm3qCB/5qvWGP/mRCfHPS7D3q+cbZCUlW7wzYWxYpzjNE2mQhx/HOMhS/y146F09IqTSmuLJiHxtrDzay0FyA6UwfhDcVlJ8Y2kBXB32Tq8BLVAcANpC2fQRJCYNhpph+PdblI+vfI25xzIOIvkD1WP3xef/Zxb1yqYrShF9K65wveTyaoNPS8iECAZjl4I6Y1sC9RV93R6C9ht1Td1q8CVjp7O0K15LhILV/r01kR0SFkmnMna+r/QxhbKDmp5445270B/XWWujNQkdDBfPpdhBWkLc5M+3F8WPmAeZkr9kqwVliQB+JX9YK3fw8IEOmeWiJnrOWtcWg1Fypo62wDs/NQhX x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?4Dxka2eN9py9ug+6S2awKdciJT8mredaWp4dm/vngIFB0pDJgLeUznXH+Ar4?= =?us-ascii?Q?fTwhLg4ew3WPC+RFJbwUbP8B8G4qSY1tPIqcCtIum29Q69KYmeYS/qatJJIq?= =?us-ascii?Q?5VwqtV4/fR74vL4RzvVeRNF2vJq+elfOQHqglwKWNooEH56tgd8AR1gVQUB3?= =?us-ascii?Q?kKeuflzyhIlofsjGLnMbdSika56SHVheSQHrSQz9oRqb5m36eH6F1MyG9I3o?= =?us-ascii?Q?iROcqceWeaqeM9YpdY5BUUHQ7urwm6ibA1N8bz/IMvL7i3LAMO7cqB9Sup2Y?= =?us-ascii?Q?c4FFk3Ue9uO+GxErazmD7zuBFv/mGsosFOmfzA2l3zDMGspbUWiJTx4s7lZs?= =?us-ascii?Q?fio8gf4F+4bCBQy07J/8CviXlajfn95ofc9lKCxxRPxVVbJkCTn5cHNg9aJA?= =?us-ascii?Q?bObwEgBA0bybGqegMD6/GRy83+zAG2dplm3dE2+w15XvdZOp0sL8uGyzkGIm?= =?us-ascii?Q?9cSuo9SAcj8JQyzZ30BvOlb6AGBvLTvKRuJv2NyLNVSrF5+P1/SpH0avBuIJ?= =?us-ascii?Q?kmhE6omK/8oRuSnj3dhoQPpv5gT2fTXbLxXeETyC0Azwctm7I4LYIr1XI/HB?= =?us-ascii?Q?/wslVgXhQK5pPft16aEOwKSXJzim5BRzfugzLPs4nz731axaZfe7kSpcy4nV?= =?us-ascii?Q?ogb4TBxJ4QP35ixnipqIk/FZYXfsfDOJqqOC+KQlJk/YnoyPbiVf1Y2ACUwd?= =?us-ascii?Q?vmANB7wZmaE9ooPB/PCL9boVHtzRVtsfGVblCjYI1frSZi/xE5tJdZ8Clc+n?= =?us-ascii?Q?BPAndzAXnGacJTkoutZbft2OoYDjmU0DXQu3QQnqXW30Y7YwRWZGsLjn13WL?= =?us-ascii?Q?fhyP7sP0JZg/eJrH6vA4c96KCCilaksOWAzVOFPEPY9f/eDpwht05W7s2/Nr?= =?us-ascii?Q?L/DwlJYVd9qDFpBRy+AE+JkhX7hVpLdl7yUQaIZpilUGVXtg5d8jjkoq+8OA?= =?us-ascii?Q?L48WyZSujS6VnUwg4L+1cg9ZDx/6SmVdWdS+l9JYS23OtbWhwlB79gRU27/0?= =?us-ascii?Q?CTVH9I1a1xowN1ztBOM6+gyLRa5dyuFcRgIqKClUIRWy6B21C7N5nHejB6te?= =?us-ascii?Q?D9ooomNN4Aw8iXuuxH8np0wnLX6gsKkd6uVLuCz5nR5huwB/JPACKQxA6Bjo?= =?us-ascii?Q?qbRuetuzhQD5Rz+tUmKQA/lGWpw2oF4ChJ55LueRulifv6tN8QnYJyVW1uXu?= =?us-ascii?Q?lo5csqG3KRclmgCRj7m6jqgaj+vQi5KaYO7KZ3y0oAwu/Nxks0EGivEGBQ2z?= =?us-ascii?Q?+1Ie52qnaz5/J7tMS7SmfTWttRM5FZhaVJWbx+l9hmOiAO4hSpUFK2tmtfh+?= =?us-ascii?Q?7LUotPd9S5jUrq6PrYHeAZ7OfYAji6AJOi5whydCVIQntrZAS6QMSnj4fw16?= =?us-ascii?Q?mgbrJ6d/snGrfT5Wj42UPhtYxZxkPILvp129WWfY9/1I2GqGeZgfFOU9+vwv?= =?us-ascii?Q?EYHbqo+w5QwvE5YzrJ7QVRbo20cNP+HH46BYESONEph6ENbbz1Vsn90nPQ1N?= =?us-ascii?Q?CeTRAych3lZfNYwqQhoYF7V/b02cF243TouQNyY70TLlq95NXzehRd3n7ayC?= =?us-ascii?Q?kIAYDumMWffv4g3EV302dRvkcqQBd5Wi/+Tnl8sk?= 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: 9a28e8ba-bd02-4700-b812-08dc5f55e6ec X-MS-Exchange-CrossTenant-originalarrivaltime: 18 Apr 2024 03:16:13.0697 (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: K2HpCnoRfPDapxx1eIxspgAQQ2Z1dU6g5fqkVO3775o/2ORYP3dzZao/WvKMhFbiWfJtmcsdFHV9jPljr0+BSQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR11MB7962 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 20:16:21 -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: BpL7EH2fy2bpDFSfWh926udIx7686176AA= 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=vqLOq96B; 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 In the validation and debug scenarios, engineers tend to read MSRs and writ= e 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 wi= ll 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 =20 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 & wr= msr_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 r= elated 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=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 > + Rebecca and Mike, >=20 > Would you be able to review this PR? >=20 > Regards, > JP >=20 > -----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 >=20 > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D4746 >=20 > 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=20 > to read / write MSRs from specific processors and fills an existing=20 > gap in this area. >=20 > 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(-) >=20 > 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. >=20 > 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=20 > available under > the terms and conditions of the BSD License that accompanies this=20 > distribution. > The full text of the license may be found at @@ -22,16 +22,23 @@=20 > #include #include #include > +#include // Needed for the definition of > EFI_AP_PROCEDURE > #include > #include > #include > #include > +#include > +#include >=20 > #ifdef __cplusplus > extern "C" { > #endif >=20 > PyTypeObject EfiGuidType; > +EFI_MP_SERVICES_PROTOCOL *gpMpService =3D NULL; > +UINTN gBSPProcessorNumber =3D 0; > +UINTN gNumberOfProcessors =3D 0; > +UINTN gNumberOfEnabledProcessors =3D 0; >=20 > 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) >=20 > +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=20 > *self, PyObject *args) > return Py_BuildValue("(II)", (unsigned long)veax, (unsigned=20 > long)vedx); } >=20 > +PyDoc_STRVAR(efi_rdmsr_ex__doc__, > +"rdmsr_ex(cpu, msr) -> (lower_32bits, higher_32bits)\n\ \n\ Read the=20 > +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\=20 > +"); > + > +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=20 > +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; >=20 > #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); >=20 > - m =3D PyModule_Create(&edk2module); > + m =3D PyModule_Create(&edk2module); > if (m =3D=3D NULL) > return m; >=20 > @@ -4870,7 +5021,7 @@ PyEdk2__Init(void) > //PyModule_AddObject(m, "statvfs_result", > // (PyObject*) &StatVFSResultType); > initialized =3D 1; > - return m; > + return m; >=20 > } >=20 > 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 >=20 > +[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 (#117942): https://edk2.groups.io/g/devel/message/117942 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-