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

Re: [PATCH v3 3/7] arm/mpu: Introduce utility functions for the pr_t type


  • To: "Orzel, Michal" <Michal.Orzel@xxxxxxx>
  • From: Luca Fancellu <Luca.Fancellu@xxxxxxx>
  • Date: Wed, 16 Apr 2025 12:31:22 +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=YKE9hTGFmIMD7PzxQ/Z3eU5/nDONibidLGD5JZxcsBI=; b=d/lhAdYTxEmr5szR4fSjlQ8KMVSs5D9vpvy9817mrjXKd9mAlWady3QJCqUbezEF7oTDI2WRTf/oMGMgMtQzvaEsiO/QJILoWGLa3tT/Cfw4426nfy0bUi/fY08uPwxixDfXvwLmX82FrgTpemx96PDlGz+rGRXFQvuIMsFsiWJ8W+BZMcRqE4fEGfFrMx1Ti/N4C+L7yi5SSYIb4UpVTaDF89yYlpQlxOrZfOBnGEyNlKbdV928bemeEd2HcWYT9nCWzAyNM3YtFPnQ9SIFrIJw7n2S5RkVprg+6T17QiftnLHAVeK14h6dR3gpfjF8L1XhPoNZZBrmBiqLx57V/Q==
  • 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=YKE9hTGFmIMD7PzxQ/Z3eU5/nDONibidLGD5JZxcsBI=; b=N4NiYA3pZ6/yxQf72zn5D44L6lnoQRDX8YleJs1tB8WFuY5v5aLHN4foOUhZPRp3cZjJ665sGDut7SaKW8/pLnXWpCeZicjWtfQKFik6rWQ150uhozLe1kmbk0oFvdQn3jXXIgNr7DGo66THZcVtvnf8vl4tXAcQiE0XWuTewqjG3aTaUSmrpkeVJPuzaZhugq4p8Alfrzmxzb/FJu9F00tw5gJM57wlTWMDMdjg8/QKqBJ5NRGs8+blP0MNmrRfOjZTuiFekm1HyQgRs73r9B49TpleAJqQYnE7F+SH5GLMAgnRE6b4lcln0YISCNpCIdjTHTwhOpkFWJ9ab3P0jQ==
  • Arc-seal: i=2; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=pass; b=EBaXw5HkQurNZJOhr+SHDoi5MEtkSzvsQ4unTMk+RLGFCQpLDh8jZ6TtHQR6GfxrS4B+pArtqJp+K9mlEejsPobtprfol2AMiIa6DTzzyq+Azu68i2kZhfFyLSuxqtAHBvn85bd9jkP/gQKIlhW0JoAYbWBbkitFGdZGi3hy+0aEj8JtrQJ49AZ5LnnK+oVSujCjystJ0oIbmferfStNlBIMvj6gnKWkRZnn/MkevraexrfNW6O2GPT1VmAaRGdRGkYwUYbDebpa0W6AhXdeK3j2Y7xHDPWP49o+kjpbVVLhVZBdnD8yzBgsn82afhQl9oSgb/Yp9OYFBB2sZjnsXQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=HMvQNMiBEs4fxX5X5iuYK2i77x236tW5Yfb4DBNu6b3VJD1Ayv43TC7/xN/FHRDldGUGTyFaw+HPRgFojm399+WCt9Owpo6RUxfHL6nbIPpMQUrlaM65Z68+x8ZQaO23OHtbE+D0OspCthAi+GOtvqvBRnoBYp2WzbjuSlP3vauHx01SpyBSBUFVhdrTd0ou5uS7ZqHL9AhlVEAr25eEloVA967UNgxkovGtBRl2sliiX6db+McwqcaOc94f4BtCn6Hk8CAgme19F91zCWf6p/h84JYF+jmfuI/ZkafF+Ch3USR7cPdPzumjeBhBEByzOs2xtGSWORr15m7C571fpw==
  • Authentication-results-original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com;
  • Cc: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Bertrand Marquis <Bertrand.Marquis@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>
  • Delivery-date: Wed, 16 Apr 2025 12:32:07 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Nodisclaimer: true
  • Thread-index: AQHbqvIP34UccZOkWUuu+Y+Ap2U3MrOmJOcAgAAb/QA=
  • Thread-topic: [PATCH v3 3/7] arm/mpu: Introduce utility functions for the pr_t type

Hi Michal,

> On 16 Apr 2025, at 11:50, Orzel, Michal <Michal.Orzel@xxxxxxx> wrote:
> 
> 
> 
> On 11/04/2025 16:56, Luca Fancellu wrote:
>> Introduce few utility function to manipulate and handle the
>> pr_t type.
>> 
>> Signed-off-by: Luca Fancellu <luca.fancellu@xxxxxxx>
>> ---
>> xen/arch/arm/include/asm/mpu.h | 40 ++++++++++++++++++++++++++++++++++
>> 1 file changed, 40 insertions(+)
>> 
>> diff --git a/xen/arch/arm/include/asm/mpu.h b/xen/arch/arm/include/asm/mpu.h
>> index 59ff22c804c1..6971507457fb 100644
>> --- a/xen/arch/arm/include/asm/mpu.h
>> +++ b/xen/arch/arm/include/asm/mpu.h
>> @@ -20,6 +20,46 @@
>> #define NUM_MPU_REGIONS_MASK    (NUM_MPU_REGIONS - 1)
>> #define MAX_MPU_REGIONS         NUM_MPU_REGIONS_MASK
>> 
>> +#ifndef __ASSEMBLY__
>> +
>> +/* Set base address of MPU protection region(pr_t). */
> What's the use of (pr_t) in this comment? pr_t is a data type. If at all, it
> would want to be ...region @pr but I think you can skip it.

ok

> 
>> +static inline void pr_set_base(pr_t *pr, paddr_t base)
>> +{
>> +    pr->prbar.reg.base = (base >> MPU_REGION_SHIFT);
> Looking at pr_t definition, base/limit is 46 bits wide. However the spec says
> that last 4bits are reserved (i.e. you should not write to them) unless 
> FEAT_LPA
> is implemented. What's our plan here?

So we’re currently supporting max 1TB, so probably this one needs to be on the
case when FEAT_LPA is considered not implemented, so I’ll change and if we will
later support more than 42 bit we could do something?

> 
>> +}
>> +
>> +/* Set limit address of MPU protection region(pr_t). */
>> +static inline void pr_set_limit(pr_t *pr, paddr_t limit)
>> +{
>> +    pr->prlar.reg.limit = ((limit - 1) >> MPU_REGION_SHIFT);
> Why -1? AFAIR these registers take inclusive addresses, so is it because you
> want caller to pass limit as exclusive and you convert it to inclusive? I 
> think
> it's quite error prone.

Yes it’s meant to be used with exclusive range, shall we document it or use
Inclusive range instead?

Cheers,
Luca


 


Rackspace

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