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

Re: [PATCH] x86/hvm/dom0: fix PVH initrd and metadata placement


  • To: Xenia Ragiadakou <xenia.ragiadakou@xxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Thu, 26 Oct 2023 09:35:07 +0200
  • 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=xsQAxk9u9hohwHEAMZJh0ndDzytoIRuYpXNu5Dpaw0o=; b=fISBe0fwUwFOWE0aJ3P1twESlzGY6sTGE6KWc7eVwyzlKMJZnQcmAIKphnZD4RalzzOjCVkUZTe1a1eVTmdqQwRlfi+pIaSFVgQVcnu3CtY6+KALQPBTLoQP+lVCLuXZvwu02MJpF4SbABI8zSJsxYwzu8v9uZieCEeeZzNi45UUYRhjVlohJ0pvl8uNtDv0X56c5SgE4ZQLD+cjzU7kxesaUPEHPdHmIc+JY3iyUqYID0/ScuEofUnxRSentnXebDbQGDUqjLid5fQ2cYURZ/Q70osc8aPtBzcmLIt+1xp3V2FY4Yd0mmiV6bSaycs/X92Szyr+KYuaPvAqeP6Pkw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SXTqlW1Ob1s+m7kx9Fz/W5TT06sWjQwS5a3xdpbq2grGGaTtP8OMMwSILYFlVlmE2l0DbkoBuKnd1D1Th889rx2ytCuZ0E2DrOnH9j/yUQdkuoFAVZb5ucugFy5yfee5rxwQwBHD3mWgm6FHt2Wva9WyDfwCjlRdA0PoDvNPoFpeFDJXePqdpkJXHss0w6i0R9DPp238K3hH3yg+fxYqLa76JD7R5I9nogyWtK6oJ8euW31I18Zgj9TbxHPw6NH5Ua27LY7H71IhlLzOxSC9MFQoH+e9TfX7mEc2Rg8hSVE+zfhasVjC7xy56Q02znUEyRWscz7dd4k3hyg3TSVDpw==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • Delivery-date: Thu, 26 Oct 2023 07:35:44 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 26.10.2023 08:45, Xenia Ragiadakou wrote:
> Given that start < kernel_end and end > kernel_start, the logic that
> determines the best placement for dom0 initrd and metadata, does not
> take into account the two cases below:
> (1) start > kernel_start && end > kernel_end
> (2) start < kernel_start && end < kernel_end
> 
> In case (1), the evaluation will result in end = kernel_start
> i.e. end < start, and will load initrd in the middle of the kernel.
> In case (2), the evaluation will result in start = kernel_end
> i.e. end < start, and will load initrd at kernel_end, that is out
> of the memory region under evaluation.

I agree there is a problem if the kernel range overlaps but is not fully
contained in the E820 range under inspection. I'd like to ask though
under what conditions that can happen, as it seems suspicious for the
kernel range to span multiple E820 ranges.

> This patch rephrases the if condition to include the above two cases
> without affecting the behaviour for the case where
> start < kernel_start && end > kernel_end
> 
> Fixes: 73b47eea2104 ('x86/dom0: improve PVH initrd and metadata placement')
> Signed-off-by: Xenia Ragiadakou <xenia.ragiadakou@xxxxxxx>
> ---
>  xen/arch/x86/hvm/dom0_build.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/xen/arch/x86/hvm/dom0_build.c b/xen/arch/x86/hvm/dom0_build.c
> index c7d47d0d4c..5fc2c12f3a 100644
> --- a/xen/arch/x86/hvm/dom0_build.c
> +++ b/xen/arch/x86/hvm/dom0_build.c
> @@ -518,7 +518,7 @@ static paddr_t __init find_memory(
>          if ( end <= kernel_start || start >= kernel_end )
>              ; /* No overlap, nothing to do. */
>          /* Deal with the kernel already being loaded in the region. */
> -        else if ( kernel_start - start > end - kernel_end )
> +        else if ( kernel_start + kernel_end > start + end )

What meaning has the sum of the start and end of either range? I can't
figure how comparing those two values will be generally correct / useful.
If the partial-overlap case needs handling in the first place, I think
new conditionals need adding (and the existing one needs constraining to
"kernel range fully contained") to use
- as before, the larger of the non-overlapping ranges at start and end
  if the kernel range is fully contained,
- the tail of the range when the overlap is at the start,
- the head of the range when the overlap is at the end.

That said, in the "kernel range fully contained" case it may want
considering to use the tail range if it is large enough, rather than
the larger of the two ranges. In fact when switching to that model, we
ought to be able to get away with one less conditional, as then the
"kernel range fully contained" case doesn't need treating specially.

Jan



 


Rackspace

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