mirror of
https://git.proxmox.com/git/mirror_ubuntu-kernels.git
synced 2026-01-05 03:52:51 +00:00
Directly compare the expected versus observed hypercall instructions when
verifying that KVM patched in the native hypercall (FIX_HYPERCALL_INSN
quirk enabled). gcc rightly complains that doing a 4-byte memcpy() with
an "unsigned char" as the source generates an out-of-bounds accesses.
Alternatively, "exp" and "obs" could be declared as 3-byte arrays, but
there's no known reason to copy locally instead of comparing directly.
In function ‘assert_hypercall_insn’,
inlined from ‘guest_main’ at x86_64/fix_hypercall_test.c:91:2:
x86_64/fix_hypercall_test.c:63:9: error: array subscript ‘unsigned int[0]’
is partly outside array bounds of ‘unsigned char[1]’ [-Werror=array-bounds]
63 | memcpy(&exp, exp_insn, sizeof(exp));
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
x86_64/fix_hypercall_test.c: In function ‘guest_main’:
x86_64/fix_hypercall_test.c:42:22: note: object ‘vmx_hypercall_insn’ of size 1
42 | extern unsigned char vmx_hypercall_insn;
| ^~~~~~~~~~~~~~~~~~
x86_64/fix_hypercall_test.c:25:22: note: object ‘svm_hypercall_insn’ of size 1
25 | extern unsigned char svm_hypercall_insn;
| ^~~~~~~~~~~~~~~~~~
In function ‘assert_hypercall_insn’,
inlined from ‘guest_main’ at x86_64/fix_hypercall_test.c:91:2:
x86_64/fix_hypercall_test.c:64:9: error: array subscript ‘unsigned int[0]’
is partly outside array bounds of ‘unsigned char[1]’ [-Werror=array-bounds]
64 | memcpy(&obs, obs_insn, sizeof(obs));
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
x86_64/fix_hypercall_test.c: In function ‘guest_main’:
x86_64/fix_hypercall_test.c:25:22: note: object ‘svm_hypercall_insn’ of size 1
25 | extern unsigned char svm_hypercall_insn;
| ^~~~~~~~~~~~~~~~~~
x86_64/fix_hypercall_test.c:42:22: note: object ‘vmx_hypercall_insn’ of size 1
42 | extern unsigned char vmx_hypercall_insn;
| ^~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
make: *** [../lib.mk:135: tools/testing/selftests/kvm/x86_64/fix_hypercall_test] Error 1
Fixes:
|
||
|---|---|---|
| .. | ||
| amx_test.c | ||
| cpuid_test.c | ||
| cr4_cpuid_sync_test.c | ||
| debug_regs.c | ||
| emulator_error_test.c | ||
| evmcs_test.c | ||
| fix_hypercall_test.c | ||
| get_msr_index_features.c | ||
| hyperv_clock.c | ||
| hyperv_cpuid.c | ||
| hyperv_features.c | ||
| hyperv_svm_test.c | ||
| kvm_clock_test.c | ||
| kvm_pv_test.c | ||
| max_vcpuid_cap_test.c | ||
| mmio_warning_test.c | ||
| monitor_mwait_test.c | ||
| nx_huge_pages_test.c | ||
| nx_huge_pages_test.sh | ||
| platform_info_test.c | ||
| pmu_event_filter_test.c | ||
| set_boot_cpu_id.c | ||
| set_sregs_test.c | ||
| sev_migrate_tests.c | ||
| smm_test.c | ||
| state_test.c | ||
| svm_int_ctl_test.c | ||
| svm_nested_soft_inject_test.c | ||
| svm_vmcall_test.c | ||
| sync_regs_test.c | ||
| triple_fault_event_test.c | ||
| tsc_msrs_test.c | ||
| tsc_scaling_sync.c | ||
| ucna_injection_test.c | ||
| userspace_io_test.c | ||
| userspace_msr_exit_test.c | ||
| vmx_apic_access_test.c | ||
| vmx_close_while_nested_test.c | ||
| vmx_dirty_log_test.c | ||
| vmx_exception_with_invalid_guest_state.c | ||
| vmx_invalid_nested_guest_state.c | ||
| vmx_msrs_test.c | ||
| vmx_nested_tsc_scaling_test.c | ||
| vmx_pmu_caps_test.c | ||
| vmx_preemption_timer_test.c | ||
| vmx_set_nested_state_test.c | ||
| vmx_tsc_adjust_test.c | ||
| xapic_ipi_test.c | ||
| xapic_state_test.c | ||
| xen_shinfo_test.c | ||
| xen_vmcall_test.c | ||
| xss_msr_test.c | ||