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

Re: [PATCH 2/9] xen/arm64: head: Don't map too much in boot_third


  • To: Julien Grall <julien@xxxxxxx>, <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Michal Orzel <michal.orzel@xxxxxxx>
  • Date: Thu, 29 Jun 2023 09:26:34 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=xen.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
  • 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=jLDKqdnRlWNhSNVoWYQ5M3Fw2pisIHkWMR/OMfPZMBc=; b=i2zuH0IJm69KF3ycDRf3np29cYqW4hxFoQqudEBPCv00gyIJCmHYt0gTWmWMfnX7x4YytRxCfrrrYM9r3Xq4VuJc2pJVg7zkkrFEBJ8V7232DmKhbV5RD34qsuMBHKfl/Zhw5YHUCtrH6kH0sEgfi22Q+930fFfawcsEHvxjmP0u7bGuMuj4tKxr2k63CaaFNJwDf9rPZpYU6dszaLCEsRkfi4q5mlzxNk46IBIuDdFrrtyLfSh42mMQQprvKfkHQEtS8a17euPiyZ+L5Myo3wcscQPyStVrn6sDCr02mg4By25o6W9vxjy1tDX5/iLSf6809f8wYzK/aAlkYgznWA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mf1jJHo9tWhduqhTlvCRUweW17gGfmBXAd9tsSlU00FBYnMUMVTTsMix6sTgZ49B9cprqoNRBO2JOBT1vt5DdoToGQHfMyTirDD73fdBhJBtHJFIJT9d6PXcwLv7Viqv7eAU8GHunEn8dtTay0HiQ/LcfejCChS0QoL/CfNYUATDSLtMoyBg3o4KyfP521p4G6cW4cxPFbwz8zt+Nzt/KU7XHCYj71fWd8FhusZsUGeFLoNOcfnRSZ08L1u1j9829aaulpDs2dBDdY5l/Snh58WqrL0yFJsE4oOk98QIn3lQP4PE/KsqTCcmZ3OwqsFVcIIhRiDAnALc4oLOQ2s9qA==
  • Cc: <Luca.Fancellu@xxxxxxx>, <Henry.Wang@xxxxxxx>, Julien Grall <jgrall@xxxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, "Bertrand Marquis" <bertrand.marquis@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>
  • Delivery-date: Thu, 29 Jun 2023 07:27:21 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 28/06/2023 20:21, Julien Grall wrote:
> 
> 
> Hi,
> 
> On 26/06/2023 12:28, Michal Orzel wrote:
>> On 25/06/2023 22:49, Julien Grall wrote:
>>> From: Julien Grall <jgrall@xxxxxxxxxx>
>>>
>>> At the moment, we are mapping the size of the reserved area for Xen
>>> (i.e. 2MB) even if the binary is smaller. We don't exactly know what's
>>> after Xen, so it is not a good idea to map more than necessary for a
>>> couple of reasons:
>>>      * We would need to use break-before-make if the extra PTE needs to
>>>        be updated to point to another region
>>>      * The extra area mapped may be mapped again by Xen with different
>>>        memory attribute. This would result to attribue mismatch.
>> s/attribue/attribute
>>
>>>
>>> Therefore, rework the logic in create_page_tables() to map only what's
>>> necessary. To simplify the logic, we also want to make sure _end
>>> is page-aligned. So align the symbol in the linker and add an assert
>>> to catch any change.
>>>
>>> Signed-off-by: Julien Grall <jgrall@xxxxxxxxxx>
>>> ---
>>>   xen/arch/arm/arm64/head.S | 15 ++++++++++++++-
>>>   xen/arch/arm/xen.lds.S    |  3 +++
>>>   2 files changed, 17 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/xen/arch/arm/arm64/head.S b/xen/arch/arm/arm64/head.S
>>> index f37133cf7ccd..66bc85d4c39e 100644
>>> --- a/xen/arch/arm/arm64/head.S
>>> +++ b/xen/arch/arm/arm64/head.S
>>> @@ -572,6 +572,19 @@ create_page_tables:
>>>           create_table_entry boot_first, boot_second, x0, 1, x1, x2, x3
>>>           create_table_entry boot_second, boot_third, x0, 2, x1, x2, x3
>>>
>>> +        /*
>>> +         * Find the size of Xen in pages and multiply by the size of a
>>> +         * PTE. This will then be compared in the mapping loop below.
>>> +         *
>>> +         * Note the multiplication is just to avoid using an extra
>>> +         * register/instruction per iteration.
>>> +         */
>>> +        ldr   x0, =_start            /* x0 := vaddr(_start) */
>> x0 is already set to vaddr of _start by the first instruction of 
>> create_page_tables
>> and is preserved by create_table_entry. You could just reuse it instead of 
>> re-loading.
> 
> I agree that the load is technically redundant. However, I find this
> approach easier to read (you don't have to remember that _start equals
> XEN_VIRT_START).
Ok. As a side note not related to this patch, would it make sense to add an 
assert in linker
script to make sure _start equals XEN_VIRT_START, since we use them 
interchangeably?

~Michal



 


Rackspace

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