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

Re: [PATCH] x86/P2M: correct type use in p2m_put_gfn()


  • To: Jan Beulich <jbeulich@xxxxxxxx>
  • From: Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Date: Wed, 4 Feb 2026 08:54:56 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=Ks249Zi7djWc+6VzCGwZrAHh5eV8oFlenDYGBSus6qQ=; b=NkAF5sJjcMB3HHynDJAy0e+Rob9AbdrtJ2Dmk65jktERey9vgT0Xwtgs1jQqt77iwMTjtFSqBTbvvbWlN2UOE7ugEDYddA2OXnwedpnOccDO4zefhcK0uzTxLBzsa9p8QSrqJEc2YOqD50WG+R2DKqO4/Mj7a7lb4fCdw+CaIqhCgkczEROCUTpjGpqKWLEIAlk0fGgDmI3Ot1xWDUZ+XcCNH1nkgpA8nvgt54ddwIykpYgBJqYSAfHywhZGG0Qolw8zDjH2s9EJidYIpz/DX1kkAZBGbblaKejGjf289ze42rEhHXULL+MRRSDO1oN7kNCF79tDPIkJRpaUBfhtoQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=evKamYEPRnMS5yELs5QPPiHTYK5h+TSDFR3B/F8xTFSz4K431C8W0mR5eD69qYwt7ABCGMytq879AQdxTvkoSIp2QfuoB/OazTG49ZINukE/9Ct6RwqefCpuv1WU5RNEdLThKo5GgiucieKPLxypJfKdQscLLfkyoVRumvVx4EzBVwfvsx6B4GOMMmkQXppTomn3rFjiWHNVXC3j/RmcQYxgZ2SimjOr/pC8xnGZN1mv5PFLozLqfGbQe/MnpLtAJIwzzcrH+xx9bvdsm/jbLBZg5/XWIWlIYl2920Hf8Bv8BTwSkfjjVhPB+6swpwaNFDpom24HqRB12M5GiGdgfQ==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
  • Cc: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • Delivery-date: Wed, 04 Feb 2026 07:55:10 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On Wed, Feb 04, 2026 at 08:49:53AM +0100, Jan Beulich wrote:
> On 04.02.2026 08:35, Roger Pau Monné wrote:
> > On Tue, Feb 03, 2026 at 03:01:27PM +0100, Jan Beulich wrote:
> >> Everywhere else gfn_t are passed into respective GFN locking macros: Do so
> >> here as well.
> >>
> >> Amends: 819cdc5a7301 ("x86/p2m: re-arrange {,__}put_gfn()")
> >> Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
> > 
> > Acked-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
> 
> Thanks.
> 
> >> ---
> >> Easy to spot by adding ASSERT(!gfn_eq(g, INVALID_GFN)) to the respective
> >> macros. While imo that should be a correct thing to do (as with
> >> hypothetical split locks a valid GFN would really need passing in, in
> >> order to be able to figure out which lock to use), we can't do so right
> >> now: The lock is acquired ahead of respective checking in a number of
> >> places, e.g. in p2m_get_gfn_type_access().
> > 
> > Could we convert those macros into static inlines?  It's dangerous to
> > use macros like those when the parameters are dropped, as the
> > parameter is not evaluated at all.
> 
> It is. Seeing how the header is used, converting may be possible. There's
> one slight concern I'd have with doing so: It would move us one step
> closer to giving the impression that the arguments passed are correct at
> all use sites (while as long as they're entirely ignored, that's kind of
> a hint that they may need checking). I can't point at it right now, but
> I'm pretty sure I had come across at least one place where they're pretty
> clearly wrong.

Well, having at least the type check is better than not checking
anything at all.  By clearly wrong you mean passing INVALID_GFN, or a
random GFN that had something do to with the context?

Thanks, Roger.



 


Rackspace

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