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

Re: [PATCH] x86/shadow: Fix PV32 shadowing in !HVM builds


  • To: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Thu, 26 Jan 2023 09:50:13 +0100
  • 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=07Olfahwhy/F/0iLY3tr63GquYMtGeh2XTGyUOO8lLA=; b=RB8Lgx8K0w04+x4cBc34vjT9xdvEewjzQF+ApS3oEs/f6h3uGFMo8HYu8ViqlUDAVN97+316sC9+lXyfbnobmU3irQenZUjBHK8tHfDIb5fS21BkX4ypdH7x4iyRYGFkjLoMKveg4D1wobj0qu4qqeA1U9Nb4uwO+j9ahSghZt2qViKY7APv018T2pZ4qq1HMMGyQdov7GzZWf/YtE4yGBqa0d4VhwQfYx9+e9j6WAUTDyVhab7p1iIF1GI8pV24RO0SYrAfGgU/AHtpSprluRAtadKcvKN8PYOnKtgSFTnBrizpUEKa1Ri5+kaGr8bdTyFjLZDUzlqGPKsPIxx6Og==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=X04Xvx0HrJ8yXtwKoMTUZwiMYwpDd0g6nHtrUxbGuij2Uv0MbJuH41N+++kYD3epQyO+IWAlieXnKrTK3f2CgtL6khOfAcRA61ZR2DJZu8x8PPukOvEns2tzulUomVTfy90yQJmaHyjp2bbD5nZp96GJvQbzodRyO3uOcWrH2/SFV/mrYaZW9RFYyDoy/+0olr1QzV7nHAxSEByeFtNgu/ncEsZF1PmYZLhAVLAv1pINeu5AxszKGW96Ucx1a+bv+yT5r5cGEFYzanmGnJnkDrmgeoGcgdg+4VvvuACMqt4mLX4ROvG6xNgEFqyCjOwYYXHlDv07p92SeaHchk8ybQ==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Roger Pau Monné <roger.pau@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxxxxx>, Tim Deegan <tim@xxxxxxx>, Xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Thu, 26 Jan 2023 09:06:24 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 25.01.2023 17:53, Andrew Cooper wrote:
> The OSSTest bisector identified an issue with c/s 1894049fa283 ("x86/shadow:
> L2H shadow type is PV32-only") in !HVM builds.
> 
> The bug is ultimately caused by sh_type_to_size[] not actually being specific
> to HVM guests, and it's position in shadow/hvm.c mislead the reasoning.
> 
> To fix the issue that OSSTest identified, SH_type_l2h_64_shadow must still
> have the value 1 in any CONFIG_PV32 build.  But simply adjusting this leaves
> us with misleading logic, and a reasonable chance of making a related error
> again in the future.
> 
> In hindsight, moving sh_type_to_size[] out of common.c in the first place a
> mistake.  Therefore, move sh_type_to_size[] back to living in common.c,
> leaving a comment explaining why it happens to be inside an HVM conditional.
> 
> This effectively reverts the second half of 4fec945409fc ("x86/shadow: adjust
> and move sh_type_to_size[]") while retaining the other improvements from the
> same changeset.
> 
> While making this change, also adjust the sh_type_to_size[] declaration to
> match its definition.
> 
> Fixes: 4fec945409fc ("x86/shadow: adjust and move sh_type_to_size[]")
> Fixes: 1894049fa283 ("x86/shadow: L2H shadow type is PV32-only")
> Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>

Now it's time for me to ask: But why? Your interpretation of "HVM-only"
is simply too restricted. As said, "HVM-only" can have two meanings -
build-time HVM-only and run time HVM-only. Code in hvm.c is also
expecting to be entered for PV guests when HVM=y - see the several
is_hvm_...(). They're all bogus though, and I have a patch pending to
remove them. But that doesn't alter the principle. See e.g. audit_p2m(),
which simply bails first thing when !paging_mode_translate(), or
p2m_pod_active(), which bails first thing when !is_hvm_domain().

Content of hvm.c (and other files which are built only when HVM=y, or
more generally any other files which have a Kconfig build time
dependency in their respective Makefile) simply has to be aware of this
fact, and hence the data (array) in question is quite fine to live where
it does.

I continue to view my 1st patch as the better approach. And in no case
do I view the 1st Fixes: tag as appropriate.

I guess we really need George or Tim to break ties here.

Jan



 


Rackspace

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