All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/2] selftests: KVM: Address some bugs caught by clang
@ 2021-09-21 17:11 ` Oliver Upton
  0 siblings, 0 replies; 8+ messages in thread
From: Oliver Upton @ 2021-09-21 17:11 UTC (permalink / raw)
  To: kvm, kvmarm
  Cc: Marc Zyngier, James Morse, Alexandru Elisei, Suzuki K Poulose,
	Paolo Bonzini, Jim Mattson, Sean Christopherson, Andrew Jones,
	Oliver Upton

Building KVM selftests for arm64 using clang throws a couple compiler
warnings. These fixes address a couple of bugs in KVM selftests that
just so happen to also placate the compiler.

Series applies cleanly to 5.15-rc2.

v1 -> v2:
 - Clarify that 1/2 is an actual bugfix, not just an attempt to silence
   clang
 - Adopt Drew's suggested fix, aligning steal_time's SMCCC call with the
   SMC64 convention

Oliver Upton (2):
  selftests: KVM: Fix check for !POLLIN in demand_paging_test
  selftests: KVM: Align SMCCC call with the spec in steal_time

 tools/testing/selftests/kvm/demand_paging_test.c | 2 +-
 tools/testing/selftests/kvm/steal_time.c         | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

-- 
2.33.0.464.g1972c5931b-goog


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

* [PATCH v2 0/2] selftests: KVM: Address some bugs caught by clang
@ 2021-09-21 17:11 ` Oliver Upton
  0 siblings, 0 replies; 8+ messages in thread
From: Oliver Upton @ 2021-09-21 17:11 UTC (permalink / raw)
  To: kvm, kvmarm; +Cc: Marc Zyngier, Sean Christopherson, Paolo Bonzini, Jim Mattson

Building KVM selftests for arm64 using clang throws a couple compiler
warnings. These fixes address a couple of bugs in KVM selftests that
just so happen to also placate the compiler.

Series applies cleanly to 5.15-rc2.

v1 -> v2:
 - Clarify that 1/2 is an actual bugfix, not just an attempt to silence
   clang
 - Adopt Drew's suggested fix, aligning steal_time's SMCCC call with the
   SMC64 convention

Oliver Upton (2):
  selftests: KVM: Fix check for !POLLIN in demand_paging_test
  selftests: KVM: Align SMCCC call with the spec in steal_time

 tools/testing/selftests/kvm/demand_paging_test.c | 2 +-
 tools/testing/selftests/kvm/steal_time.c         | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

-- 
2.33.0.464.g1972c5931b-goog

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

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

* [PATCH v2 1/2] selftests: KVM: Fix check for !POLLIN in demand_paging_test
  2021-09-21 17:11 ` Oliver Upton
@ 2021-09-21 17:11   ` Oliver Upton
  -1 siblings, 0 replies; 8+ messages in thread
From: Oliver Upton @ 2021-09-21 17:11 UTC (permalink / raw)
  To: kvm, kvmarm
  Cc: Marc Zyngier, James Morse, Alexandru Elisei, Suzuki K Poulose,
	Paolo Bonzini, Jim Mattson, Sean Christopherson, Andrew Jones,
	Oliver Upton

The logical not operator applies only to the left hand side of a bitwise
operator. As such, the check for POLLIN not being set in revents wrong.
Fix it by adding parentheses around the bitwise expression.

Fixes: 4f72180eb4da ("KVM: selftests: Add demand paging content to the demand paging test")
Reviewed-by: Andrew Jones <drjones@redhat.com>
Signed-off-by: Oliver Upton <oupton@google.com>
---
 tools/testing/selftests/kvm/demand_paging_test.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/kvm/demand_paging_test.c b/tools/testing/selftests/kvm/demand_paging_test.c
index e79c1b64977f..10edae425ab3 100644
--- a/tools/testing/selftests/kvm/demand_paging_test.c
+++ b/tools/testing/selftests/kvm/demand_paging_test.c
@@ -179,7 +179,7 @@ static void *uffd_handler_thread_fn(void *arg)
 			return NULL;
 		}
 
-		if (!pollfd[0].revents & POLLIN)
+		if (!(pollfd[0].revents & POLLIN))
 			continue;
 
 		r = read(uffd, &msg, sizeof(msg));
-- 
2.33.0.464.g1972c5931b-goog


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

* [PATCH v2 1/2] selftests: KVM: Fix check for !POLLIN in demand_paging_test
@ 2021-09-21 17:11   ` Oliver Upton
  0 siblings, 0 replies; 8+ messages in thread
From: Oliver Upton @ 2021-09-21 17:11 UTC (permalink / raw)
  To: kvm, kvmarm; +Cc: Marc Zyngier, Sean Christopherson, Paolo Bonzini, Jim Mattson

The logical not operator applies only to the left hand side of a bitwise
operator. As such, the check for POLLIN not being set in revents wrong.
Fix it by adding parentheses around the bitwise expression.

Fixes: 4f72180eb4da ("KVM: selftests: Add demand paging content to the demand paging test")
Reviewed-by: Andrew Jones <drjones@redhat.com>
Signed-off-by: Oliver Upton <oupton@google.com>
---
 tools/testing/selftests/kvm/demand_paging_test.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/kvm/demand_paging_test.c b/tools/testing/selftests/kvm/demand_paging_test.c
index e79c1b64977f..10edae425ab3 100644
--- a/tools/testing/selftests/kvm/demand_paging_test.c
+++ b/tools/testing/selftests/kvm/demand_paging_test.c
@@ -179,7 +179,7 @@ static void *uffd_handler_thread_fn(void *arg)
 			return NULL;
 		}
 
-		if (!pollfd[0].revents & POLLIN)
+		if (!(pollfd[0].revents & POLLIN))
 			continue;
 
 		r = read(uffd, &msg, sizeof(msg));
-- 
2.33.0.464.g1972c5931b-goog

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

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

* [PATCH v2 2/2] selftests: KVM: Align SMCCC call with the spec in steal_time
  2021-09-21 17:11 ` Oliver Upton
@ 2021-09-21 17:11   ` Oliver Upton
  -1 siblings, 0 replies; 8+ messages in thread
From: Oliver Upton @ 2021-09-21 17:11 UTC (permalink / raw)
  To: kvm, kvmarm
  Cc: Marc Zyngier, James Morse, Alexandru Elisei, Suzuki K Poulose,
	Paolo Bonzini, Jim Mattson, Sean Christopherson, Andrew Jones,
	Oliver Upton

The SMC64 calling convention passes a function identifier in w0 and its
parameters in x1-x17. Given this, there are two deviations in the
SMC64 call performed by the steal_time test: the function identifier is
assigned to a 64 bit register and the parameter is only 32 bits wide.

Align the call with the SMCCC by using a 32 bit register to handle the
function identifier and increasing the parameter width to 64 bits.

Suggested-by: Andrew Jones <drjones@redhat.com>
Signed-off-by: Oliver Upton <oupton@google.com>
---
 tools/testing/selftests/kvm/steal_time.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/testing/selftests/kvm/steal_time.c b/tools/testing/selftests/kvm/steal_time.c
index ecec30865a74..aafaa8e38b7c 100644
--- a/tools/testing/selftests/kvm/steal_time.c
+++ b/tools/testing/selftests/kvm/steal_time.c
@@ -118,12 +118,12 @@ struct st_time {
 	uint64_t st_time;
 };
 
-static int64_t smccc(uint32_t func, uint32_t arg)
+static int64_t smccc(uint32_t func, uint64_t arg)
 {
 	unsigned long ret;
 
 	asm volatile(
-		"mov	x0, %1\n"
+		"mov	w0, %w1\n"
 		"mov	x1, %2\n"
 		"hvc	#0\n"
 		"mov	%0, x0\n"
-- 
2.33.0.464.g1972c5931b-goog


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

* [PATCH v2 2/2] selftests: KVM: Align SMCCC call with the spec in steal_time
@ 2021-09-21 17:11   ` Oliver Upton
  0 siblings, 0 replies; 8+ messages in thread
From: Oliver Upton @ 2021-09-21 17:11 UTC (permalink / raw)
  To: kvm, kvmarm; +Cc: Marc Zyngier, Sean Christopherson, Paolo Bonzini, Jim Mattson

The SMC64 calling convention passes a function identifier in w0 and its
parameters in x1-x17. Given this, there are two deviations in the
SMC64 call performed by the steal_time test: the function identifier is
assigned to a 64 bit register and the parameter is only 32 bits wide.

Align the call with the SMCCC by using a 32 bit register to handle the
function identifier and increasing the parameter width to 64 bits.

Suggested-by: Andrew Jones <drjones@redhat.com>
Signed-off-by: Oliver Upton <oupton@google.com>
---
 tools/testing/selftests/kvm/steal_time.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/testing/selftests/kvm/steal_time.c b/tools/testing/selftests/kvm/steal_time.c
index ecec30865a74..aafaa8e38b7c 100644
--- a/tools/testing/selftests/kvm/steal_time.c
+++ b/tools/testing/selftests/kvm/steal_time.c
@@ -118,12 +118,12 @@ struct st_time {
 	uint64_t st_time;
 };
 
-static int64_t smccc(uint32_t func, uint32_t arg)
+static int64_t smccc(uint32_t func, uint64_t arg)
 {
 	unsigned long ret;
 
 	asm volatile(
-		"mov	x0, %1\n"
+		"mov	w0, %w1\n"
 		"mov	x1, %2\n"
 		"hvc	#0\n"
 		"mov	%0, x0\n"
-- 
2.33.0.464.g1972c5931b-goog

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

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

* Re: [PATCH v2 2/2] selftests: KVM: Align SMCCC call with the spec in steal_time
  2021-09-21 17:11   ` Oliver Upton
@ 2021-09-21 17:23     ` Andrew Jones
  -1 siblings, 0 replies; 8+ messages in thread
From: Andrew Jones @ 2021-09-21 17:23 UTC (permalink / raw)
  To: Oliver Upton
  Cc: kvm, kvmarm, Marc Zyngier, James Morse, Alexandru Elisei,
	Suzuki K Poulose, Paolo Bonzini, Jim Mattson,
	Sean Christopherson

On Tue, Sep 21, 2021 at 05:11:21PM +0000, Oliver Upton wrote:
> The SMC64 calling convention passes a function identifier in w0 and its
> parameters in x1-x17. Given this, there are two deviations in the
> SMC64 call performed by the steal_time test: the function identifier is
> assigned to a 64 bit register and the parameter is only 32 bits wide.
> 
> Align the call with the SMCCC by using a 32 bit register to handle the
> function identifier and increasing the parameter width to 64 bits.
> 
> Suggested-by: Andrew Jones <drjones@redhat.com>
> Signed-off-by: Oliver Upton <oupton@google.com>
> ---
>  tools/testing/selftests/kvm/steal_time.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/tools/testing/selftests/kvm/steal_time.c b/tools/testing/selftests/kvm/steal_time.c
> index ecec30865a74..aafaa8e38b7c 100644
> --- a/tools/testing/selftests/kvm/steal_time.c
> +++ b/tools/testing/selftests/kvm/steal_time.c
> @@ -118,12 +118,12 @@ struct st_time {
>  	uint64_t st_time;
>  };
>  
> -static int64_t smccc(uint32_t func, uint32_t arg)
> +static int64_t smccc(uint32_t func, uint64_t arg)
>  {
>  	unsigned long ret;
>  
>  	asm volatile(
> -		"mov	x0, %1\n"
> +		"mov	w0, %w1\n"
>  		"mov	x1, %2\n"
>  		"hvc	#0\n"
>  		"mov	%0, x0\n"
> -- 
> 2.33.0.464.g1972c5931b-goog
>

Reviewed-by: Andrew Jones <drjones@redhat.com>


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

* Re: [PATCH v2 2/2] selftests: KVM: Align SMCCC call with the spec in steal_time
@ 2021-09-21 17:23     ` Andrew Jones
  0 siblings, 0 replies; 8+ messages in thread
From: Andrew Jones @ 2021-09-21 17:23 UTC (permalink / raw)
  To: Oliver Upton
  Cc: kvm, Marc Zyngier, Sean Christopherson, Paolo Bonzini, kvmarm,
	Jim Mattson

On Tue, Sep 21, 2021 at 05:11:21PM +0000, Oliver Upton wrote:
> The SMC64 calling convention passes a function identifier in w0 and its
> parameters in x1-x17. Given this, there are two deviations in the
> SMC64 call performed by the steal_time test: the function identifier is
> assigned to a 64 bit register and the parameter is only 32 bits wide.
> 
> Align the call with the SMCCC by using a 32 bit register to handle the
> function identifier and increasing the parameter width to 64 bits.
> 
> Suggested-by: Andrew Jones <drjones@redhat.com>
> Signed-off-by: Oliver Upton <oupton@google.com>
> ---
>  tools/testing/selftests/kvm/steal_time.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/tools/testing/selftests/kvm/steal_time.c b/tools/testing/selftests/kvm/steal_time.c
> index ecec30865a74..aafaa8e38b7c 100644
> --- a/tools/testing/selftests/kvm/steal_time.c
> +++ b/tools/testing/selftests/kvm/steal_time.c
> @@ -118,12 +118,12 @@ struct st_time {
>  	uint64_t st_time;
>  };
>  
> -static int64_t smccc(uint32_t func, uint32_t arg)
> +static int64_t smccc(uint32_t func, uint64_t arg)
>  {
>  	unsigned long ret;
>  
>  	asm volatile(
> -		"mov	x0, %1\n"
> +		"mov	w0, %w1\n"
>  		"mov	x1, %2\n"
>  		"hvc	#0\n"
>  		"mov	%0, x0\n"
> -- 
> 2.33.0.464.g1972c5931b-goog
>

Reviewed-by: Andrew Jones <drjones@redhat.com>

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

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

end of thread, other threads:[~2021-09-21 17:23 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-21 17:11 [PATCH v2 0/2] selftests: KVM: Address some bugs caught by clang Oliver Upton
2021-09-21 17:11 ` Oliver Upton
2021-09-21 17:11 ` [PATCH v2 1/2] selftests: KVM: Fix check for !POLLIN in demand_paging_test Oliver Upton
2021-09-21 17:11   ` Oliver Upton
2021-09-21 17:11 ` [PATCH v2 2/2] selftests: KVM: Align SMCCC call with the spec in steal_time Oliver Upton
2021-09-21 17:11   ` Oliver Upton
2021-09-21 17:23   ` Andrew Jones
2021-09-21 17:23     ` Andrew Jones

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.