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

Re: [PATCH 4/6] arm/mpu: Introduce modify_after_init_mappings


  • To: "Orzel, Michal" <Michal.Orzel@xxxxxxx>
  • From: Luca Fancellu <Luca.Fancellu@xxxxxxx>
  • Date: Tue, 16 Dec 2025 13:11:30 +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=uoI7B1/zU8kBCvCQKWt8vAlsd5wE3WnTXgvKAvfMKkI=; b=ALvWPqP8wPjGHUoROcFKpDhZomx7ax+AnIaxEvep570p8Z491R/+ikuPzWtRNLMTPRy+PeyAV3J06tlzD+VaL0Rba6y6CQVGWH4A9LHBGOl7XaNBMr6b/vW2ajRNgMpy2stjUOF/8lyZFe/oY2dh8/tcPkg3N83dQCrMcrruJ3sy/gz5ioaU4MpIGDkmhXJBoqckShvWd89m6M+fDO0712qsFwppo9ITfyXvrCGiGGS8QBhz3YE4d6Z0t7jw4vbnoOWEYrpI6/anSV1sqOocZX957WFbUwT4h7BmVvnDSdnBM4QQWWcITt9wYIWuzbeGfsx6sZ5jHyhJaCuCVfp4rg==
  • 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=uoI7B1/zU8kBCvCQKWt8vAlsd5wE3WnTXgvKAvfMKkI=; b=ia8wqr+i8RVj4Tvy+Up64GTaW9sEVJ7Kgd3v4DWKkmX3dubygNeCvIGpWOMhRgu6sAM97d4+t3+2b4TxL+MPKDDEpvY/PyFv+4t59inOnswtZukgrkVOe+iBxpVco9deEefFT0aD/n753htZ4HR58Ll1wQCzuOMBosPGUU7mpAla2gL4N/PUBRHq4B0QWBnxkN9xfDCYFVLERXw3NQlGXk/kTUblUYHaxRFAqdi0VDppl+yF29+zJsjtj511ctUnTTa+xwE4mBy+k1ggmP0MCf5cM/8gGqrhy2CHHYlYOHfI9zlxNUh7PtsdvK/slzXpXSrfPd2tpMpwf4sUcNr9Cw==
  • Arc-seal: i=2; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=pass; b=NKCkjD6hsOeqbxrM4LWAU1eiTlzPKAkbtSNrrrL20d92BIqmXNFLjwxcleeecw7px7hkDkW1tujmEcrj0F6l04HWPNNd+YWSddggRY/Q6gHWRP+6wxduozfHZOYat6meUUhiQiGPdkB90tadZSQ3b0vyMdKGjLYCdJHiw2apomrXMmYYPnvntfTH7EmqQ4+g4e7C1lA/fSDJsk59zU0dxE9ylo969kAj04L77KzJZdKEW2hwWqZzu2v3WfJop2X6hmXRFvNpIJQpp/r/Nzk9lA5hj4agj16uagWeJLdWkOXXR/iZcsAHNmIZOqt1EQ5+jtQuL1KTJx9FI6UHaDc56g==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=kbaC0e/Ze0Ciav8HyeHfG7NAVGzNnLGifAqihBvU2j/UJzsZeNV22MgjgVCI8lJFn2npjZedkNIA11e2qH0ZUERBASFD68iyYkmsf0/E07lr2lJbR8YCKEa8WCi9TliPqpy3oQm6oZdksFe7Pj8MQz1jIVJ6LQAFnnZKu1Iq7s2VFbD412wqIRrbVJe8gxxFr7SSlGeWGRecyHXID/bcfZCQtTOlXQkusgezC68ii9zmcoRutU7cSc76gmJJKteiyL2R9yQlbRMKojvGpYmdN7JcjVw07KKBWmKxoU59O4gP5BkN1tt2nNvLR2vjG5NzLIGfLzy18LFxI86vwC078Q==
  • Authentication-results-original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com;
  • Cc: Harry Ramsey <Harry.Ramsey@xxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Bertrand Marquis <Bertrand.Marquis@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>, Hari Limaye <Hari.Limaye@xxxxxxx>
  • Delivery-date: Tue, 16 Dec 2025 13:12:56 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Nodisclaimer: true
  • Thread-index: AQHcbmyFulGILbBE7ECsCvfNrhQ4ULUkPf8A
  • Thread-topic: [PATCH 4/6] arm/mpu: Introduce modify_after_init_mappings

Hi Michael,

> On 16 Dec 2025, at 09:15, Orzel, Michal <Michal.Orzel@xxxxxxx> wrote:
> 
> 
> 
> On 28/11/2025 10:58, Harry Ramsey wrote:
>> From: Luca Fancellu <luca.fancellu@xxxxxxx>
>> 
>> During `init_done`, Xen sets the permissions of all symbols marked with
>> __ro_after_init to be read-only. Currently this is achieved by calling
>> `modify_xen_mappings` and will shrink the RW mapping on one side and
>> extend the RO mapping on the other.
> Can you be more specific about the sides you mention? How did you deduce it?
> I assume you are talking about MMU part.

You are right, this sentence is a bit misleading.
So what was written here was meant to say that on MPU modify_xen_mappings
should shrink the RW mapping region and extend the RO mapping region because
as of now they are declared like this in xen.lds.S:

read only data:
+------------------+
| _srodata         |
| _erodata         |
+-------------------+

RW data:
+---------------------------+
| __ro_after_init_start |
| __ro_after_init_end  |
| __init_begin              |
+---------------------------+

And in head.S we map like this:

/* Xen read-only data section. */
ldr x1, =_srodata
ldr x2, =_erodata
prepare_xen_region x0, x1, x2, x3, x4, x5, attr_prbar=REGION_RO_PRBAR

/* Xen read-only after init and data section. (RW data) */
ldr x1, =__ro_after_init_start
ldr x2, =__init_begin
prepare_xen_region x0, x1, x2, x3, x4, x5

Now, because (__ro_after_init_start, __ro_after_init_end) needs to become RO,
it means that RO section will be extended to (_srodata, __ro_after_init_end) and
RW section will be shrinked to (__ro_after_init_end, __init_begin):

read only data region:
+--------------------------+
| _srodata                  |
| __ro_after_init_end |
+--------------------------+

RW data region:
+---------------------------+
| __ro_after_init_end  |
| __init_begin              |
+---------------------------+

So what we’ve done is taking (__ro_after_init_start, __ro_after_init_end) from
the RW region and attach it to the RO region.

> 
>> 
>> This does not work on MPU systems at present because part-region
>> modification is not supported. Therefore introduce the function
> What else is in that region?
> Wouldn't it be better to have one region for this __ro_after_init so that we
> don't need to shrink/extend the mappings? Is it done because of number of
> regions limitation?

So if we do in this way we waste one region, because we will have 2 region 
declared
RO that are also contiguous, so easily mergeable, like how we are doing above by
Extending/shrinking.

Cheers,
Luca


 


Rackspace

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