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

Re: [PATCH v4 3/3] arm/mpu: Enable read/write to protection regions for arm32


  • To: Hari Limaye <hari.limaye@xxxxxxx>, Ayan Kumar Halder <ayan.kumar.halder@xxxxxxx>
  • From: Ayan Kumar Halder <ayankuma@xxxxxxx>
  • Date: Tue, 17 Jun 2025 17:28:54 +0100
  • 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=Rz+fx19Fsuiha2f8OkeysdgWFIsl4ZRR/PssR75h0cM=; b=YG4xkcBVZRLe5+hFvO0aDIhxlLWcCvWkTeN2GvneeOyMayH4JoTf5JgUSwPZo9xf0+3BrSqSeTJ66+a4y5lw6yRL2L04Hsv4h4TW+RD9OOEY5McGVuSslqYj5vflsHroblp+kxyRCHprsApDySic7WdYlJAtulaC6iBTEZ0XnTvFtyRAg2GZ4YiQhZSFpFA8Xa4D/RIZKaNYPiRD6okbpAgGc5OTRIVonHQf7j8pF505ZQUwDDmRTL1UckjqYY5qbfy2FTpl3p0V7COrWmUMv0VwdQ+R345sWGc5sA/xiFgn/VKC1MkOk45EbjOaJPN6vp1jErdJ1NKg1I0wwoSHlQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=q7cVa8Z33I7KqRzvPjBx6HkfptkHAAc90JcvF/5FXL2+6TBZuOqccye4hzlSfB2eLWpXP7fQOGLhJlLYG1a5GdOEGVRbxjORWO5cBHAbnCfvB25evJf/P6dD9RUlrIwzlZhrzX/VCBE7k1odr/PHNnMKEF0RBxEgtSMN0/6bVi0E6KyJlu7vvrEJz2XVDXFnIsIIDNfYU+OKis20ZbKEwcbq/qK3UJQ+iGjkjnrysgL+IZJGVOixw4I+lnFlqizFFR4Ea1Nzwf03wo76TnKgmrd2rwRSzwUhtg5wqzd8pLxL9wE2GvwYWPF1BHj1j1IA/oadzlCWHgxVtPpaeTd7aQ==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com;
  • Cc: xen-devel@xxxxxxxxxxxxxxxxxxxx, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>, Luca Fancellu <luca.fancellu@xxxxxxx>
  • Delivery-date: Tue, 17 Jun 2025 16:29:12 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>


On 17/06/2025 16:31, Hari Limaye wrote:
Hi Ayan,
Hi Hari,

+/*
+ * Armv8-R supports direct access and indirect access to the MPU regions 
through
+ * registers:
+ *  - indirect access involves changing the MPU region selector, issuing an isb
+ *    barrier and accessing the selected region through specific registers
+ *  - direct access involves accessing specific registers that point to
+ *    specific MPU regions, without changing the selector, avoiding the use of
+ *    a barrier.
+ * For Arm32 the HPR{B,L}AR<n> (for n=0..31) are used for direct access to the
+ * first 32 MPU regions.
+ * For MPU region numbered 32..254, one need to set the region number in 
HPRSELR,
+ * followed by configuring HPR{B,L}AR.
+ */
+static void prepare_selector(uint8_t *sel)
NIT: s/one need/one needs/
NIT: s/MPU region numbered/MPU regions numbered/
Ack.

Also - it's not clear to me what is meant by "followed by configuring 
HPR{B,L}AR";
if I understand correctly, once we have set the region number in HPRSELR
and issued an isb we can simply read/write HPR{B,L}AR as indicated in
the bullet point above?
yes, this is correct.

On Tue, Jun 17, 2025 at 12:12:51PM +0000, Ayan Kumar Halder wrote:
Define prepare_selector(), read_protection_region() and
write_protection_region() for arm32. Also, define
GENERATE_{READ/WRITE}_PR_REG_OTHERS to access MPU regions from 32 to 254.

Enable pr_{get/set}_{base/limit}(), region_is_valid() for arm32.
Enable pr_of_addr() for arm32.

The maximum number of regions supported is 255 (which corresponds to the
maximum value in HMPUIR).

Signed-off-by: Ayan Kumar Halder <ayan.kumar.halder@xxxxxxx>
Reviewed-by: Luca Fancellu <luca.fancellu@xxxxxxx>
---
Apart from the above, all LGTM! I've tested compilation for both 64-bit
and 32-bit and all is building successfully.

Reviewed-by: Hari Limaye <hari.limaye@xxxxxxx>
Tested-by: Hari Limaye <hari.limaye@xxxxxxx>

- Ayan




 


Rackspace

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