all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Fiona Ebner <f.ebner@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH qemu-server] close #6378: expose guest-phys-bits CPU option
Date: Tue, 12 Aug 2025 17:30:14 +0200	[thread overview]
Message-ID: <20250812153144.154949-1-f.ebner@proxmox.com> (raw)

Quoting Fabian Grünbichler from the bug report:

> Intel ships some CPUs where the CPU address width and the IOMMU
> address width are different, which requires setting that option to
> properly support huge pages and/or VFIO:
>
> https://bugzilla.kernel.org/show_bug.cgi?id=220057
> https://lore.kernel.org/all/20250502224035.3183451-1-alex.williamson@redhat.com/t
> https://lore.kernel.org/qemu-devel/20250130134346.1754143-1-clg@redhat.com/

This likely also gives users a way forward with a regression reported
in the community forum:
https://forum.proxmox.com/threads/169586/

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
---
 src/PVE/QemuServer/CPUConfig.pm               | 31 +++++++++++++------
 .../q35-viommu-intel-guest-phys-bits.conf     |  2 ++
 .../q35-viommu-intel-guest-phys-bits.conf.cmd | 25 +++++++++++++++
 3 files changed, 48 insertions(+), 10 deletions(-)
 create mode 100644 src/test/cfg2cmd/q35-viommu-intel-guest-phys-bits.conf
 create mode 100644 src/test/cfg2cmd/q35-viommu-intel-guest-phys-bits.conf.cmd

diff --git a/src/PVE/QemuServer/CPUConfig.pm b/src/PVE/QemuServer/CPUConfig.pm
index 1c7c12fc..786a99d8 100644
--- a/src/PVE/QemuServer/CPUConfig.pm
+++ b/src/PVE/QemuServer/CPUConfig.pm
@@ -223,6 +223,13 @@ my $cpu_fmt = {
         pattern => qr/$cpu_flag_any_re(;$cpu_flag_any_re)*/,
         optional => 1,
     },
+    'guest-phys-bits' => {
+        type => 'integer',
+        minimum => 32, # see target/i386/cpu.c in QEMU
+        maximum => 64,
+        description => "Number of physical address bits available to the guest.",
+        optional => 1,
+    },
     'phys-bits' => {
         type => 'string',
         format => 'pve-phys-bits',
@@ -680,18 +687,22 @@ sub get_cpu_options {
         $pve_forced_flags,
     );
 
-    my $phys_bits = '';
-    foreach my $conf ($custom_cpu, $cpu) {
-        next if !defined($conf);
-        my $conf_val = $conf->{'phys-bits'};
-        next if !$conf_val;
-        if ($conf_val eq 'host') {
-            $phys_bits = ",host-phys-bits=true";
-        } else {
-            $phys_bits = ",phys-bits=$conf_val";
+    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};
+            next if !$conf_val;
+            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";
+            } else {
+                $phys_bits = ",${phys_bits_opt}=${conf_val}";
+            }
         }
+        $cpu_str .= $phys_bits;
     }
-    $cpu_str .= $phys_bits;
 
     return ('-cpu', $cpu_str);
 }
diff --git a/src/test/cfg2cmd/q35-viommu-intel-guest-phys-bits.conf b/src/test/cfg2cmd/q35-viommu-intel-guest-phys-bits.conf
new file mode 100644
index 00000000..7decb63e
--- /dev/null
+++ b/src/test/cfg2cmd/q35-viommu-intel-guest-phys-bits.conf
@@ -0,0 +1,2 @@
+machine: q35,viommu=intel
+cpu: host,guest-phys-bits=39
diff --git a/src/test/cfg2cmd/q35-viommu-intel-guest-phys-bits.conf.cmd b/src/test/cfg2cmd/q35-viommu-intel-guest-phys-bits.conf.cmd
new file mode 100644
index 00000000..b24baeb0
--- /dev/null
+++ b/src/test/cfg2cmd/q35-viommu-intel-guest-phys-bits.conf.cmd
@@ -0,0 +1,25 @@
+/usr/bin/kvm \
+  -id 8006 \
+  -name 'vm8006,debug-threads=on' \
+  -no-shutdown \
+  -chardev 'socket,id=qmp,path=/var/run/qemu-server/8006.qmp,server=on,wait=off' \
+  -mon 'chardev=qmp,mode=control' \
+  -chardev 'socket,id=qmp-event,path=/var/run/qmeventd.sock,reconnect-ms=5000' \
+  -mon 'chardev=qmp-event,mode=control' \
+  -pidfile /var/run/qemu-server/8006.pid \
+  -daemonize \
+  -smp '1,sockets=1,cores=1,maxcpus=1' \
+  -nodefaults \
+  -boot 'menu=on,strict=on,reboot-timeout=1000,splash=/usr/share/qemu-server/bootsplash.jpg' \
+  -vnc 'unix:/var/run/qemu-server/8006.vnc,password=on' \
+  -cpu 'host,+kvm_pv_eoi,+kvm_pv_unhalt,guest-phys-bits=39' \
+  -m 512 \
+  -global 'ICH9-LPC.disable_s3=1' \
+  -global 'ICH9-LPC.disable_s4=1' \
+  -device 'intel-iommu,intremap=on,caching-mode=on' \
+  -readconfig /usr/share/qemu-server/pve-q35-4.0.cfg \
+  -device 'usb-tablet,id=tablet,bus=ehci.0,port=1' \
+  -device 'VGA,id=vga,bus=pcie.0,addr=0x1' \
+  -device 'virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3,free-page-reporting=on' \
+  -iscsi 'initiator-name=iqn.1993-08.org.debian:01:aabbccddeeff' \
+  -machine 'type=q35+pve0,kernel-irqchip=split'
-- 
2.47.2



_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

             reply	other threads:[~2025-08-12 15:30 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-12 15:30 Fiona Ebner [this message]
2025-08-13  7:34 ` [pve-devel] applied: " Fabian Grünbichler

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250812153144.154949-1-f.ebner@proxmox.com \
    --to=f.ebner@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal