All of lore.kernel.org
 help / color / mirror / Atom feed
From: Julien Grall <julien@xen.org>
To: Penny Zheng <Penny.Zheng@arm.com>, Wei Chen <Wei.Chen@arm.com>,
	"xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>
Cc: nd <nd@arm.com>, Stefano Stabellini <sstabellini@kernel.org>,
	Bertrand Marquis <Bertrand.Marquis@arm.com>,
	Volodymyr Babchuk <Volodymyr_Babchuk@epam.com>
Subject: Re: [PATCH v6 09/11] xen/arm64: create boot-time MPU protection regions
Date: Mon, 7 Nov 2022 09:29:46 +0000	[thread overview]
Message-ID: <e8b30043-64b3-a8d2-073b-289a1f85f02b@xen.org> (raw)
In-Reply-To: <AM0PR08MB453082216C4AB04CC8F47612F73C9@AM0PR08MB4530.eurprd08.prod.outlook.com>

On 07/11/2022 06:59, Penny Zheng wrote:
> Hi Julien

Hi Penny,

>>> +
>>> +/*
>>> + * In boot stage, we will use 1 MPU region:
>>> + * Region#0: Normal memory for Xen text + data + bss (2MB)
>>> + */
>>
>> Are we only going to modify the MPU in head.S? If not, then I would
>> define the layout in config_mpu.h so there are a single point where you
>> can read how this works.
>>
> 
> We will remap Xen in C codes in setup_mm().
> The whole strategy is aligned with MMU: a very simple setup(map xen
> with the maximum size, 2M) at start-of-the-day, and a fit map in
> setup_mm.

The strategy we are using for the MMU is completely broken (not 
compliant with the Arm Arm) and unnecessary. My long term goal is to 
actually remove the switch_ttbr() and most of setup_pagetables() for all 
setup but cache coloring. This means the concept of boot pages will not 
exist anymore.

For the MPU, we should aim to do better than what was done for the MMU. 
Right now, I see no argument for switching MPUs table. I am only seen 
argument against it because you need to disable the cache and is quite 
fragile.

[...]

>>> +
>>> +    ldr x2, =XEN_START_ADDRESS
>>> +    mov x3, #(XEN_START_MEM_SIZE - 1)
>>
>> XEN_START_MEM_SIZE is the maximum size of Xen. IOW, Xen may be
>> smaller
>> and you will map memory that may not be part of Xen. Therefore, you
>> likely want to compute the real size to avoid mapping too much.
>>
> 
> Later, in setup_mm we will map XEN components by components, such as,
> one MPU memory region for read-only-executable text section, one
> MPU memory region for read-only data section, etc, etc.
> So in there, XEN will be mapped fitly.

But what prevents you to do this now?

> 
> IMHO, the mapping in compiler with maximum size of Xen is also what
> MMU does.

Which is broken because we don't know what located after Xen binary. 
This could be reserved RAM, device which may requires non-caching 
attribute. Mapping those regions with caching attributes is going to break.

As I hinted above, there are a very long list of issues in the MMU boot 
code. So don't take that code for granted. Your MPU code should first be 
compliant with the Arm Arm. If it is close to the MMU code then that's a 
bonus. But bear in mind that the code may look very different soon (see 
[1]).

Cheers,

[1] 20221022150422.17707-1-julien@xen.org

-- 
Julien Grall


  reply	other threads:[~2022-11-07  9:30 UTC|newest]

Thread overview: 63+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-04 10:07 [PATCH v6 00/11] xen/arm: Add Armv8-R64 MPU support to Xen - Part#1 Wei Chen
2022-11-04 10:07 ` [PATCH v6 01/11] xen/arm: remove xen_phys_start and xenheap_phys_end from config.h Wei Chen
2022-11-06 18:42   ` Julien Grall
2022-11-04 10:07 ` [PATCH v6 02/11] xen/arm: add iounmap after initrd has been loaded in domain_build Wei Chen
2022-11-06 18:55   ` Julien Grall
2022-11-07  1:33     ` Henry Wang
2022-11-07  9:09       ` Julien Grall
2022-11-07  9:11         ` Henry Wang
2022-11-07 19:00     ` Julien Grall
2022-11-08  2:14     ` Wei Chen
2022-11-08  2:24       ` Wei Chen
2022-11-04 10:07 ` [PATCH v6 03/11] xen/arm: disable EFI boot services for MPU systems Wei Chen
2022-11-06 19:12   ` Julien Grall
2022-11-06 19:13     ` Julien Grall
2022-11-08  3:02     ` Wei Chen
2022-11-15  8:21     ` Wei Chen
2022-11-04 10:07 ` [PATCH v6 04/11] xen/arm: adjust Xen TLB helpers for Armv8-R64 PMSA Wei Chen
2022-11-04 10:07 ` [PATCH v6 05/11] xen/arm: define Xen start address for FVP BaseR platform Wei Chen
2022-11-06 19:19   ` Julien Grall
2022-11-09  4:55     ` Wei Chen
2022-11-09 18:24       ` Julien Grall
2022-11-10 22:12         ` Stefano Stabellini
2022-11-11 10:13           ` Wei Chen
2022-11-11 20:15             ` Stefano Stabellini
2022-12-05 10:17         ` Wei Chen
2022-12-05 11:02           ` Julien Grall
2022-11-14 18:52   ` Ayan Kumar Halder
2022-11-15  5:42     ` Wei Chen
2022-11-04 10:07 ` [PATCH v6 06/11] xen/arm: split MMU and MPU config files from config.h Wei Chen
2022-11-04 10:07 ` [PATCH v6 07/11] xen/arm: implement FIXMAP_ADDR for MPU systems Wei Chen
2022-11-06 19:44   ` Julien Grall
2022-11-09  6:46     ` Wei Chen
2022-11-09 18:30       ` Julien Grall
2022-11-11  7:56         ` Wei Chen
2022-11-11  9:40           ` Julien Grall
2022-11-04 10:07 ` [PATCH v6 08/11] xen/arm64: move MMU related code from head.S to head_mmu.S Wei Chen
2022-11-06 20:06   ` Julien Grall
2022-11-07  9:34     ` Julien Grall
2022-11-09  7:36     ` Wei Chen
2022-11-09 18:33       ` Julien Grall
2022-11-13 21:42       ` Julien Grall
2022-11-14  5:36         ` Wei Chen
2022-11-04 10:07 ` [PATCH v6 09/11] xen/arm64: create boot-time MPU protection regions Wei Chen
2022-11-06 20:46   ` Julien Grall
2022-11-07  6:59     ` Penny Zheng
2022-11-07  9:29       ` Julien Grall [this message]
2022-11-07 10:17         ` Penny Zheng
2022-11-04 10:07 ` [PATCH v6 10/11] xen/arm64: introduce helpers for MPU enable/disable Wei Chen
2022-11-06 20:56   ` Julien Grall
2022-11-07  9:57     ` Penny Zheng
2022-11-07 10:38       ` Julien Grall
2022-11-08  3:01         ` Penny Zheng
2022-11-04 10:07 ` [PATCH v6 11/11] xen/arm64: add setup_fixmap and remove_identity_mapping for MPU Wei Chen
2022-11-06 21:02   ` Julien Grall
2022-11-07  8:13     ` Penny Zheng
2022-11-07  9:32       ` Julien Grall
2022-11-04 10:29 ` [PATCH v6 00/11] xen/arm: Add Armv8-R64 MPU support to Xen - Part#1 Wei Chen
2022-11-06 19:02 ` Julien Grall
2022-11-07  9:52   ` Wei Chen
2022-11-07 10:16     ` Julien Grall
2022-11-07 10:30       ` Wei Chen
2022-11-10 22:25         ` Stefano Stabellini
2022-11-11 10:41           ` Wei Chen

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=e8b30043-64b3-a8d2-073b-289a1f85f02b@xen.org \
    --to=julien@xen.org \
    --cc=Bertrand.Marquis@arm.com \
    --cc=Penny.Zheng@arm.com \
    --cc=Volodymyr_Babchuk@epam.com \
    --cc=Wei.Chen@arm.com \
    --cc=nd@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.