All of lore.kernel.org
 help / color / mirror / Atom feed
From: Julien Grall <julien@xen.org>
To: Bertrand Marquis <Bertrand.Marquis@arm.com>
Cc: xen-devel <xen-devel@lists.xenproject.org>,
	Julien Grall <jgrall@amazon.com>,
	Stefano Stabellini <sstabellini@kernel.org>,
	Volodymyr Babchuk <Volodymyr_Babchuk@epam.com>
Subject: Re: [PATCH 2/7] xen/arm64: head: Introduce get_table_slot() and use it
Date: Mon, 15 Aug 2022 17:44:21 +0100	[thread overview]
Message-ID: <3136c797-652b-97c9-b356-b49fe53a40b5@xen.org> (raw)
In-Reply-To: <8FA138D1-CBF2-4BAB-9283-2573A6A09C79@arm.com>



On 15/08/2022 15:45, Bertrand Marquis wrote:
> Hi Julien,

Hi Bertrand,

>> On 12 Aug 2022, at 20:24, Julien Grall <julien@xen.org> wrote:
>>
>> From: Julien Grall <jgrall@amazon.com>
>>
>> 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@amazon.com>
> Reviewed-by: Bertrand Marquis <bertrand.marquis@arm.com>

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.

Cheers,

-- 
Julien Grall


  reply	other threads:[~2022-08-15 16:44 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-12 19:24 [PATCH 0/7] xen/arm: More clean-ups and improvement Julien Grall
2022-08-12 19:24 ` [PATCH 1/7] xen/arm64: head: Don't set x22 and update the documentation Julien Grall
2022-08-15  1:36   ` Wei Chen
2022-08-15 13:43   ` Bertrand Marquis
2022-08-12 19:24 ` [PATCH 2/7] xen/arm64: head: Introduce get_table_slot() and use it Julien Grall
2022-08-15  1:45   ` Wei Chen
2022-08-15 14:45   ` Bertrand Marquis
2022-08-15 16:44     ` Julien Grall [this message]
2022-08-16  7:36       ` Bertrand Marquis
2022-08-12 19:24 ` [PATCH 3/7] xen/arm32: " Julien Grall
2022-08-15  1:48   ` Wei Chen
2022-08-15 14:56   ` Bertrand Marquis
2022-08-12 19:24 ` [PATCH 4/7] xen/arm32: heap: Rework adr_l so it doesn't rely on where Xen is loaded Julien Grall
2022-08-15  1:56   ` Wei Chen
2022-08-15 15:28   ` Bertrand Marquis
2022-08-12 19:24 ` [PATCH 5/7] xen/arm32: head: Move earlyprintk messages to .rodata.str Julien Grall
2022-08-15  1:57   ` Jiamei Xie
2022-08-15  2:05   ` Wei Chen
2022-08-15  6:43   ` Jan Beulich
2022-08-15  8:17     ` Julien Grall
2022-08-15  8:21       ` Jan Beulich
2022-08-15 16:46         ` Julien Grall
2022-08-15 16:26   ` Bertrand Marquis
2022-08-12 19:24 ` [PATCH 6/7] xen/arm: Tweak the dump page-table walk output Julien Grall
2022-08-15  1:32   ` Henry Wang
2022-08-15 16:12   ` Bertrand Marquis
2022-08-12 19:24 ` [PATCH 7/8] patch arm32-tweak-enable-mmu.patch Julien Grall
2022-08-12 19:24 ` [PATCH 7/7] xen/arm32: traps: Dump more information for hypervisor data abort Julien Grall
2022-08-15  1:40   ` Henry Wang
2022-08-15 16:47     ` Julien Grall
2022-08-16  3:29       ` Henry Wang
2022-08-31 19:12         ` Julien Grall
2022-08-15 16:39   ` Bertrand Marquis
2022-08-15 17:04     ` Julien Grall
2022-08-16  7:28       ` Bertrand Marquis
2022-08-31 19:17         ` Julien Grall
2022-08-12 19:24 ` [PATCH 8/8] " Julien Grall
2022-08-15 16:48   ` Julien Grall

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3136c797-652b-97c9-b356-b49fe53a40b5@xen.org \
    --to=julien@xen.org \
    --cc=Bertrand.Marquis@arm.com \
    --cc=Volodymyr_Babchuk@epam.com \
    --cc=jgrall@amazon.com \
    --cc=sstabellini@kernel.org \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.