selftests: KVM: Address some bugs caught by clang
v2 cover selftests: KVM: Address some bugs caught by clang
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(-)
Signature · 1 line
2.33.0.464.g1972c5931b-goog
PATCH v2 1/2 selftests: KVM: Fix check for !POLLIN in demand_paging_test
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.
--- tools/testing/selftests/kvm/demand_paging_test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/kvm/demand_paging_test.c +1 -1
@@ -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));
Signature · 1 line
2.33.0.464.g1972c5931b-goog
PATCH v2 2/2 selftests: KVM: Align SMCCC call with the spec in steal_time
In reply to Oliver UptonThe 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.
--- tools/testing/selftests/kvm/steal_time.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tools/testing/selftests/kvm/steal_time.c +2 -2
@@ -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; asmvolatile ( -"mov x0, %1\n" +"mov w0, %w1\n" "mov x1, %2\n" "hvc #0\n" "mov %0, x0\n"
Signature · 1 line
2.33.0.464.g1972c5931b-goog
Re: [PATCH v2 2/2] selftests: KVM: Align SMCCC call with the spec in steal_time
Quoted 36 lines · 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_timetest: 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 <[email protected]>Signed-off-by Oliver Upton <[email protected]>--- tools/testing/selftests/kvm/steal_time.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)tools/testing/selftests/kvm/steal_time.c +2
-2@@ -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; asmvolatile ( -"mov x0, %1\n" +"mov w0, %w1\n" "mov x1, %2\n" "hvc #0\n" "mov %0, x0\n"Signature · 1 line
2.33.0.464.g1972c5931b-goog