[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] x86/xen: silence smatch warning in pmu_msr_chk_emulated()


  • To: Juergen Gross <jgross@xxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Thu, 20 Oct 2022 15:16:02 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Ph99jjmvxnSMHZwfBQi6Qqu0r728QlCQCKShM2Fdvog=; b=YOPMT+VBV4fCvBHelDjnd8VlpPZQa540BsJZyBjQHeszv99mXIqGhsbA/WuNwbyUlWDnptbGsskdB/HNWhL5Z2HAwzJWI1lF5zXPyYxT81OzGRi6zr2Lya1MS9Af9V6Qh5sdaDzsJ4LeUjFHVSaSq+1e+tXdFVWYRZrI1wM18ooCaXpf1EymJAmSSFw3WTAPpGPzck/SWSZLEtYVizmuQXGzOyRC3hPkIrVcvhM1pFQei5A2klygButiMeZrJNMi6FSf/roc1epOyH1jQi613S/1Atlfa/0AsrmX+mQOP/J91jO8yckRo+m+M18dXVWos77Kx+uh1XLEderAyMMGOA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LntkzugKyWwMPmXhjB7xdDMRQQKvn3DSkPivuwcQlXF0IqEMHvlZbY3ukE1d0cRksesQSYa/gJ7P1uwvzEyRn8g5Y8YbPheKP87lynzOoap40508qxYJeAUaHGcK232km8zONZjDBGjD1fkWW5fTf+L8eYpgaWaI8KYp3ZvwS1GtfDDEpQcqBCern1gSkEOCaFVb/d6MmYAT6LJo95cy5feyiE3nUCU680GhCZ8QqHiV43c65O3OvSjdY1n5IJWqP6sndv5Ohqj72A2Iy3S8pNhRrjsAFUx75Kjsq7kEbOMyzKfueBctYew8edicmDuJlRvtgbZkKpUnvUOYvAdeog==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Boris Ostrovsky <boris.ostrovsky@xxxxxxxxxx>, Thomas Gleixner <tglx@xxxxxxxxxxxxx>, Ingo Molnar <mingo@xxxxxxxxxx>, Borislav Petkov <bp@xxxxxxxxx>, Dave Hansen <dave.hansen@xxxxxxxxxxxxxxx>, "H. Peter Anvin" <hpa@xxxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx, Dan Carpenter <dan.carpenter@xxxxxxxxxx>, linux-kernel@xxxxxxxxxxxxxxx, x86@xxxxxxxxxx
  • Delivery-date: Thu, 20 Oct 2022 13:16:13 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 20.10.2022 13:37, Juergen Gross wrote:
> Commit 8714f7bcd3c2 ("xen/pv: add fault recovery control to pmu msr
> accesses") introduced code resulting in a warning issued by the smatch
> static checker, claiming to use an uninitialized variable.
> 
> This is a false positive, but work around the warning nevertheless.

The risk of introducing a problem might be quite low here, but in general
it exists: With the adjustment you remove any chance of the compiler
spotting a missing initialization before use. And I'm not convinced using
0 in such a case would actually be ending up sufficiently benign.

Jan

> --- a/arch/x86/xen/pmu.c
> +++ b/arch/x86/xen/pmu.c
> @@ -302,7 +302,7 @@ static bool xen_amd_pmu_emulate(unsigned int msr, u64 
> *val, bool is_read)
>  static bool pmu_msr_chk_emulated(unsigned int msr, uint64_t *val, bool 
> is_read,
>                                bool *emul)
>  {
> -     int type, index;
> +     int type = 0, index = 0;
>  
>       if (is_amd_pmu_msr(msr))
>               *emul = xen_amd_pmu_emulate(msr, val, is_read);




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.