kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH kvmtool 0/3] Build fixes
@ 2023-06-06 14:37 Jean-Philippe Brucker
  2023-06-06 14:37 ` [PATCH kvmtool 1/3] Makefile: Refine -s handling in the make parameters Jean-Philippe Brucker
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Jean-Philippe Brucker @ 2023-06-06 14:37 UTC (permalink / raw)
  To: kvm, will; +Cc: Jean-Philippe Brucker

A few build fixes for kvmtool. They apply independently from the vhost
fixes series I sent today.

Jean-Philippe Brucker (3):
  Makefile: Refine -s handling in the make parameters
  arm/kvm-cpu: Fix new build warning
  virtio/rng: Fix build warning from min()

 Makefile      | 2 +-
 arm/kvm-cpu.c | 3 +--
 virtio/rng.c  | 2 +-
 3 files changed, 3 insertions(+), 4 deletions(-)

-- 
2.40.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH kvmtool 1/3] Makefile: Refine -s handling in the make parameters
  2023-06-06 14:37 [PATCH kvmtool 0/3] Build fixes Jean-Philippe Brucker
@ 2023-06-06 14:37 ` Jean-Philippe Brucker
  2023-06-06 14:37 ` [PATCH kvmtool 2/3] arm/kvm-cpu: Fix new build warning Jean-Philippe Brucker
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Jean-Philippe Brucker @ 2023-06-06 14:37 UTC (permalink / raw)
  To: kvm, will; +Cc: Jean-Philippe Brucker

When looking for the silent flag 's' in MAKEFLAGS we accidentally catch
variable definitions like "ARCH=mips" or "CROSS_COMPILE=/cross/...",
causing several test builds to be silent.

MAKEFLAGS contains the single-letter make flags (without the dash),
followed by flags that don't have a single-letter equivalent such as
"--warn-undefined-variables" (with the dashes), followed by "--" and
command-line variables. For example `make ARCH=mips -k' results in
MAKEFLAGS "k -- ARCH=mips". Running $(filter-out --%) on this does not
discard ARCH=mips, only "--". However adding $(firstword) ensures that
we run the filter either on the single-letter flags or on something
beginning with "--", and avoids silent builds.

Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org>
---
 Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Makefile b/Makefile
index 6b742369..e711670d 100644
--- a/Makefile
+++ b/Makefile
@@ -3,7 +3,7 @@
 #
 
 ifeq ($(strip $(V)),)
-	ifeq ($(findstring s,$(filter-out --%,$(MAKEFLAGS))),)
+	ifeq ($(findstring s,$(filter-out --%,$(firstword $(MAKEFLAGS)))),)
 		E = @echo
 	else
 		E = @\#
-- 
2.40.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH kvmtool 2/3] arm/kvm-cpu: Fix new build warning
  2023-06-06 14:37 [PATCH kvmtool 0/3] Build fixes Jean-Philippe Brucker
  2023-06-06 14:37 ` [PATCH kvmtool 1/3] Makefile: Refine -s handling in the make parameters Jean-Philippe Brucker
@ 2023-06-06 14:37 ` Jean-Philippe Brucker
  2023-06-06 14:37 ` [PATCH kvmtool 3/3] virtio/rng: Fix build warning from min() Jean-Philippe Brucker
  2023-06-08 21:45 ` [PATCH kvmtool 0/3] Build fixes Will Deacon
  3 siblings, 0 replies; 5+ messages in thread
From: Jean-Philippe Brucker @ 2023-06-06 14:37 UTC (permalink / raw)
  To: kvm, will; +Cc: Jean-Philippe Brucker

GCC 13.1 complains about uninitialized value:

arm/kvm-cpu.c: In function 'kvm_cpu__arch_init':
arm/kvm-cpu.c:119:41: error: 'target' may be used uninitialized [-Werror=maybe-uninitialized]
  119 |         vcpu->cpu_compatible    = target->compatible;
      |                                   ~~~~~~^~~~~~~~~~~~
arm/kvm-cpu.c:40:32: note: 'target' was declared here
   40 |         struct kvm_arm_target *target;
      |                                ^~~~~~

This can't happen in practice (we call die() when no target is found), but
initialize the target variable earlier to make GCC happy.

Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org>
---
 arm/kvm-cpu.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/arm/kvm-cpu.c b/arm/kvm-cpu.c
index 98bc5fdf..a43eb90a 100644
--- a/arm/kvm-cpu.c
+++ b/arm/kvm-cpu.c
@@ -37,7 +37,7 @@ int kvm_cpu__register_kvm_arm_target(struct kvm_arm_target *target)
 
 struct kvm_cpu *kvm_cpu__arch_init(struct kvm *kvm, unsigned long cpu_id)
 {
-	struct kvm_arm_target *target;
+	struct kvm_arm_target *target = NULL;
 	struct kvm_cpu *vcpu;
 	int coalesced_offset, mmap_size, err = -1;
 	unsigned int i;
@@ -81,7 +81,6 @@ struct kvm_cpu *kvm_cpu__arch_init(struct kvm *kvm, unsigned long cpu_id)
 	err = ioctl(kvm->vm_fd, KVM_ARM_PREFERRED_TARGET, &preferred_init);
 	if (!err) {
 		/* Match preferred target CPU type. */
-		target = NULL;
 		for (i = 0; i < ARRAY_SIZE(kvm_arm_targets); ++i) {
 			if (!kvm_arm_targets[i])
 				continue;
-- 
2.40.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH kvmtool 3/3] virtio/rng: Fix build warning from min()
  2023-06-06 14:37 [PATCH kvmtool 0/3] Build fixes Jean-Philippe Brucker
  2023-06-06 14:37 ` [PATCH kvmtool 1/3] Makefile: Refine -s handling in the make parameters Jean-Philippe Brucker
  2023-06-06 14:37 ` [PATCH kvmtool 2/3] arm/kvm-cpu: Fix new build warning Jean-Philippe Brucker
@ 2023-06-06 14:37 ` Jean-Philippe Brucker
  2023-06-08 21:45 ` [PATCH kvmtool 0/3] Build fixes Will Deacon
  3 siblings, 0 replies; 5+ messages in thread
From: Jean-Philippe Brucker @ 2023-06-06 14:37 UTC (permalink / raw)
  To: kvm, will; +Cc: Jean-Philippe Brucker

On a 32-bit build GCC complains about the min() parameters:

include/linux/kernel.h:36:24: error: comparison of distinct pointer types lacks a cast [-Werror]
   36 |         (void) (&_min1 == &_min2);              \
      |                        ^~
virtio/rng.c:78:34: note: in expansion of macro 'min'
   78 |                 iov[0].iov_len = min(iov[0].iov_len, 256UL);
      |                                  ^~~

Use min_t() instead

Fixes: bc23b9d9b152 ("virtio/rng: return at least one byte of entropy")
Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org>
---
 virtio/rng.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/virtio/rng.c b/virtio/rng.c
index 77a3a113..6b366552 100644
--- a/virtio/rng.c
+++ b/virtio/rng.c
@@ -75,7 +75,7 @@ static bool virtio_rng_do_io_request(struct kvm *kvm, struct rng_dev *rdev, stru
 		 * just retry here, with the requested size clamped to that
 		 * maximum, in case we were interrupted by a signal.
 		 */
-		iov[0].iov_len = min(iov[0].iov_len, 256UL);
+		iov[0].iov_len = min_t(size_t, iov[0].iov_len, 256UL);
 		len = readv(rdev->fd, iov, 1);
 		if (len < 1)
 			return false;
-- 
2.40.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH kvmtool 0/3] Build fixes
  2023-06-06 14:37 [PATCH kvmtool 0/3] Build fixes Jean-Philippe Brucker
                   ` (2 preceding siblings ...)
  2023-06-06 14:37 ` [PATCH kvmtool 3/3] virtio/rng: Fix build warning from min() Jean-Philippe Brucker
@ 2023-06-08 21:45 ` Will Deacon
  3 siblings, 0 replies; 5+ messages in thread
From: Will Deacon @ 2023-06-08 21:45 UTC (permalink / raw)
  To: Jean-Philippe Brucker, kvm; +Cc: catalin.marinas, kernel-team, Will Deacon

On Tue, 6 Jun 2023 15:37:33 +0100, Jean-Philippe Brucker wrote:
> A few build fixes for kvmtool. They apply independently from the vhost
> fixes series I sent today.
> 
> Jean-Philippe Brucker (3):
>   Makefile: Refine -s handling in the make parameters
>   arm/kvm-cpu: Fix new build warning
>   virtio/rng: Fix build warning from min()
> 
> [...]

Applied to kvmtool (master), thanks!

[1/3] Makefile: Refine -s handling in the make parameters
      https://git.kernel.org/will/kvmtool/c/8f6cabb25d79
[2/3] arm/kvm-cpu: Fix new build warning
      https://git.kernel.org/will/kvmtool/c/426e875213d3
[3/3] virtio/rng: Fix build warning from min()
      https://git.kernel.org/will/kvmtool/c/53114134ce5a

Cheers,
-- 
Will

https://fixes.arm64.dev
https://next.arm64.dev
https://will.arm64.dev

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-06-08 21:46 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-06 14:37 [PATCH kvmtool 0/3] Build fixes Jean-Philippe Brucker
2023-06-06 14:37 ` [PATCH kvmtool 1/3] Makefile: Refine -s handling in the make parameters Jean-Philippe Brucker
2023-06-06 14:37 ` [PATCH kvmtool 2/3] arm/kvm-cpu: Fix new build warning Jean-Philippe Brucker
2023-06-06 14:37 ` [PATCH kvmtool 3/3] virtio/rng: Fix build warning from min() Jean-Philippe Brucker
2023-06-08 21:45 ` [PATCH kvmtool 0/3] Build fixes Will Deacon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).