All of lore.kernel.org
 help / color / mirror / Atom feed
From: Penny Zheng <penny.zheng@arm.com>
To: Ayan Kumar Halder <ayankuma@amd.com>, <xen-devel@lists.xenproject.org>
Cc: Wei Chen <wei.chen@arm.com>,
	Bertrand Marquis <Bertrand.Marquis@arm.com>,
	Henry Wang <Henry.Wang@arm.com>, Julien Grall <julien@xen.org>,
	"Stefano Stabellini" <sstabellini@kernel.org>,
	"Volodymyr_Babchuk@epam.com" <Volodymyr_Babchuk@epam.com>
Subject: Re: [PATCH v3 30/52] xen/mpu: populate a new region in Xen MPU mapping table
Date: Wed, 28 Jun 2023 18:13:50 +0800	[thread overview]
Message-ID: <3f30dbd3-5530-e9d3-eae9-3cb6c3072bbb@arm.com> (raw)
In-Reply-To: <e6f8d79c-ab1e-565d-f87f-843af0cfbf48@amd.com>

Hi Ayan

On 2023/6/28 18:08, Ayan Kumar Halder wrote:
> (Forgot to cc)
> 
> On 28/06/2023 11:05, Ayan Kumar Halder wrote:
>> Hi Penny,
>>
>> On 26/06/2023 04:34, Penny Zheng wrote:
>>> CAUTION: This message has originated from an External Source. Please 
>>> use proper judgment and caution when opening attachments, clicking 
>>> links, or responding to this email.
>>>
>>>
>>> The new helper xen_mpumap_update() is responsible for updating Xen 
>>> MPU memory
>>> mapping table(xen_mpumap), including creating a new entry, updating
>>> or destroying an existing one. It is equivalent to xen_pt_update in MMU.
>>> This commit only talks about populating a new entry in Xen MPU memory 
>>> mapping
>>> table(xen_mpumap). Others will be introduced in the following commits.
>>>
>>> When populating a new entry in Xen MPU memory mapping table(xen_mpumap),
>>> firstly, we shall check if requested address range [base, limit) is 
>>> mapped.
>>> If not, we shall find a free slot in xen_mpumap to insert, based on 
>>> bitmap
>>> xen_mpumap_mask, and use standard entry pr_of_xenaddr() to build up 
>>> MPU memory
>>> region structure(pr_t)
>>> In the last, we set memory attribute and permission based on variable 
>>> @flags.
>>>
>>> To summarize all region attributes in one variable @flags, layout of the
>>> flags is elaborated as follows:
>>> [0:2] Memory attribute Index
>>> [3:4] Execute Never
>>> [5:6] Access Permission
>>> [7]   Region Present
>>> Also, we provide a set of definitions(REGION_HYPERVISOR_RW, etc) that 
>>> combine
>>> the memory attribute and permission for common combinations.
>>>
>>> Signed-off-by: Penny Zheng <penny.zheng@arm.com>
>>> Signed-off-by: Wei Chen <wei.chen@arm.com>
>>> ---
>>> v3:
>>> - implement pr_set_base/pr_set_limit/region_is_valid using static
>>> inline.
>>> - define index uint8_t to limit its size
>>> - stay the same major entry map_pages_to_xen, then go different path
>>> in different context(xen_pt_update in MMU, and xen_mpumap_update in MPU)
>>> ---
>>>   xen/arch/arm/include/asm/arm64/mpu.h |  64 +++++++
>>>   xen/arch/arm/include/asm/mm.h        |   3 +
>>>   xen/arch/arm/include/asm/mpu/mm.h    |  16 ++
>>>   xen/arch/arm/include/asm/page.h      |  22 +++
>>>   xen/arch/arm/mm.c                    |  20 +++
>>>   xen/arch/arm/mmu/mm.c                |   9 +-
>>>   xen/arch/arm/mpu/mm.c                | 255 +++++++++++++++++++++++++++
>>>   7 files changed, 381 insertions(+), 8 deletions(-)
>>>   create mode 100644 xen/arch/arm/include/asm/mpu/mm.h
>>>
>>> diff --git a/xen/arch/arm/include/asm/arm64/mpu.h 
>>> b/xen/arch/arm/include/asm/arm64/mpu.h
>>> index 407fec66c9..a6b07bab02 100644
>>> --- a/xen/arch/arm/include/asm/arm64/mpu.h
>>> +++ b/xen/arch/arm/include/asm/arm64/mpu.h
>>> @@ -6,6 +6,10 @@
>>>   #ifndef __ARM64_MPU_H__
>>>   #define __ARM64_MPU_H__
>>>
>>> +#define MPU_REGION_SHIFT  6
>>
>> You are using this macro in patch 24/52 and you are defining it here.
>>
>> Please consider moving the definition to patch 24/52.
>>

Thanks for pointing out. I'll move.

>>> +#define MPU_REGION_ALIGN  (_AC(1, UL) << MPU_REGION_SHIFT)
>>> +#define MPU_REGION_MASK   (~(MPU_REGION_ALIGN - 1))
>>> +
>>>   /*
>>>    * MPUIR_EL2.Region identifies the number of regions supported by 
>>> the EL2 MPU.
>>>    * It is a 8-bit field, so 255 MPU memory regions at most.
>>> @@ -21,8 +25,33 @@
>>>   #define REGION_UART_SEL            0x07
>>>   #define MPUIR_REGION_MASK          ((_AC(1, UL) << 8) - 1)
>>>
...
>>> +static inline bool region_is_valid(pr_t *pr)
>>> +{
>>> +    return pr->prlar.reg.en;
>>> +}
>>
>> A lot of these macros and inlines can be reused on arm32 as well. I 
>> have split them as follows :-
>>
>> Refer 
>> https://github.com/Xilinx/xen/blob/xlnx_rebase_4.17/xen/arch/arm_mpu/include/asm/armv8r/mpu.h for the common definitions.
>>
>> Refer 
>> https://github.com/Xilinx/xen/blob/xlnx_rebase_4.17/xen/arch/arm_mpu/include/asm/armv8r/arm64/mpu.h for the 64 bit specific definitions
>>
>> Refer 
>> https://github.com/Xilinx/xen/blob/xlnx_rebase_4.17/xen/arch/arm_mpu/include/asm/armv8r/arm32/mpu.h for the 32 bit specific definitions (This I can add later as part of R52 port).
>>
>> Please consider splitting the definitions so that R52 can reuse the 
>> common ones.
>>

Sure. I'll try to split.

>> - Ayan
>>
>>


  reply	other threads:[~2023-06-28 10:14 UTC|newest]

Thread overview: 160+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-26  3:33 [PATCH v3 00/52] xen/arm: Add Armv8-R64 MPU support to Xen - Part#1 Penny Zheng
2023-06-26  3:33 ` [PATCH v3 01/52] xen/arm: remove xen_phys_start and xenheap_phys_end from config.h Penny Zheng
2023-06-26  3:33 ` [PATCH v3 02/52] xen/arm: make ARM_EFI selectable for Arm64 Penny Zheng
2023-06-28  8:05   ` Julien Grall
2023-07-05 11:20   ` [RANDCONFIG failure] " Andrew Cooper
2023-07-05 11:46     ` Julien Grall
2023-07-05 11:58       ` Julien Grall
2023-06-26  3:33 ` [PATCH v3 03/52] xen/arm: add an option to define Xen start address for Armv8-R Penny Zheng
2023-07-04 10:36   ` Ayan Kumar Halder
2023-07-04 11:47     ` Julien Grall
2023-07-04 12:02       ` Ayan Kumar Halder
2023-07-04 12:10         ` Julien Grall
2023-07-06  6:36       ` Penny Zheng
2023-07-04 19:21   ` Julien Grall
2023-07-06  6:38     ` Penny Zheng
2023-06-26  3:33 ` [PATCH v3 04/52] xen/arm: add .text.idmap in ld script for Xen identity map sections Penny Zheng
2023-07-04 19:24   ` Julien Grall
2023-06-26  3:33 ` [PATCH v3 05/52] xen/arm64: head: Introduce enable_boot_mmu and enable_runtime_mmu Penny Zheng
2023-07-04 11:07   ` Ayan Kumar Halder
2023-07-04 21:24   ` Julien Grall
2023-07-05  3:41     ` Penny Zheng
2023-06-26  3:33 ` [PATCH v3 06/52] xen/arm: introduce CONFIG_HAS_MMU Penny Zheng
2023-07-04 11:14   ` Ayan Kumar Halder
2023-07-04 11:44     ` Julien Grall
2023-07-04 12:04       ` Ayan Kumar Halder
2023-07-05  3:55         ` Penny Zheng
2023-06-26  3:33 ` [PATCH v3 07/52] xen/arm64: prepare for moving MMU related code from head.S Penny Zheng
2023-07-04 21:35   ` Julien Grall
2023-07-05  4:07     ` Penny Zheng
2023-06-26  3:33 ` [PATCH v3 08/52] xen/arm64: move MMU related code from head.S to mmu/head.S Penny Zheng
2023-07-04 11:51   ` Ayan Kumar Halder
2023-07-04 21:46   ` Julien Grall
2023-07-05  4:49     ` Penny Zheng
2023-07-05 10:11       ` Julien Grall
2023-07-05 10:43   ` Julien Grall
2023-07-06  6:47     ` Penny Zheng
2023-06-26  3:34 ` [PATCH v3 09/52] xen/arm: use PA == VA for EARLY_UART_VIRTUAL_ADDRESS on MPU systems Penny Zheng
2023-07-04 19:25   ` Julien Grall
2023-07-06  7:05     ` Penny Zheng
2023-06-26  3:34 ` [PATCH v3 10/52] xen/arm: Move MMU related definitions from config.h to mmu/layout.h Penny Zheng
2023-07-04 21:54   ` Julien Grall
2023-07-05  6:51     ` Penny Zheng
2023-07-05 10:30       ` Julien Grall
2023-07-06  7:36         ` Penny Zheng
2023-07-06  8:08           ` Julien Grall
2023-06-26  3:34 ` [PATCH v3 11/52] xen/arm: mmu: fold FIXMAP into MMU system Penny Zheng
2023-07-04 22:12   ` Julien Grall
2023-07-05  8:19     ` Penny Zheng
2023-07-05 10:31       ` Julien Grall
2023-07-06  8:00         ` Penny Zheng
2023-06-26  3:34 ` [PATCH v3 12/52] xen/mmu: extract early uart mapping from setup_fixmap Penny Zheng
2023-07-04 22:25   ` Julien Grall
2023-07-05  9:03     ` Penny Zheng
2023-07-05 10:35       ` Julien Grall
2023-07-06  8:01         ` Penny Zheng
2023-06-26  3:34 ` [PATCH v3 13/52] xen/mmu: extract mmu-specific codes from mm.c/mm.h Penny Zheng
2023-06-26  3:34 ` [PATCH v3 14/52] xen/mmu: move MMU-specific setup_mm to mmu/setup.c Penny Zheng
2023-06-26  3:34 ` [PATCH v3 15/52] xen: make VMAP only support in MMU system Penny Zheng
2023-06-26  6:00   ` Jan Beulich
2023-06-28  5:38     ` Penny Zheng
2023-06-28  7:59       ` Julien Grall
2023-06-28  8:41         ` Penny Zheng
2023-06-28  8:53           ` Julien Grall
2023-07-04 12:21       ` Jan Beulich
2023-06-26  3:34 ` [PATCH v3 16/52] xen/mmu: relocate copy_from_paddr into setup.c Penny Zheng
2023-06-26  3:34 ` [PATCH v3 17/52] xen/arm: do not give memory back to static heap Penny Zheng
2023-06-26  3:34 ` [PATCH v3 18/52] xen/arm: only map the init text section RW in free_init_memory Penny Zheng
2023-06-26  3:34 ` [PATCH v3 19/52] xen/arm: switch to use ioremap_xxx in common file Penny Zheng
2023-06-26  3:34 ` [PATCH v3 20/52] xen/mmu: move MMU specific P2M code to mmu/p2m.c and mmu/p2m.h Penny Zheng
2023-06-26  3:34 ` [PATCH v3 21/52] xen: introduce CONFIG_HAS_PAGING_MEMPOOL Penny Zheng
2023-06-26  7:01   ` Jan Beulich
2023-06-28  5:40     ` Penny Zheng
2023-06-26  3:34 ` [PATCH v3 22/52] xen/mmu: enable SMMU subsystem only in MMU Penny Zheng
2023-06-26  3:34 ` [PATCH v3 23/52] xen/arm: create mpu/layout.h for MPU related address definitions Penny Zheng
2023-06-26  3:34 ` [PATCH v3 24/52] xen/mpu: build up start-of-day Xen MPU memory region map Penny Zheng
2023-06-28 10:55   ` Ayan Kumar Halder
2023-06-28 11:17     ` Julien Grall
2023-06-28 13:22       ` Ayan Kumar Halder
2023-06-28 13:42         ` Julien Grall
2023-06-29 11:21           ` Ayan Kumar Halder
2023-06-29 11:55             ` Julien Grall
2023-06-30  9:26               ` Ayan Kumar Halder
2023-06-30  9:43                 ` Julien Grall
2023-06-30 10:09                   ` Andrew Cooper
2023-06-26  3:34 ` [PATCH v3 25/52] xen/mpu: introduce helpers for MPU enablement Penny Zheng
2023-06-26  3:34 ` [PATCH v3 26/52] xen/mpu: map early uart when earlyprintk on Penny Zheng
2023-06-26  3:34 ` [PATCH v3 27/52] xen/mpu: introduce setup_mm_mappings Penny Zheng
2023-06-29 14:05   ` Ayan Kumar Halder
2023-06-29 14:29     ` Julien Grall
2023-06-29 14:50       ` Ayan Kumar Halder
2023-06-30  2:41         ` Penny Zheng
2023-06-26  3:34 ` [PATCH v3 28/52] xen/mpu: plump virt/maddr conversion in MPU system Penny Zheng
2023-06-29 14:20   ` Ayan Kumar Halder
2023-06-29 14:23     ` Andrew Cooper
2023-06-29 14:44       ` Ayan Kumar Halder
2023-06-29 15:14         ` Julien Grall
2023-06-30  2:40           ` Penny Zheng
2023-06-26  3:34 ` [PATCH v3 29/52] xen/mpu: introduce a pair helper read_protection_region()/write_protection_region() Penny Zheng
2023-06-26  3:34 ` [PATCH v3 30/52] xen/mpu: populate a new region in Xen MPU mapping table Penny Zheng
2023-06-28 10:05   ` Ayan Kumar Halder
2023-06-28 10:08     ` Ayan Kumar Halder
2023-06-28 10:13       ` Penny Zheng [this message]
2023-06-26  3:34 ` [PATCH v3 31/52] xen/mpu: make early_fdt_map support in MPU systems Penny Zheng
2023-06-29 17:22   ` Ayan Kumar Halder
2023-06-30  4:07     ` Penny Zheng
2023-06-30 10:49       ` Ayan Kumar Halder
2023-06-30 11:22         ` Julien Grall
2023-06-30 14:42           ` Ayan Kumar Halder
2023-06-30 15:02             ` Julien Grall
2023-07-03  5:12               ` Penny Zheng
2023-07-03  9:20                 ` Julien Grall
2023-07-13  3:12                   ` Penny Zheng
2023-07-14 16:44                     ` Julien Grall
2023-06-26  3:34 ` [PATCH v3 32/52] xen/mpu: implement MPU version of setup_mm in mpu/setup.c Penny Zheng
2023-06-26  3:34 ` [PATCH v3 33/52] xen/mpu: initialize frametable in MPU system Penny Zheng
2023-06-30 15:19   ` Ayan Kumar Halder
2023-07-03  6:10     ` Penny Zheng
2023-07-03  9:31       ` Julien Grall
2023-07-05  9:53         ` Penny Zheng
2023-07-05 13:52           ` Julien Grall
2023-07-13  7:16             ` Penny Zheng
2023-06-26  3:34 ` [PATCH v3 34/52] xen/mpu: destroy an existing entry in Xen MPU memory mapping table Penny Zheng
2023-06-30 16:17   ` Ayan Kumar Halder
2023-07-03  7:08     ` Penny Zheng
2023-06-26  3:34 ` [PATCH v3 35/52] xen/arm: map static memory on demand Penny Zheng
2023-07-04 15:10   ` Ayan Kumar Halder
2023-07-05 10:16     ` Penny Zheng
2023-07-05 13:33       ` Ayan Kumar Halder
2023-07-13  5:59         ` Penny Zheng
2023-06-26  3:34 ` [PATCH v3 36/52] xen/mpu: implememt ioremap_xxx in MPU Penny Zheng
2023-07-05 14:01   ` Ayan Kumar Halder
2023-07-13  7:09     ` Penny Zheng
2023-06-26  3:34 ` [PATCH v3 37/52] xen/mpu: implement MPU version of copy_from_paddr Penny Zheng
2023-06-26  3:34 ` [PATCH v3 38/52] xen/mpu: map domain page in MPU system Penny Zheng
2023-06-26  3:34 ` [PATCH v3 39/52] xen/mpu: support free_init_memory " Penny Zheng
2023-06-26  3:34 ` [PATCH v3 40/52] xen/mpu: implement remove_early_mappings " Penny Zheng
2023-06-26  3:34 ` [PATCH v3 41/52] xen/mpu: Use secure hypervisor timer " Penny Zheng
2023-06-26  3:34 ` [PATCH v3 42/52] xen/mpu: implement setup_virt_paging for " Penny Zheng
2023-07-04 17:49   ` Ayan Kumar Halder
2023-07-05 10:20     ` Penny Zheng
2023-06-26  3:34 ` [PATCH v3 43/52] xen/mpu: configure VSTCR_EL2 in " Penny Zheng
2023-07-05 14:21   ` Ayan Kumar Halder
2023-07-13  7:12     ` Penny Zheng
2023-06-26  3:34 ` [PATCH v3 44/52] xen/mpu: P2M initialization " Penny Zheng
2023-07-05 15:35   ` Ayan Kumar Halder
2023-07-13  7:22     ` Penny Zheng
2023-06-26  3:34 ` [PATCH v3 45/52] xen/mpu: insert an new entry into guest physmap " Penny Zheng
2023-07-05 16:27   ` Ayan Kumar Halder
2023-06-26  3:34 ` [PATCH v3 46/52] xen/mpu: look up entry in p2m table Penny Zheng
2023-06-26  3:34 ` [PATCH v3 47/52] xen/mpu: support vcpu context switch in MPU system Penny Zheng
2023-06-26  3:34 ` [PATCH v3 48/52] xen/mpu: enable MMIO region trap " Penny Zheng
2023-06-26  3:34 ` [PATCH v3 49/52] xen/mpu: enable device passthrough " Penny Zheng
2023-06-26  3:34 ` [PATCH v3 50/52] xen/mpu: dump debug message " Penny Zheng
2023-06-26  3:34 ` [PATCH v3 51/52] xen/mpu: create stubs of function/variables for UNSUPPORTED features Penny Zheng
2023-06-26  3:34 ` [PATCH v3 52/52] xen/arm: add Kconfig option CONFIG_HAS_MPU to enable MPU system support Penny Zheng
2023-07-05 17:20   ` Ayan Kumar Halder
2023-07-05 19:51     ` Julien Grall
2023-07-04 14:17 ` [PATCH v3 00/52] xen/arm: Add Armv8-R64 MPU support to Xen - Part#1 Ayan Kumar Halder
2023-07-04 19:19 ` Julien Grall
2023-07-05 10:40 ` 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=3f30dbd3-5530-e9d3-eae9-3cb6c3072bbb@arm.com \
    --to=penny.zheng@arm.com \
    --cc=Bertrand.Marquis@arm.com \
    --cc=Henry.Wang@arm.com \
    --cc=Volodymyr_Babchuk@epam.com \
    --cc=ayankuma@amd.com \
    --cc=julien@xen.org \
    --cc=sstabellini@kernel.org \
    --cc=wei.chen@arm.com \
    --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.