diff mbox series

KVM: selftests: Fix compile error for non-x86 vm_compute_max_gfn()

Message ID 20211221125617.932371-1-anup.patel@wdc.com (mailing list archive)
State New, archived
Headers show
Series KVM: selftests: Fix compile error for non-x86 vm_compute_max_gfn() | expand

Commit Message

Anup Patel Dec. 21, 2021, 12:56 p.m. UTC
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(-)

Comments

Shuah Khan Dec. 21, 2021, 5:22 p.m. UTC | #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
Paolo Bonzini Dec. 21, 2021, 5:23 p.m. UTC | #2
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
Anup Patel Dec. 22, 2021, 3:28 a.m. UTC | #3
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
>
diff mbox series

Patch

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)