Skip to content

Commit 6564730

Browse files
committed
KVM: forward declare structs in kvm_types.h
Opaque KVM structs are useful for prototypes in asm/kvm_host.h, to avoid "'struct foo' declared inside parameter list" warnings (and consequent breakage due to conflicting types). Move them from individual files to a generic place in linux/kvm_types.h. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
1 parent d5b7706 commit 6564730

9 files changed

Lines changed: 21 additions & 34 deletions

File tree

‎arch/arm/include/asm/kvm_host.h‎

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
#ifndef __ARM_KVM_HOST_H__
2020
#define __ARM_KVM_HOST_H__
2121

22+
#include <linux/types.h>
23+
#include <linux/kvm_types.h>
2224
#include <asm/kvm.h>
2325
#include <asm/kvm_asm.h>
2426
#include <asm/kvm_mmio.h>
@@ -40,7 +42,6 @@
4042

4143
#include <kvm/arm_vgic.h>
4244

43-
struct kvm_vcpu;
4445
u32 *kvm_vcpu_reg(struct kvm_vcpu *vcpu, u8 reg_num, u32 mode);
4546
int kvm_target_cpu(void);
4647
int kvm_reset_vcpu(struct kvm_vcpu *vcpu);
@@ -149,20 +150,17 @@ struct kvm_vcpu_stat {
149150
u32 halt_wakeup;
150151
};
151152

152-
struct kvm_vcpu_init;
153153
int kvm_vcpu_set_target(struct kvm_vcpu *vcpu,
154154
const struct kvm_vcpu_init *init);
155155
int kvm_vcpu_preferred_target(struct kvm_vcpu_init *init);
156156
unsigned long kvm_arm_num_regs(struct kvm_vcpu *vcpu);
157157
int kvm_arm_copy_reg_indices(struct kvm_vcpu *vcpu, u64 __user *indices);
158-
struct kvm_one_reg;
159158
int kvm_arm_get_reg(struct kvm_vcpu *vcpu, const struct kvm_one_reg *reg);
160159
int kvm_arm_set_reg(struct kvm_vcpu *vcpu, const struct kvm_one_reg *reg);
161160
u64 kvm_call_hyp(void *hypfn, ...);
162161
void force_vm_exit(const cpumask_t *mask);
163162

164163
#define KVM_ARCH_WANT_MMU_NOTIFIER
165-
struct kvm;
166164
int kvm_unmap_hva(struct kvm *kvm, unsigned long hva);
167165
int kvm_unmap_hva_range(struct kvm *kvm,
168166
unsigned long start, unsigned long end);
@@ -187,7 +185,6 @@ struct kvm_vcpu __percpu **kvm_get_running_vcpus(void);
187185

188186
int kvm_arm_copy_coproc_indices(struct kvm_vcpu *vcpu, u64 __user *uindices);
189187
unsigned long kvm_arm_num_coproc_regs(struct kvm_vcpu *vcpu);
190-
struct kvm_one_reg;
191188
int kvm_arm_coproc_get_reg(struct kvm_vcpu *vcpu, const struct kvm_one_reg *);
192189
int kvm_arm_coproc_set_reg(struct kvm_vcpu *vcpu, const struct kvm_one_reg *);
193190

‎arch/arm64/include/asm/kvm_host.h‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
#ifndef __ARM64_KVM_HOST_H__
2323
#define __ARM64_KVM_HOST_H__
2424

25+
#include <linux/types.h>
26+
#include <linux/kvm_types.h>
2527
#include <asm/kvm.h>
2628
#include <asm/kvm_asm.h>
2729
#include <asm/kvm_mmio.h>
@@ -41,7 +43,6 @@
4143

4244
#define KVM_VCPU_MAX_FEATURES 3
4345

44-
struct kvm_vcpu;
4546
int kvm_target_cpu(void);
4647
int kvm_reset_vcpu(struct kvm_vcpu *vcpu);
4748
int kvm_arch_dev_ioctl_check_extension(long ext);
@@ -164,18 +165,15 @@ struct kvm_vcpu_stat {
164165
u32 halt_wakeup;
165166
};
166167

167-
struct kvm_vcpu_init;
168168
int kvm_vcpu_set_target(struct kvm_vcpu *vcpu,
169169
const struct kvm_vcpu_init *init);
170170
int kvm_vcpu_preferred_target(struct kvm_vcpu_init *init);
171171
unsigned long kvm_arm_num_regs(struct kvm_vcpu *vcpu);
172172
int kvm_arm_copy_reg_indices(struct kvm_vcpu *vcpu, u64 __user *indices);
173-
struct kvm_one_reg;
174173
int kvm_arm_get_reg(struct kvm_vcpu *vcpu, const struct kvm_one_reg *reg);
175174
int kvm_arm_set_reg(struct kvm_vcpu *vcpu, const struct kvm_one_reg *reg);
176175

177176
#define KVM_ARCH_WANT_MMU_NOTIFIER
178-
struct kvm;
179177
int kvm_unmap_hva(struct kvm *kvm, unsigned long hva);
180178
int kvm_unmap_hva_range(struct kvm *kvm,
181179
unsigned long start, unsigned long end);

‎arch/ia64/include/asm/kvm_host.h‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -234,9 +234,6 @@ struct kvm_vm_data {
234234
#define KVM_REQ_PTC_G 32
235235
#define KVM_REQ_RESUME 33
236236

237-
struct kvm;
238-
struct kvm_vcpu;
239-
240237
struct kvm_mmio_req {
241238
uint64_t addr; /* physical address */
242239
uint64_t size; /* size in bytes */

‎arch/mips/include/asm/kvm_host.h‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,6 @@
9696
#define CAUSEB_DC 27
9797
#define CAUSEF_DC (_ULCAST_(1) << 27)
9898

99-
struct kvm;
100-
struct kvm_run;
101-
struct kvm_vcpu;
102-
struct kvm_interrupt;
103-
10499
extern atomic_t kvm_mips_instance;
105100
extern pfn_t(*kvm_mips_gfn_to_pfn) (struct kvm *kvm, gfn_t gfn);
106101
extern void (*kvm_mips_release_pfn_clean) (pfn_t pfn);

‎arch/powerpc/include/asm/kvm_host.h‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@
5353

5454
#define KVM_ARCH_WANT_MMU_NOTIFIER
5555

56-
struct kvm;
5756
extern int kvm_unmap_hva(struct kvm *kvm, unsigned long hva);
5857
extern int kvm_unmap_hva_range(struct kvm *kvm,
5958
unsigned long start, unsigned long end);
@@ -76,10 +75,6 @@ extern void kvm_set_spte_hva(struct kvm *kvm, unsigned long hva, pte_t pte);
7675
/* Physical Address Mask - allowed range of real mode RAM access */
7776
#define KVM_PAM 0x0fffffffffffffffULL
7877

79-
struct kvm;
80-
struct kvm_run;
81-
struct kvm_vcpu;
82-
8378
struct lppaca;
8479
struct slb_shadow;
8580
struct dtl_entry;

‎arch/s390/include/asm/kvm_host.h‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,11 @@
1313

1414
#ifndef ASM_KVM_HOST_H
1515
#define ASM_KVM_HOST_H
16+
17+
#include <linux/types.h>
1618
#include <linux/hrtimer.h>
1719
#include <linux/interrupt.h>
20+
#include <linux/kvm_types.h>
1821
#include <linux/kvm_host.h>
1922
#include <linux/kvm.h>
2023
#include <asm/debug.h>
@@ -431,8 +434,6 @@ static inline bool kvm_is_error_hva(unsigned long addr)
431434
}
432435

433436
#define ASYNC_PF_PER_VCPU 64
434-
struct kvm_vcpu;
435-
struct kvm_async_pf;
436437
struct kvm_arch_async_pf {
437438
unsigned long pfault_token;
438439
};

‎arch/x86/include/asm/kvm_host.h‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,6 @@ static inline gfn_t gfn_to_index(gfn_t gfn, gfn_t base_gfn, int level)
9999

100100
#define ASYNC_PF_PER_VCPU 64
101101

102-
struct kvm_vcpu;
103-
struct kvm;
104-
struct kvm_async_pf;
105-
106102
enum kvm_reg {
107103
VCPU_REGS_RAX = 0,
108104
VCPU_REGS_RCX = 1,

‎include/linux/kvm_host.h‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,6 @@ static inline bool is_error_page(struct page *page)
140140
#define KVM_USERSPACE_IRQ_SOURCE_ID 0
141141
#define KVM_IRQFD_RESAMPLE_IRQ_SOURCE_ID 1
142142

143-
struct kvm;
144-
struct kvm_vcpu;
145143
extern struct kmem_cache *kvm_vcpu_cache;
146144

147145
extern spinlock_t kvm_lock;
@@ -325,8 +323,6 @@ struct kvm_kernel_irq_routing_entry {
325323
struct hlist_node link;
326324
};
327325

328-
struct kvm_irq_routing_table;
329-
330326
#ifndef KVM_PRIVATE_MEM_SLOTS
331327
#define KVM_PRIVATE_MEM_SLOTS 0
332328
#endif
@@ -1036,8 +1032,6 @@ static inline bool kvm_check_request(int req, struct kvm_vcpu *vcpu)
10361032

10371033
extern bool kvm_rebooting;
10381034

1039-
struct kvm_device_ops;
1040-
10411035
struct kvm_device {
10421036
struct kvm_device_ops *ops;
10431037
struct kvm *kvm;

‎include/linux/kvm_types.h‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,20 @@
1717
#ifndef __KVM_TYPES_H__
1818
#define __KVM_TYPES_H__
1919

20+
struct kvm;
21+
struct kvm_async_pf;
22+
struct kvm_device_ops;
23+
struct kvm_interrupt;
24+
struct kvm_irq_routing_table;
25+
struct kvm_memory_slot;
26+
struct kvm_one_reg;
27+
struct kvm_run;
28+
struct kvm_userspace_memory_region;
29+
struct kvm_vcpu;
30+
struct kvm_vcpu_init;
31+
32+
enum kvm_mr_change;
33+
2034
#include <asm/types.h>
2135

2236
/*

0 commit comments

Comments
 (0)