Skip to content

Commit 577e022

Browse files
Andrew Jonesbonzini
authored andcommitted
selftests: KVM: Fix non-x86 compiling
Attempting to compile on a non-x86 architecture fails with include/kvm_util.h: In function ‘vm_compute_max_gfn’: include/kvm_util.h:79:21: error: dereferencing pointer to incomplete type ‘struct kvm_vm’ return ((1ULL << vm->pa_bits) >> vm->page_shift) - 1; ^~ This is because the declaration of struct kvm_vm is in lib/kvm_util_internal.h as an effort to make it private to the test lib code. We can still provide arch specific functions, though, by making the generic function symbols weak. Do that to fix the compile error. Fixes: c8cc43c ("selftests: KVM: avoid failures due to reserved HyperTransport region") Cc: [email protected] Signed-off-by: Andrew Jones <[email protected]> Message-Id: <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
1 parent c506355 commit 577e022

File tree

2 files changed

+6
-9
lines changed

2 files changed

+6
-9
lines changed

tools/testing/selftests/kvm/include/kvm_util.h

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -71,15 +71,6 @@ enum vm_guest_mode {
7171

7272
#endif
7373

74-
#if defined(__x86_64__)
75-
unsigned long vm_compute_max_gfn(struct kvm_vm *vm);
76-
#else
77-
static inline unsigned long vm_compute_max_gfn(struct kvm_vm *vm)
78-
{
79-
return ((1ULL << vm->pa_bits) >> vm->page_shift) - 1;
80-
}
81-
#endif
82-
8374
#define MIN_PAGE_SIZE (1U << MIN_PAGE_SHIFT)
8475
#define PTES_PER_MIN_PAGE ptes_per_page(MIN_PAGE_SIZE)
8576

@@ -330,6 +321,7 @@ bool vm_is_unrestricted_guest(struct kvm_vm *vm);
330321

331322
unsigned int vm_get_page_size(struct kvm_vm *vm);
332323
unsigned int vm_get_page_shift(struct kvm_vm *vm);
324+
unsigned long vm_compute_max_gfn(struct kvm_vm *vm);
333325
uint64_t vm_get_max_gfn(struct kvm_vm *vm);
334326
int vm_get_fd(struct kvm_vm *vm);
335327

tools/testing/selftests/kvm/lib/kvm_util.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2328,6 +2328,11 @@ unsigned int vm_get_page_shift(struct kvm_vm *vm)
23282328
return vm->page_shift;
23292329
}
23302330

2331+
unsigned long __attribute__((weak)) vm_compute_max_gfn(struct kvm_vm *vm)
2332+
{
2333+
return ((1ULL << vm->pa_bits) >> vm->page_shift) - 1;
2334+
}
2335+
23312336
uint64_t vm_get_max_gfn(struct kvm_vm *vm)
23322337
{
23332338
return vm->max_gfn;

0 commit comments

Comments
 (0)