drivers/hv/hv_common.c:242 hv_kmsg_dump() error: uninitialized symbol 'bytes_written'.
Dan Carpenter
build botBCC: [email protected]
CC: [email protected]
CC: [email protected]
TO: Roman Kisel <[email protected]>
CC: Wei Liu <[email protected]>
CC: Michael Kelley <[email protected]>
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master head: ea1013c1539270e372fc99854bc6e4d94eaeff66 commit: f41ceff1748612b9e1538becc13dc2f1617d9d14 Drivers: hv: Enable VTL mode for arm64 date: 7 months ago
:::::: branch date: 9 hours ago
:::::: commit date: 7 months ago
config: arm64-randconfig-r072-20251216 (https://download.01.org/0day-ci/archive/20251217/[email protected]/config)
compiler: clang version 22.0.0git (https://github.com/llvm/llvm-project 1335a05ab8bc8339ce24be3a9da89d8c3f4e0571)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]> | Reported-by: Dan Carpenter <[email protected]> | Closes: https://lore.kernel.org/r/[email protected]/
smatch warnings:drivers/hv/hv_common.c:242 hv_kmsg_dump() error: uninitialized symbol 'bytes_written'.
vim +/bytes_written +242 drivers/hv/hv_common.c
9c318a1d9b5000 Long Li 2023-04-20 220
9c318a1d9b5000 Long Li 2023-04-20 221 /*
9c318a1d9b5000 Long Li 2023-04-20 222 * Callback from kmsg_dump. Grab as much as possible from the end of the kmsg
9c318a1d9b5000 Long Li 2023-04-20 223 * buffer and call into Hyper-V to transfer the data.
9c318a1d9b5000 Long Li 2023-04-20 224 */
9c318a1d9b5000 Long Li 2023-04-20 225 static void hv_kmsg_dump(struct kmsg_dumper *dumper,
e1a261ba599eec Jocelyn Falempe 2024-07-02 226 struct kmsg_dump_detail *detail)
9c318a1d9b5000 Long Li 2023-04-20 227 {
9c318a1d9b5000 Long Li 2023-04-20 228 struct kmsg_dump_iter iter;
9c318a1d9b5000 Long Li 2023-04-20 229 size_t bytes_written;
9c318a1d9b5000 Long Li 2023-04-20 230
9c318a1d9b5000 Long Li 2023-04-20 231 /* We are only interested in panics. */
e1a261ba599eec Jocelyn Falempe 2024-07-02 232 if (detail->reason != KMSG_DUMP_PANIC || !sysctl_record_panic_msg)
9c318a1d9b5000 Long Li 2023-04-20 233 return;
9c318a1d9b5000 Long Li 2023-04-20 234
9c318a1d9b5000 Long Li 2023-04-20 235 /*
9c318a1d9b5000 Long Li 2023-04-20 236 * Write dump contents to the page. No need to synchronize; panic should
9c318a1d9b5000 Long Li 2023-04-20 237 * be single-threaded.
9c318a1d9b5000 Long Li 2023-04-20 238 */
9c318a1d9b5000 Long Li 2023-04-20 239 kmsg_dump_rewind(&iter);
9c318a1d9b5000 Long Li 2023-04-20 240 kmsg_dump_get_buffer(&iter, false, hv_panic_page, HV_HYP_PAGE_SIZE,
9c318a1d9b5000 Long Li 2023-04-20 241 &bytes_written);
9c318a1d9b5000 Long Li 2023-04-20 @242 if (!bytes_written)
9c318a1d9b5000 Long Li 2023-04-20 243 return;
9c318a1d9b5000 Long Li 2023-04-20 244 /*
9c318a1d9b5000 Long Li 2023-04-20 245 * P3 to contain the physical address of the panic page & P4 to
9c318a1d9b5000 Long Li 2023-04-20 246 * contain the size of the panic data in that page. Rest of the
9c318a1d9b5000 Long Li 2023-04-20 247 * registers are no-op when the NOTIFY_MSG flag is set.
9c318a1d9b5000 Long Li 2023-04-20 248 */
0e3f7d120086c8 Nuno Das Neves 2024-02-20 249 hv_set_msr(HV_MSR_CRASH_P0, 0);
0e3f7d120086c8 Nuno Das Neves 2024-02-20 250 hv_set_msr(HV_MSR_CRASH_P1, 0);
0e3f7d120086c8 Nuno Das Neves 2024-02-20 251 hv_set_msr(HV_MSR_CRASH_P2, 0);
0e3f7d120086c8 Nuno Das Neves 2024-02-20 252 hv_set_msr(HV_MSR_CRASH_P3, virt_to_phys(hv_panic_page));
0e3f7d120086c8 Nuno Das Neves 2024-02-20 253 hv_set_msr(HV_MSR_CRASH_P4, bytes_written);
9c318a1d9b5000 Long Li 2023-04-20 254
9c318a1d9b5000 Long Li 2023-04-20 255 /*
9c318a1d9b5000 Long Li 2023-04-20 256 * Let Hyper-V know there is crash data available along with
9c318a1d9b5000 Long Li 2023-04-20 257 * the panic message.
9c318a1d9b5000 Long Li 2023-04-20 258 */
0e3f7d120086c8 Nuno Das Neves 2024-02-20 259 hv_set_msr(HV_MSR_CRASH_CTL,
9c318a1d9b5000 Long Li 2023-04-20 260 (HV_CRASH_CTL_CRASH_NOTIFY |
9c318a1d9b5000 Long Li 2023-04-20 261 HV_CRASH_CTL_CRASH_NOTIFY_MSG));
9c318a1d9b5000 Long Li 2023-04-20 262 }
9c318a1d9b5000 Long Li 2023-04-20 263 :::::: The code at line 242 was first introduced by commit
:::::: 9c318a1d9b5000c77527011f158a75c5483510f5 Drivers: hv: move panic report code from vmbus to hv early init code
:::::: TO: Long Li <[email protected]>
:::::: CC: Wei Liu <[email protected]>
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
From: Dan Carpenter <[email protected]> Sent: Wednesday, December 17, 2025 5:24 AM
Quoted 1 line
I'll submit a patch to fix this.
Michael
Quoted 68 lines
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:ea1013c1539270e372fc99854bc6e4d94eaeff66
commit:f41ceff1748612b9e1538becc13dc2f1617d9d14Drivers: hv: Enable VTL mode
for arm64
date: 7 months ago
config: arm64-randconfig-r072-20251216 (https://download.01.org/0day-ci/archive/20251217/[email protected]/config)
compiler: clang version 22.0.0git (https://github.com/llvm/llvm-project1335a05ab8bc8339ce24be3a9da89d8c3f4e0571)If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]> | Reported-by: Dan Carpenter <[email protected]> | Closes: https://lore.kernel.org/r/[email protected]/smatch warnings:
drivers/hv/hv_common.c:242hv_kmsg_dump()error: uninitialized symbol 'bytes_written'.vim +/bytes_written +242
drivers/hv/hv_common.c9c318a1d9b5000 Long Li 2023-04-20 225 static void hv_kmsg_dump(struct kmsg_dumper *dumper, e1a261ba599eec Jocelyn Falempe 2024-07-02 226 struct kmsg_dump_detail *detail) 9c318a1d9b5000 Long Li 2023-04-20 227 { 9c318a1d9b5000 Long Li 2023-04-20 228 struct kmsg_dump_iter iter; 9c318a1d9b5000 Long Li 2023-04-20 229 size_t bytes_written; 9c318a1d9b5000 Long Li 2023-04-20 230 9c318a1d9b5000 Long Li 2023-04-20 231 /* We are only interested in panics. */ e1a261ba599eec Jocelyn Falempe 2024-07-02 232 if (detail->reason != KMSG_DUMP_PANIC || !sysctl_record_panic_msg) 9c318a1d9b5000 Long Li 2023-04-20 233 return; 9c318a1d9b5000 Long Li 2023-04-20 234 9c318a1d9b5000 Long Li 2023-04-20 235 /* 9c318a1d9b5000 Long Li 2023-04-20 236 * Write dump contents to the page. No need to synchronize; panic should 9c318a1d9b5000 Long Li 2023-04-20 237 * be single-threaded. 9c318a1d9b5000 Long Li 2023-04-20 238 */ 9c318a1d9b5000 Long Li 2023-04-20 239 kmsg_dump_rewind(&iter); 9c318a1d9b5000 Long Li 2023-04-20 240 kmsg_dump_get_buffer(&iter, false, hv_panic_page, HV_HYP_PAGE_SIZE, 9c318a1d9b5000 Long Li 2023-04-20 241 &bytes_written);
kmsg_dump_get_buffer()is a no-op ifCONFIG_PRINTKis disabled.
9c318a1d9b5000Long Li 2023-04-20 @242 if (!bytes_written)^^^^^^^^^^^^^^uninitialized.
9c318a1d9b5000 Long Li 2023-04-20 243 return; 9c318a1d9b5000 Long Li 2023-04-20 244 /* 9c318a1d9b5000 Long Li 2023-04-20 245 * P3 to contain the physical address of the panic page & P4 to 9c318a1d9b5000 Long Li 2023-04-20 246 * contain the size of the panic data in that page. Rest of the 9c318a1d9b5000 Long Li 2023-04-20 247 * registers are no-op when the NOTIFY_MSG flag is set. 9c318a1d9b5000 Long Li 2023-04-20 248 */ 0e3f7d120086c8 Nuno Das Neves 2024-02-20 249 hv_set_msr(HV_MSR_CRASH_P0, 0); 0e3f7d120086c8 Nuno Das Neves 2024-02-20 250 hv_set_msr(HV_MSR_CRASH_P1, 0); 0e3f7d120086c8 Nuno Das Neves 2024-02-20 251 hv_set_msr(HV_MSR_CRASH_P2, 0); 0e3f7d120086c8 Nuno Das Neves 2024-02-20 252 hv_set_msr(HV_MSR_CRASH_P3, virt_to_phys(hv_panic_page)); 0e3f7d120086c8 Nuno Das Neves 2024-02-20 253 hv_set_msr(HV_MSR_CRASH_P4, bytes_written); 9c318a1d9b5000 Long Li 2023-04-20 254 9c318a1d9b5000 Long Li 2023-04-20 255 /* 9c318a1d9b5000 Long Li 2023-04-20 256 * Let Hyper-V know there is crash data available along with 9c318a1d9b5000 Long Li 2023-04-20 257 * the panic message. 9c318a1d9b5000 Long Li 2023-04-20 258 */ 0e3f7d120086c8 Nuno Das Neves 2024-02-20 259 hv_set_msr(HV_MSR_CRASH_CTL, 9c318a1d9b5000 Long Li 2023-04-20 260 (HV_CRASH_CTL_CRASH_NOTIFY | 9c318a1d9b5000 Long Li 2023-04-20 261 HV_CRASH_CTL_CRASH_NOTIFY_MSG)); 9c318a1d9b5000 Long Li 2023-04-20 262 }--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki