selftests: KVM: Fix some compiler warnings
cover selftests: KVM: Fix some compiler warnings
Building KVM selftests for arm64 using clang throws a couple compiler warnings. This series addresses the warnings found insofar that selftests can be built quietly for arm64 with clang.
Series applies cleanly to 5.15-rc2.
Oliver Upton (2):
selftests: KVM: Fix compiler warning in demand_paging_test
selftests: KVM: Fix 'asm-operand-width' warnings in steal_time.c
tools/testing/selftests/kvm/demand_paging_test.c | 2 +- tools/testing/selftests/kvm/steal_time.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
Signature · 6 lines
2.33.0.464.g1972c5931b-goog _______________________________________________ kvmarm mailing list [email protected] https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
PATCH 1/2 selftests: KVM: Fix compiler warning in demand_paging_test
Building demand_paging_test.c with clang throws the following warning:
Quoted 1 line
Quoted 1 line
demand_paging_test.c:182:7: error: logical not is only applied to the left hand side of this bitwise operator [-Werror,-Wlogical-not-parentheses]
if (!pollfd[0].revents & POLLIN)
Silence the warning by placing the bitwise operation within parentheses.
--- 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 · 6 lines
2.33.0.464.g1972c5931b-goog _______________________________________________ kvmarm mailing list [email protected] https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
Re: [PATCH 1/2] selftests: KVM: Fix compiler warning in demand_paging_test
Quoted 17 lines · Oliver Upton
Building
demand_paging_test.cwith clang throws the following warning:Quoted 1 line
Quoted 1 line
demand_paging_test.c:182:7: error: logical not is only applied to the left hand side of this bitwise operator [-Werror,-Wlogical-not-parentheses]
if (!pollfd[0].revents & POLLIN)
Silence the warning by placing the bitwise operation within parentheses.
Signed-off-by Oliver Upton <[email protected]>--- tools/testing/selftests/kvm/demand_paging_test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)tools/testing/selftests/kvm/demand_paging_test.c +0
-0
tools/testing/selftests/kvm/demand_paging_test.c static void *uffd_handler_thread_fn(void *arg) · line 182
Quoted 5 lines
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 ))
That's a bug fix. If revents was e.g. POLLPRI then this logic wouldn't have done what it's supposed to do. Maybe we should better call out that this is a fix in the summary and add a fixes tag?
Anyway,
Thanks,
drew
Quoted 6 lines
tools/testing/selftests/kvm/demand_paging_test.c +0
-0continue ; r =read (uffd, &msg,sizeof (msg));Signature · 1 line
2.33.0.464.g1972c5931b-goog
_______________________________________________
kvmarm mailing list
[email protected]
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
Re: [PATCH 1/2] selftests: KVM: Fix compiler warning in demand_paging_test
In reply to Oliver UptonQuoted 18 lines · Oliver Upton
Building
demand_paging_test.cwith clang throws the following warning:Quoted 1 line
Quoted 1 line
demand_paging_test.c:182:7: error: logical not is only applied to the left hand side of this bitwise operator [-Werror,-Wlogical-not-parentheses]
if (!pollfd[0].revents & POLLIN)
Silence the warning by placing the bitwise operation within parentheses.
Signed-off-by Oliver Upton <[email protected]>--- tools/testing/selftests/kvm/demand_paging_test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)tools/testing/selftests/kvm/demand_paging_test.c +0
-0
tools/testing/selftests/kvm/demand_paging_test.c static void *uffd_handler_thread_fn(void *arg) · line 185
Quoted 8 lines
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));
Queued (with small adjustments to the commit message and Cc: stable), thanks.
Paolo
Re: [PATCH 1/2] selftests: KVM: Fix compiler warning in demand_paging_test
Hi Paolo,
Quoted 26 lines · Paolo Bonzini
Quoted 24 lines · Oliver Upton
Building
demand_paging_test.cwith clang throws the following warning:Quoted 1 line
Quoted 1 line
demand_paging_test.c:182:7: error: logical not is only applied to the left hand side of this bitwise operator [-Werror,-Wlogical-not-parentheses]
if (!pollfd[0].revents & POLLIN)
Silence the warning by placing the bitwise operation within parentheses.
Signed-off-by Oliver Upton <[email protected]>--- 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 ;
Quoted 5 lines
tools/testing/selftests/kvm/demand_paging_test.c static void *uffd_handler_thread_fn(void *arg) · line 185
Quoted 2 lines
tools/testing/selftests/kvm/demand_paging_test.c +0
-0r =read (uffd, &msg,sizeof (msg));Queued (with small adjustments to the commit message and Cc: stable), thanks.
I sent out a v2 of this series that addressed Drew's comments here and picked up his suggested fix for 2/2. Would you like to queue that version instead?
http://lore.kernel.org/kvm/[email protected]
--
Thanks,
Oliver
PATCH 2/2 selftests: KVM: Fix 'asm-operand-width' warnings in steal_time.c
In reply to Oliver UptonBuilding steal_time.c for arm64 with clang throws the following:
Quoted 1 line
Quoted 1 line
steal_time.c:130:22: error: value size does not match register size specified by the constraint and modifier [-Werror,-Wasm-operand-widths]
: "=r" (ret) : "r" (func), "r" (arg) :
^Quoted 1 line
Quoted 1 line
steal_time.c:130:34: error: value size does not match register size specified by the constraint and modifier [-Werror,-Wasm-operand-widths]
: "=r" (ret) : "r" (func), "r" (arg) :
^Silence by casting operands to 64 bits.
--- tools/testing/selftests/kvm/steal_time.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/kvm/steal_time.c +1 -1
@@ -127,7 +127,7 @@ static int64_t smccc(uint32_t func, uint32_t arg) "mov x1, %2\n" "hvc #0\n" "mov %0, x0\n" - : "=r" (ret) : "r" (func), "r" (arg) : + : "=r" (ret) : "r" ((uint64_t)func), "r" ((uint64_t)arg) : "x0", "x1", "x2", "x3"); return ret;
Signature · 6 lines
2.33.0.464.g1972c5931b-goog _______________________________________________ kvmarm mailing list [email protected] https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
Re: [PATCH 2/2] selftests: KVM: Fix 'asm-operand-width' warnings in steal_time.c
Quoted 21 lines · Oliver Upton
Building
steal_time.cfor arm64 with clang throws the following:Quoted 1 line
Quoted 1 line
steal_time.c:130:22: error: value size does not match register size specified by the constraint and modifier [-Werror,-Wasm-operand-widths]
: "=r" (ret) : "r" (func), "r" (arg) : ^Quoted 1 line
Quoted 1 line
steal_time.c:130:34: error: value size does not match register size specified by the constraint and modifier [-Werror,-Wasm-operand-widths]
: "=r" (ret) : "r" (func), "r" (arg) : ^Silence by casting operands to 64 bits.
Signed-off-by Oliver Upton <[email protected]>--- tools/testing/selftests/kvm/steal_time.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)tools/testing/selftests/kvm/steal_time.c +0
-0
tools/testing/selftests/kvm/steal_time.c static int64_t smccc(uint32_t func, uint32_t arg) · line 130
Quoted 5 lines
tools/testing/selftests/kvm/steal_time.c +1
-1@@ -127,7 +127,7 @@ static int64_t smccc(uint32_t func, uint32_t arg) "mov x1, %2\n" "hvc #0\n" "mov %0, x0\n" - : "=r" (ret) : "r" (func), "r" (arg) : + : "=r" (ret) : "r" ((uint64_t)func), "r" ((uint64_t)arg) :
Actually, I think I'd rather fix this smccc implementation to match the spec, which I think should be done like this
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"
Thanks,
drew
Quoted 6 lines
tools/testing/selftests/kvm/steal_time.c +0
-0"x0", "x1", "x2", "x3");return ret;Signature · 1 line
2.33.0.464.g1972c5931b-goog
_______________________________________________
kvmarm mailing list
[email protected]
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
Paolo Bonzini
maintainerRe: [PATCH 2/2] selftests: KVM: Fix 'asm-operand-width' warnings in steal_time.c
Quoted 41 lines · Andrew Jones
Quoted 21 lines · Oliver Upton
Building
steal_time.cfor arm64 with clang throws the following:Quoted 1 line
Quoted 1 line
steal_time.c:130:22: error: value size does not match register size specified by the constraint and modifier [-Werror,-Wasm-operand-widths]
: "=r" (ret) : "r" (func), "r" (arg) : ^Quoted 1 line
Quoted 1 line
steal_time.c:130:34: error: value size does not match register size specified by the constraint and modifier [-Werror,-Wasm-operand-widths]
: "=r" (ret) : "r" (func), "r" (arg) : ^Silence by casting operands to 64 bits.
Signed-off-by Oliver Upton <[email protected]>--- tools/testing/selftests/kvm/steal_time.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)tools/testing/selftests/kvm/steal_time.c +0
-0tools/testing/selftests/kvm/steal_time.c static int64_t smccc(uint32_t func, uint32_t arg) · line 130
Quoted 5 lines
tools/testing/selftests/kvm/steal_time.c +1
-1@@ -127,7 +127,7 @@ static int64_t smccc(uint32_t func, uint32_t arg) "mov x1, %2\n" "hvc #0\n" "mov %0, x0\n" - : "=r" (ret) : "r" (func), "r" (arg) : + : "=r" (ret) : "r" ((uint64_t)func), "r" ((uint64_t)arg) :Actually, I think I'd rather fix this smccc implementation to match the spec, which I think should be done like this
tools/testing/selftests/kvm/steal_time.c +0
-1@@ -118,12 +118,12 @@ struct st_time {uint64_t st_time; }; -static int64_t smccc (uint32_t func,uint32_t arg)
tools/testing/selftests/kvm/steal_time.c struct st_time { · line 129
Quoted 10 lines
tools/testing/selftests/kvm/steal_time.c +2
-1+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"
Agreed, can you send out a patch? Thanks,
Paolo