[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: Luca Fancellu <Luca.Fancellu@xxxxxxx>
  • From: "Orzel, Michal" <michal.orzel@xxxxxxx>
  • Date: Wed, 16 Apr 2025 15:10:17 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none
  • 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=7MPy0DaydIbRG9Uspm6pnkMLosb5GuT87IKBRTXynqM=; b=BR3Ee3h43uGXMvR9ajNhpfzuq4kE+cFTWqOwJuitoRA2ggX8/mXUpuz7Y0V3Jth1T7e12nCBF9tXCxHACrwQD7l3VYpXLKx4tqQlcY3QDQrlwV0E27KZqjBi2VOZV5oEdZhQQ9ogtfRRS32g41wocPHF2sXD73uloW1Nz0AgmupPDO5nW9BHfhAxJMUSgrvzGITaulurp7OKQ9oCexI2dY4OKxHPdueLYgov9Dy3/I8WeXgZvOKCHETvh+KBeXEHYSm0FbP8XgxDxBiNFCKAxmOXtuSkpgf1QahJj9N5l9RT4C9yP5sdj9hiwSdTiLhHHPjl71tsjsRLXyqMwixcfA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=g5jV5Dv/RlE2cD7yGC/5csUw8zBuBWsMhzE7ZqAsYao+F3AvRde+V+AJl6a+4OZs7bcGfcT/d/lDNrLkDOJuGWebGZdxB/OHpltIhD90MmVoJ7czt0uFAfwr9u8ez7PTSxliFL8+yOfGceq1ddMfP7R2rdZdRXQ+eCnGHt1qpiiU53djXbHT1d3iuw9/WDVvbrxzBiFC+Zyu/75DFAO0syer9R6SVOLKrK+LQ4tT2JcMgGnPV+PH2ADKX1LLFFWLl/5JXHKiZ91pLVHg6UVp0QEFT5Qq6Cp9W8kaDcpjQ6gp99Zdj3yvFklnQzQULOg3EWj/2SYZszPfAKbIDSX6GA==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.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 13:10:34 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>


On 16/04/2025 14:57, Luca Fancellu wrote:
> Hi Michal,
> 
>>>
>>>>
>>>>> +}
>>>>> +
>>>>> +/* 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?
>> What's the expected behavior of callers? Are we going to set up protection
>> region based on regular start+size pair (like with MMU) or start+end? If the
>> latter for some reason (with size there are less issues), then end usually is
>> inclusive and you would not need conversion.
> 
> I think we have a mix because for example destroy_xen_mappings and 
> modify_xen_mappings
> are start and end, map_pages_to_xen instead is kind of start+size?
> 
> I moved the -1 inside pr_set_limit because it was open-coded in all the 
> places, for example when
> referencing linker symbols or output of mfn_to_maddr(mfn_add(smfn, nr_mfn)), 
> for this reason I
> thought: let’s call this one with exclusive ranges and modify internally for 
> inclusive.
Hmm, yes. Indeed we have a mix of places where end is inclusive or exclusive. I
think we can stick with exclusive address being passed to this helper unless
others have a different opinion. I know we tried to convert some places to
start+size but I don't remember the future plans.

~Michal





 


Rackspace

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