All of lore.kernel.org
 help / color / mirror / Atom feed
From: Julien Grall <julien@xen.org>
To: Penny Zheng <Penny.Zheng@arm.com>, Wei Chen <Wei.Chen@arm.com>,
	"xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>,
	Stefano Stabellini <sstabellini@kernel.org>
Cc: Bertrand Marquis <Bertrand.Marquis@arm.com>,
	Henry Wang <Henry.Wang@arm.com>, nd <nd@arm.com>
Subject: Re: Proposal for Porting Xen to Armv8-R64 - DraftA
Date: Wed, 2 Mar 2022 12:06:01 +0000	[thread overview]
Message-ID: <8b24027f-b659-098b-6faa-3591621fa0a1@xen.org> (raw)
In-Reply-To: <DU2PR08MB73257F1F8FFB2BF8F3384F66F7039@DU2PR08MB7325.eurprd08.prod.outlook.com>



On 02/03/2022 07:21, Penny Zheng wrote:
> Hi julien

Hi Penny,

>>>>
>>>>     So if the unpaused guests start executing the context switch at this
>>>>     point, then its MPU context will base on the boot-time MPU
>>> configuration.
>>>
>>> Can you explain why you want to switch the MPU configuration that late?
>>>
>>
> 
> It is more related to the implementation.
> 
> In the boot stage, we allocate MPU regions in sequence until the max.
> Since a few MPU region will get removed along the way, it leaves hole there.
> Such like when heap is ready, fdt will be reallocated in the heap, which means the
> MPU region for device tree is in no need. And also in free_init_memory, although we
> do not give back init memory to the heap, we will also destroy according MPU
> regions to make them inaccessible.
> Without ordering, we need a bitmap to record such information.
> 
> In context switch, the memory layout is quite different for guest mode and
> hypervisor mode. When switching to guest mode, only guest RAM, emulated/passthrough
> devices, etc could be seen, but in hypervisor mode, all guests RAM and device memory
> shall be seen. And without reordering, we need to iterate all MPU regions to find
> according regions to disable during runtime context switch, that's definitely a overhead.
> 
> So we propose an ordering at the tail of the boot time, to put all fixed MPU region
> in the head, like xen text/data, etc, and put all flexible ones at tail, like device memory,
> guests RAM.
> Then later in context switch,  we could easily just disable ones from tail and inserts new
> ones in the tail.

Thank you for the clarification. This makes sense to me. I would suggest 
to update the proposal to reflect this decision.

>> For PMSA, we still enforce WnX. For your use case, I assume it's alternative.
>> It still may have some possibility to avoid vmap(). But there may be some
>> security issues. We had thought to disable MPU -> update xen text -> enable
>> MPU to copy VMSA alternative's behavior. The problem with this, however,
>> is that at some point, all memory is RWX. There maybe some security risk.
>> But because it's in init stage, it probably doesn't matter as much as I thought.
>>
> 
> In MMU system, we use vmap() to change requested xen text codes(a few lines) temporarily
> to RW to apply the alternative codes, the granularity for it could be 4KB.
> 
> But on MPU system, we give the whole XEN text code a MPU region, so otherwise we disable
> the whole MPU to make it happen, which leads to a little risk for running c codes where MPU
> disabled, or all text memory becoming RWX at this alternative time.

See my answer to Wei. So long the code is compliant with the Arm Arm, it 
would be acceptable to have boot code running with RWX for a short 
period of time.

Cheers,

-- 
Julien Grall


  reply	other threads:[~2022-03-02 12:06 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-24  6:01 Proposal for Porting Xen to Armv8-R64 - DraftA Wei Chen
2022-02-24 11:52 ` Ayan Kumar Halder
2022-02-25  6:33   ` Wei Chen
2022-02-25  0:55 ` Stefano Stabellini
2022-02-25 10:48   ` Wei Chen
2022-02-25 20:12     ` Julien Grall
2022-03-01  6:29       ` Wei Chen
2022-03-01 13:17         ` Julien Grall
2022-03-02  6:43           ` Wei Chen
2022-03-02 10:24             ` Julien Grall
2022-03-03  1:35               ` Wei Chen
2022-03-03  9:15                 ` Julien Grall
2022-03-03 10:43                   ` Wei Chen
2022-02-25 23:54     ` Stefano Stabellini
2022-03-01 12:55       ` Wei Chen
2022-03-01 23:38         ` Stefano Stabellini
2022-03-02  7:13           ` Wei Chen
2022-03-02 22:55             ` Stefano Stabellini
2022-03-03  1:05               ` Wei Chen
2022-03-03  2:03                 ` Stefano Stabellini
2022-03-03  2:12                   ` Wei Chen
2022-03-03  2:15                     ` Stefano Stabellini
2022-02-25 20:55 ` Julien Grall
2022-03-01  7:51   ` Wei Chen
2022-03-02  7:21     ` Penny Zheng
2022-03-02 12:06       ` Julien Grall [this message]
2022-03-02 12:00     ` Julien Grall
2022-03-03  2:06       ` Wei Chen
2022-03-03 19:51         ` Julien Grall
2022-03-04  5:38           ` Wei Chen
2022-03-07  2:12         ` Wei Chen
2022-03-07 22:58           ` Stefano Stabellini
2022-03-08  7:28             ` Wei Chen
2022-03-08 19:49               ` Stefano Stabellini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8b24027f-b659-098b-6faa-3591621fa0a1@xen.org \
    --to=julien@xen.org \
    --cc=Bertrand.Marquis@arm.com \
    --cc=Henry.Wang@arm.com \
    --cc=Penny.Zheng@arm.com \
    --cc=Wei.Chen@arm.com \
    --cc=nd@arm.com \
    --cc=sstabellini@kernel.org \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.