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
Subject: Re: [PATCH 11/15] xen/arm: Allow lpae_is_{table, mapping} helpers to work on invalid entry
Date: Thu, 16 Aug 2018 09:51:58 +0100	[thread overview]
Message-ID: <2bf9700f-78ce-003b-33e4-836a540922bc@arm.com> (raw)
In-Reply-To: <alpine.DEB.2.10.1808151212130.15066@sstabellini-ThinkPad-X260>

Hi,

On 08/15/2018 08:13 PM, Stefano Stabellini wrote:
> On Tue, 14 Aug 2018, Julien Grall wrote:
>> Hi Stefano,
>>
>> On 08/14/2018 10:33 PM, Stefano Stabellini wrote:
>>> On Mon, 16 Jul 2018, Julien Grall wrote:
>>>> Currently, lpae_is_{table, mapping} helpers will always return false on
>>>> entry with the valid bit unset. However, it would be useful to have them
>>>     ^entries
>>>
>>>> operating on any entry. For instance to store information in advance but
>>>> still request a fault.
>>>>
>>>> With that change, the p2m is now providing an overlay for *_is_{table,
>>>> mapping} that will check the valid bit of the entry.
>>>>
>>>> Signed-off-by: Julien Grall <julien.grall@arm.com>
>>>>
>>>> ---
>>>>    xen/arch/arm/guest_walk.c  |  2 +-
>>>>    xen/arch/arm/mm.c          |  2 +-
>>>>    xen/arch/arm/p2m.c         | 22 ++++++++++++++++++----
>>>>    xen/include/asm-arm/lpae.h | 11 +++++++----
>>>>    4 files changed, 27 insertions(+), 10 deletions(-)
>>>>
>>>> diff --git a/xen/arch/arm/guest_walk.c b/xen/arch/arm/guest_walk.c
>>>> index e3e21bdad3..4a1b4cf2c8 100644
>>>> --- a/xen/arch/arm/guest_walk.c
>>>> +++ b/xen/arch/arm/guest_walk.c
>>>> @@ -566,7 +566,7 @@ static int guest_walk_ld(const struct vcpu *v,
>>>>         * PTE is invalid or holds a reserved entry (PTE<1:0> == x0)) or if
>>>> the PTE
>>>>         * maps a memory block at level 3 (PTE<1:0> == 01).
>>>>         */
>>>> -    if ( !lpae_is_mapping(pte, level) )
>>>> +    if ( !lpae_is_valid(pte) || !lpae_is_mapping(pte, level) )
>>>>            return -EFAULT;
>>>>          /* Make sure that the lower bits of the PTE's base address are
>>>> zero. */
>>>> diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c
>>>> index e3dafe5fd7..52e57fef2f 100644
>>>> --- a/xen/arch/arm/mm.c
>>>> +++ b/xen/arch/arm/mm.c
>>>> @@ -996,7 +996,7 @@ static int create_xen_entries(enum xenmap_operation
>>>> op,
>>>>        for(; addr < addr_end; addr += PAGE_SIZE, mfn = mfn_add(mfn, 1))
>>>>        {
>>>>            entry = &xen_second[second_linear_offset(addr)];
>>>> -        if ( !lpae_is_table(*entry, 2) )
>>>> +        if ( !lpae_is_valid(*entry) || !lpae_is_table(*entry, 2) )
>>>>            {
>>>>                rc = create_xen_table(entry);
>>>>                if ( rc < 0 ) {
>>>> diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c
>>>> index ec3fdcb554..07925a1be4 100644
>>>> --- a/xen/arch/arm/p2m.c
>>>> +++ b/xen/arch/arm/p2m.c
>>>> @@ -219,6 +219,20 @@ static p2m_access_t p2m_mem_access_radix_get(struct
>>>> p2m_domain *p2m, gfn_t gfn)
>>>>            return radix_tree_ptr_to_int(ptr);
>>>>    }
>>>>    +/*
>>>> + * lpae_is_* helpers don't check whether the valid bit is set in the
>>>> + * PTE. Provide our own overlay to check the valid bit.
>>>> + */
>>>> +static inline bool p2m_is_mapping(lpae_t pte, unsigned int level)
>>>> +{
>>>> +    return lpae_is_valid(pte) && lpae_is_mapping(pte, level);
>>>> +}
>>>> +
>>>> +static inline bool p2m_is_superpage(lpae_t pte, unsigned int level)
>>>> +{
>>>> +    return lpae_is_valid(pte) && lpae_is_superpage(pte, level);
>>>> +}
>>>
>>> I like the idea, but it would be clearer to me if they were called
>>> lpae_is_valid_mapping and lpae_is_valid_superpage respectively. What do
>>> you think?
>>>   > Also, we might as well move them to lpae.h and use them from mm.c and
>>> guest_walk.c as appropriate?
>>
>> lpae.h is not suitable because as I said in the commit message each page-table
>> (stage-1, stage-2) may have a different view of what "valid" means.
>>
>> At the moment, that view is the same but it is not going to stay long like
>> that. Hence the reason of prefixing with p2m_. They are specific to the p2m.
>> This is giving us some more liberty in the future while making the lpae code a
>> bit more generic.
>>
>> In guest_walk.c there are only one user, so the introduction of an helper is
>> quite limited there.
> 
> I see, so by "p2m_is_mapping" you meant specifically
> "stage2_is_mapping", right? That makes sense now.

Yes. We use the term "p2m" everywhere in Xen to refer to stage-2 
page-tables (see lpae_p2m_t). So it makes sense to prefix the helpers 
with "p2m_" here.

Cheers,

-- 
Julien Grall

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

  reply	other threads:[~2018-08-16  8:52 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-16 17:26 [PATCH 00/15] xen/arm: Bunch of clean-up/improvement Julien Grall
2018-07-16 17:26 ` [PATCH 01/15] xen/arm: cpregs: Allow HSR_CPREG* to receive more than 1 parameter Julien Grall
2018-08-14 21:47   ` Stefano Stabellini
2018-07-16 17:26 ` [PATCH 02/15] xen/arm: cpregs: Fix typo in the documentation of TTBCR Julien Grall
2018-08-14 20:39   ` Stefano Stabellini
2018-07-16 17:27 ` [PATCH 03/15] xen/arm: Introduce helpers to clear/flags flags in HCR_EL2 Julien Grall
2018-08-14 20:46   ` Stefano Stabellini
2018-08-14 21:23     ` Julien Grall
2018-08-14 21:49       ` Stefano Stabellini
2018-08-14 22:53         ` Julien Grall
2018-08-14 23:03           ` Stefano Stabellini
2018-07-16 17:27 ` [PATCH 04/15] xen/arm: p2m: Reduce the locking section in get_page_from_gva Julien Grall
2018-08-14 20:49   ` Stefano Stabellini
2018-07-16 17:27 ` [PATCH 05/15] xen/arm: p2m: Limit call to mem access code use " Julien Grall
2018-07-17  9:54   ` Razvan Cojocaru
2018-08-14 20:59   ` Stefano Stabellini
2018-07-16 17:27 ` [PATCH 06/15] xen/arm: Rework lpae_mapping Julien Grall
2018-08-14 21:04   ` Stefano Stabellini
2018-07-16 17:27 ` [PATCH 07/15] xen/arm: Rework lpae_table Julien Grall
2018-08-14 21:07   ` Stefano Stabellini
2018-07-16 17:27 ` [PATCH 08/15] xen/arm: Rename lpae_valid to lpae_is_valid Julien Grall
2018-08-14 21:09   ` Stefano Stabellini
2018-07-16 17:27 ` [PATCH 09/15] xen/arm: guest_walk: Use lpae_is_mapping to simplify the code Julien Grall
2018-08-14 21:14   ` Stefano Stabellini
2018-07-16 17:27 ` [PATCH 10/15] xen/arm: Introduce helpers to get/set an MFN from/to an LPAE entry Julien Grall
2018-08-14 21:25   ` Stefano Stabellini
2018-07-16 17:27 ` [PATCH 11/15] xen/arm: Allow lpae_is_{table, mapping} helpers to work on invalid entry Julien Grall
2018-08-14 21:33   ` Stefano Stabellini
2018-08-14 22:51     ` Julien Grall
2018-08-15 19:13       ` Stefano Stabellini
2018-08-16  8:51         ` Julien Grall [this message]
2018-07-16 17:27 ` [PATCH 12/15] xen/arm: p2m: Rename ret to mfn in p2m_lookup Julien Grall
2018-08-14 21:35   ` Stefano Stabellini
2018-07-16 17:27 ` [PATCH 13/15] xen/arm: p2m: Introduce a new variable removing_mapping in __p2m_set_entry Julien Grall
2018-08-14 21:37   ` Stefano Stabellini
2018-07-16 17:27 ` [PATCH 14/15] xen/arm: guest_walk_tables: Switch the return to bool Julien Grall
2018-08-14 21:41   ` Stefano Stabellini
2018-07-16 17:27 ` [PATCH 15/15] xen/arm: traps: Move the implementation of GUEST_BUG_ON in traps.h Julien Grall
2018-08-14 21:43   ` Stefano Stabellini
2018-08-16  8:54     ` Julien Grall
2018-08-16 18:17       ` Stefano Stabellini
2018-08-20  9:17         ` Julien Grall
2018-08-20 22:02           ` Stefano Stabellini
2018-07-23 17:12 ` [PATCH 00/15] xen/arm: Bunch of clean-up/improvement Julien Grall
2018-08-22 15:45 ` 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=2bf9700f-78ce-003b-33e4-836a540922bc@arm.com \
    --to=julien.grall@arm.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.