From: Julien Grall <julien.grall@arm.com>
To: Stefano Stabellini <sstabellini@kernel.org>
Cc: andre.przywara@arm.com, nd@arm.com, xen-devel@lists.xen.org
Subject: Re: [PATCH v2 22/24] xen/arm: mm: Embed permission in the flags
Date: Wed, 20 Sep 2017 23:13:16 +0100 [thread overview]
Message-ID: <b0fcf0a9-ada4-f522-b15d-7d9f7051f875@arm.com> (raw)
In-Reply-To: <alpine.DEB.2.10.1709201403530.2968@sstabellini-ThinkPad-X260>
On 20/09/2017 22:07, Stefano Stabellini wrote:
> On Wed, 20 Sep 2017, Julien Grall wrote:
>> Hi,
>>
>> On 20/09/17 00:59, Stefano Stabellini wrote:
>>> On Tue, 12 Sep 2017, Julien Grall wrote:
>>>> Currently, it is not possible to specify the permission of a new
>>>> mapping. It would be necessary to use the function modify_xen_mappings
>>>> with a different set of flags.
>>>>
>>>> Introduce a couple of new flags for the permissions (Non-eXecutable,
>>>> Read-Only) and also provides definition that combine the memory attribute
>>>> and permission for common combinations.
>>>>
>>>> PAGE_HYPERVISOR is now an alias to PAGE_HYPERVISOR_RW (read-write,
>>>> non-executable mappings). This does not affect the current mapping using
>>>> PAGE_HYPERVISOR because Xen is currently forcing all the mapping to be
>>>> non-executable by default (see mfn_to_xen_entry).
>>>>
>>>> A follow-up patch will change modify_xen_mappings to use the new flags.
>>>>
>>>> Signed-off-by: Julien Grall <julien.grall@arm.com>
>>>>
>>>> ---
>>>>
>>>> Changes in v2:
>>>> - Update the commit message
>>>> ---
>>>> xen/include/asm-arm/page.h | 22 +++++++++++++++++++---
>>>> 1 file changed, 19 insertions(+), 3 deletions(-)
>>>>
>>>> diff --git a/xen/include/asm-arm/page.h b/xen/include/asm-arm/page.h
>>>> index 4022b7dc33..814ed126ec 100644
>>>> --- a/xen/include/asm-arm/page.h
>>>> +++ b/xen/include/asm-arm/page.h
>>>> @@ -66,12 +66,28 @@
>>>> * Layout of the flags used for updating the hypervisor page tables
>>>> *
>>>> * [0:2] Memory Attribute Index
>>>> + * [3:4] Permission flags
>>>> */
>>>> #define PAGE_AI_MASK(x) ((x) & 0x7U)
>>>> -#define PAGE_HYPERVISOR (MT_NORMAL)
>>>> -#define PAGE_HYPERVISOR_NOCACHE (MT_DEVICE_nGnRE)
>>>> -#define PAGE_HYPERVISOR_WC (MT_NORMAL_NC)
>>>> +#define _PAGE_XN_BIT 3
>>>> +#define _PAGE_RO_BIT 4
>>>> +#define _PAGE_XN (1U << _PAGE_XN_BIT)
>>>> +#define _PAGE_RO (1U << _PAGE_RO_BIT)
>>>> +#define PAGE_XN_MASK(x) (((x) >> _PAGE_XN_BIT) & 0x1U)
>>>> +#define PAGE_RO_MASK(x) (((x) >> _PAGE_RO_BIT) & 0x1U)
>>>> +
>>>> +/* Device memory will always be mapped read-write non-executable. */
>>>> +#define _PAGE_DEVICE _PAGE_XN
>>>> +#define _PAGE_NORMAL MT_NORMAL
>>>
>>> I think I understand the intent behind these two definitions, but I find
>>> them more confusing then useful. Specifically, I find confusing that
>>> _PAGE_DEVICE specifies permissions but not memory attributes, while
>>> _PAGE_NORMAL specifies memory attributes but not permissions.
>>
>> Well, it is just contain the common bits for normal memory and device memory.
>> They are not related and are not meant to be used outside of this file except
>> for very specific use case.
>
> Yes, I think that is key. More below.
>
>
>> Such as you want to introduce a new device type
>> and you want to default attributes. Hence the prefixed underscore.
>>
>> Furthermore, it is much easier to reason with _PAGE_DEVICE rather than
>> _PAGE_XN. At least you have one place explaining why the mapping is
>> non-executable. And also it also extending default attribute more easily.
>
> If they are not mean to be used outside of this file, then I am fine with
> them. But please write it in the comment explicitly on top for them.
>
> Something like:
>
> * Convenience #defines to build the PAGE_HYPERVISOR* defines below. Not
> * meant to be used outside of this file.
I will add that.
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-09-20 22:13 UTC|newest]
Thread overview: 72+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-12 10:03 [PATCH v2 00/24] xen/arm: Memory subsystem clean-up Julien Grall
2017-09-12 10:03 ` [PATCH v2 01/24] xen/x86: mm: Introduce {G, M}FN <-> {G, M}ADDR helpers Julien Grall
2017-09-12 10:14 ` Andrew Cooper
2017-09-12 10:29 ` Wei Liu
2017-09-12 10:03 ` [PATCH v2 02/24] xen/mm: Use typesafe MFN for alloc_boot_pages return Julien Grall
2017-09-12 10:27 ` Jan Beulich
2017-09-12 10:29 ` Wei Liu
2017-09-12 14:19 ` George Dunlap
2017-09-15 23:33 ` Stefano Stabellini
2017-09-12 10:03 ` [PATCH v2 03/24] xen/mm: Use __virt_to_mfn in map_domain_page instead of virt_to_mfn Julien Grall
2017-09-12 10:29 ` Wei Liu
2017-09-15 23:39 ` Stefano Stabellini
2017-09-12 10:03 ` [PATCH v2 04/24] xen/arm: mm: Redefine mfn_to_virt to use typesafe Julien Grall
2017-09-15 23:56 ` Stefano Stabellini
2017-09-16 9:27 ` Julien Grall
2017-09-19 22:58 ` Stefano Stabellini
2017-09-12 10:03 ` [PATCH v2 05/24] xen/arm: hsr_iabt: Document RES0 field Julien Grall
2017-09-15 23:43 ` Stefano Stabellini
2017-09-15 23:45 ` [PATCH v2 06/24] xen/arm: traps: Don't define FAR_EL2 for ARM32 Stefano Stabellini
2017-09-12 10:03 ` Julien Grall
2017-09-12 10:03 ` [PATCH v2 07/24] xen/arm: arm32: Don't define FAR_EL1 Julien Grall
2017-09-15 23:51 ` Stefano Stabellini
2017-09-12 10:03 ` [PATCH v2 08/24] xen/arm: Add FnV field in hsr_*abt Julien Grall
2017-09-15 23:58 ` Stefano Stabellini
2017-09-12 10:03 ` [PATCH v2 09/24] xen/arm: Introduce hsr_xabt to gather common bits between hsr_dabt and Julien Grall
2017-09-12 15:01 ` Julien Grall
2017-09-16 0:04 ` Stefano Stabellini
2017-09-12 10:03 ` [PATCH v2 10/24] xen/arm: traps: Introduce a helper to read the hypersivor fault register Julien Grall
2017-09-16 0:08 ` Stefano Stabellini
2017-09-12 10:03 ` [PATCH v2 11/24] xen/arm: traps: Improve logging for data/prefetch abort fault Julien Grall
2017-09-16 0:15 ` Stefano Stabellini
2017-09-12 10:03 ` [PATCH v2 12/24] xen/arm: Replace ioremap_attr(PAGE_HYPERVISOR_NOCACHE) call by ioremap_nocache Julien Grall
2017-09-16 0:17 ` Stefano Stabellini
2017-09-12 10:03 ` [PATCH v2 13/24] xen/arm: page: Remove unused attributes DEV_NONSHARED and DEV_CACHED Julien Grall
2017-09-19 23:32 ` Stefano Stabellini
2017-09-20 17:55 ` Julien Grall
2017-09-12 10:03 ` [PATCH v2 14/24] xen/arm: page: Use directly BUFFERABLE and drop DEV_WC Julien Grall
2017-09-19 23:33 ` Stefano Stabellini
2017-09-20 17:56 ` Julien Grall
2017-09-12 10:03 ` [PATCH v2 15/24] xen/arm: page: Prefix memory types with MT_ Julien Grall
2017-09-16 0:29 ` Stefano Stabellini
2017-09-12 10:03 ` [PATCH v2 16/24] xen/arm: page: Use ARMv8 naming to improve readability Julien Grall
2017-09-19 23:45 ` Stefano Stabellini
2017-09-21 15:17 ` Julien Grall
2017-09-21 15:46 ` Stefano Stabellini
2017-09-21 15:52 ` Andre Przywara
2017-09-21 16:37 ` Julien Grall
2017-09-12 10:03 ` [PATCH v2 17/24] xen/arm: page: Clean-up the definition of MAIRVAL Julien Grall
2017-09-19 23:51 ` Stefano Stabellini
2017-09-20 17:57 ` Julien Grall
2017-09-20 21:03 ` Stefano Stabellini
2017-09-20 22:11 ` Julien Grall
2017-09-12 10:03 ` [PATCH v2 18/24] xen/arm: mm: Rename and clarify AP[1] in the stage-1 page table Julien Grall
2017-09-19 23:01 ` Stefano Stabellini
2017-09-12 10:03 ` [PATCH v2 19/24] xen/arm: Switch to SYS_STATE_boot just after end_boot_allocator() Julien Grall
2017-09-19 23:02 ` Stefano Stabellini
2017-09-12 10:03 ` [PATCH v2 20/24] xen/arm: mm: Rename 'ai' into 'flags' in create_xen_entries Julien Grall
2017-09-19 23:10 ` Stefano Stabellini
2017-09-12 10:03 ` [PATCH v2 21/24] xen/arm: page: Describe the layout of flags used to update page tables Julien Grall
2017-09-19 23:11 ` Stefano Stabellini
2017-09-12 10:03 ` [PATCH v2 22/24] xen/arm: mm: Embed permission in the flags Julien Grall
2017-09-19 23:59 ` Stefano Stabellini
2017-09-20 18:03 ` Julien Grall
2017-09-20 21:07 ` Stefano Stabellini
2017-09-20 22:13 ` Julien Grall [this message]
2017-09-12 10:03 ` [PATCH v2 23/24] xen/arm: mm: Handle permission flags when adding a new mapping Julien Grall
2017-09-19 23:17 ` Stefano Stabellini
2017-10-02 13:30 ` Julien Grall
2017-09-12 10:03 ` [PATCH v2 24/24] xen/arm: mm: Use memory flags for modify_xen_mappings rather than custom one Julien Grall
2017-09-20 0:02 ` Stefano Stabellini
2017-09-20 0:29 ` [PATCH v2 00/24] xen/arm: Memory subsystem clean-up Stefano Stabellini
2017-09-20 21:12 ` Stefano Stabellini
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=b0fcf0a9-ada4-f522-b15d-7d9f7051f875@arm.com \
--to=julien.grall@arm.com \
--cc=andre.przywara@arm.com \
--cc=nd@arm.com \
--cc=sstabellini@kernel.org \
--cc=xen-devel@lists.xen.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).