From: Ayan Kumar Halder <ayankuma@amd.com>
To: Luca Fancellu <Luca.Fancellu@arm.com>, Julien Grall <julien@xen.org>
Cc: Julien Grall <julien.grall.oss@gmail.com>,
Ayan Kumar Halder <ayan.kumar.halder@amd.com>,
"xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>,
Stefano Stabellini <sstabellini@kernel.org>,
Bertrand Marquis <Bertrand.Marquis@arm.com>,
Michal Orzel <michal.orzel@amd.com>,
Volodymyr Babchuk <Volodymyr_Babchuk@epam.com>
Subject: Re: [PATCH v4 4/6] xen/arm: mpu: Create boot-time MPU protection regions
Date: Thu, 31 Oct 2024 16:16:35 +0000 [thread overview]
Message-ID: <dc16b377-bf99-4afb-87fa-2bc45cdfa62d@amd.com> (raw)
In-Reply-To: <19C963C9-97C2-442D-B9AC-9CE7CF3B50F2@arm.com>
On 30/10/2024 10:51, Luca Fancellu wrote:
> Hi Julien,
Hi Luca/Julien,
>
>> On 30 Oct 2024, at 10:32, Julien Grall <julien@xen.org> wrote:
>>
>> On 30/10/2024 10:08, Luca Fancellu wrote:
>>> Hi Julien,
>>>> On 30 Oct 2024, at 09:52, Julien Grall <julien.grall.oss@gmail.com> wrote:
>>>>
>>>> On Wed, 30 Oct 2024 at 09:17, Luca Fancellu <Luca.Fancellu@arm.com> wrote:
>>>>> Hi Ayan,
>>>>>
>>>>> While I rebased the branch on top of your patches, I saw you’ve changed the number of regions
>>>>> mapped at boot time, can I ask why?
>>>> I have asked the change. If you look at the layout...
>>> Apologies, I didn’t see you’ve asked the change
>> No need to apologies! I think I asked a few revisions ago.
>>
>>>>> Compared to https://patchwork.kernel.org/project/xen-devel/patch/20230626033443.2943270-25-Penny.Zheng@arm.com/:
>>>>
>>>> ... you have two sections with the same permissions:
>>>>
>>>> xen_mpumap[1] : Xen read-only data
>>>> xen_mpumap[2] : Xen read-only after init data
>>>> xen_mpumap[3] : Xen read-write data
>>>>
>>>> During boot, [2] and [3] will share the same permissions. After boot,
>>>> this will be [1] and [2]. Given the number of MPU regions is limited,
>>>> this is a bit of a waste.
>>>>
>>>> We also don't want to have a hole in the middle of Xen sections. So
>>>> folding seemed to be a good idea.
>>>>
>>>>>> +FUNC(enable_boot_cpu_mm)
>>>>>> +
>>>>>> + /* Get the number of regions specified in MPUIR_EL2 */
>>>>>> + mrs x5, MPUIR_EL2
>>>>>> +
>>>>>> + /* x0: region sel */
>>>>>> + mov x0, xzr
>>>>>> + /* Xen text section. */
>>>>>> + ldr x1, =_stext
>>>>>> + ldr x2, =_etext
>>>>>> + prepare_xen_region x0, x1, x2, x3, x4, x5, attr_prbar=REGION_TEXT_PRBAR
>>>>>> +
>>>>>> + /* Xen read-only data section. */
>>>>>> + ldr x1, =_srodata
>>>>>> + ldr x2, =_erodata
>>>>>> + prepare_xen_region x0, x1, x2, x3, x4, x5, attr_prbar=REGION_RO_PRBAR
>>>>>> +
>>>>>> + /* Xen read-only after init and data section. (RW data) */
>>>>>> + ldr x1, =__ro_after_init_start
>>>>>> + ldr x2, =__init_begin
>>>>>> + prepare_xen_region x0, x1, x2, x3, x4, x5
>>>>> ^— this, for example, will block Xen to call init_done(void) later, I understand this is earlyboot,
>>>>> but I guess we don’t want to make subsequent changes to this part when introducing the
>>>>> patches to support start_xen()
>>>> Can you be a bit more descriptive... What will block?
>>> This call in setup.c:
>>> rc = modify_xen_mappings((unsigned long)&__ro_after_init_start,
>>> (unsigned long)&__ro_after_init_end,
>>> PAGE_HYPERVISOR_RO);
>>> Cannot work anymore because xen_mpumap[2] is wider than only (__ro_after_init_start, __ro_after_init_end).
>> Is this because the implementation of modify_xen_mappings() is only able to modify a full region? IOW, it would not be able to split regions and/or merge them?
> Yes, the code is, at the moment, not smart enough to do that, it will only modify a full region.
>
>>> If that is what we want, then we could wrap the above call into something MMU specific that will execute the above call and
>>> something MPU specific that will modify xen_mpumap[1] from (_srodata, _erodata) to (_srodata, __ro_after_init_end)
>>> and xen_mpumap[2] from (__ro_after_init_start, __init_begin) to (__ro_after_init_end, __init_begin).
>> I think it would make sense to have the call mmu/mpu specific. This would allow to limit the number of MPU regions used by Xen itself.
>>
>> The only problem is IIRC the region is not fixed because we will skip empty regions during earlyboot.
> Yes, but I think we can assume that X(_srodata, _erodata) and Y(__ro_after_init_start, __init_begin) won’t never be empty for Xen?
>
> In that case, the call to mpumap_contain_region() should be able to retrieve the full region X and the partial region Y and
> a specific function could modify the ranges of both given the respective indexes.
>
> Code in my branch: https://gitlab.com/xen-project/people/lucafancellu/xen/-/blob/r82_rebased/xen/arch/arm/mpu/mm.c#L382
Can we keep the current patch as it is ? We can revisit
enable_boot_cpu_mm() when we enable start_xen() for mpu.
I can send a respin once we are aligned.
- Ayan
next prev parent reply other threads:[~2024-10-31 16:17 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-28 12:45 [PATCH v4 0/6] Enable early bootup of AArch64 MPU systems Ayan Kumar Halder
2024-10-28 12:45 ` [PATCH v4 1/6] xen/arm: Skip initializing the BSS section when it is empty Ayan Kumar Halder
2024-10-28 14:45 ` Luca Fancellu
2024-11-01 13:55 ` Julien Grall
2024-10-28 12:45 ` [PATCH v4 2/6] xen/arm: mpu: Introduce choice between MMU and MPU Ayan Kumar Halder
2024-10-29 9:53 ` Andrew Cooper
2024-10-29 16:49 ` oleksii.kurochko
2024-10-28 12:45 ` [PATCH v4 3/6] xen/arm: mpu: Define Xen start address for MPU systems Ayan Kumar Halder
2024-10-28 14:53 ` Luca Fancellu
2024-11-01 13:57 ` Julien Grall
2024-10-28 12:45 ` [PATCH v4 4/6] xen/arm: mpu: Create boot-time MPU protection regions Ayan Kumar Halder
2024-10-28 15:14 ` Luca Fancellu
2024-10-28 15:37 ` Luca Fancellu
2024-10-29 16:20 ` Ayan Kumar Halder
2024-10-29 16:25 ` Luca Fancellu
2024-10-30 9:16 ` Luca Fancellu
2024-10-30 9:52 ` Julien Grall
2024-10-30 10:08 ` Luca Fancellu
2024-10-30 10:32 ` Julien Grall
2024-10-30 10:51 ` Luca Fancellu
2024-10-31 16:16 ` Ayan Kumar Halder [this message]
2024-11-01 14:11 ` Julien Grall
2024-11-01 17:08 ` Ayan Kumar Halder
2024-11-01 17:11 ` Ayan Kumar Halder
2024-10-28 12:45 ` [PATCH v4 5/6] xen/arm: mpu: Enable MPU Ayan Kumar Halder
2024-10-28 15:39 ` Luca Fancellu
2024-11-01 14:19 ` Julien Grall
2024-10-28 12:45 ` [PATCH v4 6/6] xen/arm: mpu: Implement a dummy enable_secondary_cpu_mm Ayan Kumar Halder
2024-10-28 12:55 ` Jan Beulich
2024-10-28 14:39 ` Ayan Kumar Halder
2024-10-28 15:01 ` Jan Beulich
2024-10-28 17:38 ` Ayan Kumar Halder
2024-10-29 8:08 ` Jan Beulich
2024-10-29 9:30 ` Luca Fancellu
2024-10-29 9:41 ` Jan Beulich
2024-10-29 9:58 ` Luca Fancellu
2024-11-01 14:22 ` [PATCH v4 0/6] Enable early bootup of AArch64 MPU systems 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=dc16b377-bf99-4afb-87fa-2bc45cdfa62d@amd.com \
--to=ayankuma@amd.com \
--cc=Bertrand.Marquis@arm.com \
--cc=Luca.Fancellu@arm.com \
--cc=Volodymyr_Babchuk@epam.com \
--cc=ayan.kumar.halder@amd.com \
--cc=julien.grall.oss@gmail.com \
--cc=julien@xen.org \
--cc=michal.orzel@amd.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.