tools/testing/selftests/kvm/include/kvm_util.h | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
The inline version of vm_compute_max_gfn() in kvm_util.h directly
access members of "struct kvm_vm" which causes compile errors for
non-x86 architectures because lib/elf.c includes "kvm_util.h" before
"kvm_util_internal.h".
This patch fixes above described compile error by converting inline
version of vm_compute_max_gfn() into a macro.
Fixes: c8cc43c1eae2 ("selftests: KVM: avoid failures due to reserved
HyperTransport region")
Signed-off-by: Anup Patel <anup.patel@wdc.com>
---
tools/testing/selftests/kvm/include/kvm_util.h | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/tools/testing/selftests/kvm/include/kvm_util.h b/tools/testing/selftests/kvm/include/kvm_util.h
index da2b702da71a..2279e340ca58 100644
--- a/tools/testing/selftests/kvm/include/kvm_util.h
+++ b/tools/testing/selftests/kvm/include/kvm_util.h
@@ -74,10 +74,8 @@ enum vm_guest_mode {
#if defined(__x86_64__)
unsigned long vm_compute_max_gfn(struct kvm_vm *vm);
#else
-static inline unsigned long vm_compute_max_gfn(struct kvm_vm *vm)
-{
- return ((1ULL << vm->pa_bits) >> vm->page_shift) - 1;
-}
+#define vm_compute_max_gfn(vm) \
+ ((unsigned long)(((1ULL << (vm)->pa_bits) >> (vm)->page_shift) - 1))
#endif
#define MIN_PAGE_SIZE (1U << MIN_PAGE_SHIFT)
--
2.25.1
On 12/21/21 5:56 AM, Anup Patel wrote: > The inline version of vm_compute_max_gfn() in kvm_util.h directly > access members of "struct kvm_vm" which causes compile errors for > non-x86 architectures because lib/elf.c includes "kvm_util.h" before > "kvm_util_internal.h". > > This patch fixes above described compile error by converting inline > version of vm_compute_max_gfn() into a macro. Thank you for the patch. Please include the actual compile error in the change log and send v2, thanks, -- Shuah
On 12/21/21 18:22, Shuah Khan wrote: > On 12/21/21 5:56 AM, Anup Patel wrote: >> The inline version of vm_compute_max_gfn() in kvm_util.h directly >> access members of "struct kvm_vm" which causes compile errors for >> non-x86 architectures because lib/elf.c includes "kvm_util.h" before >> "kvm_util_internal.h". >> >> This patch fixes above described compile error by converting inline >> version of vm_compute_max_gfn() into a macro. > > Thank you for the patch. Please include the actual compile error in the > change log and send v2, Hi, a similar patch is already queued and should get to Linus today or tomorrow. Paolo
On Tue, Dec 21, 2021 at 10:53 PM Paolo Bonzini <pbonzini@redhat.com> wrote: > > On 12/21/21 18:22, Shuah Khan wrote: > > On 12/21/21 5:56 AM, Anup Patel wrote: > >> The inline version of vm_compute_max_gfn() in kvm_util.h directly > >> access members of "struct kvm_vm" which causes compile errors for > >> non-x86 architectures because lib/elf.c includes "kvm_util.h" before > >> "kvm_util_internal.h". > >> > >> This patch fixes above described compile error by converting inline > >> version of vm_compute_max_gfn() into a macro. > > > > Thank you for the patch. Please include the actual compile error in the > > change log and send v2, > > Hi, a similar patch is already queued and should get to Linus today or > tomorrow. Thanks Paolo, I missed Andrew's fix for this. Regards, Anup > > Paolo >
© 2016 - 2026 Red Hat, Inc.