[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v1 3/4] xen/arm: mpu: Create boot-time MPU protection regions
- To: Ayan Kumar Halder <ayankuma@xxxxxxx>
- From: Luca Fancellu <Luca.Fancellu@xxxxxxx>
- Date: Wed, 4 Sep 2024 18:14:20 +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=iYMHzqC8C9S8YzhtcPpA6Zwqs8HNic8uir2C4NSj6gw=; b=ObY8H86DVs5cRNhoV/IF1sZICK2em38WWp4myCGeHAbrnK4VLxENZPYrTbqyLK8RLT/QRPLsx8UY/F+tAHOKrLZstIDNla4Y2mI9gmhbzxamwGVLbTWFVM00ssjlflciMZRmIrC6DN4wqq5T+Pz8h5e+iaVewr0aGly856IQUTCa3AQC+l+w9sg1RQkEPJ7VW4cF8APdBhUyKaS2lCDgqgKLBwEw/oXsNpw47yiM9pQDNcvQ+2Dayu1XqbdRIgQksW3Eb6jkv9gYXzAlKbNb+kaTlpi+rNUEE2CUf3BeeirenBedcnXBIKTQnAlMctHYF8Ebv3L9wYS/WzvkKDOGXg==
- 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=iYMHzqC8C9S8YzhtcPpA6Zwqs8HNic8uir2C4NSj6gw=; b=kInB9eu0p+TjoUkFqiiPv2/43cb/+4afdPItt/AytRPL8mTpEIyaSchJ5zZgMmcaY5MWoDNZ3i+6Ucw1qy4aGh6WXZg9we2hseUTB0f78SlsCAiVebHZSKZCpi7PQi0xqoxaNgIYki0kuX3NkxVY9HTWkQC0+SEYvhUzblxSe5ACobsYZujIVZoFTNqakFHz6L20ERC4TPBC6fLwmSRfcxSbtcOrjTjoT4HhPUPMRthmJqeSZ4p8R0Cc80TK3dK5i1ZpLRN6YJ9c3g1KLgSzhPYqwlhxs98wAAutSNjI49EUYnt228a5NADdTXnhU/OC5eUt7mXQNH2b+cPOre8afA==
- Arc-seal: i=2; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=pass; b=iVdU43nWJrqK4QtaxzViCJUgXmuvefi+I/bFT9HIHIM7bHMCVIDQtOSrvM3HjI/ODBENxpPEmsKKc2n1MyIL8ibThv0o3LR4FEhi9HwelQZNgJyz40CFuR461QCpm0fABwDj32/k15Pk3mzupQ5nZjH+vRSzcM99jy3KcnEMMvaq7fbDIHbfjmt3bRoKWvV1Z65IDi91X8BJivYs3StOYntpQihNrxXnW6CnjHwXdpM0iVlLBWtZXCxwtoqfiecKfflEgPBZMKiT8ktSyF5DbiH+q9a0PtbILjVT9d0lxaK7+FFJIccKhGtEMNGKU3nhZYA6qeHEyjQz9r4L13dapA==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=qhLmvXsrNtYiKGunFpTk65lyZ2slDf10RpZeJD4kOEIRS37MeVChVii6z9rzcKjlL+ymx6zUUPSalvc4I6NSHpdHP9mpsb3WXK1ozusL3vl9Kcw08FYw0Ek503DCxjyU8gf4C3gD/ThRdMkVhbHjHkjjj45U4VG2j3Z3e0Fe2DQUoQEI+8OGoLP5C2YPKK639QexRBNJisH4l2+z8jptY1IKtbJ6pEWF2PVi/nAbCwcwpHq4tq+Hnbf8zxjYMxC86pAnA9PtotUODanIBf0iQD8CsBTPoGhq2fTzbTO0lZI9Isa55LRh9tMAuq8tHvHFUVwPEKNP4KpNIOwQAZkqBw==
- Authentication-results-original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com;
- Cc: Julien Grall <julien@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: Wed, 04 Sep 2024 18:15:05 +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: AQHa9XoHude8SoLzqU+vDRBIKLz30bI8y1SAgArTwQCAAGJvgA==
- Thread-topic: [PATCH v1 3/4] xen/arm: mpu: Create boot-time MPU protection regions
Hi Ayan,
Apologies but I can’t do a full review yet,
>>> +
>>> +/* MPU normal memory attributes. */
>>> +#define PRBAR_NORMAL_MEM 0x30 /* SH=11 AP=00 XN=00 */
>>> +#define PRLAR_NORMAL_MEM 0x0f /* NS=0 ATTR=111 EN=1 */
>>> +
>>> +.macro write_pr, sel, prbar, prlar
>>> + msr PRSELR_EL2, \sel
>>> + dsb sy
>>
>> I am not sure I understand why this is a dsb rather than isb. Can you
>> clarify?
>
> ISB is not needed here as the memory protection hasn't been activated yet.
> The above instruction just selects the memory region and the below two
> instructions sets the base address and limit for that memory region. After
> the three instructions, we need an ISB so that the memory protection takes
> into affect for further instruction fetches.
>
> However, a DSB is needed here as the below two instructions depend on this.
> So, we definitely want this instruction to complete.
>
> Further, refer to the note in ARM DDI 0600A.d ID120821, C1.7.1 "Protection
> region attributes"
>
> 0.
>
> ```Writes to MPU registers are only guaranteed to be visible
> following a Context synchronization event and DSB operation.```
>
> Thus, I infer that DSB is necessary here.
I think this was a mistake from the author of this patch, in my opinion there
should be an ISB
after setting PRSELR_ELx, to enforce a synchronisation before writing
PR{B,L}AR_ELx which
depends on the value written on PRSELR.
Cheers,
Luca
|