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

Re: [PATCH 2/7] xen/arm64: head: Introduce get_table_slot() and use it


  • To: Julien Grall <julien@xxxxxxx>
  • From: Bertrand Marquis <Bertrand.Marquis@xxxxxxx>
  • Date: Tue, 16 Aug 2022 07:36:14 +0000
  • Accept-language: en-GB, en-US
  • Arc-authentication-results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 63.35.35.123) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com; arc=pass (0 oda=1 ltdi=1 spf=[1,1,smtp.mailfrom=arm.com] dkim=[1,1,header.d=arm.com] dmarc=[1,1,header.from=arm.com])
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none
  • Arc-message-signature: i=2; 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=Me0OIHxGTdFg3VoBOptvDUZWz6VFHEct8/YScgGSXsU=; b=YptLLaKGPN8oHYLEQxJ0Ymtb0/LXZI0Fod176VUOhkHXGWcmBTCdLTJS/0PL1Z4QWAfm9Tkz0oQt9Enjb7u0kXPrty44IUtui/kSyoM8anZ8LCqwuUjn6Nl7nj6ysz2xLrDIafuYPNSAFRGtuYH8sCzgK5kRl8knv+9y9k6zxmKyB8fs6WFI7n9jKc+PyQybUlboBCvl+BFsjkJjbvYDGwSDG9mfn+tjTrWoEa9LDfzU43H7jo2/g49nMOQq0AqjKQ4eydMBJSGnbOE5mh++wFgJhUiudm3TMmzXOAp/iMzXULUYQRKrjyq7hhA7+K1bmbJL/QQS3IEnqzw0kSo+KA==
  • 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=Me0OIHxGTdFg3VoBOptvDUZWz6VFHEct8/YScgGSXsU=; b=aPeiM7O30efEElYEeDNdp2VsMsnNEgkIuzfh5IvqHBAiqDyOavqtVIkjDJisymC+OPLpCfD4ZU4ImX3JedX901ZTFNdfYXPt0Ubg656Ov4KQ8apAiwMyHoOCfyvu3srsfd7AvkNZ3dGGoEI8XPy8Ol+C/UvHvPRBAVvHqI7se3zi31Y/WBq03jZ2ywGn4f03saUK20HY7KdWfW3NGbz/Tvy7R9uvTUgmlQx0Fk20Fbwe7YcTXtw3CBeagUt9MgUpCX+WvqPMeePOh+HM+EkAlevZAJTlNekbPfXA50bXjPP982OAv3kd2JvtDUavlff/XIBKa+OGKA8H6FUBPLDLMA==
  • Arc-seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=dHE29NwTRMFQSrcW36qEF6gllvNQ2pcBHycaZFEEChX8jwS770SqR/HP9hNZFusE+grkXxaC+VtSIoJAWBo96IHrePL5FkhnYdK8ShPrJlEXETVAS1TONqC1ZobHC6usxiavzz6FWaWTVmYNFXSECY0m1dv4pssKs6+pOdgN2DVcmw1W3InB92plwhHliDX77nAEpIQcMkRUZjcHro4UKXI5hBpckQj9jiHOlSdBqpprM97crNu3CkgfdAGOZEhIbu/Tuyw0h9uQA8YYSDQtlANNXJnXKhP+Rxy8Xwzr/jI+2Ktr+lO4cAf5VLgwE4dpoAtYY6vLF2Hthr3XXN4IRg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fXs4yTqJzPlkMPJiDT7fjFZvzCnopLi0NEaH6bX0vZk0CqQWu6VB7Rw0a3Y546ssAg+Bu/Tt4ANef4r0hkTNcFIWVJha5pXqDst0BrKQ9AiXuK0VMEK43b8Adh6jvOFMCRaQnTH9zoiJhjy6Cl/wT8u3Na1qS6HzO7t1WN4I7ddKsl8e9tQLE8nLvQcbn8iC/kPMz12iE8BEpQuUZWot4YV3E5qGQglT0EdOY4vvXMcva22bs6Xs0JiKRiX/AR8rk2hv63cqIezibOMqJBg7Y7zcj+Un94xJiYP7WU6MB4dYsNqrgoX/3Y9xEFlyMix/uYsqSu5273JGLjuJqSpudw==
  • Authentication-results-original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com;
  • Cc: xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Julien Grall <jgrall@xxxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>
  • Delivery-date: Tue, 16 Aug 2022 07:36:43 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Nodisclaimer: true
  • Original-authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com;
  • Thread-index: AQHYroFCs26JN7h8TUSY3teW0vzrLK2wDkCAgAAhRoCAAPkxAA==
  • Thread-topic: [PATCH 2/7] xen/arm64: head: Introduce get_table_slot() and use it

Hi,

> On 15 Aug 2022, at 17:44, Julien Grall <julien@xxxxxxx> wrote:
> 
> 
> 
> On 15/08/2022 15:45, Bertrand Marquis wrote:
>> Hi Julien,
> 
> Hi Bertrand,
> 
>>> On 12 Aug 2022, at 20:24, Julien Grall <julien@xxxxxxx> wrote:
>>> 
>>> From: Julien Grall <jgrall@xxxxxxxxxx>
>>> 
>>> There are a few places in the code that need to find the slot
>>> at a given page-table level.
>>> 
>>> So create a new macro get_table_slot() for that. This will reduce
>>> the effort to figure out whether the code is doing the right thing.
>>> 
>>> Take the opportunity to use 'ubfx'. The only benefits is reducing
>>> the number of instructions from 2 to 1.
>>> 
>>> The new macro is used everywhere we need to compute the slot. This
>>> requires to tweak the parameter of create_table_entry() to pass
>>> a level rather than shift.
>>> 
>>> Note, for slot 0 the code is currently skipping the masking part. While
>>> this is fine, it is safer to mask it as technically slot 0 only covers
>>> bit 48 - 39 bit (assuming 4KB page granularity).
>>> 
>>> Take the opportunity to correct the comment when finding the second
>>> slot for the identity mapping (we are computing the second slot
>>> rather than first).
>>> 
>>> Signed-off-by: Julien Grall <jgrall@xxxxxxxxxx>
>> Reviewed-by: Bertrand Marquis <bertrand.marquis@xxxxxxx>
> 
> Thanks!
> 
>>> 
>>> ----
>>> 
>>>    This patch also has the benefits to reduce the number
>>>    of use of {ZEROETH, FIRST, SECOND, THIRD}_SHIFT. The next
>>>    patch for arm32 will reduce further.
>>> ---
>>> xen/arch/arm/arm64/head.S | 55 +++++++++++++++++++++------------------
>>> 1 file changed, 30 insertions(+), 25 deletions(-)
>>> 
>>> diff --git a/xen/arch/arm/arm64/head.S b/xen/arch/arm/arm64/head.S
>>> index 26cc7705f556..ad014716db6f 100644
>>> --- a/xen/arch/arm/arm64/head.S
>>> +++ b/xen/arch/arm/arm64/head.S
>>> @@ -493,13 +493,24 @@ cpu_init:
>>>         ret
>>> ENDPROC(cpu_init)
>>> 
>>> +/*
>>> + * Macro to find the slot number at a given page-table level
>>> + *
>>> + * slot:     slot computed
>>> + * virt:     virtual address
>>> + * lvl:      page-table level
>>> + */
>>> +.macro get_table_slot, slot, virt, lvl
>>> +        ubfx  \slot, \virt, #XEN_PT_LEVEL_SHIFT(\lvl), #XEN_PT_LPAE_SHIFT
>>> +.endm
>>> +
>> Crawling through the macros to verify the code was not that easy.
>> This is not related to this patch but XEN_PT_* macros could really do with 
>> more comments.
> 
> To me, the name of the macros are self-explaining. So I am not entirely what 
> to write in the comments. Please suggest.

I will add that in my todo list and try to suggest something in the future 
(this is really not critical).
I was just pointing out because doing a deep review for someone who did not 
write this is complex due to the macros of macros of macros of macros ...

Cheers
Bertrand

> 
> Cheers,
> 
> -- 
> Julien Grall




 


Rackspace

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