All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marc Zyngier <maz@kernel.org>
To: Paolo Bonzini <pbonzini@redhat.com>, Andrew Jones <drjones@redhat.com>
Cc: kvm@vger.kernel.org, kernel-team@android.com,
	kvmarm@lists.cs.columbia.edu,
	linux-arm-kernel@lists.infradead.org
Subject: [PATCH 1/5] KVM: selftests: Fix vm_compute_max_gfn on !x86
Date: Thu, 16 Dec 2021 12:31:31 +0000	[thread overview]
Message-ID: <20211216123135.754114-2-maz@kernel.org> (raw)
In-Reply-To: <20211216123135.754114-1-maz@kernel.org>

Compiling the selftestts on arm64 leads to this:

gcc -Wall -Wstrict-prototypes -Wuninitialized -O2 -g -std=gnu99 -fno-stack-protector -fno-PIE -I../../../../tools/include -I../../../../tools/arch/arm64/include -I../../../../usr/include/ -Iinclude -Ilib -Iinclude/aarch64 -I..   -c lib/kvm_util.c -o /home/maz/arm-platforms/tools/testing/selftests/kvm/lib/kvm_util.o
In file included from lib/kvm_util.c:10:
include/kvm_util.h: In function ‘vm_compute_max_gfn’:
include/kvm_util.h:79:21: error: invalid use of undefined type ‘struct kvm_vm’
   79 |  return ((1ULL << vm->pa_bits) >> vm->page_shift) - 1;
      |                     ^~
include/kvm_util.h:79:37: error: invalid use of undefined type ‘struct kvm_vm’
   79 |  return ((1ULL << vm->pa_bits) >> vm->page_shift) - 1;
      |                                     ^~
[...]

This is all because struct kvm_vm is not defined yet (only declared).
Sidestep the whole issue by making vm_compute_max_gfn() a macro.

Fixes: c8cc43c1eae2 ("selftests: KVM: avoid failures due to reserved HyperTransport region")
Signed-off-by: Marc Zyngier <maz@kernel.org>
---
 tools/testing/selftests/kvm/include/kvm_util.h | 9 +++++----
 1 file changed, 5 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..c74241ddf8b1 100644
--- a/tools/testing/selftests/kvm/include/kvm_util.h
+++ b/tools/testing/selftests/kvm/include/kvm_util.h
@@ -74,10 +74,11 @@ 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)						\
+	({								\
+		struct kvm_vm *__vm = vm;				\
+		((1ULL << __vm->pa_bits) >> __vm->page_shift) - 1;	\
+	})
 #endif
 
 #define MIN_PAGE_SIZE		(1U << MIN_PAGE_SHIFT)
-- 
2.30.2

_______________________________________________
kvmarm mailing list
kvmarm@lists.cs.columbia.edu
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm

WARNING: multiple messages have this Message-ID (diff)
From: Marc Zyngier <maz@kernel.org>
To: Paolo Bonzini <pbonzini@redhat.com>, Andrew Jones <drjones@redhat.com>
Cc: James Morse <james.morse@arm.com>,
	Suzuki K Poulose <suzuki.poulose@arm.com>,
	Alexandru Elisei <alexandru.elisei@arm.com>,
	kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org, kernel-team@android.com
Subject: [PATCH 1/5] KVM: selftests: Fix vm_compute_max_gfn on !x86
Date: Thu, 16 Dec 2021 12:31:31 +0000	[thread overview]
Message-ID: <20211216123135.754114-2-maz@kernel.org> (raw)
In-Reply-To: <20211216123135.754114-1-maz@kernel.org>

Compiling the selftestts on arm64 leads to this:

gcc -Wall -Wstrict-prototypes -Wuninitialized -O2 -g -std=gnu99 -fno-stack-protector -fno-PIE -I../../../../tools/include -I../../../../tools/arch/arm64/include -I../../../../usr/include/ -Iinclude -Ilib -Iinclude/aarch64 -I..   -c lib/kvm_util.c -o /home/maz/arm-platforms/tools/testing/selftests/kvm/lib/kvm_util.o
In file included from lib/kvm_util.c:10:
include/kvm_util.h: In function ‘vm_compute_max_gfn’:
include/kvm_util.h:79:21: error: invalid use of undefined type ‘struct kvm_vm’
   79 |  return ((1ULL << vm->pa_bits) >> vm->page_shift) - 1;
      |                     ^~
include/kvm_util.h:79:37: error: invalid use of undefined type ‘struct kvm_vm’
   79 |  return ((1ULL << vm->pa_bits) >> vm->page_shift) - 1;
      |                                     ^~
[...]

This is all because struct kvm_vm is not defined yet (only declared).
Sidestep the whole issue by making vm_compute_max_gfn() a macro.

Fixes: c8cc43c1eae2 ("selftests: KVM: avoid failures due to reserved HyperTransport region")
Signed-off-by: Marc Zyngier <maz@kernel.org>
---
 tools/testing/selftests/kvm/include/kvm_util.h | 9 +++++----
 1 file changed, 5 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..c74241ddf8b1 100644
--- a/tools/testing/selftests/kvm/include/kvm_util.h
+++ b/tools/testing/selftests/kvm/include/kvm_util.h
@@ -74,10 +74,11 @@ 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)						\
+	({								\
+		struct kvm_vm *__vm = vm;				\
+		((1ULL << __vm->pa_bits) >> __vm->page_shift) - 1;	\
+	})
 #endif
 
 #define MIN_PAGE_SIZE		(1U << MIN_PAGE_SHIFT)
-- 
2.30.2


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

WARNING: multiple messages have this Message-ID (diff)
From: Marc Zyngier <maz@kernel.org>
To: Paolo Bonzini <pbonzini@redhat.com>, Andrew Jones <drjones@redhat.com>
Cc: James Morse <james.morse@arm.com>,
	Suzuki K Poulose <suzuki.poulose@arm.com>,
	Alexandru Elisei <alexandru.elisei@arm.com>,
	kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org, kernel-team@android.com
Subject: [PATCH 1/5] KVM: selftests: Fix vm_compute_max_gfn on !x86
Date: Thu, 16 Dec 2021 12:31:31 +0000	[thread overview]
Message-ID: <20211216123135.754114-2-maz@kernel.org> (raw)
In-Reply-To: <20211216123135.754114-1-maz@kernel.org>

Compiling the selftestts on arm64 leads to this:

gcc -Wall -Wstrict-prototypes -Wuninitialized -O2 -g -std=gnu99 -fno-stack-protector -fno-PIE -I../../../../tools/include -I../../../../tools/arch/arm64/include -I../../../../usr/include/ -Iinclude -Ilib -Iinclude/aarch64 -I..   -c lib/kvm_util.c -o /home/maz/arm-platforms/tools/testing/selftests/kvm/lib/kvm_util.o
In file included from lib/kvm_util.c:10:
include/kvm_util.h: In function ‘vm_compute_max_gfn’:
include/kvm_util.h:79:21: error: invalid use of undefined type ‘struct kvm_vm’
   79 |  return ((1ULL << vm->pa_bits) >> vm->page_shift) - 1;
      |                     ^~
include/kvm_util.h:79:37: error: invalid use of undefined type ‘struct kvm_vm’
   79 |  return ((1ULL << vm->pa_bits) >> vm->page_shift) - 1;
      |                                     ^~
[...]

This is all because struct kvm_vm is not defined yet (only declared).
Sidestep the whole issue by making vm_compute_max_gfn() a macro.

Fixes: c8cc43c1eae2 ("selftests: KVM: avoid failures due to reserved HyperTransport region")
Signed-off-by: Marc Zyngier <maz@kernel.org>
---
 tools/testing/selftests/kvm/include/kvm_util.h | 9 +++++----
 1 file changed, 5 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..c74241ddf8b1 100644
--- a/tools/testing/selftests/kvm/include/kvm_util.h
+++ b/tools/testing/selftests/kvm/include/kvm_util.h
@@ -74,10 +74,11 @@ 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)						\
+	({								\
+		struct kvm_vm *__vm = vm;				\
+		((1ULL << __vm->pa_bits) >> __vm->page_shift) - 1;	\
+	})
 #endif
 
 #define MIN_PAGE_SIZE		(1U << MIN_PAGE_SHIFT)
-- 
2.30.2


  reply	other threads:[~2021-12-16 12:31 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-16 12:31 [PATCH 0/5] KVM: arm64: Selftest IPA fixes Marc Zyngier
2021-12-16 12:31 ` Marc Zyngier
2021-12-16 12:31 ` Marc Zyngier
2021-12-16 12:31 ` Marc Zyngier [this message]
2021-12-16 12:31   ` [PATCH 1/5] KVM: selftests: Fix vm_compute_max_gfn on !x86 Marc Zyngier
2021-12-16 12:31   ` Marc Zyngier
2021-12-16 12:31 ` [PATCH 2/5] KVM: selftests: Initialise default mode in each test Marc Zyngier
2021-12-16 12:31   ` Marc Zyngier
2021-12-16 12:31   ` Marc Zyngier
2021-12-23 17:00   ` Andrew Jones
2021-12-23 17:00     ` Andrew Jones
2021-12-23 17:00     ` Andrew Jones
2021-12-16 12:31 ` [PATCH 3/5] KVM: selftests: arm64: Introduce a variable default IPA size Marc Zyngier
2021-12-16 12:31   ` Marc Zyngier
2021-12-16 12:31   ` Marc Zyngier
2021-12-23 16:17   ` Andrew Jones
2021-12-23 16:17     ` Andrew Jones
2021-12-23 16:17     ` Andrew Jones
2021-12-16 12:31 ` [PATCH 4/5] KVM: selftests: arm64: Check for supported page sizes Marc Zyngier
2021-12-16 12:31   ` Marc Zyngier
2021-12-16 12:31   ` Marc Zyngier
2021-12-23 16:26   ` Andrew Jones
2021-12-23 16:26     ` Andrew Jones
2021-12-23 16:26     ` Andrew Jones
2021-12-16 12:31 ` [PATCH 5/5] KVM: selftests: arm64: Add support for VM_MODE_P36V48_{4K, 64K} Marc Zyngier
2021-12-16 12:31   ` [PATCH 5/5] KVM: selftests: arm64: Add support for VM_MODE_P36V48_{4K,64K} Marc Zyngier
2021-12-16 12:31   ` [PATCH 5/5] KVM: selftests: arm64: Add support for VM_MODE_P36V48_{4K, 64K} Marc Zyngier
2021-12-23 16:32   ` [PATCH 5/5] KVM: selftests: arm64: Add support for VM_MODE_P36V48_{4K,64K} Andrew Jones
2021-12-23 16:32     ` Andrew Jones
2021-12-23 16:32     ` Andrew Jones

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211216123135.754114-2-maz@kernel.org \
    --to=maz@kernel.org \
    --cc=drjones@redhat.com \
    --cc=kernel-team@android.com \
    --cc=kvm@vger.kernel.org \
    --cc=kvmarm@lists.cs.columbia.edu \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=pbonzini@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.