public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [edk2-devel] [PATCH] OvmfPkg: Set PcdCpuMaxLogicalProcessorNumber in OvmfXen
@ 2024-04-24 13:36 Alejandro Vallejo via groups.io
  2024-04-25  7:31 ` Gerd Hoffmann
  0 siblings, 1 reply; 6+ messages in thread
From: Alejandro Vallejo via groups.io @ 2024-04-24 13:36 UTC (permalink / raw)
  To: devel
  Cc: Alejandro Vallejo, Anthony Perard, Ard Biesheuvel, Gerd Hoffmann,
	Jiewen Yao

Bump the compile-time constant for maximum processor count from 64 to 128
in order to allow that many vCPUs to be brought online on Xen guests with
the default OVMF configuration.

Cc: Anthony Perard <anthony.perard@citrix.com>
Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Signed-off-by: Alejandro Vallejo <alejandro.vallejo@cloud.com>
---
 OvmfPkg/OvmfXen.dsc | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/OvmfPkg/OvmfXen.dsc b/OvmfPkg/OvmfXen.dsc
index fa1a570e746a..44a9b0cbae68 100644
--- a/OvmfPkg/OvmfXen.dsc
+++ b/OvmfPkg/OvmfXen.dsc
@@ -503,6 +503,9 @@
   # Noexec settings for DXE.
   gEfiMdeModulePkgTokenSpaceGuid.PcdSetNxForStack|FALSE
 
+  # UefiCpuPkg PCDs related to initial AP bringup and general AP management.
+  gUefiCpuPkgTokenSpaceGuid.PcdCpuMaxLogicalProcessorNumber|128
+
   # Set memory encryption mask
   gEfiMdeModulePkgTokenSpaceGuid.PcdPteMemoryEncryptionAddressOrMask|0x0
 
-- 
2.34.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#118247): https://edk2.groups.io/g/devel/message/118247
Mute This Topic: https://groups.io/mt/105721898/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [edk2-devel] [PATCH] OvmfPkg: Set PcdCpuMaxLogicalProcessorNumber in OvmfXen
  2024-04-24 13:36 [edk2-devel] [PATCH] OvmfPkg: Set PcdCpuMaxLogicalProcessorNumber in OvmfXen Alejandro Vallejo via groups.io
@ 2024-04-25  7:31 ` Gerd Hoffmann
  2024-04-25 10:42   ` Alejandro Vallejo via groups.io
  0 siblings, 1 reply; 6+ messages in thread
From: Gerd Hoffmann @ 2024-04-25  7:31 UTC (permalink / raw)
  To: Alejandro Vallejo; +Cc: devel, Anthony Perard, Ard Biesheuvel, Jiewen Yao

On Wed, Apr 24, 2024 at 02:36:32PM +0100, Alejandro Vallejo wrote:
> Bump the compile-time constant for maximum processor count from 64 to 128
> in order to allow that many vCPUs to be brought online on Xen guests with
> the default OVMF configuration.

> +  # UefiCpuPkg PCDs related to initial AP bringup and general AP management.
> +  gUefiCpuPkgTokenSpaceGuid.PcdCpuMaxLogicalProcessorNumber|128

Note that this is a dynamic PCD, so you can set it at runtime to the
number of vcpus present in the VM.  See MaxCpuCountInitialization() in
OvmfPkg/PlatformPei/Platform.c for example.

take care,
  Gerd



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#118274): https://edk2.groups.io/g/devel/message/118274
Mute This Topic: https://groups.io/mt/105721898/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [edk2-devel] [PATCH] OvmfPkg: Set PcdCpuMaxLogicalProcessorNumber in OvmfXen
  2024-04-25  7:31 ` Gerd Hoffmann
@ 2024-04-25 10:42   ` Alejandro Vallejo via groups.io
  2024-04-25 10:59     ` Anthony PERARD via groups.io
  0 siblings, 1 reply; 6+ messages in thread
From: Alejandro Vallejo via groups.io @ 2024-04-25 10:42 UTC (permalink / raw)
  To: Gerd Hoffmann; +Cc: devel, Anthony Perard, Ard Biesheuvel, Jiewen Yao

Hi,

On 25/04/2024 08:31, Gerd Hoffmann wrote:
> On Wed, Apr 24, 2024 at 02:36:32PM +0100, Alejandro Vallejo wrote:
>> Bump the compile-time constant for maximum processor count from 64 to 128
>> in order to allow that many vCPUs to be brought online on Xen guests with
>> the default OVMF configuration.
> 
>> +  # UefiCpuPkg PCDs related to initial AP bringup and general AP management.
>> +  gUefiCpuPkgTokenSpaceGuid.PcdCpuMaxLogicalProcessorNumber|128
> 
> Note that this is a dynamic PCD, so you can set it at runtime to the
> number of vcpus present in the VM.  See MaxCpuCountInitialization() in
> OvmfPkg/PlatformPei/Platform.c for example.
> 
> take care,
>   Gerd
> 

Thanks for the heads up. Do you mean setting it at runtime through
fw_cfg? I saw PlatformMaxCpuCountInitialization() providing some
customizability, but Xen's toolstack doesn't provide fw_cfg at the
moment so it can't (as far as I've seen) use it.

I'm currently forced to do the override at compile time passing this...

    --pcd gUefiCpuPkgTokenSpaceGuid.PcdCpuMaxLogicalProcessorNumber=128

... to build.sh, but I'd rather have the default max match Xen's idea of
max unless there's a strong reason not to.

Cheers,
Alejandro


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#118286): https://edk2.groups.io/g/devel/message/118286
Mute This Topic: https://groups.io/mt/105721898/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [edk2-devel] [PATCH] OvmfPkg: Set PcdCpuMaxLogicalProcessorNumber in OvmfXen
  2024-04-25 10:42   ` Alejandro Vallejo via groups.io
@ 2024-04-25 10:59     ` Anthony PERARD via groups.io
  2024-04-25 13:58       ` Gerd Hoffmann
  0 siblings, 1 reply; 6+ messages in thread
From: Anthony PERARD via groups.io @ 2024-04-25 10:59 UTC (permalink / raw)
  To: Alejandro Vallejo; +Cc: Gerd Hoffmann, devel, Ard Biesheuvel, Jiewen Yao

On Thu, Apr 25, 2024 at 11:42:01AM +0100, Alejandro Vallejo wrote:
> Hi,
> 
> On 25/04/2024 08:31, Gerd Hoffmann wrote:
> > On Wed, Apr 24, 2024 at 02:36:32PM +0100, Alejandro Vallejo wrote:
> >> Bump the compile-time constant for maximum processor count from 64 to 128
> >> in order to allow that many vCPUs to be brought online on Xen guests with
> >> the default OVMF configuration.
> > 
> >> +  # UefiCpuPkg PCDs related to initial AP bringup and general AP management.
> >> +  gUefiCpuPkgTokenSpaceGuid.PcdCpuMaxLogicalProcessorNumber|128
> > 
> > Note that this is a dynamic PCD, so you can set it at runtime to the
> > number of vcpus present in the VM.  See MaxCpuCountInitialization() in
> > OvmfPkg/PlatformPei/Platform.c for example.
> > 
> > take care,
> >   Gerd
> > 
> 
> Thanks for the heads up. Do you mean setting it at runtime through
> fw_cfg? I saw PlatformMaxCpuCountInitialization() providing some
> customizability, but Xen's toolstack doesn't provide fw_cfg at the
> moment so it can't (as far as I've seen) use it.

We don't need fw_cfg to set a PCD at runtime.

It's a bit more complicated than setting it at build time, but we can
always ask Xen how many vcpu we have and set the PCD accordingly. This
is something that can happen in OvmfPkg/XenPlatformPei module.

But to be honest, I don't know if it's worth it, because I don't know the
downside of having a higher value for PcdCpuMaxLogicalProcessorNumber.

Cheers,

-- 
Anthony PERARD


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#118304): https://edk2.groups.io/g/devel/message/118304
Mute This Topic: https://groups.io/mt/105721898/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [edk2-devel] [PATCH] OvmfPkg: Set PcdCpuMaxLogicalProcessorNumber in OvmfXen
  2024-04-25 10:59     ` Anthony PERARD via groups.io
@ 2024-04-25 13:58       ` Gerd Hoffmann
  2024-06-28 14:25         ` Alejandro Vallejo via groups.io
  0 siblings, 1 reply; 6+ messages in thread
From: Gerd Hoffmann @ 2024-04-25 13:58 UTC (permalink / raw)
  To: Anthony PERARD; +Cc: Alejandro Vallejo, devel, Ard Biesheuvel, Jiewen Yao

  Hi,
 
> It's a bit more complicated than setting it at build time, but we can
> always ask Xen how many vcpu we have and set the PCD accordingly. This
> is something that can happen in OvmfPkg/XenPlatformPei module.

Exactly.

> But to be honest, I don't know if it's worth it, because I don't know the
> downside of having a higher value for PcdCpuMaxLogicalProcessorNumber.

Well, the downside is that you have to keep ovmf and xen in sync
manually.  Your call.  If you prefer to do it that way I have no
objections, just wanted point out the alternative approach.

take care,
  Gerd



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#118301): https://edk2.groups.io/g/devel/message/118301
Mute This Topic: https://groups.io/mt/105721898/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [edk2-devel] [PATCH] OvmfPkg: Set PcdCpuMaxLogicalProcessorNumber in OvmfXen
  2024-04-25 13:58       ` Gerd Hoffmann
@ 2024-06-28 14:25         ` Alejandro Vallejo via groups.io
  0 siblings, 0 replies; 6+ messages in thread
From: Alejandro Vallejo via groups.io @ 2024-06-28 14:25 UTC (permalink / raw)
  To: Gerd Hoffmann, Anthony PERARD; +Cc: devel, Ard Biesheuvel, Jiewen Yao

On Thu Apr 25, 2024 at 2:58 PM BST, Gerd Hoffmann wrote:
>   Hi,
>  
> > It's a bit more complicated than setting it at build time, but we can
> > always ask Xen how many vcpu we have and set the PCD accordingly. This
> > is something that can happen in OvmfPkg/XenPlatformPei module.
>
> Exactly.
>
> > But to be honest, I don't know if it's worth it, because I don't know the
> > downside of having a higher value for PcdCpuMaxLogicalProcessorNumber.
>
> Well, the downside is that you have to keep ovmf and xen in sync
> manually.  Your call.  If you prefer to do it that way I have no
> objections, just wanted point out the alternative approach.
>
> take care,
>   Gerd

FYI, I've created a Xen Gitlab ticket to expose the maximum number of vCPUs as
discussed. It shoudn't be hard to expose the information in the Xen-specific
CPUID leaves at 0x4000000X (they are visible even with Viridian enabled, so that
should be fine).

I'll re-send a runtime version of this patch based on that information after
the required CPUID extension is in place.

https://gitlab.com/xen-project/xen/-/issues/191

Cheers,
Alejandro


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#119727): https://edk2.groups.io/g/devel/message/119727
Mute This Topic: https://groups.io/mt/105721898/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-06-28 14:25 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-24 13:36 [edk2-devel] [PATCH] OvmfPkg: Set PcdCpuMaxLogicalProcessorNumber in OvmfXen Alejandro Vallejo via groups.io
2024-04-25  7:31 ` Gerd Hoffmann
2024-04-25 10:42   ` Alejandro Vallejo via groups.io
2024-04-25 10:59     ` Anthony PERARD via groups.io
2024-04-25 13:58       ` Gerd Hoffmann
2024-06-28 14:25         ` Alejandro Vallejo via groups.io

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox