[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>, Jan Beulich <jbeulich@xxxxxxxx>
  • From: Boris Ostrovsky <boris.ostrovsky@xxxxxxxxxx>
  • Date: Thu, 20 Oct 2022 10:22:17 -0400
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.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=oDA76FvYITBlSHbEfX0s8L75NKxf4Oi+JoKzayh4O2Q=; b=CpfT2FeH99LetQkpnCUx31LUUI8YBl4Xe44QsxDJv591WlrmQS1WqBhlvJlyYrqaJi0pHv3jbPXe56e7e3ogwf0lNPHWYExxfD8Mv+A/Ad7q3oxl7KUn+Nnrb/rlwxg6tr9Vdt091+88JsiKFxaxhad2vzh4VyzrjAOYJ6yFLny/WbPJ4MglqycbJ8xgDE0lPbUUPnN4ulFbd9PaixqCq2LoXmqaOb0TMjaCLdqlY9+l/Kvt9f2kLJrIQPkgrVVxM6hfThS9ql4lkdtrkkI7rUeXwzr4gZBLFWwdL4DEf+ozsdwdjs18zgMg6F/Jk8csgQTpM6VyyCDjq4K1bUFEpg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QnKwZgBwfRK0z7t2Tbt6UQMGUd+U9emLavrkp6ByfTDUbQkhX95wfv3iD870qk6T2ChYfgaei/Q5R2lQVySTFjzoPTuPitWj4UBYDpQDS/P0eDlJJRXkyNH7YYuVRaLZpEHl11eC8z7VBxs9s7sR5nVof8TEFapJL8cPOLRRGpJlxbMeAdq/ZFBzMc+zovZ1NJ9YA/nM9GXDgrfKCxYPYvb3XqwoDtBsDVPvCjqMgqKrm7aX6Rsc79rYvDLQ8omiW0donJgGhLHs8Bsld/vCgnC2fYOeGuD4umW0R9hZRf8+qlQrogZAjA9vU6kkpOjLHIThcnmzuSXBd0ua5eKS7Q==
  • Cc: 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 14:23:07 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>


On 10/20/22 9:34 AM, Juergen Gross wrote:
On 20.10.22 15:16, Jan Beulich wrote:
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.

Hmm, an alternative would be to initialize it to -1 and add a test for the
index to be >= 0 before using it.

Or to live with the smash warning with the chance, that a compiler might be
warning for the same reason in the future.


Is smatch complaining about both variables or just index? There are two cases 
in is_intel_pmu_msr() where it returns true but index is not set so perhaps 
that's what bothers smatch? It shold not complain if is_intel_pmu_msr() returns 
false.


-boris




 


Rackspace

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