All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] x86/hvm/dom0: fix PVH initrd and metadata placement
@ 2023-10-26  6:45 Xenia Ragiadakou
  2023-10-26  7:35 ` Jan Beulich
  0 siblings, 1 reply; 23+ messages in thread
From: Xenia Ragiadakou @ 2023-10-26  6:45 UTC (permalink / raw)
  To: xen-devel
  Cc: Xenia Ragiadakou, Jan Beulich, Andrew Cooper,
	Roger Pau Monné, Wei Liu

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@amd.com>
---
 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



^ permalink raw reply related	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2023-10-30 12:12 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-26  6:45 [PATCH] x86/hvm/dom0: fix PVH initrd and metadata placement Xenia Ragiadakou
2023-10-26  7:35 ` Jan Beulich
2023-10-26  8:34   ` Xenia Ragiadakou
2023-10-26  8:45     ` Jan Beulich
2023-10-26  9:46       ` Xenia Ragiadakou
2023-10-26 11:51         ` Jan Beulich
2023-10-26 12:35           ` Xenia Ragiadakou
2023-10-26 12:37             ` Jan Beulich
2023-10-26 13:58               ` Xenia Ragiadakou
2023-10-26 14:55                 ` Jan Beulich
2023-10-26 15:01                   ` Roger Pau Monné
2023-10-26 16:55                   ` Xenia Ragiadakou
2023-10-27  6:37                     ` Jan Beulich
2023-10-27 11:18                       ` Xenia Ragiadakou
2023-10-27 12:01                         ` Jan Beulich
2023-10-30  7:37                           ` Xenia Ragiadakou
2023-10-30 11:18                             ` Roger Pau Monné
2023-10-30 12:12                             ` Jan Beulich
2023-10-26 10:31     ` Andrew Cooper
2023-10-26 11:41       ` Jan Beulich
2023-10-26 12:09         ` Xenia Ragiadakou
2023-10-26 12:35           ` Jan Beulich
2023-10-26 14:58           ` Roger Pau Monné

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.