Skip to contentSkip to conversation

qemu-kvm: fix build with KVM_CAP_SET_GUEST_DEBUG

PATCH In review Michael S. Tsirkin 3 participants 7 messages Oct 7, 2009 – Oct 8, 2009 1 message not in the archive KVM

lore
Share & tools
lore
#1 lore raw

PATCH 1/3 qemu-kvm: fix build with KVM_CAP_SET_GUEST_DEBUG

In reply to a message not in the archive

Fix build with KVM_CAP_SET_GUEST_DEBUG: use QLIST macro to declare list head.

---
 qemu-kvm.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
qemu-kvm.h +1 -1
index 4523e25..d6748c7 100644
@@ -1229,7 +1229,7 @@ typedef struct KVMState {
     int broken_set_mem_region;
     int migration_log;
 #ifdef KVM_CAP_SET_GUEST_DEBUG
-    struct kvm_sw_breakpoint_head kvm_sw_breakpoints;
+    QTAILQ_HEAD(, kvm_sw_breakpoint) kvm_sw_breakpoints;
 #endif
     struct kvm_context kvm_context;
 } KVMState;
Signature · 1 line
1.6.5.rc2
#5 lore raw

PATCH 2/3 qemu-kvm: fix build on 32 bit

In reply to a message not in the archive

Fix build on 32 bit system: cast 64 bit integer
to pointer through pointer-sized integer. Without this, I get:
qemu-kvm.c:1557: error: cast to pointer from integer of different size

---
 qemu-kvm.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)
qemu-kvm.c +3 -2
index a4a90ed..62ca050 100644
@@ -588,7 +588,7 @@ int kvm_register_phys_mem(kvm_context_t kvm,
     struct kvm_userspace_memory_region memory = {
         .memory_size = len,
         .guest_phys_addr = phys_start,
-        .userspace_addr = (unsigned long) (intptr_t) userspace_addr,
+        .userspace_addr = (unsigned long) (uintptr_t) userspace_addr,
         .flags = log ? KVM_MEM_LOG_DIRTY_PAGES : 0,
     };
     int r;
@@ -1554,7 +1554,8 @@ static void sigbus_handler(int n, struct qemu_signalfd_siginfo *siginfo,
         CPUState *cenv;
 
         /* Hope we are lucky for AO MCE */
-        if (do_qemu_ram_addr_from_host((void *)siginfo->ssi_addr, &paddr)) {
+        if (do_qemu_ram_addr_from_host((void *)(intptr_t)siginfo->ssi_addr,
+				       &paddr)) {
             fprintf(stderr, "Hardware memory error for memory used by "
                     "QEMU itself instead of guest system!: %llx\n",
                     (unsigned long long)siginfo->ssi_addr);
Signature · 1 line
1.6.5.rc2
#6 lore raw

PATCH 3/3 qemu-kvm: convert kvm_types to ISO

In reply to a message not in the archive

Convert kvm-types to use ISO C types so that it can be included independently of other headers. This is on top of header patch set I sent previously.

---
 kvm/include/linux/kvm_types.h |   50 ++++++++++++++++++++--------------------
 1 files changed, 25 insertions(+), 25 deletions(-)
kvm/include/linux/kvm_types.h +25 -25
index c65f89e..5c0b739 100644
@@ -70,41 +70,41 @@
  *  hfn - host frame number
  */
 
-typedef unsigned long  gva_t;
-typedef u64            gpa_t;
-typedef unsigned long  gfn_t;
+typedef unsigned long gva_t;
+typedef unsigned long long gpa_t;
+typedef unsigned long gfn_t;
 
-typedef unsigned long  hva_t;
-typedef u64            hpa_t;
-typedef unsigned long  hfn_t;
+typedef unsigned long hva_t;
+typedef unsigned long long hpa_t;
+typedef unsigned long hfn_t;
 
 typedef hfn_t pfn_t;
 
 union kvm_ioapic_redirect_entry {
-	u64 bits;
+	unsigned long long bits;
 	struct {
-		u8 vector;
-		u8 delivery_mode:3;
-		u8 dest_mode:1;
-		u8 delivery_status:1;
-		u8 polarity:1;
-		u8 remote_irr:1;
-		u8 trig_mode:1;
-		u8 mask:1;
-		u8 reserve:7;
-		u8 reserved[4];
-		u8 dest_id;
+		unsigned char vector;
+		unsigned char delivery_mode:3;
+		unsigned char dest_mode:1;
+		unsigned char delivery_status:1;
+		unsigned char polarity:1;
+		unsigned char remote_irr:1;
+		unsigned char trig_mode:1;
+		unsigned char mask:1;
+		unsigned char reserve:7;
+		unsigned char reserved[4];
+		unsigned char dest_id;
 	} fields;
 };
 
 struct kvm_lapic_irq {
-	u32 vector;
-	u32 delivery_mode;
-	u32 dest_mode;
-	u32 level;
-	u32 trig_mode;
-	u32 shorthand;
-	u32 dest_id;
+	unsigned vector;
+	unsigned delivery_mode;
+	unsigned dest_mode;
+	unsigned level;
+	unsigned trig_mode;
+	unsigned shorthand;
+	unsigned dest_id;
 };
 
 #endif /* __KVM_TYPES_H__ */
Signature · 1 line
1.6.5.rc2
#2 lore raw
In reply to Michael S. Tsirkin
Quoted 13 lines · Michael S. Tsirkin

Fix build with KVM_CAP_SET_GUEST_DEBUG: use QLIST macro to declare list head.

---
 qemu-kvm.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
qemu-kvm.h +0 -0
index 4523e25..d6748c7 100644

qemu-kvm.h typedef struct KVMState { · line 1235

Quoted 8 lines
qemu-kvm.h +1 -1
@@ -1229,7 +1229,7 @@ typedef struct KVMState {
     int broken_set_mem_region;
     int migration_log;
 #ifdef KVM_CAP_SET_GUEST_DEBUG
-    struct kvm_sw_breakpoint_head kvm_sw_breakpoints;
+    QTAILQ_HEAD(, kvm_sw_breakpoint) kvm_sw_breakpoints;
 #endif
     struct kvm_context kvm_context;
 } KVMState;

If it's required here I bet we need this upstream too, right? Then please also file a corresponding patch for qemu.

Thanks,
Jan

Signature · 2 lines
Siemens AG, Corporate Technology, CT SE 2
Corporate Competence Center Embedded Linux
#3 lore raw
Quoted 9 lines · Jan Kiszka
Quoted 8 lines · Michael S. Tsirkin

Fix build with KVM_CAP_SET_GUEST_DEBUG: use QLIST macro to declare list head.

---
 qemu-kvm.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
Quoted 15 lines

qemu-kvm.h typedef struct KVMState { · line 1235

Quoted 13 lines
qemu-kvm.h +1 -1
index 4523e25..d6748c7 100644
@@ -1229,7 +1229,7 @@ typedef struct KVMState {
     int broken_set_mem_region;
     int migration_log;
 #ifdef KVM_CAP_SET_GUEST_DEBUG
-    struct kvm_sw_breakpoint_head kvm_sw_breakpoints;
+    QTAILQ_HEAD(, kvm_sw_breakpoint) kvm_sw_breakpoints;
 #endif
     struct kvm_context kvm_context;
 } KVMState;

If it's required here I bet we need this upstream too, right?

No, upstream does not have qemu-kvm.h
All these files are qemu-kvm only.
upstream builds fine as is.

Quoted 9 lines

Then
please also file a corresponding patch for qemu.

Thanks,
Jan

Signature · 2 lines
Siemens AG, Corporate Technology, CT SE 2
Corporate Competence Center Embedded Linux
#4 lore raw
Quoted 25 lines · Michael S. Tsirkin
Quoted 9 lines · Jan Kiszka
Quoted 8 lines · Michael S. Tsirkin

Fix build with KVM_CAP_SET_GUEST_DEBUG: use QLIST macro to declare list head.

---
 qemu-kvm.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
Quoted 14 lines

qemu-kvm.h typedef struct KVMState { · line 1235

Quoted 13 lines
qemu-kvm.h +1 -1
index 4523e25..d6748c7 100644
@@ -1229,7 +1229,7 @@ typedef struct KVMState {
     int broken_set_mem_region;
     int migration_log;
 #ifdef KVM_CAP_SET_GUEST_DEBUG
-    struct kvm_sw_breakpoint_head kvm_sw_breakpoints;
+    QTAILQ_HEAD(, kvm_sw_breakpoint) kvm_sw_breakpoints;
 #endif
     struct kvm_context kvm_context;
 } KVMState;

If it's required here I bet we need this upstream too, right?

Quoted 3 lines

No, upstream does not have qemu-kvm.h
All these files are qemu-kvm only.
upstream builds fine as is.

Upstream has KVMState, too, but it also has a cleaner header structuring than qemu-kvm (as the latter is morphing towards to former). So yes, this is a qemu-kvm-only workaround.

Jan

Signature · 2 lines
Siemens AG, Corporate Technology, CT SE 2
Corporate Competence Center Embedded Linux
#7 lore raw

Re: [PATCH 3/3] qemu-kvm: convert kvm_types to ISO

In reply to Michael S. Tsirkin
Quoted 5 lines · Michael S. Tsirkin

Convert kvm-types to use ISO C types so that it can be included independently of other headers. This is on top of header patch set I sent previously.

Applied first two, but these headers are completely unnecessary for userspace, so I removed them instead.

Quoted 72 lines
kvm/include/linux/kvm_types.h +25 -25
index c65f89e..5c0b739 100644
@@ -70,41 +70,41 @@
   *  hfn - host frame number
   */
 
-typedef unsigned long  gva_t;
-typedef u64            gpa_t;
-typedef unsigned long  gfn_t;
+typedef unsigned long gva_t;
+typedef unsigned long long gpa_t;
+typedef unsigned long gfn_t;
 
-typedef unsigned long  hva_t;
-typedef u64            hpa_t;
-typedef unsigned long  hfn_t;
+typedef unsigned long hva_t;
+typedef unsigned long long hpa_t;
+typedef unsigned long hfn_t;
 
  typedef hfn_t pfn_t;
 
  union kvm_ioapic_redirect_entry {
-	u64 bits;
+	unsigned long long bits;
  	struct {
-		u8 vector;
-		u8 delivery_mode:3;
-		u8 dest_mode:1;
-		u8 delivery_status:1;
-		u8 polarity:1;
-		u8 remote_irr:1;
-		u8 trig_mode:1;
-		u8 mask:1;
-		u8 reserve:7;
-		u8 reserved[4];
-		u8 dest_id;
+		unsigned char vector;
+		unsigned char delivery_mode:3;
+		unsigned char dest_mode:1;
+		unsigned char delivery_status:1;
+		unsigned char polarity:1;
+		unsigned char remote_irr:1;
+		unsigned char trig_mode:1;
+		unsigned char mask:1;
+		unsigned char reserve:7;
+		unsigned char reserved[4];
+		unsigned char dest_id;
  	} fields;
  };
 
  struct kvm_lapic_irq {
-	u32 vector;
-	u32 delivery_mode;
-	u32 dest_mode;
-	u32 level;
-	u32 trig_mode;
-	u32 shorthand;
-	u32 dest_id;
+	unsigned vector;
+	unsigned delivery_mode;
+	unsigned dest_mode;
+	unsigned level;
+	unsigned trig_mode;
+	unsigned shorthand;
+	unsigned dest_id;
  };
 
  #endif /* __KVM_TYPES_H__ */
Signature · 1 line
error compiling committee.c: too many arguments to function