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

[bug report] xen/pv: add fault recovery control to pmu msr accesses


  • To: jgross@xxxxxxxx
  • From: Dan Carpenter <dan.carpenter@xxxxxxxxxx>
  • Date: Thu, 13 Oct 2022 16:55:06 +0300
  • 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=bpSvYUzf1hnen2JnJINY3EOINx560cm6soQcdO2nURQ=; b=EJaOIUcDkDLV4/mCsrLTpETshMom7WaHaTyb4IJfpK/8UWPdcKP4UxP7wZjfN/MDbzxqdyLrRwtNTxPc6HxqktzlVVDHUKfIu6fOMHXFsUUF13EStA5w1+zahl5K7hGJSqsXY2btm440haNoRXLQnYhGwq53L+Xxe9cENfzarKcRECu3SH7x9rTTKQ8X+0CEtg8x4sLqZjez35+hf4KUzIwkNXKH6n9Stp+fMVlTE3TKasSqYxdknJSW1ZGR6tUFZ3NhRTyr/K/j+G2g5xBnrp48RcjUMwWHsceU5y8CYk7cFc7dh0mw40usCjw2ERZO77Z1p1lyREj1JsrAcjvKww==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WD+GaC/ERnk3CqUOpLMestIfzelwKrerOi1XO+o0JR4E8GJ5HXPGiOdtYzoMK7Ki6SO+m75f/y2WZHigTr5jUyqBE7rm4jRzdR7ZkIEzXEtnxH4mmExqTRdKOD//0Dn1mj/aiFk4sjL8BVxcve357bdVVyrQojktPtJ9BKRVWHERGC99QzVlH6EpTh95HJ+JKpk/gRHmNM2BFw6p+90sVX0FgjV/oi8E/k9DHN98GCYXEYrVTkhOM8qs2wo99AJ5nasvw0CLGApLCFnehLtH3yt8lVkaDIM3w2xB/Lp/JcBr/hTawW2eJP9TYbgtgVUT03g2CnwTeMWzy/XJ5VCaCw==
  • Cc: xen-devel@xxxxxxxxxxxxxxxxxxxx
  • Delivery-date: Thu, 13 Oct 2022 13:55:35 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Hello Juergen Gross,

The patch 8714f7bcd3c2: "xen/pv: add fault recovery control to pmu
msr accesses" from Sep 26, 2022, leads to the following Smatch static
checker warning:

        arch/x86/xen/pmu.c:310 pmu_msr_chk_emulated()
        error: uninitialized symbol 'index'.

arch/x86/xen/pmu.c
    302 static bool pmu_msr_chk_emulated(unsigned int msr, uint64_t *val, bool 
is_read,
    303                                  bool *emul)
    304 {
    305         int type, index;
    306 
    307         if (is_amd_pmu_msr(msr))
    308                 *emul = xen_amd_pmu_emulate(msr, val, is_read);
    309         else if (is_intel_pmu_msr(msr, &type, &index))
--> 310                 *emul = xen_intel_pmu_emulate(msr, val, type, index, 
is_read);

Smatch is correct that we're passing "index" when it wasn't initialized
but it's not used so it's a false positive.  I think KMSan will print
the same warning as well.  It's technically undefined behavior, but also
we care more about real life GCC than the C standard...

Another thing to consider is that eventually we're going to make zeroing
the stack enabled by default and when we do that the performance hit for
setting index to zero will go away for most people.  (Zeroing the stack
makes uninitialized variable bugs defined behavior and has security
benefits).

    311         else
    312                 return false;
    313 
    314         return true;
    315 }

regards,
dan carpenter



 


Rackspace

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