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

Re: [PATCH] x86/mem-sharing: short-circuit p2m_is_shared() when MEM_SHARING=n


  • To: Jan Beulich <jbeulich@xxxxxxxx>
  • From: Tamas K Lengyel <tamas@xxxxxxxxxxxxx>
  • Date: Thu, 10 Apr 2025 21:03:52 -0400
  • Arc-authentication-results: i=1; mx.zohomail.com; dkim=pass header.i=tklengyel.com; spf=pass smtp.mailfrom=tamas@xxxxxxxxxxxxx; dmarc=pass header.from=<tamas@xxxxxxxxxxxxx>
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1744333471; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To; bh=EA8LXa/Kr1rDhgq7fsazy42w7N5pCyv4+5e8QlYl2DQ=; b=fJKknIg+K5CxxdFre0LuscTZUBbnEj7xgCLAfO6UngiZbdS1LumZm+qj51MOY4BW0T/keD5c3tNzfwM/wP4oNGD+G8o9Y6ZXVkZ3Jly28OhsYGc6JQNmmHS30wzGR+CnFy6H5nvxaT6kVnHbbAG67SsK5rvZqcDfW3X8CaucKgg=
  • Arc-seal: i=1; a=rsa-sha256; t=1744333471; cv=none; d=zohomail.com; s=zohoarc; b=iXTcrXk885wj3zze+M5BZXFb4LHht6SaOkzV62qw4bWRgVNAIAnlBlY9S/S+YMx6KYUE495aKu6XpiKxctr5SpWAIMJGV/hUFF4UzkCMM1PLryE4goDKB8yQdC7CxSicZffO4PjgB9VpzNA6LYuXupZcdW/HSdXl6fcFGaok7pA=
  • Cc: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Delivery-date: Fri, 11 Apr 2025 01:04:49 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On Thu, Apr 3, 2025 at 4:42 AM Jan Beulich <jbeulich@xxxxxxxx> wrote:
>
> Some of the uses of dom_cow aren't easily DCE-able (without extra
> #ifdef-ary), and hence it being constantly NULL when MEM_SHARING=n
> misguides Coverity into thinking that there may be a NULL deref in
>
>         if ( p2m_is_shared(t) )
>             d = dom_cow;
>
>         if ( get_page(page, d) )
>             return page;
>
> (in get_page_from_mfn_and_type()). Help the situation by making
> p2m_is_shared() be compile-time false when MEM_SHARING=n, thus also
> permitting the compiler to DCE some other code.
>
> Note that p2m_is_sharable() isn't used outside of mem_sharing.c, and
> hence P2M_SHARABLE_TYPES can simply be left undefined when
> MEM_SHARING=n.
>
> Coverity ID: 1645573
> Fixes: 79d91e178a1a ("dom_cow is needed for mem-sharing only")
> Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>

Reviewed-by: Tamas K Lengyel <tamas@xxxxxxxxxxxxx>

> ---
> Might be nice to also eliminate p2m_ram_shared (and for MEM_PAGING=n
> also the three paging types) entirely from such builds, to eliminate the
> risk of accidental use. Yet that would apparently also come at the price
> of more #ifdef-ary. Opinions?

I don't think the risk of accidental use is a concern. I wouldn't
touch them unless they lead to similar confusion with coverity or some
other tool.

Cheers,
Tamas



 


Rackspace

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