x86/hyperv: Add Write/Read MSR registers via ghcb page
Subsystems (2)
Hello Tianyu Lan,
The patch faff44069ff5: "x86/hyperv: Add Write/Read MSR registers via ghcb page" from Oct 25, 2021, leads to the following Smatch static checker warning:
arch/x86/kernel/cpu/mshyperv.c:73 hv_get_non_nested_register() error: uninitialized symbol 'value'.
arch/x86/kernel/cpu/mshyperv.c
63
64 #if IS_ENABLED(CONFIG_HYPERV)
65 u64 hv_get_non_nested_register(unsigned int reg)
66 {
67 u64 value;
68
69 if (hv_is_synic_reg(reg) && hv_isolation_type_snp())
70 hv_ghcb_msr_read(reg, &value);
^^^^^^There are three places in hv_ghcb_msr_read() which don't initialize value.
71 else
72 rdmsrl(reg, value);
--> 73 return value;
74 }regards,
dan carpenter
Does making 0 as the default value makes sense?
Regards,
Jinank
Quoted 29 lines · Dan Carpenter
Hello Tianyu Lan,
The patch
faff44069ff5: "x86/hyperv: Add Write/Read MSR registers via ghcb page" from Oct 25, 2021, leads to the following Smatch static checker warning:arch/x86/kernel/cpu/mshyperv.c:73 hv_get_non_nested_register() error: uninitialized symbol 'value'.
arch/x86/kernel/cpu/mshyperv.c63 64 #if IS_ENABLED(CONFIG_HYPERV) 65 u64 hv_get_non_nested_register(unsigned int reg) 66 { 67 u64 value; 68 69 if (hv_is_synic_reg(reg) && hv_isolation_type_snp()) 70 hv_ghcb_msr_read(reg, &value); ^^^^^^There are three places in
hv_ghcb_msr_read()which don't initialize value.71 else 72 rdmsrl(reg, value); --> 73 return value; 74 }regards,
dan carpenter
Quoted 2 lines · Jinank Jain
Does making 0 as the default value makes sense?
That would silence the warning, and most distros are going to enable the config to zero it out anyway so it has no impact on runtime.
regards,
dan carpenter
Quoted 6 lines · Dan Carpenter
Quoted 2 lines · Jinank Jain
Does making 0 as the default value makes sense?
That would silence the warning, and most distros are going to enable the config to zero it out anyway so it has no impact on runtime.
The config to zero out stack variables. CONFIG_INIT_STACK_ALL_ZERO.
regards,
dan carpenter