[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v3 5/6] xen/arm: mpu: Enable MPU
- To: Julien Grall <julien@xxxxxxx>
- From: Luca Fancellu <Luca.Fancellu@xxxxxxx>
- Date: Tue, 22 Oct 2024 09:41:02 +0000
- Accept-language: en-GB, en-US
- Arc-authentication-results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 63.35.35.123) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=pass (signature was verified) header.d=arm.com; arc=pass (0 oda=1 ltdi=1 spf=[1,1,smtp.mailfrom=arm.com] dkim=[1,1,header.d=arm.com] dmarc=[1,1,header.from=arm.com])
- Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none
- Arc-message-signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=HarXrckkJaLj21h4AuSMkcradpaBEuoWuIiL4YAfb5c=; b=tlpXabY8br49meZP+usLzHc3vBDP77BsZGFMu0dzQPlreyd9y7+dc6gsBobZCRVsCB3LTf1XE+1slNxUhqvcOyaKtrNviFJykerOL9zJdCLtIZ1H08jwr6ez3XZv9ePBj/iJfHzfjKPHs1KhB5BPMuwkoVPNT1JsbheEkaE/5nFvBCl/XIpO52n/4V3RbxnRjjD7FeMW6LgpL95NcbKLb2W6UEBCLiBy4YIrBB7F54Z1NNNJCAAivzzXRYbeuhmvuwOu0fKSjlW9lmfwfHKcaM0H1H9/OaLGKFwwD1VghOljmkMevPkldG1nH6TlkFzbMeEDOaKe/7FwPN/KZgsTSQ==
- Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=HarXrckkJaLj21h4AuSMkcradpaBEuoWuIiL4YAfb5c=; b=uzyLw6NFKll0kdZuxO3wWyNP0CjqpP2htHhIDwu0k9M77S7Dou375EM6CI5LeDZyngWKUgSqK2FkaNslvQJERXOk9dOTjbL8Qz2T2lqUAIbDChjc8vtwPq/vbuJ47WceFU5fapTOT5W8P7IIitaGigLZXQOwLASl4TrOreJf2V9SpegOsh1e9DnM6rsn+Ac+r4C3r+tnoRYI96SYtzRLnqyP7jlwqfGHYw21U8OJUcNdYizjmcBDZVdmoildLiIEoCKZCaSfYz9qENP0YQhhZQ5VN0cdUEY5Xwrlf6WvjlrIs7EbSU/3DN48EAhG8ZlUsUWUjIV21+MgDqPkUNrmIQ==
- Arc-seal: i=2; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=pass; b=fezVyDcUNc41b7XeNJn1q5yb5g3OBmBXSwMyKNAy1lHMSuusvL0VGrAnCD4KTH4dVprTUri1QB7x53rDOJKdF87g1pqMIbHU68kUHnzwrNpi+UpICIONlvg/QRAlVaPvBp2FGfXp9WsTKH+gzNMYG8w87EUUsyD5EeyRx5sNdp9jgzJbQJAV8mFPlGrskrfeQvHx01z0wiOpbaf79n0GX/O/lHb3RfTBrx5eidF3K/debgJepUDE+r1V3rgex1vYyx91MFvC+1dlFWXKz9Zk3N3BAvFTJR6+JmXHkhOQ1mH6bziPVk+uFXql0NYamby/njD+X7O+0mLy60BEAQwbdQ==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=H/lDVxSvCOfezrox6QXfDP4RAHPwREps8Pe9bjWP/2k4+YI1faC6nSc4rumO3p9mBeZTQtwrboR/Wf2zI6BPflzZ8t8tGplnd+rJV+hvkvp6C18O7RjsUbWgpZmJtElq7C1Kch88+g7E5vkrCAk5B2c3NO3J1woebzecuJ+4lIWJpykQQwmX2iAmRvOLKJN1oNBPJFyKR6XkILl1/eVWbPvxUK5LFkkpb0VG9o9rTPPl7DNrqEVghcSxFRJ3yrgCp272OE6ztSZFt7sK7/z838BllgxdXeMKo2rsqkcsfp+S2NnZkDEaYIKw+rLrKJeqVnhkuBz8jD/jRHPJShwYHw==
- Authentication-results-original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com;
- Cc: Ayan Kumar Halder <ayankuma@xxxxxxx>, Ayan Kumar Halder <ayan.kumar.halder@xxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Bertrand Marquis <Bertrand.Marquis@xxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>
- Delivery-date: Tue, 22 Oct 2024 09:41:50 +0000
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
- Nodisclaimer: true
- Original-authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com;
- Thread-index: AQHbGx2Ge9N55hTx/U2iD9lYiTVQprKNIysAgARC6gCAAA8agIAAAOKAgAEgqoA=
- Thread-topic: [PATCH v3 5/6] xen/arm: mpu: Enable MPU
Hi Julien,
> On 21 Oct 2024, at 17:27, Julien Grall <julien@xxxxxxx> wrote:
>
>
>
> On 21/10/2024 17:24, Luca Fancellu wrote:
>> Hi Ayan,
>>>>> + */
>>>>> +FUNC_LOCAL(enable_mpu)
>>>>> + mrs x0, SCTLR_EL2
>>>>> + bic x0, x0, #SCTLR_ELx_BR /* Disable Background region */
>>>>> + orr x0, x0, #SCTLR_Axx_ELx_M /* Enable MPU */
>>>>> + orr x0, x0, #SCTLR_Axx_ELx_C /* Enable D-cache */
>>>>> + orr x0, x0, #SCTLR_Axx_ELx_WXN /* Enable WXN */
>>>>
>>>> NIT: Can't we have a single "orr" instruction to set all the flags?
>>> Yes, I will change this.
>>>>
>>>>> + dsb sy
>>>>
>>>> I still question this use of "dsb sy"...
>>>
>>> Actually I kept this to ensure that all outstanding memory access are
>>> completed before MPU is enabled.
>>>
>>> However, prepare_xen_region() is invoked before this and it has a 'dsb sy'
>>> at the end.
>>>
>>> So we can drop this barrier.
>> I suggest to keep the barrier here and drop the one in prepare_xen_region
>> instead,
>
> I think the barriers in prepare_xen_region() should be kept because we may
> want to use the helper *after* the MPU is turned on.
Sure I agree, given that the current code was only called before enabling the
MPU I was ok to drop the barrier in prepare_xen_region,
but given that the macro could be reused, it’s safer to keep them both.
>
>> have a look in my branch:
>> https://gitlab.com/xen-project/xen/-/merge_requests/7/diffs?commit_id=f42a2816f9bd95f2f6957887be910cb9acd140b5
>> During my testing I was having trouble without this barrier.
>
> Was it before or after removing the barriers in prepare_xen_region()? If the
> latter, then I am a bit puzzled why you need it. Did you investigate a bit
> more?
I don’t recall unfortunately, I tried to reproduce the issue removing the
barrier from enable_mpu and adding it into prepare_xen_region only but it’s
working fine
or at least I’m not able to reproduce the issue I was having, of course I
wouldn’t remove it from both since it goes against the arm arm, so I think the
logic
here should be keeping both the barriers:
1) dsb+isb barrier after writing prbar/prlar as the arm arm recommends (in case
the macro is used with MPU enabled in the future)
2) dsb+isb barrier after enabling the MPU, since we are enabling the MPU but
also because we are disabling the background region
Cheers,
Luca
|