KVM: selftests: Fix GUEST_PRINTF() format warnings in ARM code
Sean Christopherson
reviewerPATCH 1/1 KVM: selftests: Fix GUEST_PRINTF() format warnings in ARM code
Fix a pile of -Wformat warnings in the KVM ARM selftests code, almost all of which are benign "long" versus "long long" issues (selftests are 64-bit only, and the guest printf code treats "ll" the same as "l"). The code itself isn't problematic, but the warnings make it impossible to build ARM selftests with -Werror, which does detect real issues from time to time.
Opportunistically have GUEST_ASSERT_BITMAP_REG() interpret set_expected, which is a bool, as an unsigned decimal value, i.e. have it print '0' or '1' instead of '0x0' or '0x1'.
---
Compile tested only, mainly because I'm rushing through things on Friday afternoon, not because testing on ARM is actually problematic for me.
tools/testing/selftests/kvm/aarch64/arch_timer.c | 4 ++-- .../testing/selftests/kvm/aarch64/debug-exceptions.c | 2 +- tools/testing/selftests/kvm/aarch64/hypercalls.c | 4 ++-- .../testing/selftests/kvm/aarch64/page_fault_test.c | 2 +- .../selftests/kvm/aarch64/vpmu_counter_access.c | 12 ++++++------ 5 files changed, 12 insertions(+), 12 deletions(-)
tools/testing/selftests/kvm/aarch64/arch_timer.c +2 -2
@@ -158,9 +158,9 @@ static void guest_validate_irq(unsigned int intid,/* Basic 'timer condition met' check */ __GUEST_ASSERT (xcnt >= cval, -"xcnt = 0x%llx, cval = 0x%llx, xcnt_diff_us = 0x%llx" , +"xcnt = 0x%lx, cval = 0x%lx, xcnt_diff_us = 0x%lx" , xcnt, cval, xcnt_diff_us); -__GUEST_ASSERT (xctl &CTL_ISTATUS ,"xcnt = 0x%llx" , xcnt); +__GUEST_ASSERT (xctl &CTL_ISTATUS ,"xcnt = 0x%lx" , xcnt);WRITE_ONCE (shared_data->nr_iter, shared_data->nr_iter +1 ); }
tools/testing/selftests/kvm/aarch64/debug-exceptions.c +1 -1
@@ -365,7 +365,7 @@ static void guest_wp_handler(struct ex_regs *regs)static void guest_ss_handler (struct ex_regs *regs) { -__GUEST_ASSERT (ss_idx <4 ,"Expected index < 4, got '%u'" , ss_idx); +__GUEST_ASSERT (ss_idx <4 ,"Expected index < 4, got '%lu'" , ss_idx); ss_addr[ss_idx++] = regs->pc; regs->pstate |=SPSR_SS ; }
tools/testing/selftests/kvm/aarch64/hypercalls.c +2 -2
@@ -105,12 +105,12 @@ static void guest_test_hvc(const struct test_hvc_info *hc_info)case TEST_STAGE_HVC_IFACE_FEAT_DISABLED :case TEST_STAGE_HVC_IFACE_FALSE_INFO :__GUEST_ASSERT (res.a0 ==SMCCC_RET_NOT_SUPPORTED , -"a0 = 0x%lx, func_id = 0x%x, arg1 = 0x%llx, stage = %u" , +"a0 = 0x%lx, func_id = 0x%x, arg1 = 0x%lx, stage = %u" , res.a0, hc_info->func_id, hc_info->arg1, stage);break ;case TEST_STAGE_HVC_IFACE_FEAT_ENABLED :__GUEST_ASSERT (res.a0 !=SMCCC_RET_NOT_SUPPORTED , -"a0 = 0x%lx, func_id = 0x%x, arg1 = 0x%llx, stage = %u" , +"a0 = 0x%lx, func_id = 0x%x, arg1 = 0x%lx, stage = %u" , res.a0, hc_info->func_id, hc_info->arg1, stage);break ;default :
tools/testing/selftests/kvm/aarch64/page_fault_test.c +1 -1
@@ -292,7 +292,7 @@ static void guest_code(struct test_desc *test)static void no_dabt_handler (struct ex_regs *regs) { -GUEST_FAIL ("Unexpected dabt, far_el1 = 0x%llx" ,read_sysreg (far_el1)); +GUEST_FAIL ("Unexpected dabt, far_el1 = 0x%lx" ,read_sysreg (far_el1)); }static void no_iabt_handler (struct ex_regs *regs)
tools/testing/selftests/kvm/aarch64/vpmu_counter_access.c +6 -6
@@ -195,11 +195,11 @@ struct pmc_accessor pmc_accessors[] = { \if (set_expected) \__GUEST_ASSERT ((_tval & mask), \ -"tval: 0x%lx; mask: 0x%lx; set_expected: 0x%lx" , \ +"tval: 0x%lx; mask: 0x%lx; set_expected: %u" , \ _tval, mask, set_expected); \else \__GUEST_ASSERT (!(_tval & mask), \ -"tval: 0x%lx; mask: 0x%lx; set_expected: 0x%lx" , \ +"tval: 0x%lx; mask: 0x%lx; set_expected: %u" , \ _tval, mask, set_expected); \ }
@@ -286,7 +286,7 @@ static void test_access_pmc_regs(struct pmc_accessor *acc, int pmc_idx) acc->write_typer (pmc_idx, write_data); read_data = acc->read_typer (pmc_idx);__GUEST_ASSERT (read_data == write_data, -"pmc_idx: 0x%lx; acc_idx: 0x%lx; read_data: 0x%lx; write_data: 0x%lx" , +"pmc_idx: 0x%x; acc_idx: 0x%lx; read_data: 0x%lx; write_data: 0x%lx" , pmc_idx,PMC_ACC_TO_IDX (acc), read_data, write_data);/*
@@ -297,14 +297,14 @@ static void test_access_pmc_regs(struct pmc_accessor *acc, int pmc_idx)/* The count value must be 0, as it is disabled and reset */ __GUEST_ASSERT (read_data ==0 , -"pmc_idx: 0x%lx; acc_idx: 0x%lx; read_data: 0x%lx" , +"pmc_idx: 0x%x; acc_idx: 0x%lx; read_data: 0x%lx" , pmc_idx,PMC_ACC_TO_IDX (acc), read_data); write_data = read_data + pmc_idx +0x12345 ; acc->write_cntr (pmc_idx, write_data); read_data = acc->read_cntr (pmc_idx);__GUEST_ASSERT (read_data == write_data, -"pmc_idx: 0x%lx; acc_idx: 0x%lx; read_data: 0x%lx; write_data: 0x%lx" , +"pmc_idx: 0x%x; acc_idx: 0x%lx; read_data: 0x%lx; write_data: 0x%lx" , pmc_idx,PMC_ACC_TO_IDX (acc), read_data, write_data); }
@@ -379,7 +379,7 @@ static void guest_code(uint64_t expected_pmcr_n)int i, pmc;__GUEST_ASSERT (expected_pmcr_n <=ARMV8_PMU_MAX_GENERAL_COUNTERS , -"Expected PMCR.N: 0x%lx; ARMv8 general counters: 0x%lx" , +"Expected PMCR.N: 0x%lx; ARMv8 general counters: 0x%x" , expected_pmcr_n,ARMV8_PMU_MAX_GENERAL_COUNTERS ); pmcr =read_sysreg (pmcr_el0);
base-commit: 41bccc98fb7931d63d03f326a746ac4d429c1dd3
Signature · 1 line
2.43.0.594.gd9cf4e227d-goog
Quoted 11 lines · Sean Christopherson
Fix a pile of -Wformat warnings in the KVM ARM selftests code, almost all of which are benign "long" versus "long long" issues (selftests are 64-bit only, and the guest printf code treats "ll" the same as "l"). The code itself isn't problematic, but the warnings make it impossible to build ARM selftests with -Werror, which does detect real issues from time to time.
Opportunistically have
GUEST_ASSERT_BITMAP_REG()interpretset_expected, which is a bool, as an unsigned decimal value, i.e. have it print '0' or '1' instead of '0x0' or '0x1'.Signed-off-by Sean Christopherson <[email protected]>
This all looks good to me. Just want to confirm before applying: you're not planning any other patches that'll go through your tree that depend on this right?
Figured not since you sent it separately, but just want to be sure.
Signature · 2 lines
Thanks, Oliver
Sean Christopherson
reviewerQuoted 11 lines · Oliver Upton
Quoted 10 lines · Sean Christopherson
Fix a pile of -Wformat warnings in the KVM ARM selftests code, almost all of which are benign "long" versus "long long" issues (selftests are 64-bit only, and the guest printf code treats "ll" the same as "l"). The code itself isn't problematic, but the warnings make it impossible to build ARM selftests with -Werror, which does detect real issues from time to time.
Opportunistically have
GUEST_ASSERT_BITMAP_REG()interpretset_expected, which is a bool, as an unsigned decimal value, i.e. have it print '0' or '1' instead of '0x0' or '0x1'.
Quoted 5 lines
Quoted 1 line
Signed-off-by Sean Christopherson <[email protected]>This all looks good to me. Just want to confirm before applying: you're not planning any other patches that'll go through your tree that depend on this right?
Correct. There's one patch in kvm-x86/selftests (see below) that touches some of the same files, but unless I had a bad -ENOCOFFEE on Friday, there are no conflicts.
[2/5] KVM: selftests: aarch64: Remove redundant newlines
https://github.com/kvm-x86/linux/commit/95be17e4008b
Quoted 11 lines · Sean Christopherson
Fix a pile of -Wformat warnings in the KVM ARM selftests code, almost all of which are benign "long" versus "long long" issues (selftests are 64-bit only, and the guest printf code treats "ll" the same as "l"). The code itself isn't problematic, but the warnings make it impossible to build ARM selftests with -Werror, which does detect real issues from time to time.
Opportunistically have
GUEST_ASSERT_BITMAP_REG()interpretset_expected, which is a bool, as an unsigned decimal value, i.e. have it print '0' or '1' instead of '0x0' or '0x1'.Signed-off-by Sean Christopherson <[email protected]>
tools/testing/selftests/kvm/aarch64/arch_timer.c static void guest_validate_irq(unsigned int intid, · line 163
Quoted 13 lines
tools/testing/selftests/kvm/aarch64/arch_timer.c +2
-2@@ -158,9 +158,9 @@ static void guest_validate_irq(unsigned int intid,/* Basic 'timer condition met' check */ __GUEST_ASSERT (xcnt >= cval, -"xcnt = 0x%llx, cval = 0x%llx, xcnt_diff_us = 0x%llx" , +"xcnt = 0x%lx, cval = 0x%lx, xcnt_diff_us = 0x%lx" , xcnt, cval, xcnt_diff_us); -__GUEST_ASSERT (xctl &CTL_ISTATUS ,"xcnt = 0x%llx" , xcnt); +__GUEST_ASSERT (xctl &CTL_ISTATUS ,"xcnt = 0x%lx" , xcnt);
Unrelated to your patch, but it looks to me that we actually want to print 'xctl' instead of 'xcnt' in the second __GUEST_ASSERT().
Thanks,
Zenghui
+cc Anup
FYI -- this patch is touching the arch_timer code. I did a test merge with kvm_riscv_queue and there weren't any conflicts, but in case that changes this patch will appear on kvm-arm64/misc in my tree.
Signature · 2 lines
Thanks, Oliver
Quoted 11 lines · Sean Christopherson
Fix a pile of -Wformat warnings in the KVM ARM selftests code, almost all of which are benign "long" versus "long long" issues (selftests are 64-bit only, and the guest printf code treats "ll" the same as "l"). The code itself isn't problematic, but the warnings make it impossible to build ARM selftests with -Werror, which does detect real issues from time to time.
Opportunistically have
GUEST_ASSERT_BITMAP_REG()interpretset_expected, which is a bool, as an unsigned decimal value, i.e. have it print '0' or '1' instead of '0x0' or '0x1'.Signed-off-by Sean Christopherson <[email protected]>
Dammit, forgot to actually CC Anup. I'll blame jet lag.
Quoted 22 lines · Oliver Upton
+cc Anup
FYI -- this patch is touching the
arch_timercode. I did a test merge withkvm_riscv_queueand there weren't any conflicts, but in case that changes this patch will appear on kvm-arm64/misc in my tree.Signature · 2 lines
Thanks, OliverQuoted 11 lines · Sean Christopherson
Fix a pile of -Wformat warnings in the KVM ARM selftests code, almost all of which are benign "long" versus "long long" issues (selftests are 64-bit only, and the guest printf code treats "ll" the same as "l"). The code itself isn't problematic, but the warnings make it impossible to build ARM selftests with -Werror, which does detect real issues from time to time.
Opportunistically have
GUEST_ASSERT_BITMAP_REG()interpretset_expected, which is a bool, as an unsigned decimal value, i.e. have it print '0' or '1' instead of '0x0' or '0x1'.Signed-off-by Sean Christopherson <[email protected]>
Signature · 2 lines
Thanks, Oliver
Oliver Upton
AppliedQuoted 11 lines · Sean Christopherson
Fix a pile of -Wformat warnings in the KVM ARM selftests code, almost all of which are benign "long" versus "long long" issues (selftests are 64-bit only, and the guest printf code treats "ll" the same as "l"). The code itself isn't problematic, but the warnings make it impossible to build ARM selftests with -Werror, which does detect real issues from time to time.
Opportunistically have
GUEST_ASSERT_BITMAP_REG()interpretset_expected, which is a bool, as an unsigned decimal value, i.e. have it print '0' or '1' instead of '0x0' or '0x1'.[...]
Applied to kvmarm/next, thanks!
[1/1] KVM: selftests: Fix GUEST_PRINTF() format warnings in ARM code
https://git.kernel.org/kvmarm/kvmarm/c/06fdd894b473
--
Best,
Oliver