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 CF527941269 for ; Thu, 18 Apr 2024 06:18:59 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=W+Nf9FMHSbTe8sdWdnG7TuyErjNW5jD4arT6ezlfhmE=; 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=1713421138; v=1; b=bcA8kg3aQNPu2AIY+cVrb5Dg2El2fL3TH6Pa9+bLuCRqkf4T8eGQCYKY87fetvC52TSTW6ba HVbwMvIaMZ+QUN0MZjlpJ9y5CfWvIhfuUX2qhK75F0FZxMUmfwGjYYjXUWWwxO7qoaihZIlJdKZ ZKhGVS+8WAzkkUr3xH7EnPmMkHlxWnAf454JWPhp4qFj7WwCZ0EA2jEi/XjJ6/EzvOFmxFTOGcK OdQvm78UYgxvzZECKzJNVtCek6OHSuC3M/LW0slJJGJMjWeboaJc0EGb/mDf+pSOgiwL4Ix4Obk emOjrbwxtQQYZhJmLJKz0FxY2MrSr94HmWB900ZmZY+yA== X-Received: by 127.0.0.2 with SMTP id 3TOfYY7687511xUfrwglgz5P; Wed, 17 Apr 2024 23:18:58 -0700 X-Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.19]) by mx.groups.io with SMTP id smtpd.web10.6453.1713421136865853602 for ; Wed, 17 Apr 2024 23:18:57 -0700 X-CSE-ConnectionGUID: 2rhk3JlVQHy4cC/1F0wARg== X-CSE-MsgGUID: a1mc/i8KT56vm3d9+beOdw== X-IronPort-AV: E=McAfee;i="6600,9927,11047"; a="8810249" X-IronPort-AV: E=Sophos;i="6.07,211,1708416000"; d="scan'208";a="8810249" X-Received: from orviesa004.jf.intel.com ([10.64.159.144]) by fmvoesa113.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Apr 2024 23:18:56 -0700 X-CSE-ConnectionGUID: m2mbNtAsR6aYXx4HtIdIUg== X-CSE-MsgGUID: Gak8yTFvTaKXXaJZsKYgYw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,211,1708416000"; d="scan'208";a="27678123" X-Received: from fmsmsx603.amr.corp.intel.com ([10.18.126.83]) by orviesa004.jf.intel.com with ESMTP/TLS/AES256-GCM-SHA384; 17 Apr 2024 23:18:56 -0700 X-Received: from fmsmsx612.amr.corp.intel.com (10.18.126.92) 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; Wed, 17 Apr 2024 23:18:55 -0700 X-Received: from fmsmsx602.amr.corp.intel.com (10.18.126.82) by fmsmsx612.amr.corp.intel.com (10.18.126.92) 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 23:18:55 -0700 X-Received: from FMSEDG603.ED.cps.intel.com (10.1.192.133) 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 23:18:55 -0700 X-Received: from NAM11-CO1-obe.outbound.protection.outlook.com (104.47.56.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 23:18:55 -0700 X-Received: from PH7PR11MB5943.namprd11.prod.outlook.com (2603:10b6:510:13f::19) by CY8PR11MB6938.namprd11.prod.outlook.com (2603:10b6:930:5a::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7472.27; Thu, 18 Apr 2024 06:18:52 +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 06:18:52 +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/YUIAAIlQAgAARb6A= Date: Thu, 18 Apr 2024 06:18:52 +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_|CY8PR11MB6938:EE_ x-ms-office365-filtering-correlation-id: 1b26e5a9-0ee9-427d-096a-08dc5f6f6b36 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam-message-info: jPsUgplQOBWFGOToc/sI0eBYGtALAlys9taeCcvbnn4Ww86qqjKM/Z2wPPJTF55tSKCk/OrlKUME3hP//kkBRqsOsxDYH03ZZLPfRme8u9BLJwQUfAAFe2PtT8RvA88AmL6dcYmXFsI2cxh5so5LrN6jYeO61N5H5FdMEECCCZvAObJ0CXRmSwwUxyIHJQuEoBSWUJnYDOUO07aooiIdeQmBClWGVUTpUM3uM39MgYb8Kt6+p6zs5qH+QJ4VRxesnfn2ECHrz96dcp42FrUpWqnqw3RkiZPDt1cKdYsaxb2GkzolNnY1gQtDGpFLcRv1/l+2WpEcKGduYA+zxssYx1FggZ79LXcox3r1ItXuDYAk0qR9TYOqbdxb68LxS791IOqPcXW80g7ZpvlHwfcrzISxiXNF26FBFzgHTyXb/GpYp/CQgT1sgbRboscRKCe/Mb00MNEIXrznPD2VV5lyFbZHledg02r6dkogyzwHuI9OfSYSvTb1a7okPRl4vP1ISfrQSgjLJOkuw8ZE/7CG5uf5oYCC/eoU2dqq6AntEh+eFb/BqbdpS6w78gpJy0BaRup7DBHX2CMWlkhoY1aSAub4mtSABSdRodvMAgT8Ws9WpAV5sI1C9RLGEP/u4+TEFbTngX8WAyafMVULG9dH22a0CPO+Q1+6aOT7KWHR0Ay/q9fYYRZfvfC/SgPBMRHc x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?u1iebOowBfGuGLfVFZtkyJkaVQB6C/Rz3rMWAoCj1cm7Njwm8SZTSOtSHdVP?= =?us-ascii?Q?80RKuAoxz5LoWGIwRnH7nYzHNViANF8CuuQYNqlcWaPu8QKcu14+bOvr0oDC?= =?us-ascii?Q?GkjcVzh/dRXbGn3bWvhe4wSQsnCEcYcAAkjjyCqLselDyUvB2dZKH9TipXci?= =?us-ascii?Q?SpjPk71WNgBR1OoIyfGBjRfMtmjDlUQA/PhI6rLMm8Z2RLQcYrAQzop5fAji?= =?us-ascii?Q?9pP7uY2GClW0zBKPZtn8jVHI4W/ItBwCqIzikt4rXBcNJQUbiKsUu77y1mRX?= =?us-ascii?Q?rbMK9RXN/flLOOgNP5jHdxqw530qZHa9YIo4ouqfAidU/hiJP/mbpq4feW9C?= =?us-ascii?Q?p+pmS+HVipgnLsxiIM1k2JKn4SF9wPm1DIjNJ5wtBlZpFSa4HQ+1YKOxZCWC?= =?us-ascii?Q?6tkKCu0McK3ZOpqgfCmQxG9Fzw/J60PG7tTbnsr7VKg0BHjnTk5+HYBoLK0V?= =?us-ascii?Q?bJk8F7O/Vf4pdBOh0Cm44qvQuU1MSaVzZgsmfF2FR9e2RxyBRrBQlC8TeOLO?= =?us-ascii?Q?UBdTEmVJOKdDwhi3T+lTYd4ILNuXCv+TgFncxjExeBchshE3LTXLK94cvqtQ?= =?us-ascii?Q?PrqsZi/dmxMQYFMUmBro0LJC1TRPiJdFy6xmY+vAPCL4L36KxZwxoF1d4vjB?= =?us-ascii?Q?Yj7wIn2K9nCJQJql2RbRkOHWs1cpIa5sTTDnI91bH5TsfAa2a728fyXBhMfz?= =?us-ascii?Q?Sy3JyzwfhUkmQ+aWDIpd0nTkqC5GKg+2MQPgzFbEzxGvOfp9yFjwaKPnRnDr?= =?us-ascii?Q?XhnDzryNWELyyf4ovKFk9ZvMR3J7QD4EiSKoqkoiJ0881lh18r35fMvlsMM6?= =?us-ascii?Q?Mk4h/AHcw9k4bz4BrIJop85isp+ufjHS/JLrA5EGu1Hu5zTdDvssLuu5tS2B?= =?us-ascii?Q?wUGhB2P2oBfZWSuGwDoNnjgd1PmSPFUhiiGJHhC7w5BrGsLCQe4PkrQHzmvS?= =?us-ascii?Q?MX3LbopcmUA+8It6Py3K2SMfQS0yoDHygAXPY2Lh5snvFu55pNhnu6OLZBiP?= =?us-ascii?Q?+75199e/LNL95ubF0Y0/1/hLWtz5wX7o7sntAB/DEzAMctxRwb9IwL9mZLgZ?= =?us-ascii?Q?0nmvo9aFEZdGp7NDQVo0LAMxIiGo8wnAR5TKVh7kNP0pBHfUmP/YM1fzqaHm?= =?us-ascii?Q?orZitvgYMMM1uzMjfsPRqkHmKw6sjy+BTVbaSMjiI0ubDPBw6lshMvhF35jV?= =?us-ascii?Q?tlm5PlQrvD8pzx55OfCCIGpzYe2XPyQ1mi9i81uRiZNbAcz/w7FyZMLk84YD?= =?us-ascii?Q?Ol/HryO39O8R3lJcv+JsT1YaAjabr6bkMrRWBtoR1Ufb9pQIGaiv14J74JBk?= =?us-ascii?Q?732FwoVsWYVRHJ+2GhDGtvU2JK/YgkFSYD/YQo1PWxETypeM3s1ITxY0223v?= =?us-ascii?Q?wNtoJBY94Pvl49sEDt2LCsyD3rvXFrwxsLphNLvES2ndOsH+RF7CJw3eliSc?= =?us-ascii?Q?nnXS+WfgKbFQjvi+Pg7N5RcJCbq6VcY/X8LhvMYfrfczNz5r6/bnydvlkkzR?= =?us-ascii?Q?25wzCNMuGI2bA4tEiC9UZJZNtwBaZ2Yb9OpYXSXUPnIDAaKwPOIF7C0/PrMe?= =?us-ascii?Q?QZw/XZj1KiDiM+ORmgLuvae/yoYv+nNMQeo/oDrD?= 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: 1b26e5a9-0ee9-427d-096a-08dc5f6f6b36 X-MS-Exchange-CrossTenant-originalarrivaltime: 18 Apr 2024 06:18:52.4415 (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: J2GDVbvxxgT+fSGb/pVBeC/4Jf+tksCsZjQ1dpLQrxLugKLVwYO25gFm+Eylc8w21cfaMhGqh6G6CVIFJ3OEmA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY8PR11MB6938 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 23:18:57 -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: E8w5pVHfhbdbQyJu5LcOWHF3x7686176AA= 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=bcA8kg3a; 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 Thanks Mike. I shall make necessary changes and submit the PR again for rev= iew. Regards, JP -----Original Message----- From: Kinney, Michael D =20 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 (#117944): https://edk2.groups.io/g/devel/message/117944 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-