[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v1] xen/arm: AArch32-V8R: Add MPU register definitions


  • To: Ayan Kumar Halder <ayankuma@xxxxxxx>
  • From: Luca Fancellu <Luca.Fancellu@xxxxxxx>
  • Date: Tue, 29 Apr 2025 12:11:32 +0000
  • Accept-language: en-GB, en-US
  • Arc-authentication-results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 4.158.2.129) smtp.rcpttodomain=amd.com 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=mowOPD5oIW5OewRgMIrVTFCwYQi6n9pxGWenuRl0O8g=; b=U7WkCuMXdj7pmrLSPtPVmia4gyCFYW3SBcJp6H5GFggmNjs2iVZ7NRVFUcHDVwQThHn01gSbvZnHL9aqiVNmsPCgombd/MwfOGej4Gn9SxL/I1IOwf5h4BfUjbsAXI31HBLOZwxZ67fC+Evxca/uA9EOmiJYQkYOfo+DyMjphmbZkCHQUzNO060a3Kq+bIZBftmWD1QL+JM0UN3ZLsxotY2EIpcUfXvIvNdwdHUI0lE1F5alfARe5ZPHBxEshVGrYOElgNZ9dyQfjm8dYKbTdiaAh4R2jFduIHkvooBRop7gQqDhhz34cdmTMz7ygCr7Y/1XaKmfYZPq2BOdWLigxw==
  • 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=mowOPD5oIW5OewRgMIrVTFCwYQi6n9pxGWenuRl0O8g=; b=nNGcTz6egwDsZ3OKJ0JTDzDQJ7JwAk4wJndW2aX1xQIq5DY+gvBGVohzpiS6q1oYzGZeyAMw3ryDiNpRyNUOd23ODUYNk5VgknTTlKeV/IpXvtsaebVvBbbsNnoI8nCuNjz8kUAu3Tz1Zv8twzu1JLVlpL16VRWYFK5ps4krCteTNh4gN805xt1aPYsZeNBW5vzUSXqh7MjMeKNPi/J7YyMDuil+U/1KKwrHCQZBgVruqz5JZp+kuSHrVMhSf8BSzE/bPO97Ma69bXVPODJoPRdEGHhZSNZ203hGSBWOFnFTtZ0PKduqTk6j870HzsPiuF1Pt3Fl2SNmlBnIwlrVFw==
  • Arc-seal: i=2; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=pass; b=Ii0rA+AdmgGnaCSvWw6vJMgWeMhzxs0ZRlKaUHanXZdl+NAtdi5ANq+ERNoSMCji7z7D4TCx72evTNaBuzjz6uAhkLAIEXMNvUDu50p1g9bUqZwMyC8rOqiwzuPbTx8mO2QhyKDAzRVfYT2ilwK5LS/uj2i+PIsGoq1emU6gOBR0h1Hec+A1Y8uqEerfvKI+gFxTpjUWZcaQ+Vfx6b0hRNS7zPm24LsAJpEwdn1b5VR0w+5TdLIE/Tih3a3MWApU0abUjpM3CBEoebNaXG+1V4B77dA/e1nRxa40ScYUqUnq2iRxe7r/9Dh0qNa7nlYJbtAyaop01yv+obQly/woKA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=gaNv6qEx7vTZ1y2yYd9Bvsti/imAw/Hz/6jK0T1JEukF7iSzFPCKjSwu0OmezdPinGhwn+0KmtKEfpIM3Z59CInAyDjUS+CCJk+ocflOfToOhXOGkAjjsiRpwpmrNhwpa4z2k1nXxJdQovg28Ld6DYUZyBh/fZgAZVejUKq1rMK316Vu7Bk03U8bby2IZkpkbYL9esRzrpwsgp8+A5jjRx52YEZ4bi1DbhskqU2MNQEWw/D89I7/BuBs0QLvLpsUuXyDkAYvRHBw1kiyIPCIyAov/gui2Y+OtxNu6bsYYLc6xOKEXn2I0zBJmYT+gLmnSRPzUE2BtOaB7p6K9Eh9Tg==
  • Authentication-results-original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com;
  • Cc: Julien Grall <julien@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, 29 Apr 2025 12:12:23 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Nodisclaimer: true
  • Thread-index: AQHbr7FEzJkzCX7IxEuG28e/+R7zurOo3KoAgAt3HYCABS1xgIABHSuAgAABxgA=
  • Thread-topic: [PATCH v1] xen/arm: AArch32-V8R: Add MPU register definitions

Hi Ayan,

>>>>> +        /*
>>>>> +         * There is no actual ns bit in hardware. It is used here for
>>>>> +         * compatibility with Armr64 code. Thus, we are reusing a res0 
>>>>> bit for ns.
>>>> typo: Arm64.
>>> Ack
>>>>> +         */
>>>> Hmmmm, this would mean someone may mistakenly set the bit to 0 by mistake. 
>>>> If the field is always meant to be 0 on arm64, then I would consider to 
>>>> name is res0 on arm64 with an explanation.
>>>> 
>>>> This would make clear the bit is not supposed to have a value other than 0.
>>> On Arm64, ns == 0 as it can only support secure mode.
>>> 
>>> So we can change this on Arm64 as well :-
>>> 
>>> unsigned int res0:2; /* ns == 0 as only secure mode is supported */
>>> 
>>> @Luca to clarify
>> From the specifications: "Non-secure bit. Specifies whether the output 
>> address is in the Secure or Non-secure memory”, I’m not sure
>> that we should remove it from Arm64, so I don’t think you should have 
>> something only for compatibility, maybe the code accessing .ns
>> can be compiled out for Arm32 or we can have arch-specific implementation. I 
>> think you are referring to pr_of_xenaddr when you say
>> “compatibility with Arm64 code"
> 
> Yes, that is correct. So are you saying that we should have an "ifdef" in the 
> function.
> 
> +++ b/xen/arch/arm/mpu/mm.c
> @@ -221,7 +221,9 @@ pr_t pr_of_xenaddr(paddr_t base, paddr_t limit, unsigned 
> attr)
>      /* Build up value for PRLAR_EL2. */
>      prlar = (prlar_t) {
>          .reg = {
> +#ifdef CONFIG_ARM_64
>              .ns = 0,        /* Hyp mode is in secure world */
> +#endif
>              .ai = attr,
>              .en = 1,        /* Region enabled */
>          }};
> 
> I am ok with this. I just want to know if you and Julien are aligned as well.

this is my proposal, yes

>>>>> 
>>>> NIT: Is there any way we could generate the values using macros?
>>> This looks tricky. So I will prefer to keep this as it is.
>>>>> +
>>>>>   /* Aliases of AArch64 names for use in common code */
>>>>>   #ifdef CONFIG_ARM_32
>>>>>   /* Alphabetically... */
>>>>>   #define MPUIR_EL2       HMPUIR
>>>>>   #define PRBAR_EL2       HPRBAR
>>>>> +#define PRBAR0_EL2      HPRBAR0
>>>> AFAIU, the alias will be mainly used in the macro generate
>>>> the switch. Rather than open-coding all the PR*AR_EL2, can we
>>>> provide two macros PR{B, L}AR_N that will be implemented as
>>>> HPR{B,L}AR##n for arm32 and PR{B,L}AR##n for arm64?
>>> Yes , we can have
>>> 
>>> #define PR{B,L}AR_EL2_(n)          HPR{B,L}AR##n for arm32
>>> 
>>> #define PR{B,L}AR_EL2_(n)          PR{B,L}AR##n##_EL2
>> we could have them in mm.c, I see in your v2 you’ve put them in cpregs.h,
>> but since they are only used by the generator, I would put them there.
> 
> You mean the above two macros should be moved to mm.c. I am ok with that.
> 
> Just 2 more things to be aligned :-
> 
> 1. Are we ok to use PRBAR_EL2_(num) and PRLAR_EL2_(num) in the common code 
> (ie mpu/mm.c) ?
> 
> 2. Are you ok to introduce ifdef in prepare_selector() ?
> 
> Please have a look at my v2 for reference.

I will change my implementation to introduce on Arm64 PR{B,L}AR_EL2_(num) -> 
PR{B,L}AR##num##_EL2,
I will then protect everything with CONFIG_ARM_64, this will ensure proper 
compilation on both architecture.

When you will introduce your changes, you will have only to revert the #ifdef 
CONFIG_ARM_64 that protects
the common code and implement the changes to build on Arm32.

I think this is the best way to ensure we are not blocked by each other while 
keeping the churn as low as possible.

Please @julien and/or other maintainers let me know your opinion on this.

Cheers,
Luca

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.