Re: [PATCH] kvm: Fix build warnings

From: Borislav Petkov
Date: Tue May 31 2011 - 05:02:29 EST


On Tue, May 31, 2011 at 11:20:55AM +0300, Avi Kivity wrote:
> On 05/31/2011 10:38 AM, Ingo Molnar wrote:
> >* Borislav Petkov<bp@xxxxxxxxx> wrote:
> >
> >> +++ b/arch/x86/kvm/paging_tmpl.h
> >> @@ -121,7 +121,7 @@ static int FNAME(walk_addr_generic)(struct guest_walker *walker,
> >> gva_t addr, u32 access)
> >> {
> >> pt_element_t pte;
> >> - pt_element_t __user *ptep_user;
> >> + pt_element_t __user *uninitialized_var(ptep_user);
> >
> >Note that doing this is actually actively dangerous for two reasons.
> >
> >
>
> <snip lots of good advice>
>
> >Please fix it instead.
>
> s/instead/in addition/; while all those changes are good, they are
> much too large for 3.0. Let's push the simple fix for 3.0 and queue
> the bigger refactoring to 3.1.

Just to clarify: Hell, it is _not_ I who's fixing this! Virtualization
folks are crazy anyway and I'm not touching their code except for
trivial fixes :-).

The story: I saw the humongous function and being lazier than Ingo, I
just wanted to shut up the warning. Knowing that uninitialized_var()
is a dangerous thing to use, I asked whether people who know the code
can guarantee that ptep_user is not going to be used uninitialized and
Takuya confirmed.

But yes, it'll be much better if kvm people could take a good hard look
at it and try to simplify it. Also, while they're at it, I'd suggest
they actually trace whether that unlikely() annotation actually brings
any performance speedup - if it doesn't, out the door with it and here's
more simplification right there.

Thanks.

--
Regards/Gruss,
Boris.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/