Skip to contentSkip to conversation

update-linux-headers changes

PATCH Superseded Paolo Bonzini 2 participants 6 messages Sep 9, 2015

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

cover update-linux-headers changes

Patch 1 updates the Linux headers, which required an unexpected change to hw/pci/pcie_aer.c.

Patch 2 modifies the update-linux-headers script so that asm-x86/hyperv.h can be moved to standard-headers. This is required by the Hyper-V crash MSR patches, which use a Hyper-V define in cpu.h.

Paolo Bonzini (2):
update Linux headers to 4.2
target-i386: move asm-x86/hyperv.h to standard-headers

 hw/pci/pcie_aer.c                                  |   4 +-
 .../standard-headers}/asm-x86/hyperv.h             |  12 +-
 include/standard-headers/linux/pci_regs.h          | 381 +++++++++++++++------
 include/standard-headers/linux/virtio_ring.h       |   3 +-
 linux-headers/asm-x86/hyperv.h                     | 251 +-------------
 linux-headers/asm-x86/kvm.h                        |   4 +-
 linux-headers/linux/kvm.h                          |   1 -
 scripts/update-linux-headers.sh                    |  78 +++--
 target-i386/kvm.c                                  |   2 +-
 9 files changed, 342 insertions(+), 394 deletions(-)
 copy {linux-headers => include/standard-headers}/asm-x86/hyperv.h (97%)
Signature · 1 line
2.4.3
#1 lore raw

PATCH 1/2 update Linux headers to 4.2

---
 hw/pci/pcie_aer.c                            |   4 +-
 include/standard-headers/linux/pci_regs.h    | 381 ++++++++++++++++++++-------
 include/standard-headers/linux/virtio_ring.h |   3 +-
 linux-headers/asm-x86/hyperv.h               |   2 +
 linux-headers/asm-x86/kvm.h                  |   4 +-
 linux-headers/linux/kvm.h                    |   1 -
 scripts/update-linux-headers.sh              |   1 +
 7 files changed, 294 insertions(+), 102 deletions(-)
hw/pci/pcie_aer.c +2 -2
index f1847ac..8e4bd56 100644
@@ -827,8 +827,8 @@ typedef struct PCIEAERErrorName {
  */
 static const struct PCIEAERErrorName pcie_aer_error_list[] = {
     {
-        .name = "TRAIN",
-        .val = PCI_ERR_UNC_TRAIN,
+        .name = "UND",
+        .val = PCI_ERR_UNC_UND,
         .correctable = false,
     }, {
         .name = "DLP",
include/standard-headers/linux/pci_regs.h +285 -96

623 lines not on this page · raw message

include/standard-headers/linux/virtio_ring.h +2 -1
index 6fe276f..023c6db 100644
@@ -31,6 +31,7 @@
  * SUCH DAMAGE.
  *
  * Copyright Rusty Russell IBM Corporation 2007. */
+#include <stdint.h>
 #include "standard-headers/linux/types.h"
 #include "standard-headers/linux/virtio_types.h"
 
@@ -143,7 +144,7 @@ static inline void vring_init(struct vring *vr, unsigned int num, void *p,
 	vr->num = num;
 	vr->desc = p;
 	vr->avail = p + num*sizeof(struct vring_desc);
-	vr->used = (void *)(((unsigned long)&vr->avail->ring[num] + sizeof(__virtio16)
+	vr->used = (void *)(((uintptr_t)&vr->avail->ring[num] + sizeof(__virtio16)
 		+ align-1) & ~(align - 1));
 }
 
linux-headers/asm-x86/hyperv.h +2 -0
index 8fba544..f36d56b 100644
@@ -108,6 +108,8 @@
 #define HV_X64_HYPERCALL_PARAMS_XMM_AVAILABLE		(1 << 4)
 /* Support for a virtual guest idle state is available */
 #define HV_X64_GUEST_IDLE_STATE_AVAILABLE		(1 << 5)
+/* Guest crash data handler available */
+#define HV_X64_GUEST_CRASH_MSR_AVAILABLE		(1 << 10)
 
 /*
  * Implementation recommendations. Indicates which behaviors the hypervisor
linux-headers/asm-x86/kvm.h +2 -2
index a4ae82e..cd54147 100644
@@ -354,7 +354,7 @@ struct kvm_xcrs {
 struct kvm_sync_regs {
 };
 
-#define KVM_QUIRK_LINT0_REENABLED	(1 << 0)
-#define KVM_QUIRK_CD_NW_CLEARED		(1 << 1)
+#define KVM_X86_QUIRK_LINT0_REENABLED	(1 << 0)
+#define KVM_X86_QUIRK_CD_NW_CLEARED	(1 << 1)
 
 #endif /* _ASM_X86_KVM_H */
linux-headers/linux/kvm.h +0 -1
index b974c85..3bac873 100644
@@ -317,7 +317,6 @@ struct kvm_run {
 		struct {
 #define KVM_SYSTEM_EVENT_SHUTDOWN       1
 #define KVM_SYSTEM_EVENT_RESET          2
-#define KVM_SYSTEM_EVENT_CRASH          3
 			__u32 type;
 			__u64 flags;
 		} system_event;
scripts/update-linux-headers.sh +1 -0
index f0e830c..7f7b592 100755
@@ -39,6 +39,7 @@ cp_virtio() {
             if
                 grep '#include' "$f" | grep -v -e 'linux/virtio' \
                                              -e 'linux/types' \
+                                             -e 'stdint' \
                                              -e 'linux/if_ether' \
                                              -e 'sys/' \
                                              > /dev/null
Signature · 1 line
2.4.3
#2 lore raw

Re: [Qemu-devel] [PATCH 1/2] update Linux headers to 4.2

Quoted 16 lines · On Wed, 9 Sep 2015 15:25:51 +0200 Paolo Bonzini <[email protected]> wrote:
---
 hw/pci/pcie_aer.c                            |   4 +-
 include/standard-headers/linux/pci_regs.h    | 381 ++++++++++++++++++++-------
 include/standard-headers/linux/virtio_ring.h |   3 +-
 linux-headers/asm-x86/hyperv.h               |   2 +
 linux-headers/asm-x86/kvm.h                  |   4 +-
 linux-headers/linux/kvm.h                    |   1 -
 scripts/update-linux-headers.sh              |   1 +
 7 files changed, 294 insertions(+), 102 deletions(-)
linux-headers/linux/kvm.h +0 -0
index b974c85..3bac873 100644

linux-headers/linux/kvm.h struct kvm_run { · line 320

Quoted 4 lines
linux-headers/linux/kvm.h +0 -1
@@ -317,7 +317,6 @@ struct kvm_run {
 		struct {
 #define KVM_SYSTEM_EVENT_SHUTDOWN       1
 #define KVM_SYSTEM_EVENT_RESET          2
-#define KVM_SYSTEM_EVENT_CRASH          3

I wonder where this hunk comes from? I don't see it when I run (your modified) update-linux-headers.sh against qemu master + Linux 4.2?

Quoted 15 lines
linux-headers/linux/kvm.h +0 -0
 			__u32 type;
 			__u64 flags;
 		} system_event;
scripts/update-linux-headers.sh +1 -0
index f0e830c..7f7b592 100755
@@ -39,6 +39,7 @@ cp_virtio() {
             if
                 grep '#include' "$f" | grep -v -e 'linux/virtio' \
                                              -e 'linux/types' \
+                                             -e 'stdint' \
                                              -e 'linux/if_ether' \
                                              -e 'sys/' \
                                              > /dev/null
#3 lore raw

Re: [Qemu-devel] [PATCH 1/2] update Linux headers to 4.2

Quoted 11 lines · Cornelia Huck
Quoted 9 lines

linux-headers/linux/kvm.h struct kvm_run { · line 320

Quoted 9 lines
linux-headers/linux/kvm.h +0 -1
index b974c85..3bac873 100644
@@ -317,7 +317,6 @@ struct kvm_run {
 		struct {
 #define KVM_SYSTEM_EVENT_SHUTDOWN       1
 #define KVM_SYSTEM_EVENT_RESET          2
-#define KVM_SYSTEM_EVENT_CRASH          3

I wonder where this hunk comes from? I don't see it when I run (your modified) update-linux-headers.sh against qemu master + Linux 4.2?

That line actually will be added in Linux 4.3, it's in this patch just because of an unclean tree.

Paolo

#4 lore raw

PATCH 2/2 target-i386: move asm-x86/hyperv.h to standard-headers

In reply to Paolo Bonzini

The Hyper-V definitions are an industry standard and can be used from code that is not KVM-specific.

The changes to scripts/update-linux-headers.sh are required because there is both an asm-x86/hyperv.h and a linux/hyperv.h file. linux/hyperv.h introduces dependencies on additional Linux uapi headers, so we only want the former.

The solution is to make cp_virtio (now renamed to cp_portable) copy one file only, instead of using the "find" command, and call it multiple times. The new function is really just a reindentation of the old one.

---
 .../standard-headers}/asm-x86/hyperv.h             |  10 +-
 linux-headers/asm-x86/hyperv.h                     | 253 +--------------------
 scripts/update-linux-headers.sh                    |  79 ++++---
 target-i386/kvm.c                                  |   2 +-
 4 files changed, 49 insertions(+), 295 deletions(-)
 copy {linux-headers => include/standard-headers}/asm-x86/hyperv.h (98%)
include/standard-headers/asm-x86/hyperv.h renamed from linux-headers/asm-x86/hyperv.h +5 -5
similarity index 98%
copy from linux-headers/asm-x86/hyperv.h
copy to include/standard-headers/asm-x86/hyperv.h
index f36d56b..a2123ca 100644
@@ -1,7 +1,7 @@
 #ifndef _ASM_X86_HYPERV_H
 #define _ASM_X86_HYPERV_H
 
-#include <linux/types.h>
+#include "standard-headers/linux/types.h"
 
 /*
  * The below CPUID leaves are present if VersionAndFeatures.HypervisorPresent
@@ -243,10 +243,10 @@
 #define HV_STATUS_INSUFFICIENT_BUFFERS		19
 
 typedef struct _HV_REFERENCE_TSC_PAGE {
-	__u32 tsc_sequence;
-	__u32 res1;
-	__u64 tsc_scale;
-	__s64 tsc_offset;
+	uint32_t tsc_sequence;
+	uint32_t res1;
+	uint64_t tsc_scale;
+	int64_t tsc_offset;
 } HV_REFERENCE_TSC_PAGE, *PHV_REFERENCE_TSC_PAGE;
 
 #endif
linux-headers/asm-x86/hyperv.h +1 -252

253 lines not on this page · raw message

scripts/update-linux-headers.sh +42 -37

114 lines not on this page · raw message

target-i386/kvm.c +1 -1
index 066d03d..d8a11be 100644
@@ -33,7 +33,7 @@
 #include "hw/i386/apic_internal.h"
 #include "hw/i386/apic-msidef.h"
 #include "exec/ioport.h"
-#include <asm/hyperv.h>
+#include "standard-headers/asm-x86/hyperv.h"
 #include "hw/pci/pci.h"
 #include "migration/migration.h"
 #include "exec/memattrs.h"
Signature · 1 line
2.4.3
#5 lore raw

Re: [Qemu-devel] [PATCH 2/2] target-i386: move asm-x86/hyperv.h to standard-headers

Quoted 55 lines · On Wed, 9 Sep 2015 15:25:52 +0200 Paolo Bonzini <[email protected]> wrote:

The Hyper-V definitions are an industry standard and can be used from code that is not KVM-specific.

The changes to scripts/update-linux-headers.sh are required because there is both an asm-x86/hyperv.h and a linux/hyperv.h file. linux/hyperv.h introduces dependencies on additional Linux uapi headers, so we only want the former.

The solution is to make cp_virtio (now renamed to cp_portable) copy one file only, instead of using the "find" command, and call it multiple times. The new function is really just a reindentation of the old one.

---
 .../standard-headers}/asm-x86/hyperv.h             |  10 +-
 linux-headers/asm-x86/hyperv.h                     | 253 +--------------------
 scripts/update-linux-headers.sh                    |  79 ++++---
 target-i386/kvm.c                                  |   2 +-
 4 files changed, 49 insertions(+), 295 deletions(-)
 copy {linux-headers => include/standard-headers}/asm-x86/hyperv.h (98%)
scripts/update-linux-headers.sh +2 -22
index 7f7b592..a5f8935 100755
@@ -28,39 +28,33 @@ if [ -z "$output" ]; then
     output="$PWD"
 fi
 
-cp_virtio() {
-    from=$1
+cp_portable() {
+    f=$1
     to=$2
-    virtio=$(find "$from" -name '*virtio*h' -o -name "input.h" -o -name "pci_regs.h")
-    if [ "$virtio" ]; then
-        rm -rf "$to"
-        mkdir -p "$to"
-        for f in $virtio; do
-            if
-                grep '#include' "$f" | grep -v -e 'linux/virtio' \
-                                             -e 'linux/types' \
-                                             -e 'stdint' \
-                                             -e 'linux/if_ether' \
-                                             -e 'sys/' \
-                                             > /dev/null
-            then
-                echo "Unexpected #include in input file $f".
-                exit 2
-            fi
-
-            header=$(basename "$f");
-            sed -e 's/__u\([0-9][0-9]*\)/uint\1_t/g' \
-                -e 's/__s\([0-9][0-9]*\)/int\1_t/g' \

scripts/update-linux-headers.sh if [ -z "$output" ]; then · line 34

Quoted 10 lines
scripts/update-linux-headers.sh +1 -9
-                -e 's/__le\([0-9][0-9]*\)/uint\1_t/g' \
-                -e 's/__be\([0-9][0-9]*\)/uint\1_t/g' \
-                -e 's/<linux\/\([^>]*\)>/"standard-headers\/linux\/\1"/' \
-                -e 's/__bitwise__//' \
-                -e 's/__attribute__((packed))/QEMU_PACKED/' \
-                -e 's/__inline__/inline/' \
-                -e '/sys\/ioctl.h/d' \
-                "$f" > "$to/$header";
-        done
+    mkdir -p "$to"

I'd probably move the mkdir outside of this function and...

Quoted 27 lines
scripts/update-linux-headers.sh +22 -0
+    if
+        grep '#include' "$f" | grep -v -e 'linux/virtio' \
+                                     -e 'linux/types' \
+                                     -e 'stdint' \
+                                     -e 'linux/if_ether' \
+                                     -e 'sys/' \
+                                     > /dev/null
+    then
+        echo "Unexpected #include in input file $f".
+        exit 2
     fi
+
+    header=$(basename "$f");
+    sed -e 's/__u\([0-9][0-9]*\)/uint\1_t/g' \
+        -e 's/__s\([0-9][0-9]*\)/int\1_t/g' \
+        -e 's/__le\([0-9][0-9]*\)/uint\1_t/g' \
+        -e 's/__be\([0-9][0-9]*\)/uint\1_t/g' \
+        -e 's/<linux\/\([^>]*\)>/"standard-headers\/linux\/\1"/' \
+        -e 's/__bitwise__//' \
+        -e 's/__attribute__((packed))/QEMU_PACKED/' \
+        -e 's/__inline__/inline/' \
+        -e '/sys\/ioctl.h/d' \
+        "$f" > "$to/$header";
 }
 
 # This will pick up non-directories too (eg "Kconfig") but we will

scripts/update-linux-headers.sh cp_virtio() { · line 65

Quoted 4 lines
scripts/update-linux-headers.sh +1 -0
@@ -68,6 +62,8 @@ cp_virtio() {
 ARCHLIST=$(cd "$linux/arch" && echo *)
 
 for arch in $ARCHLIST; do
+    rm -rf "$output/include/standard-headers/$arch"

...move this line to...

Quoted 6 lines
scripts/update-linux-headers.sh +1 -0
+
     # Discard anything which isn't a KVM-supporting architecture
     if ! [ -e "$linux/arch/$arch/include/asm/kvm.h" ] &&
         ! [ -e "$linux/arch/$arch/include/uapi/asm/kvm.h" ] ; then
@@ -86,14 +82,16 @@ for arch in $ARCHLIST; do
     for header in kvm.h kvm_para.h; do

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

Quoted 10 lines
scripts/update-linux-headers.sh +0 -5
         cp "$tmpdir/include/asm/$header" "$output/linux-headers/asm-$arch"
     done
-    if [ $arch = x86 ]; then
-        cp "$tmpdir/include/asm/hyperv.h" "$output/linux-headers/asm-x86"
-    fi
     if [ $arch = powerpc ]; then
         cp "$tmpdir/include/asm/epapr_hcalls.h" "$output/linux-headers/asm-powerpc/"
     fi
-
-    cp_virtio "$tmpdir/include/asm" "$output/include/standard-headers/asm-$arch"

...just before you actually handle the architectures with standard headers.

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

Quoted 6 lines
scripts/update-linux-headers.sh +6 -0
+    if [ $arch = s390 ]; then
+        cp_portable "$tmpdir/include/asm/kvm_virtio.h" "$output/include/standard-headers/asm-s390/"
+        cp_portable "$tmpdir/include/asm/virtio-ccw.h" "$output/include/standard-headers/asm-s390/"
+    fi
+    if [ $arch = x86 ]; then
+        cp_portable "$tmpdir/include/asm/hyperv.h" "$output/include/standard-headers/asm-$arch/"

Either make this "asm-x86" or use "asm-$arch" instead of "asm-s390" above; else looks a bit inconsistent :)

Quoted 17 lines
scripts/update-linux-headers.sh +4 -0
+    fi
 done
 
 rm -rf "$output/linux-headers/linux"
@@ -113,6 +111,9 @@ else
     cp "$linux/COPYING" "$output/linux-headers"
 fi
 
+cat <<EOF >$output/linux-headers/asm-x86/hyperv.h
+#include "standard-headers/asm-x86/hyperv.h"
+EOF
 cat <<EOF >$output/linux-headers/linux/virtio_config.h
 #include "standard-headers/linux/virtio_config.h"
 EOF
@@ -120,7 +121,11 @@ cat <<EOF >$output/linux-headers/linux/virtio_ring.h
 #include "standard-headers/linux/virtio_ring.h"
 EOF

scripts/update-linux-headers.sh cat <<EOF >$output/linux-headers/linux/virtio_ring.h · line 131

Quoted 10 lines
scripts/update-linux-headers.sh +5 -1
 
-cp_virtio "$tmpdir/include/linux/" "$output/include/standard-headers/linux"
+rm -rf "$output/include/standard-headers/linux"
+for i in "$tmpdir"/include/linux/*virtio*.h "$tmpdir/include/linux/input.h" \
+         "$tmpdir/include/linux/pci_regs.h"; do
+    cp_portable "$i" "$output/include/standard-headers/linux"
+done
 
 cat <<EOF >$output/include/standard-headers/linux/types.h
 #include <stdint.h>

On the whole, this looks reasonable.