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

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


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Xenia Ragiadakou <xenia.ragiadakou@xxxxxxx>
  • Date: Thu, 26 Oct 2023 09:45:43 +0300
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0)
  • 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=cZmZu8VfwSbwtFpJZOvSNULRvtAyCT7XDIOBfHqGsio=; b=M3C9PpnRfTiiiOwMEAVrtkzuglY2sfoGOEHX4RhUfW0eJl22lpKtPVMiN3kDMknUtQLiObl+DmnYq5gm9fd6BC7Cpx6Hxq/m+sjmrFgs8q9cAcjX51G9adHVNT7Lm2Ua1f+1SWE7HO+tCaa/kHJg2Vfa3kcoq/j5knazL1kFP2inve/ifoy1AwyfrKFA/4Pb4rsuM+seMj32uTYzM2bLPPyvgqYiQC3lx8I9oTSsGOJ87S+PmhbGxKDP9psqkTAyn6lay8GwYxExsYDDUrSj7PAU1jO6IKfiO7X8o845mQOScwWP3pN03L5eId7f/g55DsVON2yjniHRcTNvTzcOSA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WDmY3j6d424QovQ8UZy0TsneEQKvdf8iUzeJoC1ZYaSQUNH/cm0U7vQkchQoelBduQobC/kKvFs7W8H7xGKvq6/W7pHmr1dTfxxzoFncsKws5BbzzN4oYNyPhrdHhKX3VXfF1pNFv2fNA+1zskroE/pkQxHSypbeAnojOAHXfcIECoahItCV7o8JXZPozG5q8gbE2uYiS/n+O/jg7Me3Da7eJirhL+vzF+uLuaUaJGwW/cn6xnEeL4aSrCD6jgCmoZlPF7Qjv3VL5c/ULO3t+33xsJbux3ND80mJ70Ynr7qym9Wjxv+0rHWPhxv23fHllA153Go/n/oanOutk8n2sA==
  • Cc: Xenia Ragiadakou <xenia.ragiadakou@xxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>
  • Delivery-date: Thu, 26 Oct 2023 06:46:06 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

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.

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 )
             end = kernel_start;
         else
             start = kernel_end;
-- 
2.34.1




 


Rackspace

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