* [PATCH qemu-server 1/4] cpu config: split resolve_cpu_flags() function
2026-03-23 13:27 [PATCH-SERIES qemu-server 0/4] cpu config: warn that OVMF might limit phys-bits to 40 without pdpe1gb CPU flag Fiona Ebner
@ 2026-03-23 13:27 ` Fiona Ebner
2026-03-23 13:27 ` [PATCH qemu-server 2/4] move get_host_phys_address_bits() to helpers module Fiona Ebner
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Fiona Ebner @ 2026-03-23 13:27 UTC (permalink / raw)
To: pve-devel
In preparation to re-use the resolved flags for a check.
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
---
src/PVE/QemuServer/CPUConfig.pm | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/src/PVE/QemuServer/CPUConfig.pm b/src/PVE/QemuServer/CPUConfig.pm
index 1a4f2510..c689efad 100644
--- a/src/PVE/QemuServer/CPUConfig.pm
+++ b/src/PVE/QemuServer/CPUConfig.pm
@@ -778,7 +778,7 @@ sub is_abstracted {
# },
# ...
# }
-sub resolve_cpu_flags {
+my sub resolve_cpu_flags {
my @flag_hashes = @_;
my $flags = {};
@@ -836,6 +836,12 @@ sub resolve_cpu_flags {
}
}
+ return $flags;
+}
+
+my sub print_cpu_flags {
+ my ($flags) = @_;
+
my $flag_str = '';
# sort for command line stability
for my $flag_name (sort keys %$flags) {
@@ -957,7 +963,7 @@ sub get_cpu_options {
my $cpu_str = $cputype;
# will be resolved in parameter order
- $cpu_str .= resolve_cpu_flags(
+ my $resolved_flags = resolve_cpu_flags(
$pve_flags,
$hv_flags,
$builtin_cputype_flags,
@@ -965,6 +971,7 @@ sub get_cpu_options {
$vm_flags,
$pve_forced_flags,
);
+ $cpu_str .= print_cpu_flags($resolved_flags);
for my $phys_bits_opt (qw(guest-phys-bits phys-bits)) {
my $phys_bits = '';
--
2.47.3
^ permalink raw reply [flat|nested] 5+ messages in thread* [PATCH qemu-server 2/4] move get_host_phys_address_bits() to helpers module
2026-03-23 13:27 [PATCH-SERIES qemu-server 0/4] cpu config: warn that OVMF might limit phys-bits to 40 without pdpe1gb CPU flag Fiona Ebner
2026-03-23 13:27 ` [PATCH qemu-server 1/4] cpu config: split resolve_cpu_flags() function Fiona Ebner
@ 2026-03-23 13:27 ` Fiona Ebner
2026-03-23 13:27 ` [PATCH qemu-server 3/4] cpu config: get cpu options: avoid shadowing $conf variable Fiona Ebner
2026-03-23 13:27 ` [PATCH qemu-server 4/4] cpu config: warn that OVMF might limit phys-bits to 40 without pdpe1gb CPU flag Fiona Ebner
3 siblings, 0 replies; 5+ messages in thread
From: Fiona Ebner @ 2026-03-23 13:27 UTC (permalink / raw)
To: pve-devel
To be re-used by a check in the CPU config module.
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
---
src/PVE/QemuServer/Helpers.pm | 18 ++++++++++++++++++
src/PVE/QemuServer/Memory.pm | 23 +++--------------------
src/test/run_config2command_tests.pl | 11 ++++++++---
3 files changed, 29 insertions(+), 23 deletions(-)
diff --git a/src/PVE/QemuServer/Helpers.pm b/src/PVE/QemuServer/Helpers.pm
index e14e9ad4..65f4ce5f 100644
--- a/src/PVE/QemuServer/Helpers.pm
+++ b/src/PVE/QemuServer/Helpers.pm
@@ -369,4 +369,22 @@ sub get_iscsi_initiator_name {
return $initiator;
}
+my $_host_bits;
+
+sub get_host_phys_address_bits {
+ return $_host_bits if defined($_host_bits);
+
+ my $fh = IO::File->new('/proc/cpuinfo', "r") or return;
+ while (defined(my $line = <$fh>)) {
+ # hopefully we never need to care about mixed (big.LITTLE) archs
+ if ($line =~ m/^address sizes\s*:\s*(\d+)\s*bits physical/i) {
+ $_host_bits = int($1);
+ $fh->close();
+ return $_host_bits;
+ }
+ }
+ $fh->close();
+ return; # undef, cannot really do anything..
+}
+
1;
diff --git a/src/PVE/QemuServer/Memory.pm b/src/PVE/QemuServer/Memory.pm
index 7ebfc545..ab337bea 100644
--- a/src/PVE/QemuServer/Memory.pm
+++ b/src/PVE/QemuServer/Memory.pm
@@ -93,24 +93,6 @@ sub parse_memory {
return $res;
}
-my $_host_bits;
-
-sub get_host_phys_address_bits {
- return $_host_bits if defined($_host_bits);
-
- my $fh = IO::File->new('/proc/cpuinfo', "r") or return;
- while (defined(my $line = <$fh>)) {
- # hopefully we never need to care about mixed (big.LITTLE) archs
- if ($line =~ m/^address sizes\s*:\s*(\d+)\s*bits physical/i) {
- $_host_bits = int($1);
- $fh->close();
- return $_host_bits;
- }
- }
- $fh->close();
- return; # undef, cannot really do anything..
-}
-
my sub get_max_mem {
my ($conf) = @_;
@@ -122,14 +104,15 @@ my sub get_max_mem {
my $bits;
if (my $phys_bits = $cpu->{'phys-bits'}) {
if ($phys_bits eq 'host') {
- $bits = get_host_phys_address_bits();
+ $bits = PVE::QemuServer::Helpers::get_host_phys_address_bits();
} elsif ($phys_bits =~ /^(\d+)$/) {
$bits = int($phys_bits);
}
}
if (!defined($bits)) {
- my $host_bits = get_host_phys_address_bits() // 36; # fixme: what fallback?
+ # fixme: what fallback?
+ my $host_bits = PVE::QemuServer::Helpers::get_host_phys_address_bits() // 36;
if ($cpu->{cputype} && $cpu->{cputype} =~ /^(host|max)$/) {
$bits = $host_bits;
} else {
diff --git a/src/test/run_config2command_tests.pl b/src/test/run_config2command_tests.pl
index f7f3a2d5..3c4a695c 100755
--- a/src/test/run_config2command_tests.pl
+++ b/src/test/run_config2command_tests.pl
@@ -370,6 +370,14 @@ $qemu_server_config->mock(
},
);
+my $qemu_server_helpers;
+$qemu_server_helpers = Test::MockModule->new('PVE::QemuServer::Helpers');
+$qemu_server_helpers->mock(
+ get_host_phys_address_bits => sub {
+ return 46;
+ },
+);
+
my $qemu_server_memory;
$qemu_server_memory = Test::MockModule->new('PVE::QemuServer::Memory');
$qemu_server_memory->mock(
@@ -380,9 +388,6 @@ $qemu_server_memory->mock(
my ($id) = @_;
return 1;
},
- get_host_phys_address_bits => sub {
- return 46;
- },
);
my $pve_common_tools;
--
2.47.3
^ permalink raw reply [flat|nested] 5+ messages in thread* [PATCH qemu-server 3/4] cpu config: get cpu options: avoid shadowing $conf variable
2026-03-23 13:27 [PATCH-SERIES qemu-server 0/4] cpu config: warn that OVMF might limit phys-bits to 40 without pdpe1gb CPU flag Fiona Ebner
2026-03-23 13:27 ` [PATCH qemu-server 1/4] cpu config: split resolve_cpu_flags() function Fiona Ebner
2026-03-23 13:27 ` [PATCH qemu-server 2/4] move get_host_phys_address_bits() to helpers module Fiona Ebner
@ 2026-03-23 13:27 ` Fiona Ebner
2026-03-23 13:27 ` [PATCH qemu-server 4/4] cpu config: warn that OVMF might limit phys-bits to 40 without pdpe1gb CPU flag Fiona Ebner
3 siblings, 0 replies; 5+ messages in thread
From: Fiona Ebner @ 2026-03-23 13:27 UTC (permalink / raw)
To: pve-devel
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
---
src/PVE/QemuServer/CPUConfig.pm | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/PVE/QemuServer/CPUConfig.pm b/src/PVE/QemuServer/CPUConfig.pm
index c689efad..8da9010e 100644
--- a/src/PVE/QemuServer/CPUConfig.pm
+++ b/src/PVE/QemuServer/CPUConfig.pm
@@ -975,9 +975,9 @@ sub get_cpu_options {
for my $phys_bits_opt (qw(guest-phys-bits phys-bits)) {
my $phys_bits = '';
- foreach my $conf ($custom_cpu, $cpu) {
- next if !defined($conf);
- my $conf_val = $conf->{$phys_bits_opt};
+ for my $cpu_conf ($custom_cpu, $cpu) {
+ next if !defined($cpu_conf);
+ my $conf_val = $cpu_conf->{$phys_bits_opt};
next if !$conf_val;
if ($conf_val eq 'host') {
die "unexpected value 'host' for guest-phys-bits"
--
2.47.3
^ permalink raw reply [flat|nested] 5+ messages in thread* [PATCH qemu-server 4/4] cpu config: warn that OVMF might limit phys-bits to 40 without pdpe1gb CPU flag
2026-03-23 13:27 [PATCH-SERIES qemu-server 0/4] cpu config: warn that OVMF might limit phys-bits to 40 without pdpe1gb CPU flag Fiona Ebner
` (2 preceding siblings ...)
2026-03-23 13:27 ` [PATCH qemu-server 3/4] cpu config: get cpu options: avoid shadowing $conf variable Fiona Ebner
@ 2026-03-23 13:27 ` Fiona Ebner
3 siblings, 0 replies; 5+ messages in thread
From: Fiona Ebner @ 2026-03-23 13:27 UTC (permalink / raw)
To: pve-devel
OVMF limits phys-bits to 40 if no 1 GiB pages are available. When
built in debug mode, OVMF logs a debug message about this. But
otherwise, there is no user-visible log of this happening.
In practice, VMs with a lot of memory or VMs with GPU passthrough with
a lot of vRAM might not boot when the pdpe1gb CPU flag is not present.
In particular, this is the case for the built-in x86-64-vX models that
are based on the qemu64 model as well as the backend default kvm64.
It can't be expected that Proxmox VE users check the EDK II source
code to figure this out, so log a warning. The warning is limited to
CPU models based on the qemu64 and kvm64 models, since checking for
other models would require the CPU model expansion which is currently
not cheap to get. This should cover most problematic scenarios.
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
---
src/PVE/QemuServer/CPUConfig.pm | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)
diff --git a/src/PVE/QemuServer/CPUConfig.pm b/src/PVE/QemuServer/CPUConfig.pm
index 8da9010e..fb9af277 100644
--- a/src/PVE/QemuServer/CPUConfig.pm
+++ b/src/PVE/QemuServer/CPUConfig.pm
@@ -879,6 +879,21 @@ sub parse_cpuflag_list {
return $res;
}
+my sub check_phys_bits_above_40_compat {
+ my ($bios, $cpu_type, $cpu_flags) = @_;
+
+ # Would need to check CPU model expansion for others, but that information is not cheap to get
+ # right now. Checking with 'qemu64' and 'kvm64' should cover most problematic scenarios.
+ return if $cpu_type ne 'qemu64' && $cpu_type ne 'kvm64';
+
+ return if !$bios || $bios ne 'ovmf';
+
+ if (!$cpu_flags->{pdpe1gb} || $cpu_flags->{pdpe1gb}->{op} eq '-') {
+ log_warn("OVMF firmware might limit CPU 'phys-bits' to 40"
+ . " - enable the 'pdpe1gb' CPU flag to avoid this");
+ }
+}
+
# Calculate QEMU's '-cpu' argument from a given VM configuration
sub get_cpu_options {
my ($conf, $arch, $kvm, $kvm_off, $machine_version, $winversion, $gpu_passthrough) = @_;
@@ -973,6 +988,8 @@ sub get_cpu_options {
);
$cpu_str .= print_cpu_flags($resolved_flags);
+ my $using_phys_bits_above_40;
+
for my $phys_bits_opt (qw(guest-phys-bits phys-bits)) {
my $phys_bits = '';
for my $cpu_conf ($custom_cpu, $cpu) {
@@ -982,14 +999,23 @@ sub get_cpu_options {
if ($conf_val eq 'host') {
die "unexpected value 'host' for guest-phys-bits"
if $phys_bits_opt eq 'guest-phys-bits';
+
$phys_bits = ",host-phys-bits=true";
+
+ my $host_phys_bits = PVE::QemuServer::Helpers::get_host_phys_address_bits();
+ $using_phys_bits_above_40 = 1 if defined($host_phys_bits) && $host_phys_bits > 40;
} else {
$phys_bits = ",${phys_bits_opt}=${conf_val}";
+
+ $using_phys_bits_above_40 = 1 if $phys_bits_opt eq 'phys-bits' && $conf_val > 40;
}
}
$cpu_str .= $phys_bits;
}
+ check_phys_bits_above_40_compat($conf->{bios}, $cputype, $resolved_flags)
+ if $using_phys_bits_above_40;
+
return ('-cpu', $cpu_str);
}
--
2.47.3
^ permalink raw reply [flat|nested] 5+ messages in thread