Skip to contentSkip to conversation

update-linux-headers: prepare for updating to 6.9+ and for SNP patches

PATCH In review Paolo Bonzini 3 participants 13 messages Jun 3, 2024 – Jun 4, 2024 RISC-V

lore
Share & tools
lore
#0 lore raw

cover update-linux-headers: prepare for updating to 6.9+ and for SNP patches

This series contains a few cleanups and fixes to update-linux-headers.sh, which I needed or found in order to pass CI for the SEV-SNP patches.

First, updating linux-headers/ fails due to the lack of arch/loongarch/include/uapi/asm/bitsperlong.h. I am not sure if I am doing something wrong but it is caused by commit 3efc75ad9d9 ("scripts/update-linux-headers.sh: Remove temporary directory inbetween", 2024-05-29); if so, I guess I'm 1-1 with Thomas given my own bug in commit 66210a1a30 that he fixed.

Before commit 3efc75ad9d9, the missing file would incorrectly cause stale files to be included in linux-headers/. The files were never committed to qemu.git, but were wrong nevertheless. The build would just use the system version of the files, which is opposite to the idea of importing Linux header files into QEMU's tree.

Second, pvpanic.h was incorrectly included in a slightly different path than what is used in Linux.

Third, SNP host-side patches will need linux/kvm_para.h, because some of the supported distros do not have a definition for KVM_HC_MAP_GPA_RANGE. Including it is a bit complicated because we also have a version of x86's kvm_para.h under include/standard-headers/; linux/kvm_para.h tries to include <asm/kvm_para.h> and that could cause conflicts. So, the linux/kvm_para.h is also placed in include/standard-headers (patch 4).

Pankaj Gupta (1):
linux-headers: Update to current kvm/next

Paolo Bonzini (3):
update-linux-headers: fix forwarding to asm-generic headers
update-linux-headers: move pvpanic.h to correct directory
update-linux-headers: import linux/kvm_para.h header

 include/standard-headers/linux/kvm_para.h     | 38 ++++++++++++++
 .../{linux => misc}/pvpanic.h                 |  0
 linux-headers/asm-loongarch/kvm.h             |  4 ++
 linux-headers/asm-riscv/kvm.h                 |  1 +
 linux-headers/asm-x86/kvm.h                   | 52 ++++++++++++++++++-
 linux-headers/asm-x86/kvm_para.h              |  1 +
 linux-headers/linux/kvm_para.h                |  2 +
 linux-headers/linux/vhost.h                   | 15 +++---
 hw/misc/pvpanic-isa.c                         |  2 +-
 hw/misc/pvpanic-pci.c                         |  2 +-
 hw/misc/pvpanic.c                             |  2 +-
 scripts/update-linux-headers.sh               | 37 +++++++++++--
 12 files changed, 141 insertions(+), 15 deletions(-)
 create mode 100644 include/standard-headers/linux/kvm_para.h
 rename include/standard-headers/{linux => misc}/pvpanic.h (100%)
 create mode 100644 linux-headers/asm-x86/kvm_para.h
 create mode 100644 linux-headers/linux/kvm_para.h
Signature · 1 line
2.45.1
#1 lore raw

PATCH 1/4 update-linux-headers: fix forwarding to asm-generic headers

Afer commit 3efc75ad9d9 ("scripts/update-linux-headers.sh: Remove temporary directory inbetween", 2024-05-29), updating linux-headers/ results in errors such as

cp: cannot stat '/tmp/tmp.1A1Eejh1UE/headers/include/asm/bitsperlong.h': No such file or directory

because Loongarch does not have an asm/bitsperlong.h file and uses the generic version. Before commit 3efc75ad9d9, the missing file would incorrectly cause stale files to be included in linux-headers/. The files were never committed to qemu.git, but were wrong nevertheless. The build would just use the system version of the files, which is opposite to the idea of importing Linux header files into QEMU's tree.

Create forwarding headers, resembling the ones that are generated during a kernel build by scripts/Makefile.asm-generic, if a file is only installed under include/asm-generic/.

---
 scripts/update-linux-headers.sh | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
scripts/update-linux-headers.sh +8 -1
index 23afe8c08ad..ae34d18572b 100755
@@ -118,7 +118,14 @@ for arch in $ARCHLIST; do
     rm -rf "$output/linux-headers/asm-$arch"
     mkdir -p "$output/linux-headers/asm-$arch"
     for header in kvm.h unistd.h bitsperlong.h mman.h; do
-        cp "$hdrdir/include/asm/$header" "$output/linux-headers/asm-$arch"
+        if test -f "$hdrdir/include/asm/$header"; then
+            cp "$hdrdir/include/asm/$header" "$output/linux-headers/asm-$arch"
+        elif test -f "$hdrdir/include/asm-generic/$header"; then
+            # not installed as <asm/bitsperlong.h>, but used as such in kernel sources
+            cat <<EOF >$output/linux-headers/asm-$arch/$header
+#include <asm-generic/$header>
+EOF
+        fi
     done
 
     if [ $arch = mips ]; then
Signature · 1 line
2.45.1
Reviewed-by on v1 1/4
#2 lore raw

Re: [PATCH 1/4] update-linux-headers: fix forwarding to asm-generic headers

Quoted 5 lines · Paolo Bonzini

Afer commit 3efc75ad9d9 ("scripts/update-linux-headers.sh: Remove temporary directory inbetween", 2024-05-29), updating linux-headers/ results in errors such as

cp: cannot stat '/tmp/tmp.1A1Eejh1UE/headers/include/asm/bitsperlong.h': No such file or directory

Oops, sorry, I was pretty sure the update was working for me when I tested the patch ... maybe I was on an older branch that didn't have loongarch support yet.

scripts/update-linux-headers.sh for arch in $ARCHLIST; do · line 124

Quoted 13 lines
scripts/update-linux-headers.sh +4 -1
index 23afe8c08ad..ae34d18572b 100755
@@ -118,7 +118,14 @@ for arch in $ARCHLIST; do
      rm -rf "$output/linux-headers/asm-$arch"
      mkdir -p "$output/linux-headers/asm-$arch"
      for header in kvm.h unistd.h bitsperlong.h mman.h; do
-        cp "$hdrdir/include/asm/$header" "$output/linux-headers/asm-$arch"
+        if test -f "$hdrdir/include/asm/$header"; then
+            cp "$hdrdir/include/asm/$header" "$output/linux-headers/asm-$arch"
+        elif test -f "$hdrdir/include/asm-generic/$header"; then
+            # not installed as <asm/bitsperlong.h>, but used as such in kernel sources

Maybe change the comment to talk about <asm/$header> instead of <asm/bitsperlong.h> ?

scripts/update-linux-headers.sh for arch in $ARCHLIST; do · line 131

Quoted 7 lines
scripts/update-linux-headers.sh +4 -0
+            cat <<EOF >$output/linux-headers/asm-$arch/$header
+#include <asm-generic/$header>
+EOF
+        fi
      done
 
      if [ $arch = mips ]; then
#3 lore raw

PATCH 2/4 update-linux-headers: move pvpanic.h to correct directory

In reply to Paolo Bonzini

Linux has <misc/pvpanic.h>, not <linux/pvpanic.h>. Use the same directory for QEMU's include/standard-headers/ copy.

---
 include/standard-headers/{linux => misc}/pvpanic.h | 0
 hw/misc/pvpanic-isa.c                              | 2 +-
 hw/misc/pvpanic-pci.c                              | 2 +-
 hw/misc/pvpanic.c                                  | 2 +-
 scripts/update-linux-headers.sh                    | 6 ++++--
 5 files changed, 7 insertions(+), 5 deletions(-)
 rename include/standard-headers/{linux => misc}/pvpanic.h (100%)
include/standard-headers/misc/pvpanic.h renamed from include/standard-headers/linux/pvpanic.h +0 -0
similarity index 100%
rename from include/standard-headers/linux/pvpanic.h
rename to include/standard-headers/misc/pvpanic.h
hw/misc/pvpanic-isa.c +1 -1
index ccec50f61bb..b4f84c41109 100644
@@ -21,7 +21,7 @@
 #include "hw/misc/pvpanic.h"
 #include "qom/object.h"
 #include "hw/isa/isa.h"
-#include "standard-headers/linux/pvpanic.h"
+#include "standard-headers/misc/pvpanic.h"
 #include "hw/acpi/acpi_aml_interface.h"
 
 OBJECT_DECLARE_SIMPLE_TYPE(PVPanicISAState, PVPANIC_ISA_DEVICE)
hw/misc/pvpanic-pci.c +1 -1
index 83be95d0d24..4d44a881dad 100644
@@ -21,7 +21,7 @@
 #include "hw/misc/pvpanic.h"
 #include "qom/object.h"
 #include "hw/pci/pci_device.h"
-#include "standard-headers/linux/pvpanic.h"
+#include "standard-headers/misc/pvpanic.h"
 
 OBJECT_DECLARE_SIMPLE_TYPE(PVPanicPCIState, PVPANIC_PCI_DEVICE)
 
hw/misc/pvpanic.c +1 -1
index 1540e9091a4..80289ecf5fe 100644
@@ -21,7 +21,7 @@
 #include "hw/qdev-properties.h"
 #include "hw/misc/pvpanic.h"
 #include "qom/object.h"
-#include "standard-headers/linux/pvpanic.h"
+#include "standard-headers/misc/pvpanic.h"
 
 static void handle_event(int event)
 {
scripts/update-linux-headers.sh +4 -2
index ae34d18572b..7b39cc426e0 100755
@@ -231,10 +231,12 @@ for i in "$hdrdir"/include/linux/*virtio*.h \
          "$hdrdir/include/linux/const.h" \
          "$hdrdir/include/linux/kernel.h" \
          "$hdrdir/include/linux/vhost_types.h" \
-         "$hdrdir/include/linux/sysinfo.h" \
-         "$hdrdir/include/misc/pvpanic.h"; do
+         "$hdrdir/include/linux/sysinfo.h"; do
     cp_portable "$i" "$output/include/standard-headers/linux"
 done
+mkdir -p "$output/include/standard-headers/misc"
+cp_portable "$hdrdir/include/misc/pvpanic.h" \
+            "$output/include/standard-headers/misc"
 mkdir -p "$output/include/standard-headers/drm"
 cp_portable "$hdrdir/include/drm/drm_fourcc.h" \
             "$output/include/standard-headers/drm"
Signature · 1 line
2.45.1
Reviewed-by on v1 2/4
#4 lore raw

Re: [PATCH 2/4] update-linux-headers: move pvpanic.h to correct directory

Quoted 4 lines · Paolo Bonzini

Linux has <misc/pvpanic.h>, not <linux/pvpanic.h>. Use the same directory for QEMU's include/standard-headers/ copy.

Quoted 8 lines
---
  include/standard-headers/{linux => misc}/pvpanic.h | 0
  hw/misc/pvpanic-isa.c                              | 2 +-
  hw/misc/pvpanic-pci.c                              | 2 +-
  hw/misc/pvpanic.c                                  | 2 +-
  scripts/update-linux-headers.sh                    | 6 ++++--
  5 files changed, 7 insertions(+), 5 deletions(-)

rename include/standard-headers/{linux => misc}/pvpanic.h (100%)

#5 lore raw

PATCH 3/4 linux-headers: Update to current kvm/next

In reply to Paolo Bonzini

From: Pankaj Gupta <[email protected]>

Also brings in an linux-headers/linux/vhost.h fix from v6.9-rc4.

Message-ID: <[email protected]>

---
 linux-headers/asm-loongarch/kvm.h |  4 +++
 linux-headers/asm-riscv/kvm.h     |  1 +
 linux-headers/asm-x86/kvm.h       | 52 ++++++++++++++++++++++++++++++-
 linux-headers/linux/vhost.h       | 15 ++++-----
 4 files changed, 64 insertions(+), 8 deletions(-)
linux-headers/asm-loongarch/kvm.h +4 -0
index 109785922cf..f9abef38231 100644
@@ -17,6 +17,8 @@
 #define KVM_COALESCED_MMIO_PAGE_OFFSET	1
 #define KVM_DIRTY_LOG_PAGE_OFFSET	64
 
+#define KVM_GUESTDBG_USE_SW_BP		0x00010000
+
 /*
  * for KVM_GET_REGS and KVM_SET_REGS
  */
@@ -72,6 +74,8 @@ struct kvm_fpu {
 
 #define KVM_REG_LOONGARCH_COUNTER	(KVM_REG_LOONGARCH_KVM | KVM_REG_SIZE_U64 | 1)
 #define KVM_REG_LOONGARCH_VCPU_RESET	(KVM_REG_LOONGARCH_KVM | KVM_REG_SIZE_U64 | 2)
+/* Debugging: Special instruction for software breakpoint */
+#define KVM_REG_LOONGARCH_DEBUG_INST	(KVM_REG_LOONGARCH_KVM | KVM_REG_SIZE_U64 | 3)
 
 #define LOONGARCH_REG_SHIFT		3
 #define LOONGARCH_REG_64(TYPE, REG)	(TYPE | KVM_REG_SIZE_U64 | (REG << LOONGARCH_REG_SHIFT))
linux-headers/asm-riscv/kvm.h +1 -0
index b1c503c2959..e878e7cc397 100644
@@ -167,6 +167,7 @@ enum KVM_RISCV_ISA_EXT_ID {
 	KVM_RISCV_ISA_EXT_ZFA,
 	KVM_RISCV_ISA_EXT_ZTSO,
 	KVM_RISCV_ISA_EXT_ZACAS,
+	KVM_RISCV_ISA_EXT_SSCOFPMF,
 	KVM_RISCV_ISA_EXT_MAX,
 };
 
linux-headers/asm-x86/kvm.h +51 -1

75 lines not on this page · raw message

linux-headers/linux/vhost.h +8 -7
index bea69739061..b95dd84eef2 100644
@@ -179,12 +179,6 @@
 /* Get the config size */
 #define VHOST_VDPA_GET_CONFIG_SIZE	_IOR(VHOST_VIRTIO, 0x79, __u32)
 
-/* Get the count of all virtqueues */
-#define VHOST_VDPA_GET_VQS_COUNT	_IOR(VHOST_VIRTIO, 0x80, __u32)
-
-/* Get the number of virtqueue groups. */
-#define VHOST_VDPA_GET_GROUP_NUM	_IOR(VHOST_VIRTIO, 0x81, __u32)
-
 /* Get the number of address spaces. */
 #define VHOST_VDPA_GET_AS_NUM		_IOR(VHOST_VIRTIO, 0x7A, unsigned int)
 
@@ -228,10 +222,17 @@
 #define VHOST_VDPA_GET_VRING_DESC_GROUP	_IOWR(VHOST_VIRTIO, 0x7F,	\
 					      struct vhost_vring_state)
 
+
+/* Get the count of all virtqueues */
+#define VHOST_VDPA_GET_VQS_COUNT	_IOR(VHOST_VIRTIO, 0x80, __u32)
+
+/* Get the number of virtqueue groups. */
+#define VHOST_VDPA_GET_GROUP_NUM	_IOR(VHOST_VIRTIO, 0x81, __u32)
+
 /* Get the queue size of a specific virtqueue.
  * userspace set the vring index in vhost_vring_state.index
  * kernel set the queue size in vhost_vring_state.num
  */
-#define VHOST_VDPA_GET_VRING_SIZE	_IOWR(VHOST_VIRTIO, 0x80,	\
+#define VHOST_VDPA_GET_VRING_SIZE	_IOWR(VHOST_VIRTIO, 0x82,	\
 					      struct vhost_vring_state)
 #endif
Signature · 1 line
2.45.1
#6 lore raw

Re: [PATCH 3/4] linux-headers: Update to current kvm/next

Quoted 7 lines · Paolo Bonzini

From: Pankaj Gupta <[email protected]>

Also brings in an linux-headers/linux/vhost.h fix from v6.9-rc4.

Quoted 8 lines

Message-ID: <[email protected]>

---
 linux-headers/asm-loongarch/kvm.h |  4 +++
 linux-headers/asm-riscv/kvm.h     |  1 +
 linux-headers/asm-x86/kvm.h       | 52 ++++++++++++++++++++++++++++++-
 linux-headers/linux/vhost.h       | 15 ++++-----
 4 files changed, 64 insertions(+), 8 deletions(-)

Hm, I'm not sure updating to kvm/next is a good idea ("current kvm/next" does not mean anything without a commit hash anyway.) I think we should only update to something that's in Linus' tree already... how stable is kvm/next?

#7 lore raw

Re: [PATCH 3/4] linux-headers: Update to current kvm/next

Quoted 4 lines · Cornelia Huck

Hm, I'm not sure updating to kvm/next is a good idea ("current kvm/next" does not mean anything without a commit hash anyway.) I think we should only update to something that's in Linus' tree already... how stable is kvm/next?

It is stable, things are only applied there once UAPI is set. Even rebasing is very rare.

The problem here is that if (as is the case for 6.11) the merge window only opens once QEMU is in freeze, waiting for it would delay merging the QEMU side by 4 months. In this case, the patches barely missed 6.10.

Paolo

#8 lore raw

Re: [PATCH 3/4] linux-headers: Update to current kvm/next

Quoted 6 lines · Paolo Bonzini
Quoted 4 lines · Cornelia Huck

Hm, I'm not sure updating to kvm/next is a good idea ("current kvm/next" does not mean anything without a commit hash anyway.) I think we should only update to something that's in Linus' tree already... how stable is kvm/next?

Quoted 7 lines

It is stable, things are only applied there once UAPI is set. Even rebasing is very rare.

The problem here is that if (as is the case for 6.11) the merge window only opens once QEMU is in freeze, waiting for it would delay merging the QEMU side by 4 months. In this case, the patches barely missed 6.10.

If we're confident that it's stable, can we please mention a hash? "current" is not very descriptive :)

#9 lore raw

Re: [PATCH 3/4] linux-headers: Update to current kvm/next

Quoted 12 lines · Cornelia Huck
Quoted 9 lines · Paolo Bonzini
Quoted 4 lines · Cornelia Huck

Hm, I'm not sure updating to kvm/next is a good idea ("current kvm/next" does not mean anything without a commit hash anyway.) I think we should only update to something that's in Linus' tree already... how stable is kvm/next?

It is stable, things are only applied there once UAPI is set. Even rebasing is very rare.

Quoted 6 lines
Quoted 4 lines

The problem here is that if (as is the case for 6.11) the merge window only opens once QEMU is in freeze, waiting for it would delay merging the QEMU side by 4 months. In this case, the patches barely missed 6.10.

If we're confident that it's stable, can we please mention a hash?

Sure, it's commit 6f627b425378915b6eda30908bedefc21b70b8c4.

Paolo

Quoted 2 lines

"current" is not very descriptive :)

#10 lore raw

PATCH 4/4 update-linux-headers: import linux/kvm_para.h header

In reply to Paolo Bonzini

Right now QEMU is importing arch/x86/include/uapi/asm/kvm_para.h because it includes definitions for kvmclock and for KVM CPUID bits. However, other definitions for KVM hypercall values and return codes are included in include/uapi/linux/kvm_para.h and they will be used by SEV-SNP.

To ensure that it is possible to include both <linux/kvm_para.h> and "standard-headers/asm-x86/kvm_para.h" without conflicts, include linux/kvm_para.h as a portable header too, and forward linux-headers/ files to those in include/standard-headers. Note that <linux/kvm_para.h> will include architecture-specific definitions as well, but "standard-headers/linux/kvm_para.h" will not because it can be used in architecture-independent files.

This could easily be extended to other architectures, but right now they do not need any symbol in their specific kvm_para.h files.

---
 include/standard-headers/linux/kvm_para.h | 38 +++++++++++++++++++++++
 linux-headers/asm-x86/kvm_para.h          |  1 +
 linux-headers/linux/kvm_para.h            |  2 ++
 scripts/update-linux-headers.sh           | 22 ++++++++++++-
 4 files changed, 62 insertions(+), 1 deletion(-)
 create mode 100644 include/standard-headers/linux/kvm_para.h
 create mode 100644 linux-headers/asm-x86/kvm_para.h
 create mode 100644 linux-headers/linux/kvm_para.h
include/standard-headers/linux/kvm_para.h new file +38 -0
new file mode 100644
index 00000000000..015c1663021
@@ -0,0 +1,38 @@
+/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
+#ifndef __LINUX_KVM_PARA_H
+#define __LINUX_KVM_PARA_H
+
+/*
+ * This header file provides a method for making a hypercall to the host
+ * Architectures should define:
+ * - kvm_hypercall0, kvm_hypercall1...
+ * - kvm_arch_para_features
+ * - kvm_para_available
+ */
+
+/* Return values for hypercalls */
+#define KVM_ENOSYS		1000
+#define KVM_EFAULT		EFAULT
+#define KVM_EINVAL		EINVAL
+#define KVM_E2BIG		E2BIG
+#define KVM_EPERM		EPERM
+#define KVM_EOPNOTSUPP		95
+
+#define KVM_HC_VAPIC_POLL_IRQ		1
+#define KVM_HC_MMU_OP			2
+#define KVM_HC_FEATURES			3
+#define KVM_HC_PPC_MAP_MAGIC_PAGE	4
+#define KVM_HC_KICK_CPU			5
+#define KVM_HC_MIPS_GET_CLOCK_FREQ	6
+#define KVM_HC_MIPS_EXIT_VM		7
+#define KVM_HC_MIPS_CONSOLE_OUTPUT	8
+#define KVM_HC_CLOCK_PAIRING		9
+#define KVM_HC_SEND_IPI		10
+#define KVM_HC_SCHED_YIELD		11
+#define KVM_HC_MAP_GPA_RANGE		12
+
+/*
+ * hypercalls use architecture specific
+ */
+
+#endif /* __LINUX_KVM_PARA_H */
linux-headers/asm-x86/kvm_para.h new file +1 -0
new file mode 100644
index 00000000000..1d3e0e0b07a
@@ -0,0 +1 @@
+#include "standard-headers/asm-x86/kvm_para.h"
linux-headers/linux/kvm_para.h new file +2 -0
new file mode 100644
index 00000000000..6a1e672259c
@@ -0,0 +1,2 @@
+#include "standard-headers/linux/kvm_para.h"
+#include <asm/kvm_para.h>
scripts/update-linux-headers.sh +21 -1
index 7b39cc426e0..e579c348959 100755
@@ -63,6 +63,7 @@ cp_portable() {
                                      -e 'linux/kernel' \
                                      -e 'linux/sysinfo' \
                                      -e 'asm/setup_data.h' \
+                                     -e 'asm/kvm_para.h' \
                                      > /dev/null
     then
         echo "Unexpected #include in input file $f".
@@ -70,6 +71,15 @@ cp_portable() {
     fi
 
     header=$(basename "$f");
+
+    if test -z "$arch"; then
+        # Let users of include/standard-headers/linux/ headers pick the
+        # asm-* header that they care about
+        arch_cmd='/<asm\/\([^>]*\)>/d'
+    else
+        arch_cmd='s/<asm\/\([^>]*\)>/"standard-headers\/asm-'$arch'\/\1"/'
+    fi
+
     sed -e 's/__aligned_u64/__u64 __attribute__((aligned(8)))/g' \
         -e 's/__u\([0-9][0-9]*\)/uint\1_t/g' \
         -e 's/u\([0-9][0-9]*\)/uint\1_t/g' \
@@ -78,7 +88,7 @@ cp_portable() {
         -e 's/__be\([0-9][0-9]*\)/uint\1_t/g' \
         -e 's/"\(input-event-codes\.h\)"/"standard-headers\/linux\/\1"/' \
         -e 's/<linux\/\([^>]*\)>/"standard-headers\/linux\/\1"/' \
-        -e 's/<asm\/\([^>]*\)>/"standard-headers\/asm-'$arch'\/\1"/' \
+        -e "$arch_cmd" \
         -e 's/__bitwise//' \
         -e 's/__attribute__((packed))/QEMU_PACKED/' \
         -e 's/__inline__/inline/' \
@@ -158,7 +168,12 @@ EOF
         cp "$hdrdir/include/asm/unistd_32.h" "$output/linux-headers/asm-x86/"
         cp "$hdrdir/include/asm/unistd_x32.h" "$output/linux-headers/asm-x86/"
         cp "$hdrdir/include/asm/unistd_64.h" "$output/linux-headers/asm-x86/"
+
         cp_portable "$hdrdir/include/asm/kvm_para.h" "$output/include/standard-headers/asm-$arch"
+        cat <<EOF >$output/linux-headers/asm-$arch/kvm_para.h
+#include "standard-headers/asm-$arch/kvm_para.h"
+EOF
+
         # Remove everything except the macros from bootparam.h avoiding the
         # unnecessary import of several video/ist/etc headers
         sed -e '/__ASSEMBLY__/,/__ASSEMBLY__/d' \
@@ -208,6 +223,10 @@ if [ -d "$linux/LICENSES" ]; then
     done
 fi
 
+cat <<EOF >$output/linux-headers/linux/kvm_para.h
+#include "standard-headers/linux/kvm_para.h"
+#include <asm/kvm_para.h>
+EOF
 cat <<EOF >$output/linux-headers/linux/virtio_config.h
 #include "standard-headers/linux/virtio_config.h"
 EOF
@@ -230,6 +249,7 @@ for i in "$hdrdir"/include/linux/*virtio*.h \
          "$hdrdir/include/linux/ethtool.h" \
          "$hdrdir/include/linux/const.h" \
          "$hdrdir/include/linux/kernel.h" \
+         "$hdrdir/include/linux/kvm_para.h" \
          "$hdrdir/include/linux/vhost_types.h" \
          "$hdrdir/include/linux/sysinfo.h"; do
     cp_portable "$i" "$output/include/standard-headers/linux"
Signature · 1 line
2.45.1
Reviewed-by on v1 4/4
#11 lore raw

Re: [PATCH 4/4] update-linux-headers: import linux/kvm_para.h header

Quoted 24 lines · Paolo Bonzini

Right now QEMU is importing arch/x86/include/uapi/asm/kvm_para.h because it includes definitions for kvmclock and for KVM CPUID bits. However, other definitions for KVM hypercall values and return codes are included in include/uapi/linux/kvm_para.h and they will be used by SEV-SNP.

To ensure that it is possible to include both <linux/kvm_para.h> and "standard-headers/asm-x86/kvm_para.h" without conflicts, include linux/kvm_para.h as a portable header too, and forward linux-headers/ files to those in include/standard-headers. Note that <linux/kvm_para.h> will include architecture-specific definitions as well, but "standard-headers/linux/kvm_para.h" will not because it can be used in architecture-independent files.

This could easily be extended to other architectures, but right now they do not need any symbol in their specific kvm_para.h files.

---
  include/standard-headers/linux/kvm_para.h | 38 +++++++++++++++++++++++
  linux-headers/asm-x86/kvm_para.h          |  1 +
  linux-headers/linux/kvm_para.h            |  2 ++
  scripts/update-linux-headers.sh           | 22 ++++++++++++-
  4 files changed, 62 insertions(+), 1 deletion(-)
Quoted 3 lines

create mode 100644 include/standard-headers/linux/kvm_para.h create mode 100644 linux-headers/asm-x86/kvm_para.h create mode 100644 linux-headers/linux/kvm_para.h

Reviewed-by on the v1 series
#12 lore raw
In reply to Paolo Bonzini
Quoted 44 lines · Paolo Bonzini

This series contains a few cleanups and fixes to update-linux-headers.sh, which I needed or found in order to pass CI for the SEV-SNP patches.

First, updating linux-headers/ fails due to the lack of arch/loongarch/include/uapi/asm/bitsperlong.h. I am not sure if I am doing something wrong but it is caused by commit 3efc75ad9d9 ("scripts/update-linux-headers.sh: Remove temporary directory inbetween", 2024-05-29); if so, I guess I'm 1-1 with Thomas given my own bug in commit 66210a1a30 that he fixed.

Before commit 3efc75ad9d9, the missing file would incorrectly cause stale files to be included in linux-headers/. The files were never committed to qemu.git, but were wrong nevertheless. The build would just use the system version of the files, which is opposite to the idea of importing Linux header files into QEMU's tree.

Second, pvpanic.h was incorrectly included in a slightly different path than what is used in Linux.

Third, SNP host-side patches will need linux/kvm_para.h, because some of the supported distros do not have a definition for KVM_HC_MAP_GPA_RANGE. Including it is a bit complicated because we also have a version of x86's kvm_para.h under include/standard-headers/; linux/kvm_para.h tries to include <asm/kvm_para.h> and that could cause conflicts. So, the linux/kvm_para.h is also placed in include/standard-headers (patch 4).

Pankaj Gupta (1):
linux-headers: Update to current kvm/next

Paolo Bonzini (3):
update-linux-headers: fix forwarding to asm-generic headers
update-linux-headers: move pvpanic.h to correct directory
update-linux-headers: import linux/kvm_para.h header

 include/standard-headers/linux/kvm_para.h     | 38 ++++++++++++++
 .../{linux => misc}/pvpanic.h                 |  0
 linux-headers/asm-loongarch/kvm.h             |  4 ++
 linux-headers/asm-riscv/kvm.h                 |  1 +
 linux-headers/asm-x86/kvm.h                   | 52 ++++++++++++++++++-
 linux-headers/asm-x86/kvm_para.h              |  1 +
 linux-headers/linux/kvm_para.h                |  2 +
 linux-headers/linux/vhost.h                   | 15 +++---
 hw/misc/pvpanic-isa.c                         |  2 +-
Quoted 8 lines
 hw/misc/pvpanic-pci.c                         |  2 +-
 hw/misc/pvpanic.c                             |  2 +-
 scripts/update-linux-headers.sh               | 37 +++++++++++--
 12 files changed, 141 insertions(+), 15 deletions(-)
 create mode 100644 include/standard-headers/linux/kvm_para.h
 rename include/standard-headers/{linux => misc}/pvpanic.h (100%)
 create mode 100644 linux-headers/asm-x86/kvm_para.h
 create mode 100644 linux-headers/linux/kvm_para.h

With the hash added to the headers update,

for the series.