[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v3 1/6] arm/mpu: Find MPU region by range
- To: Hari Limaye <Hari.Limaye@xxxxxxx>
- From: "Orzel, Michal" <michal.orzel@xxxxxxx>
- Date: Tue, 15 Jul 2025 10:45:00 +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=GfygdWLF9eVg1C32B7mA02F9up0l0eO/JwLclgacNKA=; b=o+2Z1Mr/ubYoKUFKF/o3yVER/Ha4ov5lTSFQz/lenlN43Y0crVktSAsbF1x7KAKOkOiOT7Loy5SdcMnFH7Ab9mjsUUry1U0HJiNXXEpjHig2mcGNYgawh6rOYbt9EernsGGrnRWp4un8Sbzi7pxfPBFmrl9IH1Xez+E9eMTFPmIfOK6Nk/2i7tGZyWfgpqKL8r6EyciKn1uUrSioDoLq5suN0YQWoW0xGWRI4cuQH07o+c6mDrje2OiM71897IDGPlmNuYRRK2Oh9z5gTdKwSDvNksLNh1mnw0CDlANaZk5uSLvzpSLhEt6Lt7+zQ/z7LUGLovUdLEKSfG4YQgXBIA==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=VeKxQMU5ozGm7OqGYrV4m2RMoNzuk/HanIqWk6nbe01u31X6zoSqGjdcfYmeBg117zGkKkriTsYcnepoDeDwDm4vS5dwkcmetgIN+q7ZVvesZ2iqOqPulXC2J2mUFby4OcNbP2VwHMWlqxgjBigRkqAg7c5z02oN/I1NAKmJeT8MXpQ9zXB98zWNiO8PotMy0Y1yrYxuyZgChpA/uIjKkLsT/0rx9WTI5Bqsq024ZrYR3Xve+xKyeMKuWL43EcX39//ezpORFtHgzoUsl7RvbCAQ3OUUSmWzknZ1QyPH4iULZ5KjJeV97wxqgEQCN/FjjCPhFBJbINCqCceR0fgA7g==
- 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>, Luca Fancellu <Luca.Fancellu@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Bertrand Marquis <Bertrand.Marquis@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>
- Delivery-date: Tue, 15 Jul 2025 08:45:34 +0000
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
On 15/07/2025 10:36, Hari Limaye wrote:
> Hi Michal,
>
>>> +int mpumap_contains_region(pr_t *table, uint8_t nr_regions, paddr_t base,
>>> + paddr_t limit, uint8_t *index)
>>> +{
>>> + ASSERT(index);
>>> + *index = INVALID_REGION_IDX;
>>> +
>>> + /*
>>> + * The caller supplies a half-open interval [base, limit), i.e. limit
>>> is the
>>> + * first byte *after* the region. Require limit strictly greater than
>>> base,
>>> + * which is necessarily a non-empty region.
>>> + */
>>> + ASSERT(base < limit);
>> Well, that does not guarantee a non-empty region.
>> Consider passing [x, x+1). The assert will pass, even though the region is
>> empty.
>>
>> ~Michal
>>
>
> Apologies, I may well be missing something here! Please could you suggest a
> code snippet to understand your expectation here / what you would prefer the
> assert to be?
>
> As I understand it, with a half-open interval [base, limit) as is passed to
> this function, the size is `limit - base` and so the region [x, x+1) will
> have size 1. The empty region starting at the same address would be [x, x).
> But perhaps I am making the off-by-one error here.
Hmm, I think I made a mistake here. Region of size 1B would have base == limit
in registers. All good then.
~Michal
|