* [PATCH 0/4] update-linux-headers: prepare for updating to 6.9+ and for SNP patches
@ 2024-06-03 13:11 Paolo Bonzini
2024-06-03 13:11 ` [PATCH 1/4] update-linux-headers: fix forwarding to asm-generic headers Paolo Bonzini
` (4 more replies)
0 siblings, 5 replies; 13+ messages in thread
From: Paolo Bonzini @ 2024-06-03 13:11 UTC (permalink / raw)
To: qemu-devel; +Cc: thuth, cohuck
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
--
2.45.1
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH 1/4] update-linux-headers: fix forwarding to asm-generic headers
2024-06-03 13:11 [PATCH 0/4] update-linux-headers: prepare for updating to 6.9+ and for SNP patches Paolo Bonzini
@ 2024-06-03 13:11 ` Paolo Bonzini
2024-06-03 14:54 ` Thomas Huth
2024-06-03 13:11 ` [PATCH 2/4] update-linux-headers: move pvpanic.h to correct directory Paolo Bonzini
` (3 subsequent siblings)
4 siblings, 1 reply; 13+ messages in thread
From: Paolo Bonzini @ 2024-06-03 13:11 UTC (permalink / raw)
To: qemu-devel; +Cc: thuth, cohuck
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/.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
| 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
--git a/scripts/update-linux-headers.sh b/scripts/update-linux-headers.sh
index 23afe8c08ad..ae34d18572b 100755
--- a/scripts/update-linux-headers.sh
+++ b/scripts/update-linux-headers.sh
@@ -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
--
2.45.1
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 2/4] update-linux-headers: move pvpanic.h to correct directory
2024-06-03 13:11 [PATCH 0/4] update-linux-headers: prepare for updating to 6.9+ and for SNP patches Paolo Bonzini
2024-06-03 13:11 ` [PATCH 1/4] update-linux-headers: fix forwarding to asm-generic headers Paolo Bonzini
@ 2024-06-03 13:11 ` Paolo Bonzini
2024-06-03 14:58 ` Thomas Huth
2024-06-03 13:11 ` [PATCH 3/4] linux-headers: Update to current kvm/next Paolo Bonzini
` (2 subsequent siblings)
4 siblings, 1 reply; 13+ messages in thread
From: Paolo Bonzini @ 2024-06-03 13:11 UTC (permalink / raw)
To: qemu-devel; +Cc: thuth, cohuck
Linux has <misc/pvpanic.h>, not <linux/pvpanic.h>. Use the same
directory for QEMU's include/standard-headers/ copy.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
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 +-
| 6 ++++--
5 files changed, 7 insertions(+), 5 deletions(-)
rename include/standard-headers/{linux => misc}/pvpanic.h (100%)
diff --git a/include/standard-headers/linux/pvpanic.h b/include/standard-headers/misc/pvpanic.h
similarity index 100%
rename from include/standard-headers/linux/pvpanic.h
rename to include/standard-headers/misc/pvpanic.h
diff --git a/hw/misc/pvpanic-isa.c b/hw/misc/pvpanic-isa.c
index ccec50f61bb..b4f84c41109 100644
--- a/hw/misc/pvpanic-isa.c
+++ b/hw/misc/pvpanic-isa.c
@@ -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)
diff --git a/hw/misc/pvpanic-pci.c b/hw/misc/pvpanic-pci.c
index 83be95d0d24..4d44a881dad 100644
--- a/hw/misc/pvpanic-pci.c
+++ b/hw/misc/pvpanic-pci.c
@@ -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)
diff --git a/hw/misc/pvpanic.c b/hw/misc/pvpanic.c
index 1540e9091a4..80289ecf5fe 100644
--- a/hw/misc/pvpanic.c
+++ b/hw/misc/pvpanic.c
@@ -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)
{
--git a/scripts/update-linux-headers.sh b/scripts/update-linux-headers.sh
index ae34d18572b..7b39cc426e0 100755
--- a/scripts/update-linux-headers.sh
+++ b/scripts/update-linux-headers.sh
@@ -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"
--
2.45.1
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 3/4] linux-headers: Update to current kvm/next
2024-06-03 13:11 [PATCH 0/4] update-linux-headers: prepare for updating to 6.9+ and for SNP patches Paolo Bonzini
2024-06-03 13:11 ` [PATCH 1/4] update-linux-headers: fix forwarding to asm-generic headers Paolo Bonzini
2024-06-03 13:11 ` [PATCH 2/4] update-linux-headers: move pvpanic.h to correct directory Paolo Bonzini
@ 2024-06-03 13:11 ` Paolo Bonzini
2024-06-03 15:58 ` Cornelia Huck
2024-06-03 13:11 ` [PATCH 4/4] update-linux-headers: import linux/kvm_para.h header Paolo Bonzini
2024-06-04 8:31 ` [PATCH 0/4] update-linux-headers: prepare for updating to 6.9+ and for SNP patches Cornelia Huck
4 siblings, 1 reply; 13+ messages in thread
From: Paolo Bonzini @ 2024-06-03 13:11 UTC (permalink / raw)
To: qemu-devel; +Cc: thuth, cohuck, Pankaj Gupta, Michael Roth
From: Pankaj Gupta <pankaj.gupta@amd.com>
Also brings in an linux-headers/linux/vhost.h fix from v6.9-rc4.
Co-developed-by: Michael Roth <michael.roth@amd.com>
Signed-off-by: Michael Roth <michael.roth@amd.com>
Signed-off-by: Pankaj Gupta <pankaj.gupta@amd.com>
Message-ID: <20240530111643.1091816-3-pankaj.gupta@amd.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
| 4 +++
| 1 +
| 52 ++++++++++++++++++++++++++++++-
| 15 ++++-----
4 files changed, 64 insertions(+), 8 deletions(-)
--git a/linux-headers/asm-loongarch/kvm.h b/linux-headers/asm-loongarch/kvm.h
index 109785922cf..f9abef38231 100644
--- a/linux-headers/asm-loongarch/kvm.h
+++ b/linux-headers/asm-loongarch/kvm.h
@@ -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))
--git a/linux-headers/asm-riscv/kvm.h b/linux-headers/asm-riscv/kvm.h
index b1c503c2959..e878e7cc397 100644
--- a/linux-headers/asm-riscv/kvm.h
+++ b/linux-headers/asm-riscv/kvm.h
@@ -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,
};
--git a/linux-headers/asm-x86/kvm.h b/linux-headers/asm-x86/kvm.h
index 31c95c2dfe4..1c8f9182348 100644
--- a/linux-headers/asm-x86/kvm.h
+++ b/linux-headers/asm-x86/kvm.h
@@ -695,6 +695,11 @@ enum sev_cmd_id {
/* Second time is the charm; improved versions of the above ioctls. */
KVM_SEV_INIT2,
+ /* SNP-specific commands */
+ KVM_SEV_SNP_LAUNCH_START = 100,
+ KVM_SEV_SNP_LAUNCH_UPDATE,
+ KVM_SEV_SNP_LAUNCH_FINISH,
+
KVM_SEV_NR_MAX,
};
@@ -709,7 +714,9 @@ struct kvm_sev_cmd {
struct kvm_sev_init {
__u64 vmsa_features;
__u32 flags;
- __u32 pad[9];
+ __u16 ghcb_version;
+ __u16 pad1;
+ __u32 pad2[8];
};
struct kvm_sev_launch_start {
@@ -820,6 +827,48 @@ struct kvm_sev_receive_update_data {
__u32 pad2;
};
+struct kvm_sev_snp_launch_start {
+ __u64 policy;
+ __u8 gosvw[16];
+ __u16 flags;
+ __u8 pad0[6];
+ __u64 pad1[4];
+};
+
+/* Kept in sync with firmware values for simplicity. */
+#define KVM_SEV_SNP_PAGE_TYPE_NORMAL 0x1
+#define KVM_SEV_SNP_PAGE_TYPE_ZERO 0x3
+#define KVM_SEV_SNP_PAGE_TYPE_UNMEASURED 0x4
+#define KVM_SEV_SNP_PAGE_TYPE_SECRETS 0x5
+#define KVM_SEV_SNP_PAGE_TYPE_CPUID 0x6
+
+struct kvm_sev_snp_launch_update {
+ __u64 gfn_start;
+ __u64 uaddr;
+ __u64 len;
+ __u8 type;
+ __u8 pad0;
+ __u16 flags;
+ __u32 pad1;
+ __u64 pad2[4];
+};
+
+#define KVM_SEV_SNP_ID_BLOCK_SIZE 96
+#define KVM_SEV_SNP_ID_AUTH_SIZE 4096
+#define KVM_SEV_SNP_FINISH_DATA_SIZE 32
+
+struct kvm_sev_snp_launch_finish {
+ __u64 id_block_uaddr;
+ __u64 id_auth_uaddr;
+ __u8 id_block_en;
+ __u8 auth_key_en;
+ __u8 vcek_disabled;
+ __u8 host_data[KVM_SEV_SNP_FINISH_DATA_SIZE];
+ __u8 pad0[3];
+ __u16 flags;
+ __u64 pad1[4];
+};
+
#define KVM_X2APIC_API_USE_32BIT_IDS (1ULL << 0)
#define KVM_X2APIC_API_DISABLE_BROADCAST_QUIRK (1ULL << 1)
@@ -870,5 +919,6 @@ struct kvm_hyperv_eventfd {
#define KVM_X86_SW_PROTECTED_VM 1
#define KVM_X86_SEV_VM 2
#define KVM_X86_SEV_ES_VM 3
+#define KVM_X86_SNP_VM 4
#endif /* _ASM_X86_KVM_H */
--git a/linux-headers/linux/vhost.h b/linux-headers/linux/vhost.h
index bea69739061..b95dd84eef2 100644
--- a/linux-headers/linux/vhost.h
+++ b/linux-headers/linux/vhost.h
@@ -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
--
2.45.1
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 4/4] update-linux-headers: import linux/kvm_para.h header
2024-06-03 13:11 [PATCH 0/4] update-linux-headers: prepare for updating to 6.9+ and for SNP patches Paolo Bonzini
` (2 preceding siblings ...)
2024-06-03 13:11 ` [PATCH 3/4] linux-headers: Update to current kvm/next Paolo Bonzini
@ 2024-06-03 13:11 ` Paolo Bonzini
2024-06-03 15:05 ` Thomas Huth
2024-06-04 8:31 ` [PATCH 0/4] update-linux-headers: prepare for updating to 6.9+ and for SNP patches Cornelia Huck
4 siblings, 1 reply; 13+ messages in thread
From: Paolo Bonzini @ 2024-06-03 13:11 UTC (permalink / raw)
To: qemu-devel; +Cc: thuth, cohuck
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.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
include/standard-headers/linux/kvm_para.h | 38 +++++++++++++++++++++++
| 1 +
| 2 ++
| 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
diff --git a/include/standard-headers/linux/kvm_para.h b/include/standard-headers/linux/kvm_para.h
new file mode 100644
index 00000000000..015c1663021
--- /dev/null
+++ b/include/standard-headers/linux/kvm_para.h
@@ -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 */
--git a/linux-headers/asm-x86/kvm_para.h b/linux-headers/asm-x86/kvm_para.h
new file mode 100644
index 00000000000..1d3e0e0b07a
--- /dev/null
+++ b/linux-headers/asm-x86/kvm_para.h
@@ -0,0 +1 @@
+#include "standard-headers/asm-x86/kvm_para.h"
--git a/linux-headers/linux/kvm_para.h b/linux-headers/linux/kvm_para.h
new file mode 100644
index 00000000000..6a1e672259c
--- /dev/null
+++ b/linux-headers/linux/kvm_para.h
@@ -0,0 +1,2 @@
+#include "standard-headers/linux/kvm_para.h"
+#include <asm/kvm_para.h>
--git a/scripts/update-linux-headers.sh b/scripts/update-linux-headers.sh
index 7b39cc426e0..e579c348959 100755
--- a/scripts/update-linux-headers.sh
+++ b/scripts/update-linux-headers.sh
@@ -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"
--
2.45.1
^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH 1/4] update-linux-headers: fix forwarding to asm-generic headers
2024-06-03 13:11 ` [PATCH 1/4] update-linux-headers: fix forwarding to asm-generic headers Paolo Bonzini
@ 2024-06-03 14:54 ` Thomas Huth
0 siblings, 0 replies; 13+ messages in thread
From: Thomas Huth @ 2024-06-03 14:54 UTC (permalink / raw)
To: Paolo Bonzini, qemu-devel; +Cc: cohuck
On 03/06/2024 15.11, Paolo Bonzini wrote:
> 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.
> diff --git a/scripts/update-linux-headers.sh b/scripts/update-linux-headers.sh
> index 23afe8c08ad..ae34d18572b 100755
> --- a/scripts/update-linux-headers.sh
> +++ b/scripts/update-linux-headers.sh
> @@ -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> ?
> + cat <<EOF >$output/linux-headers/asm-$arch/$header
> +#include <asm-generic/$header>
> +EOF
> + fi
> done
>
> if [ $arch = mips ]; then
Reviewed-by: Thomas Huth <thuth@redhat.com>
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 2/4] update-linux-headers: move pvpanic.h to correct directory
2024-06-03 13:11 ` [PATCH 2/4] update-linux-headers: move pvpanic.h to correct directory Paolo Bonzini
@ 2024-06-03 14:58 ` Thomas Huth
0 siblings, 0 replies; 13+ messages in thread
From: Thomas Huth @ 2024-06-03 14:58 UTC (permalink / raw)
To: Paolo Bonzini, qemu-devel; +Cc: cohuck
On 03/06/2024 15.11, Paolo Bonzini wrote:
> Linux has <misc/pvpanic.h>, not <linux/pvpanic.h>. Use the same
> directory for QEMU's include/standard-headers/ copy.
>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
> 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%)
Reviewed-by: Thomas Huth <thuth@redhat.com>
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 4/4] update-linux-headers: import linux/kvm_para.h header
2024-06-03 13:11 ` [PATCH 4/4] update-linux-headers: import linux/kvm_para.h header Paolo Bonzini
@ 2024-06-03 15:05 ` Thomas Huth
0 siblings, 0 replies; 13+ messages in thread
From: Thomas Huth @ 2024-06-03 15:05 UTC (permalink / raw)
To: Paolo Bonzini, qemu-devel; +Cc: cohuck
On 03/06/2024 15.11, Paolo Bonzini wrote:
> 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.
>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
> 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
Reviewed-by: Thomas Huth <thuth@redhat.com>
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 3/4] linux-headers: Update to current kvm/next
2024-06-03 13:11 ` [PATCH 3/4] linux-headers: Update to current kvm/next Paolo Bonzini
@ 2024-06-03 15:58 ` Cornelia Huck
2024-06-03 16:01 ` Paolo Bonzini
0 siblings, 1 reply; 13+ messages in thread
From: Cornelia Huck @ 2024-06-03 15:58 UTC (permalink / raw)
To: Paolo Bonzini, qemu-devel; +Cc: thuth, Pankaj Gupta, Michael Roth
On Mon, Jun 03 2024, Paolo Bonzini <pbonzini@redhat.com> wrote:
> From: Pankaj Gupta <pankaj.gupta@amd.com>
>
> Also brings in an linux-headers/linux/vhost.h fix from v6.9-rc4.
>
> Co-developed-by: Michael Roth <michael.roth@amd.com>
> Signed-off-by: Michael Roth <michael.roth@amd.com>
> Signed-off-by: Pankaj Gupta <pankaj.gupta@amd.com>
> Message-ID: <20240530111643.1091816-3-pankaj.gupta@amd.com>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
> 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?
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 3/4] linux-headers: Update to current kvm/next
2024-06-03 15:58 ` Cornelia Huck
@ 2024-06-03 16:01 ` Paolo Bonzini
2024-06-03 16:25 ` Cornelia Huck
0 siblings, 1 reply; 13+ messages in thread
From: Paolo Bonzini @ 2024-06-03 16:01 UTC (permalink / raw)
To: Cornelia Huck; +Cc: qemu-devel, thuth, Pankaj Gupta, Michael Roth
On Mon, Jun 3, 2024 at 5:58 PM Cornelia Huck <cohuck@redhat.com> wrote:
> 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
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 3/4] linux-headers: Update to current kvm/next
2024-06-03 16:01 ` Paolo Bonzini
@ 2024-06-03 16:25 ` Cornelia Huck
2024-06-03 16:40 ` Paolo Bonzini
0 siblings, 1 reply; 13+ messages in thread
From: Cornelia Huck @ 2024-06-03 16:25 UTC (permalink / raw)
To: Paolo Bonzini; +Cc: qemu-devel, thuth, Pankaj Gupta, Michael Roth
On Mon, Jun 03 2024, Paolo Bonzini <pbonzini@redhat.com> wrote:
> On Mon, Jun 3, 2024 at 5:58 PM Cornelia Huck <cohuck@redhat.com> wrote:
>> 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.
If we're confident that it's stable, can we please mention a hash?
"current" is not very descriptive :)
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 3/4] linux-headers: Update to current kvm/next
2024-06-03 16:25 ` Cornelia Huck
@ 2024-06-03 16:40 ` Paolo Bonzini
0 siblings, 0 replies; 13+ messages in thread
From: Paolo Bonzini @ 2024-06-03 16:40 UTC (permalink / raw)
To: Cornelia Huck; +Cc: qemu-devel, thuth, Pankaj Gupta, Michael Roth
On Mon, Jun 3, 2024 at 6:25 PM Cornelia Huck <cohuck@redhat.com> wrote:
>
> On Mon, Jun 03 2024, Paolo Bonzini <pbonzini@redhat.com> wrote:
>
> > On Mon, Jun 3, 2024 at 5:58 PM Cornelia Huck <cohuck@redhat.com> wrote:
> >> 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.
>
> If we're confident that it's stable, can we please mention a hash?
Sure, it's commit 6f627b425378915b6eda30908bedefc21b70b8c4.
Paolo
> "current" is not very descriptive :)
>
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 0/4] update-linux-headers: prepare for updating to 6.9+ and for SNP patches
2024-06-03 13:11 [PATCH 0/4] update-linux-headers: prepare for updating to 6.9+ and for SNP patches Paolo Bonzini
` (3 preceding siblings ...)
2024-06-03 13:11 ` [PATCH 4/4] update-linux-headers: import linux/kvm_para.h header Paolo Bonzini
@ 2024-06-04 8:31 ` Cornelia Huck
4 siblings, 0 replies; 13+ messages in thread
From: Cornelia Huck @ 2024-06-04 8:31 UTC (permalink / raw)
To: Paolo Bonzini, qemu-devel; +Cc: thuth
On Mon, Jun 03 2024, Paolo Bonzini <pbonzini@redhat.com> wrote:
> 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
With the hash added to the headers update,
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
for the series.
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2024-06-04 8:32 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-03 13:11 [PATCH 0/4] update-linux-headers: prepare for updating to 6.9+ and for SNP patches Paolo Bonzini
2024-06-03 13:11 ` [PATCH 1/4] update-linux-headers: fix forwarding to asm-generic headers Paolo Bonzini
2024-06-03 14:54 ` Thomas Huth
2024-06-03 13:11 ` [PATCH 2/4] update-linux-headers: move pvpanic.h to correct directory Paolo Bonzini
2024-06-03 14:58 ` Thomas Huth
2024-06-03 13:11 ` [PATCH 3/4] linux-headers: Update to current kvm/next Paolo Bonzini
2024-06-03 15:58 ` Cornelia Huck
2024-06-03 16:01 ` Paolo Bonzini
2024-06-03 16:25 ` Cornelia Huck
2024-06-03 16:40 ` Paolo Bonzini
2024-06-03 13:11 ` [PATCH 4/4] update-linux-headers: import linux/kvm_para.h header Paolo Bonzini
2024-06-03 15:05 ` Thomas Huth
2024-06-04 8:31 ` [PATCH 0/4] update-linux-headers: prepare for updating to 6.9+ and for SNP patches Cornelia Huck
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).