[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 13:51:51 +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=JfcuZRtPsYSUnyW/22vNJGRa0kD7hx/z6RqcxLhjiOE=; b=i1YVgKNvFljK4zTEQdC8OmQvuOiDe2Egpt1QWyFDacfEvOuDtz1wFCjetc3nS6KjWrXL/IzIX7ouTlheCgtL2d+G5w4Famxd6CIlLuIOvaU6SjGgOa6h67N2dCHsZXIbSqJaQshhrTfsBU6Hb9ckYSLCb0vMXoe9Sjt7F8FR6L7AWtQewnSGSAcZqQDe+axB7FXnyXAiRCO/Gv4cuzkjHcmZY/r+pqNpT9C+pE5t73hJW4L1I2xQnImpImHGoEC5qoF8OFnK0WkfwhXMhl0KTaEEe05/U/Kax5wwoxtGEmBow+AShsCGvGFoBOONg4LkUI3hnledqD1mzwuJDyGERg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FPAl8pORgYKSm2nqC8pLfkA2flEd9BTCdbJcFVxLdLZKWqosIp3BkaoM9vvkCr7/OP6ZEcTPYIdS1BjUfio19LliKunysEKNvvFiSTrxOPe0ixnK/w8xFRlDLClMttCRlnb/RzwJv8FB+qj5yDlroJuLmdvkaBr0V2rb/48aT3shp5qHm1NAUAsFSfuk9g86yeg8gEBU6/Y1/7qSnV/1fyusqMFNsyInsF41s37724Cg3ifaj5m2rJiPJCJY+OWW6FoNGnRrLnnaSYP0j5ZrmYqVFt+YYZ0OmB1MEbhIxzqUBCZUltp50xVC59o1ur1MwZMKBs6qySV7/exabjw3/Q==
  • 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 11:52:08 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 26.10.2023 11:46, Xenia Ragiadakou wrote:
> On 26/10/23 11:45, Jan Beulich wrote:
>> On 26.10.2023 10:34, Xenia Ragiadakou wrote:
>>> On 26/10/23 10:35, Jan Beulich wrote:
>>>> On 26.10.2023 08:45, Xenia Ragiadakou wrote:
>>>>> --- 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.
>>> Yes it is not quite straight forward to understand and is based on the
>>> assumption that end > kernel_start and start < kernel_end, due to
>>> the first condition failing.
>>>
>>> Both cases:
>>> (start < kernel_start && end < kernel_end) and
>>> (kernel_start - start > end - kernel_end)
>>> fall into the condition ( kernel_start + kernel_end > start + end )
>>>
>>> And both the cases:
>>> (start > kernel_start && end > kernel_end) and
>>> (end - kernel_end > kernel_start - start)
>>> fall into the condition ( kernel_start + kernel_end < start + end )
>>>
>>> ... unless of course I miss a case
>> Well, mathematically (i.e. ignoring the potential for overflow) the
>> original expression and your replacement are identical anyway. But
>> overflow needs to be taken into consideration, and hence there is a
>> (theoretical only at this point) risk with the replacement expression
>> as well. As a result I still think that ...
>>
>>>> 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.
>> ... this alternative approach may want considering (provided we need
>> to make a change in the first place, which I continue to be
>> unconvinced of).
> Hmm, I see your point regarding the overflow.
> Given that start < kernel_end and end > kernel_start, this could
> be resolved by changing the above condition into:
> if ( kernel_end - start > end - kernel_start )
> 
> Would that work for you?

That would look quite a bit more natural, yes. But I don't think it covers
all cases: What if the E820 range is a proper sub-range of the kernel one?
If we consider kernel range crossing E820 region boundaries, we also need
to take that possibility into account, I think.

Jan



 


Rackspace

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