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

RE: [PATCH v6 10/11] xen/arm64: introduce helpers for MPU enable/disable


  • To: Julien Grall <julien@xxxxxxx>, Wei Chen <Wei.Chen@xxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Penny Zheng <Penny.Zheng@xxxxxxx>
  • Date: Tue, 8 Nov 2022 03:01:42 +0000
  • Accept-language: en-US
  • Arc-authentication-results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 63.35.35.123) smtp.rcpttodomain=lists.xenproject.org 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=armh.onmicrosoft.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=arcselector9901; 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=7jkLaB4R+FaIlTOUeDTc4Xb+ckoCt2cWhkOFAmxpWyk=; b=h8PNzZS2cALTb2TtazDfIqqCW/8/sjtGfwne/EfsEel4Bf84fSCIjS6HZ603sp0p7PEwXvck/tFKn96QMZX4LoGE+4AiZfD1gGQUAiAadC5F2pl5lr4cGCOeqSgi1/6DzEdO1r3/QHontbmN6Hv1NuEiXfJ/fNxA1dWMmiKnfbxV27n07Rzn2VS+GtusX1pf0jGR55AfovfhX2/u6I+LszYBIQtyd+EIxReExDReaPQ/3zaLkwgDA6VvuA8Wy/vHkMwAvVWoGM0YIMeuYsjMGv6oaCR8VucHGtCktEHXTudaH+Pjcq/UieMLFIx7ISSxVrW1dTa1hla05y8/kqLQoQ==
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=7jkLaB4R+FaIlTOUeDTc4Xb+ckoCt2cWhkOFAmxpWyk=; b=QH3M1Gs/eCmmE9XwETB8mLnepwaxHSvqBUssa5UVGNDh3kpXYxoQi6RQossQG8k9bzF/Ecz6nBRvir6v4hpqXCY070EMxBDQ5YT6HMGUkGbyE48WbRffhAjG7QGxSM3s738Hwhq852Ua0g3yrs4a5Pmk2q4PEBSpjPoHeqpN78Z2EofOBS9ooVp1lOCjZ4VmFHuLAl503vsWAziH8Uv1AVvNYHz0fGRJCzUdZ4rp4zvuJakaHK0YF5RdfFIFgUWCB3HfI5QDmpdz6gwy82u3arMkQv9lnMpma97V228xbQIv44HJxfjhSPp9h0NuS+dOLs6yFmob7MMIOxQDZ5rV6w==
  • Arc-seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=abvVDdCBzNImLoMZbpH2lfnJdn/w81V7aABMgNg5RatNeX/2qDGndF7p2JUqaPP3tT1ZyiUIdGOtXE7HlgRUuhUPjrgFncdqcbMcGz0rqVs+j1yA+TPmJDrCbNyuPzV9fyf9baNu/Uhsb+y/bJQQCF4YWtXsWTDqiVEHHIcx0HGQI7x2cpk8Ta5pRgYehK+ta0AfgkRu/Vkzg3YPaKHtHgQWSxKR57cFJCOueJdzh5LGA3/jY2CT9jdJCCygVuE1dFMp4JUtTKZaab/FilQSG7FuHNztCYnh71dBtCYoFGbTKbOejk8wdxijDoQzmv6IiRBHLfgwyCSSunGtU/R6bA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OLE7a1Q1o8BIu3bkB3S+iy1XULwJOT8VLQx4A4ug1L/1Gu2RczO2+sbnLiEaMBiCRILK1v/rOYD/rsUiiJknWYo0C8qSICB2BI7x84iw0fmVCpBfG3DMIzVfG0EeNW+XZYQ2vrAw46qZyHv9VKZaLqGyusGOqFJRcCM1aEwzPUDydZILTQKUdg0SkMJpBWrofZkPEQmGQbFRuo5BBumIaXkWFPNUF6H4A0NzXBLYg+3Pbzmen3vdnuUspBmz10R7aIl1pMQ2qKU69mAfR0OhevV1rA/zF10HoK5kgo1toIFCLD8u/lCj7EedHWJY0LuXppQDHax14ytO5LJ4NHBIIw==
  • Authentication-results-original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com;
  • Cc: nd <nd@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Bertrand Marquis <Bertrand.Marquis@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>
  • Delivery-date: Tue, 08 Nov 2022 03:02:15 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Nodisclaimer: true
  • Original-authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com;
  • Thread-index: AQHY8DVttaMHoZmFwkey/b3g/gof864yY/8AgADDtcCAACIBAIABDoXw
  • Thread-topic: [PATCH v6 10/11] xen/arm64: introduce helpers for MPU enable/disable


> -----Original Message-----
> From: Julien Grall <julien@xxxxxxx>
> Sent: Monday, November 7, 2022 6:38 PM
> To: Penny Zheng <Penny.Zheng@xxxxxxx>; Wei Chen
> <Wei.Chen@xxxxxxx>; xen-devel@xxxxxxxxxxxxxxxxxxxx
> Cc: nd <nd@xxxxxxx>; Stefano Stabellini <sstabellini@xxxxxxxxxx>; Bertrand
> Marquis <Bertrand.Marquis@xxxxxxx>; Volodymyr Babchuk
> <Volodymyr_Babchuk@xxxxxxxx>
> Subject: Re: [PATCH v6 10/11] xen/arm64: introduce helpers for MPU
> enable/disable
> 
> 
> 
> On 07/11/2022 09:57, Penny Zheng wrote:
> > Hi Julien
> 
> Hi Penny,

Hi Julien

> 
> >
> >> -----Original Message-----
> >> From: Xen-devel <xen-devel-bounces@xxxxxxxxxxxxxxxxxxxx> On Behalf Of
> >> Julien Grall
> >> Sent: Monday, November 7, 2022 4:56 AM
> >> To: Wei Chen <Wei.Chen@xxxxxxx>; xen-devel@xxxxxxxxxxxxxxxxxxxx
> >> Cc: nd <nd@xxxxxxx>; Penny Zheng <Penny.Zheng@xxxxxxx>; Stefano
> >> Stabellini <sstabellini@xxxxxxxxxx>; Bertrand Marquis
> >> <Bertrand.Marquis@xxxxxxx>; Volodymyr Babchuk
> >> <Volodymyr_Babchuk@xxxxxxxx>
> >> Subject: Re: [PATCH v6 10/11] xen/arm64: introduce helpers for MPU
> >> enable/disable
> >>
> >> Hi Wei,
> >>
> >> On 04/11/2022 10:07, Wei Chen wrote:
> >>> From: Penny Zheng <penny.zheng@xxxxxxx>
> >>>
> >>> We need some helpers for Xen to enable/disable MPU in boot-time and
> >>> runtime. For MPU enable helper, we know that it's an essential
> >>> requirement of MPU system. But for MPU disable, we need to use it
> >>> for some special situations. For example, in the progress of
> >>> tranferring from boot-time to runtime, we need to update the MPU
> >>> protection regions configuration, but we can't modify an MPU
> >>> protection region if there is some data accessed by Xen. But in
> >>> boot-time all of Xen text, data and BSS are in one MPU protection
> >>> region, if Xen want to update this protection region, above restriction 
> >>> will
> be triggered.
> >>
> >> This raises the following question: Why can't we create the split
> >> regions right now?
> >>
> >
> > The reason why we are not creating the split regions right now is that
> > we are trying to go the same path MMU goes.
> 
> The MMU code is going to change pretty soon (see [1] for some ground
> work). The runtime page-tables for CPU0 will be created in assembly code
> and never switched after (aside when using cache coloring).
> 
> Although, I don't think I will apply the proper permissions in assembly (this 
> is
> a bit trickier than with the MPU).
> 
> > Then we could reuse as much
> > same interfaces as we could, in order to not leave #ifdef
> > CONFIG_HAS_MPU all over the place.
> Do you have a list of those interfaces that would require #ifdef?
> 
> >
> >> In particular, disabling the MMU/Cache is fairly risky because you
> >> need to ensure that anything in the cache you care about have been
> >> written back to the RAM).
> >>
> >
> > Hope I could understand your concern totally, you are worrying about
> > stale info left in the cache, even if it's always 1:1 mapping on the
> > MPU system, memory attributes could be different before and after?
> 
> No. I am more concerned about...
> 
> > So it is never enough that we only flush the variables which we will
> > use during the disabling time, it should be everything in the
> > cache...:/
> 
> ... this. We don't only need to flush before they are accessed but also after 
> if
> they are modified.
> 
> It is possible to do it correctly, but it requires to be very careful.
> So if we can avoid disabling the cache/MPU then it will be a lot better.
> 
> >
> > Since in current design, there are two time points in boot time where
> > we will disable MPU/Cache to configure MPU.
> >
> > One is in setup_mm, here, we will map XEN components by components,
> > each MPU memory region for a different component.
> > The other is near the end of boot time, we will reorg the whole MPU
> > memory region layout before going runtime, and we will keep unchanging
> regions in the front and flexible ones in the rear.
> 
> You should not need any reorg if you map the boot-only section towards in
> the higher slot index (or just after the fixed ones).
> 

"in the higher slot index" is really shining a light in my mind ;) And I'll try 
to enable it
in v2.

> Cheers,
> 
> [1] 20221022150422.17707-1-julien@xxxxxxx
> 
> --
> Julien Grall

 


Rackspace

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