From: Julien Grall <julien.grall@arm.com>
To: Sergej Proskurin <proskurin@sec.in.tum.de>,
xen-devel@lists.xenproject.org
Cc: Stefano Stabellini <sstabellini@kernel.org>
Subject: Re: [PATCH v4 7/9] arm/mem_access: Add long-descriptor based gpt
Date: Fri, 23 Jun 2017 15:35:40 +0100 [thread overview]
Message-ID: <b98409be-91d1-f504-77cd-4b17a1a7d087@arm.com> (raw)
In-Reply-To: <526a3a7d-cec5-6005-ab20-3a33bdef489e@sec.in.tum.de>
On 23/06/17 15:23, Sergej Proskurin wrote:
> Hi Julien,
>
> [...]
>
>>> +static bool get_ttbr_and_gran_64bit(uint64_t *ttbr, unsigned int *gran,
>>> + register_t tcr, enum active_ttbr
>>> ttbrx)
>>> +{
>>> + bool disabled;
>>> +
>>> + if ( ttbrx == TTBR0_ACTIVE )
>>> + {
>>> + /* Normalize granule size. */
>>> + switch ( tcr & TCR_TG0_MASK )
>>> + {
>>> + case TCR_TG0_16K:
>>> + *gran = GRANULE_SIZE_INDEX_16K;
>>> + break;
>>> + case TCR_TG0_64K:
>>> + *gran = GRANULE_SIZE_INDEX_64K;
>>> + break;
>>> + default:
>>
>> Please explain why you use 4K by default.
>>
>
> Fair question. According to ARM DDI 0487B.a D7-2487, if the
> TCR_EL1.{TG0|TG1} holds a reserved value, it is implementation defined
> how the value is interpreted by the underlying hardware. My
> implementation in v4 strongly followed the pseudo-code in ARM DDI
> 0487B.a, which suggested to use fall back to 4K by default.
>
> However, agree with you at this point. My next patch series explicitly
> checks if 4K has to be set or not and returns an error on reserved
> values as we cannot be know how the hardware behaves on reserved values.
No. You should not return an error here as you would not be compliant
with the ARM ARM. I just asked to add a comment explain why you choose
4K, even if it says "We follow the pseudo-code".
>
> [...]
>
>>> +
>>> + /*
>>> + * According to to ARM DDI 0487B.a J1-5927, we return an error if
>>> the found
>>> + * 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_valid(pte) || ((level == 3) && lpae_mapping(pte)) )
>>
>> If you look at the comment on top of lpae_mapping, it should only be
>> used for L0..L2 ptes. So why are you using it on L3 ptes?
>>
>
> Yes, I saw the comment. Yet, I would like to check exactly for this
> mapping. If the mapping would as in the check above, it would be an
> error, which is treated accordingly. In v3, you have suggested to look
> at the the lpae_is_superpage macro, which, in my opinion, is not the
> right construct to use at this point. If you should not like this check,
> I could fall back to my previous implementation:
>
> if ( !p2m_valid(pte) || ((level == 3) && !p2m_table(pte)) )
> return -EFAULT;
If you look at the ARM ARM (D4.3.1 and D4.3.2 in DDI0487B.a)
* level 0,1,2 will have bit 1 set for table and cleared for mapping.
* level 3 will have bit 1 set for mapping
If you use p2m_table to check it the bit is set, then it mislead
completely the user as this entry is not a table at all.
In any, this is totally wrong to use p2m_table and p2m_mapping here as
it would not report correctly the value. So please don't use an helper
that does not make sense here. You should just open-code it or introduce
a helper (such as lpae_page with appropriate) to properly check the bit.
Cheers,
--
Julien Grall
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
next prev parent reply other threads:[~2017-06-23 14:35 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-20 20:33 [PATCH v4 0/9] arm/mem_access: Walk guest page tables in SW if mem_access is active Sergej Proskurin
2017-06-20 20:33 ` [PATCH v4 1/9] arm/mem_access: Add (TCR_|TTBCR_)* defines Sergej Proskurin
2017-06-22 10:42 ` Julien Grall
2017-06-20 20:33 ` [PATCH v4 2/9] arm/mem_access: Add defines supporting PTs with varying page sizes Sergej Proskurin
2017-06-22 10:52 ` Julien Grall
2017-06-20 20:33 ` [PATCH v4 3/9] arm/mem_access: Add short-descriptor pte typedefs Sergej Proskurin
2017-07-04 16:22 ` Julien Grall
2017-07-04 16:24 ` Julien Grall
2017-06-20 20:33 ` [PATCH v4 4/9] arm/mem_access: Introduce GV2M_EXEC permission Sergej Proskurin
2017-06-20 20:33 ` [PATCH v4 5/9] arm/mem_access: Extend BIT-operations to unsigned long long Sergej Proskurin
2017-06-22 11:13 ` Julien Grall
2017-06-20 20:33 ` [PATCH v4 6/9] arm/mem_access: Add software guest-page-table walk Sergej Proskurin
2017-06-22 11:16 ` Julien Grall
2017-06-22 11:36 ` Sergej Proskurin
2017-06-20 20:33 ` [PATCH v4 7/9] arm/mem_access: Add long-descriptor based gpt Sergej Proskurin
2017-06-22 12:12 ` Julien Grall
2017-06-23 14:23 ` Sergej Proskurin
2017-06-23 14:35 ` Julien Grall [this message]
2017-06-22 13:54 ` Julien Grall
2017-06-20 20:33 ` [PATCH v4 8/9] arm/mem_access: Add short-descriptor " Sergej Proskurin
2017-06-22 13:53 ` Julien Grall
2017-06-23 19:09 ` Sergej Proskurin
2017-06-23 20:46 ` Julien Grall
2017-06-26 7:57 ` Sergej Proskurin
2017-06-20 20:33 ` [PATCH v4 9/9] arm/mem_access: Walk the guest's pt in software Sergej Proskurin
2017-06-20 20:44 ` Tamas K Lengyel
2017-06-20 20:59 ` Sergej Proskurin
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=b98409be-91d1-f504-77cd-4b17a1a7d087@arm.com \
--to=julien.grall@arm.com \
--cc=proskurin@sec.in.tum.de \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).