Re: [PATCH v2 9/9] KVM: arm64: Add UBSan tests for PKVM.

From: kernel test robot
Date: Fri Jan 15 2021 - 09:32:36 EST


Hi Elena,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on arm64/for-next/core]
[cannot apply to kvmarm/next soc/for-next arm/for-next xlnx/master v5.11-rc3 next-20210115]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url: https://github.com/0day-ci/linux/commits/Elena-Petrova/UBSan-Enablement-for-hyp-nVHE-code/20210115-112509
base: https://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-next/core
config: arm64-allyesconfig (attached as .config)
compiler: aarch64-linux-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/cd5e5083db55d9959f564a72bc348d83425a2838
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Elena-Petrova/UBSan-Enablement-for-hyp-nVHE-code/20210115-112509
git checkout cd5e5083db55d9959f564a72bc348d83425a2838
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=arm64

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@xxxxxxxxx>

All warnings (new ones prefixed by >>):

In file included from arch/arm64/kvm/kvm_ubsan_buffer.c:12:
include/kvm/arm_pmu.h:52:15: warning: 'struct kvm_device_attr' declared inside parameter list will not be visible outside of this definition or declaration
52 | struct kvm_device_attr *attr);
| ^~~~~~~~~~~~~~~
include/kvm/arm_pmu.h:54:15: warning: 'struct kvm_device_attr' declared inside parameter list will not be visible outside of this definition or declaration
54 | struct kvm_device_attr *attr);
| ^~~~~~~~~~~~~~~
include/kvm/arm_pmu.h:56:15: warning: 'struct kvm_device_attr' declared inside parameter list will not be visible outside of this definition or declaration
56 | struct kvm_device_attr *attr);
| ^~~~~~~~~~~~~~~
arch/arm64/kvm/kvm_ubsan_buffer.c:19:6: warning: no previous prototype for '__kvm_check_ubsan_data' [-Wmissing-prototypes]
19 | void __kvm_check_ubsan_data(struct kvm_ubsan_info *slot)
| ^~~~~~~~~~~~~~~~~~~~~~
arch/arm64/kvm/kvm_ubsan_buffer.c: In function '__kvm_check_ubsan_data':
>> arch/arm64/kvm/kvm_ubsan_buffer.c:21:2: warning: enumeration value 'UBSAN_NONE' not handled in switch [-Wswitch]
21 | switch (slot->type) {
| ^~~~~~
arch/arm64/kvm/kvm_ubsan_buffer.c: At top level:
arch/arm64/kvm/kvm_ubsan_buffer.c:62:6: warning: no previous prototype for 'iterate_kvm_ubsan_buffer' [-Wmissing-prototypes]
62 | void iterate_kvm_ubsan_buffer(unsigned long left, unsigned long right)
| ^~~~~~~~~~~~~~~~~~~~~~~~
arch/arm64/kvm/kvm_ubsan_buffer.c:75:6: warning: no previous prototype for '__kvm_check_ubsan_buffer' [-Wmissing-prototypes]
75 | void __kvm_check_ubsan_buffer(void)
| ^~~~~~~~~~~~~~~~~~~~~~~~
--
In file included from arch/arm64/kvm/hyp/nvhe/hyp-main.c:16:
arch/arm64/kvm/hyp/include/hyp/test_ubsan.h: In function 'test_ubsan_out_of_bounds':
>> arch/arm64/kvm/hyp/include/hyp/test_ubsan.h:55:15: warning: variable 'arr' set but not used [-Wunused-but-set-variable]
55 | volatile int arr[4];
| ^~~
arch/arm64/kvm/hyp/include/hyp/test_ubsan.h: In function 'test_ubsan_load_invalid_value':
>> arch/arm64/kvm/hyp/include/hyp/test_ubsan.h:63:19: warning: variable 'ptr' set but not used [-Wunused-but-set-variable]
63 | bool val, val2, *ptr;
| ^~~
arch/arm64/kvm/hyp/include/hyp/test_ubsan.h: In function 'test_ubsan_object_size_mismatch':
>> arch/arm64/kvm/hyp/include/hyp/test_ubsan.h:87:27: warning: variable 'val2' set but not used [-Wunused-but-set-variable]
87 | volatile long long *ptr, val2;
| ^~~~
arch/arm64/kvm/hyp/nvhe/hyp-main.c: At top level:
arch/arm64/kvm/hyp/nvhe/hyp-main.c:183:6: warning: no previous prototype for 'handle_trap' [-Wmissing-prototypes]
183 | void handle_trap(struct kvm_cpu_context *host_ctxt)
| ^~~~~~~~~~~


vim +/UBSAN_NONE +21 arch/arm64/kvm/kvm_ubsan_buffer.c

aba3219bbab3bb5c George Popescu 2021-01-14 15
aba3219bbab3bb5c George Popescu 2021-01-14 16 DECLARE_KVM_DEBUG_BUFFER(struct kvm_ubsan_info, kvm_ubsan_buffer,
aba3219bbab3bb5c George Popescu 2021-01-14 17 kvm_ubsan_buff_wr_ind, KVM_UBSAN_BUFFER_SIZE);
aba3219bbab3bb5c George Popescu 2021-01-14 18
c8a90dc1d55ba5e3 George Popescu 2021-01-14 19 void __kvm_check_ubsan_data(struct kvm_ubsan_info *slot)
c8a90dc1d55ba5e3 George Popescu 2021-01-14 20 {
c8a90dc1d55ba5e3 George Popescu 2021-01-14 @21 switch (slot->type) {
c8a90dc1d55ba5e3 George Popescu 2021-01-14 22 case UBSAN_OUT_OF_BOUNDS:
c8a90dc1d55ba5e3 George Popescu 2021-01-14 23 __ubsan_handle_out_of_bounds(&slot->out_of_bounds_data,
c8a90dc1d55ba5e3 George Popescu 2021-01-14 24 slot->u_val.lval);
c8a90dc1d55ba5e3 George Popescu 2021-01-14 25 break;
125f434abd282604 George Popescu 2021-01-14 26 case UBSAN_UNREACHABLE_DATA:
125f434abd282604 George Popescu 2021-01-14 27 __ubsan_handle_builtin_unreachable(&slot->unreachable_data);
125f434abd282604 George Popescu 2021-01-14 28 break;
3bd940afa9486b82 George Popescu 2021-01-14 29 case UBSAN_SHIFT_OUT_OF_BOUNDS:
3bd940afa9486b82 George Popescu 2021-01-14 30 __ubsan_handle_shift_out_of_bounds(&slot->shift_out_of_bounds_data,
3bd940afa9486b82 George Popescu 2021-01-14 31 slot->u_val.lval, slot->u_val.rval);
3bd940afa9486b82 George Popescu 2021-01-14 32 break;
3b42f0d25b7dd280 George Popescu 2021-01-14 33 case UBSAN_INVALID_DATA:
3b42f0d25b7dd280 George Popescu 2021-01-14 34 __ubsan_handle_load_invalid_value(&slot->invalid_value_data,
3b42f0d25b7dd280 George Popescu 2021-01-14 35 slot->u_val.lval);
3b42f0d25b7dd280 George Popescu 2021-01-14 36 break;
e7832e63ca596782 George Popescu 2021-01-14 37 case UBSAN_TYPE_MISMATCH:
e7832e63ca596782 George Popescu 2021-01-14 38 __ubsan_handle_type_mismatch(&slot->type_mismatch_data,
e7832e63ca596782 George Popescu 2021-01-14 39 slot->u_val.lval);
e7832e63ca596782 George Popescu 2021-01-14 40 break;
aaa9326468ea971e George Popescu 2021-01-14 41 case UBSAN_OVERFLOW_DATA:
aaa9326468ea971e George Popescu 2021-01-14 42 if (slot->u_val.op == '/') {
aaa9326468ea971e George Popescu 2021-01-14 43 __ubsan_handle_divrem_overflow(&slot->overflow_data,
aaa9326468ea971e George Popescu 2021-01-14 44 slot->u_val.lval, slot->u_val.rval);
aaa9326468ea971e George Popescu 2021-01-14 45 } else if (slot->u_val.op == '!') {
aaa9326468ea971e George Popescu 2021-01-14 46 __ubsan_handle_negate_overflow(&slot->overflow_data,
aaa9326468ea971e George Popescu 2021-01-14 47 slot->u_val.lval);
aaa9326468ea971e George Popescu 2021-01-14 48 } else if (slot->u_val.op == '+') {
aaa9326468ea971e George Popescu 2021-01-14 49 __ubsan_handle_add_overflow(&slot->overflow_data,
aaa9326468ea971e George Popescu 2021-01-14 50 slot->u_val.lval, slot->u_val.rval);
aaa9326468ea971e George Popescu 2021-01-14 51 } else if (slot->u_val.op == '-') {
aaa9326468ea971e George Popescu 2021-01-14 52 __ubsan_handle_sub_overflow(&slot->overflow_data,
aaa9326468ea971e George Popescu 2021-01-14 53 slot->u_val.lval, slot->u_val.rval);
aaa9326468ea971e George Popescu 2021-01-14 54 } else if (slot->u_val.op == '*') {
aaa9326468ea971e George Popescu 2021-01-14 55 __ubsan_handle_mul_overflow(&slot->overflow_data,
aaa9326468ea971e George Popescu 2021-01-14 56 slot->u_val.lval, slot->u_val.rval);
aaa9326468ea971e George Popescu 2021-01-14 57 }
aaa9326468ea971e George Popescu 2021-01-14 58 break;
c8a90dc1d55ba5e3 George Popescu 2021-01-14 59 }
c8a90dc1d55ba5e3 George Popescu 2021-01-14 60 }
aba3219bbab3bb5c George Popescu 2021-01-14 61

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@xxxxxxxxxxxx

Attachment: .config.gz
Description: application/gzip