[acrn:4.19/lts 4/85] drivers/acrn/acrn_hvlog.c:324:20: error: comparison is always true due to limited range of data type

From: kernel test robot
Date: Mon Aug 09 2021 - 02:03:13 EST


tree: https://github.com/projectacrn/acrn-kernel 4.19/lts
head: 8abec6c5ebdace7220ecfa35b317c76f62e29c31
commit: 7b2bb5a7bdf187b11d915fc6e03cd619f5420ce9 [4/85] acrn/vhm/Kconfig: Remove the limitation that acrn can't work with VMAP_STACK
config: x86_64-allyesconfig (attached as .config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0
reproduce (this is a W=1 build):
# https://github.com/projectacrn/acrn-kernel/commit/7b2bb5a7bdf187b11d915fc6e03cd619f5420ce9
git remote add acrn https://github.com/projectacrn/acrn-kernel
git fetch --no-tags acrn 4.19/lts
git checkout 7b2bb5a7bdf187b11d915fc6e03cd619f5420ce9
# save the attached .config to linux build tree
make W=1 ARCH=x86_64

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

All errors (new ones prefixed by >>):

drivers/acrn/acrn_hvlog.c: In function 'init_hvlog_dev':
>> drivers/acrn/acrn_hvlog.c:324:20: error: comparison is always true due to limited range of data type [-Werror=type-limits]
324 | for (i = --idx; i >= 0; i--)
| ^~
cc1: all warnings being treated as errors
--
drivers/char/vhm/vhm_dev.c: In function 'vhm_dev_ioctl':
drivers/char/vhm/vhm_dev.c:222:22: error: comparison is always false due to limited range of data type [-Werror=type-limits]
222 | (created_vm->vmid == ACRN_INVALID_VMID)) {
| ^~
drivers/char/vhm/vhm_dev.c: In function 'vhm_init':
>> drivers/char/vhm/vhm_dev.c:853:29: error: comparison of unsigned expression >= 0 is always true [-Werror=type-limits]
853 | api_version.minor_version >= SUPPORT_HV_API_VERSION_MINOR) {
| ^~
cc1: all warnings being treated as errors
--
drivers/vhm/vhm_ioreq.c: In function 'acrn_ioreq_driver_init':
>> drivers/vhm/vhm_ioreq.c:1068:6: error: old-style function definition [-Werror=old-style-definition]
1068 | void acrn_ioreq_driver_init()
| ^~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors


vim +324 drivers/acrn/acrn_hvlog.c

3180a3e35e863c Li, Fei1 2018-08-31 266
ea8f7911fecb2f Kaige Fu 2018-12-12 267 static int init_hvlog_dev(uint64_t base, uint32_t hvlog_type)
3180a3e35e863c Li, Fei1 2018-08-31 268 {
ea8f7911fecb2f Kaige Fu 2018-12-12 269 int err = 0;
ea8f7911fecb2f Kaige Fu 2018-12-12 270 uint16_t idx, i;
ea8f7911fecb2f Kaige Fu 2018-12-12 271 shared_buf_t *sbuf;
ea8f7911fecb2f Kaige Fu 2018-12-12 272 struct acrn_hvlog *hvlog;
ea8f7911fecb2f Kaige Fu 2018-12-12 273 uint32_t ele_size, ele_num, size;
50086cb4071235 Fu YanX 2019-05-13 274 uint64_t offset;
3180a3e35e863c Li, Fei1 2018-08-31 275
ea8f7911fecb2f Kaige Fu 2018-12-12 276 if (!base)
ea8f7911fecb2f Kaige Fu 2018-12-12 277 return -ENODEV;
ea8f7911fecb2f Kaige Fu 2018-12-12 278
ea8f7911fecb2f Kaige Fu 2018-12-12 279 size = (hvlog_buf_size >> 1) / pcpu_nr;
ea8f7911fecb2f Kaige Fu 2018-12-12 280 ele_size = LOG_ENTRY_SIZE;
ea8f7911fecb2f Kaige Fu 2018-12-12 281 ele_num = (size - SBUF_HEAD_SIZE) / ele_size;
3180a3e35e863c Li, Fei1 2018-08-31 282
ea8f7911fecb2f Kaige Fu 2018-12-12 283 foreach_cpu(idx, pcpu_nr) {
ea8f7911fecb2f Kaige Fu 2018-12-12 284 hvlog = &acrn_hvlog_devs[hvlog_type][idx];
ea8f7911fecb2f Kaige Fu 2018-12-12 285
ea8f7911fecb2f Kaige Fu 2018-12-12 286 switch (hvlog_type) {
ea8f7911fecb2f Kaige Fu 2018-12-12 287 case SBUF_CUR_HVLOG:
ea8f7911fecb2f Kaige Fu 2018-12-12 288 snprintf(hvlog->name, sizeof(hvlog->name),
ea8f7911fecb2f Kaige Fu 2018-12-12 289 "acrn_hvlog_cur_%hu", idx);
50086cb4071235 Fu YanX 2019-05-13 290 offset = (base + (size * idx)) - hvlog_buf_phyaddr_base;
50086cb4071235 Fu YanX 2019-05-13 291 sbuf = hvlog_buf_virtaddr_base + offset;
50086cb4071235 Fu YanX 2019-05-13 292 sbuf = sbuf_construct(ele_num, ele_size, sbuf);
50086cb4071235 Fu YanX 2019-05-13 293 sbuf_share_setup(idx, ACRN_HVLOG, base + (size * idx));
ea8f7911fecb2f Kaige Fu 2018-12-12 294 break;
ea8f7911fecb2f Kaige Fu 2018-12-12 295 case SBUF_LAST_HVLOG:
ea8f7911fecb2f Kaige Fu 2018-12-12 296 snprintf(hvlog->name, sizeof(hvlog->name),
ea8f7911fecb2f Kaige Fu 2018-12-12 297 "acrn_hvlog_last_%hu", idx);
50086cb4071235 Fu YanX 2019-05-13 298 offset = (base + (size * idx)) - hvlog_buf_phyaddr_base;
50086cb4071235 Fu YanX 2019-05-13 299 sbuf = hvlog_buf_virtaddr_base + offset;
50086cb4071235 Fu YanX 2019-05-13 300 sbuf = sbuf_check_valid(ele_num, ele_size, sbuf);
ea8f7911fecb2f Kaige Fu 2018-12-12 301 hvlog_mark_unread(sbuf);
ea8f7911fecb2f Kaige Fu 2018-12-12 302 break;
ea8f7911fecb2f Kaige Fu 2018-12-12 303 default:
ea8f7911fecb2f Kaige Fu 2018-12-12 304 return -EINVAL;
ea8f7911fecb2f Kaige Fu 2018-12-12 305 }
ea8f7911fecb2f Kaige Fu 2018-12-12 306
ea8f7911fecb2f Kaige Fu 2018-12-12 307 hvlog->miscdev.name = hvlog->name;
ea8f7911fecb2f Kaige Fu 2018-12-12 308 hvlog->miscdev.minor = MISC_DYNAMIC_MINOR;
ea8f7911fecb2f Kaige Fu 2018-12-12 309 hvlog->miscdev.fops = &acrn_hvlog_fops;
ea8f7911fecb2f Kaige Fu 2018-12-12 310 hvlog->pcpu_num = idx;
ea8f7911fecb2f Kaige Fu 2018-12-12 311 hvlog->sbuf = sbuf;
ea8f7911fecb2f Kaige Fu 2018-12-12 312
ea8f7911fecb2f Kaige Fu 2018-12-12 313 err = misc_register(&(hvlog->miscdev));
ea8f7911fecb2f Kaige Fu 2018-12-12 314 if (err < 0) {
3180a3e35e863c Li, Fei1 2018-08-31 315 pr_err("Failed to register %s, errno %d\n",
ea8f7911fecb2f Kaige Fu 2018-12-12 316 hvlog->name, err);
ea8f7911fecb2f Kaige Fu 2018-12-12 317 goto err_reg;
3180a3e35e863c Li, Fei1 2018-08-31 318 }
3180a3e35e863c Li, Fei1 2018-08-31 319 }
3180a3e35e863c Li, Fei1 2018-08-31 320
3180a3e35e863c Li, Fei1 2018-08-31 321 return 0;
3180a3e35e863c Li, Fei1 2018-08-31 322
ea8f7911fecb2f Kaige Fu 2018-12-12 323 err_reg:
ea8f7911fecb2f Kaige Fu 2018-12-12 @324 for (i = --idx; i >= 0; i--)
ea8f7911fecb2f Kaige Fu 2018-12-12 325 misc_deregister(&acrn_hvlog_devs[hvlog_type][i].miscdev);
3180a3e35e863c Li, Fei1 2018-08-31 326
ea8f7911fecb2f Kaige Fu 2018-12-12 327 return err;
3180a3e35e863c Li, Fei1 2018-08-31 328 }
3180a3e35e863c Li, Fei1 2018-08-31 329

:::::: The code at line 324 was first introduced by commit
:::::: ea8f7911fecb2fda9cf183bdb45f2326fb817fdc HVLog: Refine acrn_hvlog to remove the limitation on fixed CPU number

:::::: TO: Kaige Fu <kaige.fu@xxxxxxxxx>
:::::: CC: Nikunj A. Dadhania <nikunj.dadhania@xxxxxxxxx>

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

Attachment: .config.gz
Description: application/gzip