All of lore.kernel.org
 help / color / mirror / Atom feed
From: Julien Grall <julien.grall@arm.com>
To: Stefano Stabellini <sstabellini@kernel.org>
Cc: xen-devel@lists.xenproject.org,
	Volodymyr Babchuk <Volodymyr_Babchuk@epam.com>
Subject: Re: [Xen-devel] [[PATCH for-4.13]] xen/arm: mm: Allow generic xen page-tables helpers to be called early
Date: Wed, 2 Oct 2019 18:49:06 +0100	[thread overview]
Message-ID: <2148a78c-633a-bf2e-acd1-ace9f8e62e1a@arm.com> (raw)
In-Reply-To: <72de38de-2856-8873-ed70-6c354786bba3@arm.com>

Hi,

Gentle ping.

Cheers,

On 9/20/19 4:26 PM, Julien Grall wrote:
> Hi,
> 
> On 20/09/2019 16:16, Stefano Stabellini wrote:
>> On Fri, 20 Sep 2019, Julien Grall wrote:
>>> On 20/09/2019 00:37, Stefano Stabellini wrote:
>>>> On Tue, 17 Sep 2019, Julien Grall wrote:
>>>>> The current implementations of xen_{map, unmap}_table() expect
>>>>> {map, unmap}_domain_page() to be usable. Those helpers are used to
>>>>> map/unmap page tables while update Xen page-tables.
>>>>>
>>>>> Since commit 022387ee1a "xen/arm: mm: Don't open-code Xen PT update in
>>>>> {set, clear}_fixmap()", setup_fixmap() will make use of the helpers
>>>>> mentioned above. When booting Xen using GRUB, setup_fixmap() may be 
>>>>> used
>>>>> before map_domain_page() can be called. This will result to data 
>>>>> abort:
>>>>>
>>>>> (XEN) Data Abort Trap. Syndrome=0x5
>>>>> (XEN) CPU0: Unexpected Trap: Data Abort
>>>>>
>>>>> [...]
>>>>>
>>>>> (XEN) Xen call trace:
>>>>> (XEN)    [<000000000025ab6c>] mm.c#xen_pt_update+0x2b4/0x59c (PC)
>>>>> (XEN)    [<000000000025ab20>] mm.c#xen_pt_update+0x268/0x59c (LR)
>>>>> (XEN)    [<000000000025ae70>] set_fixmap+0x1c/0x2c
>>>>> (XEN)    [<00000000002a9c98>] copy_from_paddr+0x7c/0xdc
>>>>> (XEN)    [<00000000002a4ae0>] has_xsm_magic+0x18/0x34
>>>>> (XEN)    [<00000000002a5b5c>] bootfdt.c#early_scan_node+0x398/0x560
>>>>> (XEN)    [<00000000002a5de0>] device_tree_for_each_node+0xbc/0x144
>>>>> (XEN)    [<00000000002a5ed4>] boot_fdt_info+0x6c/0x260
>>>>> (XEN)    [<00000000002ac0d0>] start_xen+0x108/0xc74
>>>>> (XEN)    [<000000000020044c>] arm64/head.o#paging+0x60/0x88
>>>>>
>>>>> During early boot, the page tables are either statically allocated in
>>>>> Xen binary or allocated via alloc_boot_pages().
>>>>>
>>>>> For statically allocated page-tables, they will already be mapped as
>>>>> part of Xen binary. So we can easily find the virtual address.
>>>>>
>>>>> For dynamically allocated page-tables, we need to rely
>>>>> map_domain_page() to be functionally working.
>>>>>
>>>>> For arm32, the call will be usable much before page can be dynamically
>>>>> allocated (see setup_pagetables()). For arm64, the call will be usable
>>>>> after setup_xenheap_mappings().
>>>>>
>>>>> In both cases, memory are given to the boot allocator afterwards. 
>>>>> So we
>>>>> can rely on map_domain_page() for mapping page tables allocated
>>>>> dynamically.
>>>>>
>>>>> The helpers xen_{map, unmap}_table() are now updated to take into
>>>>> account the case where page-tables are part of Xen binary.
>>>>>
>>>>> Fixes: 022387ee1a ('xen/arm: mm: Don't open-code Xen PT update in 
>>>>> {set,
>>>>> clear}_fixmap()')
>>>>> Signed-off-by: Julien Grall <julien.grall@arm.com>
>>>>> ---
>>>>>    xen/arch/arm/mm.c | 20 ++++++++++++++++++++
>>>>>    1 file changed, 20 insertions(+)
>>>>>
>>>>> diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c
>>>>> index e1cdeaaf2f..da6303a8fd 100644
>>>>> --- a/xen/arch/arm/mm.c
>>>>> +++ b/xen/arch/arm/mm.c
>>>>> @@ -950,11 +950,31 @@ static int create_xen_table(lpae_t *entry)
>>>>>      static lpae_t *xen_map_table(mfn_t mfn)
>>>>>    {
>>>>> +    /*
>>>>> +     * We may require to map the page table before 
>>>>> map_domain_page() is
>>>>> +     * useable. The requirements here is it must be useable as 
>>>>> soon as
>>>>> +     * page-tables are allocated dynamically via alloc_boot_pages().
>>>>> +     */
>>>>> +    if ( system_state == SYS_STATE_early_boot )
>>>>> +    {
>>>>> +        vaddr_t va = mfn_to_maddr(mfn) - phys_offset;
>>>>> +
>>>>> +        if ( is_kernel(va) )
>>>>> +            return (lpae_t *)va;
>>>>
>>>> Is it intended to continue if it is not a xen text page? Shouldn't we
>>>> BUG() or WARN?
>>> Yes, I wrote the rationale in the commit message and a summary in a 
>>> few lines
>>> above. For convenience, I pasted the commit message again here:
>> The commit message explains what you are doing but I am still missing
>> something.
>>
>> Why are we continuing if system_state == SYS_STATE_early_boot and
>> !is_kernel(va)?
>>
>> The commit message explains that if system_state == SYS_STATE_early_boot
>> pagetable pages are static, right? 
> That's not correct. Below an excerpt of the commit message:
> 
> "During early boot, the page tables are either statically allocated in
> Xen binary or allocated via alloc_boot_pages()."
> 
> An example of dynamic allocation happening when system_state == 
> SYS_STATE_early_boot is in setup_xenheap_mappings(). alloc_boot_pages() 
> will be used to allocate intermediate page-tables as the runtime 
> allocator is not yet ready.
> 
>> Only after dynamic allocation are
>> possible it makes sense to use map_domain_page, and dynamic allocations
>> are possible roughly when system_state switched to SYS_STATE_boot.
> 
> That's not correct. alloc_boot_pages() is actually here to allow dynamic 
> allocation before the memory subsystem (and therefore the runtime 
> allocator) is initialized.
> 
> Half of the commit message actually explain when dynamic allocation can 
> be used. I am not entirely sure what is unclear in it so please suggest 
> a different commit message.
> 
> Cheers,
> 

-- 
Julien Grall

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

  reply	other threads:[~2019-10-02 17:49 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-17 16:02 [Xen-devel] [[PATCH for-4.13]] xen/arm: mm: Allow generic xen page-tables helpers to be called early Julien Grall
2019-09-19 23:37 ` Stefano Stabellini
2019-09-20  9:44   ` Julien Grall
2019-09-20 15:16     ` Stefano Stabellini
2019-09-20 15:26       ` Julien Grall
2019-10-02 17:49         ` Julien Grall [this message]
2019-10-03  1:02         ` Stefano Stabellini
2019-10-07 20:35           ` Julien Grall
2019-10-08  0:18             ` Stefano Stabellini
2019-10-08 14:02               ` Julien Grall
2019-10-08 22:24                 ` Stefano Stabellini
2019-10-10 16:56                   ` Julien Grall
2019-10-11  0:32                     ` Stefano Stabellini
2019-10-11 10:14                       ` Julien Grall
2019-10-11 17:11                         ` Stefano Stabellini
2019-10-11 17:51                           ` Julien Grall
2019-10-11 19:01                             ` Stefano Stabellini
2019-10-11 19:14                               ` Julien Grall
2019-09-25 15:23 ` Julien Grall
2019-09-25 15:27   ` Jürgen Groß
2019-10-11  9:53 ` Xia, Hongyan
2019-10-16 12:46   ` Julien Grall
2019-10-16 13:16     ` Xia, Hongyan
2019-10-10 17:52 [Xen-devel] [PATCH for-4.13] " Julien Grall
2019-10-11  0:27 ` Stefano Stabellini
2019-10-11 13:06   ` Julien Grall
2019-10-11 13:33   ` 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=2148a78c-633a-bf2e-acd1-ace9f8e62e1a@arm.com \
    --to=julien.grall@arm.com \
    --cc=Volodymyr_Babchuk@epam.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.