linux-hyperv.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [bug report] x86/hyperv: Add Write/Read MSR registers via ghcb page
@ 2023-01-16  8:37 Dan Carpenter
  2023-01-17 10:56 ` Jinank Jain
  0 siblings, 1 reply; 4+ messages in thread
From: Dan Carpenter @ 2023-01-16  8:37 UTC (permalink / raw)
  To: Tianyu.Lan; +Cc: linux-hyperv, Jinank Jain

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [bug report] x86/hyperv: Add Write/Read MSR registers via ghcb page
  2023-01-16  8:37 [bug report] x86/hyperv: Add Write/Read MSR registers via ghcb page Dan Carpenter
@ 2023-01-17 10:56 ` Jinank Jain
  2023-01-17 11:00   ` Dan Carpenter
  0 siblings, 1 reply; 4+ messages in thread
From: Jinank Jain @ 2023-01-17 10:56 UTC (permalink / raw)
  To: Dan Carpenter, Tianyu.Lan; +Cc: linux-hyperv

Does making 0 as the default value makes sense?

Regards,

Jinank

On 1/16/2023 2:07 PM, Dan Carpenter wrote:
> 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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [bug report] x86/hyperv: Add Write/Read MSR registers via ghcb page
  2023-01-17 10:56 ` Jinank Jain
@ 2023-01-17 11:00   ` Dan Carpenter
  2023-01-17 11:06     ` Dan Carpenter
  0 siblings, 1 reply; 4+ messages in thread
From: Dan Carpenter @ 2023-01-17 11:00 UTC (permalink / raw)
  To: Jinank Jain; +Cc: Tianyu.Lan, linux-hyperv

On Tue, Jan 17, 2023 at 04:26:13PM +0530, Jinank Jain wrote:
> 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


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [bug report] x86/hyperv: Add Write/Read MSR registers via ghcb page
  2023-01-17 11:00   ` Dan Carpenter
@ 2023-01-17 11:06     ` Dan Carpenter
  0 siblings, 0 replies; 4+ messages in thread
From: Dan Carpenter @ 2023-01-17 11:06 UTC (permalink / raw)
  To: Jinank Jain; +Cc: Tianyu.Lan, linux-hyperv

On Tue, Jan 17, 2023 at 02:00:25PM +0300, Dan Carpenter wrote:
> On Tue, Jan 17, 2023 at 04:26:13PM +0530, Jinank Jain wrote:
> > 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


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-01-17 11:07 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-16  8:37 [bug report] x86/hyperv: Add Write/Read MSR registers via ghcb page Dan Carpenter
2023-01-17 10:56 ` Jinank Jain
2023-01-17 11:00   ` Dan Carpenter
2023-01-17 11:06     ` Dan Carpenter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).