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

Re: [Xen-devel] [PATCH v3 26/28] xen/arm64: head: Use a page mapping for the 1:1 mapping in create_page_tables()



Hi Stefano,

On 8/24/19 2:16 AM, Stefano Stabellini wrote:
On Mon, 12 Aug 2019, Julien Grall wrote:
          lsr   x2, x19, #THIRD_SHIFT  /* Base address for 4K mapping */
          lsl   x2, x2, #THIRD_SHIFT
@@ -674,21 +591,80 @@ create_page_tables:
          cmp   x1, #(LPAE_ENTRIES<<3) /* 512 entries per page */
          b.lt  1b

Why can't we use create_mapping_entry here?

If we re-use create_mapping_entry, then we will compute everything at each loop.

At the moment, the loop execute 3 instructions (excluding the branch and comparison). We would end up to have an extra 5 instructions for arm64 (9 instruction for arm32).

At the moment, we iterate 512 times the loop, so this adds 2560 instructions (resp. 4608) in the boot code. Long-term plan, we will want to increase the Xen mapping to 4MB (so you double up the number iteration).

This is a less than ideal solution. I haven't come up with a clever solution so far, hence why it is left alone.



-        /* Defer fixmap and dtb mapping until after paging enabled, to
-         * avoid them clashing with the 1:1 mapping. */
+        /*
+         * If Xen is loaded at exactly XEN_VIRT_START then we don't
+         * need an additional 1:1 mapping, the virtual mapping will
+         * suffice.
+         */
+        cmp   x19, #XEN_VIRT_START
+        bne   1f
+        ret
+1:
+        /*
+         * Only the first page of Xen will be part of the 1:1 mapping.
+         * All the boot_*_id tables are linked together even if they may
+         * not be all used. They will then be linked to the boot page
+         * tables at the correct level.
+         */
+        create_table_entry boot_first_id, boot_second_id, x19, FIRST_SHIFT, 
x0, x1, x2
+        create_table_entry boot_second_id, boot_third_id, x19, SECOND_SHIFT, 
x0, x1, x2

If I understood the code right, it is not actually required to link
boot_first_id -> boot_second_id and/or boot_second_id -> boot_third_id:
it depends on whether x19 clashes with XEN_FIRST_SLOT, XEN_SECOND_SLOT,
etc. Do you think it would be possible without making the code complex
to only call create_table_entry boot_first_id, boot_second_id and
create_table_entry boot_second_id, boot_third_id when required?  So
moving the calls below after the relevant checks? It looks like it could
be done by adding those calls before "ret". I wouldn't mind if they are
duplicated but we could avoid it by adding appropriate labels and having
a single return path:

out1:
   create_table_entry boot_first_id, boot_second_id, x19, FIRST_SHIFT, x0, x1, 
x2
out2:
   create_table_entry boot_second_id, boot_third_id, x19, SECOND_SHIFT, x0, x1, 
x2
out3:
   ret

I have implemented something similar. I will send it as part of the next version in a bit.

Cheers,

--
Julien Grall

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

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