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

Re: [PATCH v3 5/6] xen/arm: mpu: Enable MPU


  • To: Julien Grall <julien@xxxxxxx>
  • From: Luca Fancellu <Luca.Fancellu@xxxxxxx>
  • Date: Tue, 22 Oct 2024 16:31:31 +0000
  • Accept-language: en-GB, 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=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=+iogjHvKULRhpoZnqEEqrhODqSBOgmiczakkfqa6Hjw=; b=ifMpu8iYXoyscivp4B9s3ruJsw7aWuR+4iTFrq3pi9Fd6Vbiy0JaI6k963PPM6x3ry0o01PQ7oOCf1Tc1zYEjoHJy7SLttH11723KXE6A2su6FY9gw3mbI4YEshXvbNltmqENd9eH00pKLsAsx3UJMDNvuo8xo2ve0dIxinQAHmQ1ShHNRB1C0Gy3zi6jKRn0MFHJtI9hsKDEALxne3W9ESgo6HIfc3oo6bkSTtNqrlZ65+4AVcQMAW/zUte9Soe9CbNCf4W24D3FHu9ijIx8mkKm+GrQFvQDerOGLVpvpdLfSwIJJBPkKAya0dJqFT9PeLpqEReojOYj5I73LotUg==
  • 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=+iogjHvKULRhpoZnqEEqrhODqSBOgmiczakkfqa6Hjw=; b=TxQQwpEBFfqjkqO7HFNC3VOxlJmCKJk5X3OSS7F4QxPoRMnqSVeH2RZucP7dloQ9Nk+CSkMAcT5hu4zFCW2mI53bHXA52fVEmTSgoHmgFlSPQ0VhEGVROtSNCjOBevu2X8YPFDIDnC/U4hIusIbPg8jEaJctBH5JKVpG6bkd5JpOyp1h6HZJZ1ht8fKCmqWANVX3ACxSPofA1pUQoCmBxxoh/K+z429caTYvYWVpla7ZXZ2vwKEVI22QTubnd8UZjZlyH2ZmCcFsa1rPR0X4SjagkJt7SiwqVlwtj87PAyWaywaHVhGDi1c/UY6t3tpD79AwGLjyl1KQE/IWwbZ0zg==
  • Arc-seal: i=2; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=pass; b=LdoxShfHIVTQbCBaj6quzf3DsqjgFNaP9lOks0FKpRPl5FJMcVdv/vUAjyxNIZM+zSnlY8C8aefiDlgidrbue+ixTZJk5X4/V1EP1+Tw8pw2sqnwi7HSggugMv7UPdmK4gkjXyRPLETljfEc7z0FFfZx+mNQyRTmg0yNn7wiu9cB0ZiQm6p0dmbfz1mufG9DtCNE3MIPQ2SRvei38r4YDGRUTk8JfxjzTOe3ptGIJ9k3JnZDbJ99XLeXPcfi7QFWUwh2ggN4DKnT2xI4quxnlV/tHGRGG9RWJXSWM/SctH+8vguv0Qkt3Jk321rQIFjLWSVoc2npPXJ/8dX7qlGcCw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=YHgGAeyqubyMQDQ1VPfECAeZcXsffk6/XHzfJbz20FLXDX7WyKjocXMMVM3LE6bmcxtQVH/kfl36PJcOQH1QOVrlduMlIiHVqahOkhdrYgPOe4GJaDoZqQl+bWdjmtHH3A7VLtF1EopLpsFX1/HbXh4YU2x1tSbc3fbxhE3FTj1KrQeot4ULF3PMa0x1AVcjUMAGr13Ds0KpjzOdhj63Y9gbb46520Pml2fHfE/BZIam3w41cowyGg0ISgCCbodzd0Ud000u2UoeQpxIYHf+rJik5dYtHqbyC7f+su/84vS/+IG0ge3doS5qzo8GdnRsh1JUYyxVg1JidoEB35u0LA==
  • Authentication-results-original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com;
  • Cc: Ayan Kumar Halder <ayankuma@xxxxxxx>, Ayan Kumar Halder <ayan.kumar.halder@xxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Bertrand Marquis <Bertrand.Marquis@xxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>
  • Delivery-date: Tue, 22 Oct 2024 16:31:54 +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: AQHbGx2Ge9N55hTx/U2iD9lYiTVQprKNIysAgARC6gCAAA8agIAAAOKAgAEgqoCAAAHOgIAAAmiAgAA3SQCAADcxAA==
  • Thread-topic: [PATCH v3 5/6] xen/arm: mpu: Enable MPU

Hi Julien,

> On 22 Oct 2024, at 14:13, Julien Grall <julien@xxxxxxx> wrote:
> 
> 
> 
> On 22/10/2024 10:56, Luca Fancellu wrote:
>>> On 22 Oct 2024, at 10:47, Julien Grall <julien@xxxxxxx> wrote:
>>> 
>>> Hi Luca,
>>> 
>>> On 22/10/2024 10:41, Luca Fancellu wrote:
>>>>> On 21 Oct 2024, at 17:27, Julien Grall <julien@xxxxxxx> wrote:
>>>> 2) dsb+isb barrier after enabling the MPU, since we are enabling the MPU 
>>>> but also because we are disabling the background region
>>> 
>>> TBH, I don't understand this one. Why would disabling the background region 
>>> requires a dsb + isb? Do you have any pointer in the Armv8-R specification?
>> I’m afraid this is only my deduction, Section C1.4 of the Arm® Architecture 
>> Reference Manual Supplement Armv8, for R-profile AArch64 architecture,
>> (DDI 0600B.a) explains what is the background region, it says it implements 
>> physical address range(s), so when we disable it, we would like any data
>> access to complete before changing this implementation defined range with 
>> the ranges defined by us tweaking PRBAR/PRLAR, am I right?
> 
> My mental model for the ordering is similar to a TLB flush which is:
>   1/ dsb nsh
>   2/ tlbi
>   3/ dsb nsh
>   4/ isb
> 
> Enabling the MPU is effectively 2. AFAIK, 1 is only necessary to ensure the 
> update to the page-tables. But it is not a requirement to ensure any data 
> access are completed (otherwise, we would have needed a dsb sy because we 
> don't know how far the access are going...).

Uhm… I’m not sure we are on the same page, probably I explained that wrongly, 
so my point is that:

FUNC_LOCAL(enable_mpu)
    mrs   x0, SCTLR_EL2
    bic   x0, x0, #SCTLR_ELx_BR       /* Disable Background region */
    orr   x0, x0, #SCTLR_Axx_ELx_M    /* Enable MPU */
    orr   x0, x0, #SCTLR_Axx_ELx_C    /* Enable D-cache */
    orr   x0, x0, #SCTLR_Axx_ELx_WXN  /* Enable WXN */
    dsb   sy
    ^— This data barrier is needed in order to complete any data access, which 
guarantees that all explicit memory accesses before
           this instruction complete, so we can safely turn ON the MPU and 
disable the background region.
    msr   SCTLR_EL2, x0
    isb

    ret
END(enable_mpu)

I didn’t understand if your point is that it is not needed or if it is needed 
but in a different location.

> 
> Cheers,
> 
> -- 
> Julien Grall
> 


 


Rackspace

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