Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 62BE8C369AB for ; Tue, 15 Apr 2025 11:25:57 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.953679.1348128 (Exim 4.92) (envelope-from ) id 1u4eQF-00013Z-Br; Tue, 15 Apr 2025 11:25:47 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 953679.1348128; Tue, 15 Apr 2025 11:25:47 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1u4eQF-00013S-7m; Tue, 15 Apr 2025 11:25:47 +0000 Received: by outflank-mailman (input) for mailman id 953679; Tue, 15 Apr 2025 11:25:45 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1u4eQD-00013M-Eq for xen-devel@lists.xenproject.org; Tue, 15 Apr 2025 11:25:45 +0000 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2062e.outbound.protection.outlook.com [2a01:111:f403:2415::62e]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 5b512903-19ec-11f0-9ffb-bf95429c2676; Tue, 15 Apr 2025 13:25:39 +0200 (CEST) Received: from BN9PR12MB5273.namprd12.prod.outlook.com (2603:10b6:408:11e::22) by DS0PR12MB9398.namprd12.prod.outlook.com (2603:10b6:8:1b3::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8632.31; Tue, 15 Apr 2025 11:25:36 +0000 Received: from BN9PR12MB5273.namprd12.prod.outlook.com ([fe80::cf66:58ab:47be:4b13]) by BN9PR12MB5273.namprd12.prod.outlook.com ([fe80::cf66:58ab:47be:4b13%5]) with mapi id 15.20.8632.036; Tue, 15 Apr 2025 11:25:36 +0000 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 5b512903-19ec-11f0-9ffb-bf95429c2676 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=byfxC0yYTNv4oW9FmBGU9AVZE8dhZorAC6iMC0n1iekkrFqzZfnJeN+i7tMqpVJf9MgIBneKOb2SZwkEaCYYKmwX+pTrz1ZEWusGjtqEcrbrscmQo3+cDTP5S7cw08drWZpbrrTh/Tc4quVEMEIckr65Peg2qJI/XJZUWHC8V5zoDb9wOMP188WwgbWChJr3YtVhhyfl6KTEIffEWWC+oubvuDLsrAVKpdglMyD/q6sOYGICs5eAa4GGHDJtgw4JhLxYLNOYV2DTKrr6N9Xoay68oUvBeKu5KQjsLcI8e/wBAeMqcdDjJVdBJ/ZYaQ4TVhpm8A++EAiER6m9MS42/A== 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=aF0X0EOR7KbMeuIcbzNNJTOzpB6njaxE1Lpwg1TlxSs=; b=l73jRp5aC1mHlssdl9Yfl/1PjAX/EVSgajAsJwfeQ1OdbzFIlsRCIZpJt9B53BUwSCOnbgB4nNz5Y1eTftLgR59WLNazII0JiJksozkkg2BKyxP2p0Rlec2u90m5kBUJ5+28f2kOKsWtJLvmA6dhT+hC27Tjlz6aKVvjAIiIEpyCpfddma+9ia2tK3JM4SWS2+YgmLCPXd07ivdIfd/GjuLhOjf6IkolVAXH5OEk9Wjjz6tNRNRijPK7UemmUG9x5YFaMvUKzPIxvKIKWTuq9iTGRzl290jMblgTbMin/hJ2acKMevAA896HZdqDyK3fEz9u1vS/hnzXe+3HJ0vZLg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=aF0X0EOR7KbMeuIcbzNNJTOzpB6njaxE1Lpwg1TlxSs=; b=CPt2ZoCMfseGx2r8KgiVwK91zfy9tjUid/qRNH5CS7sP4aUUd2vVTVZqWV5rqiI2REC7Xhl1I5n3oZih/Jf3GyrFNG8uS0dXQAK+WCXmN84uanVOPyCcGP3KNDz2rSn0QC1O0ahBhJ5pWWTd7H6G/zqCx+8z2nza7sknu7tOb2M= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com; Message-ID: <105b0e9c-6991-445f-af36-6e76a916a15a@amd.com> Date: Tue, 15 Apr 2025 13:25:33 +0200 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v3 7/7] arm/mpu: Implement setup_mpu for MPU system To: Luca Fancellu , Julien Grall Cc: "xen-devel@lists.xenproject.org" , Stefano Stabellini , Bertrand Marquis , Volodymyr Babchuk References: <20250411145655.140667-1-luca.fancellu@arm.com> <20250411145655.140667-8-luca.fancellu@arm.com> <923a2fc0-4eeb-4e09-a56d-7471a56fe3bf@xen.org> <4771188E-B307-4452-A900-2ACACC1CE333@arm.com> <9eec0359-e9e9-4d38-abc0-3cde6eb94e3b@xen.org> <0CED25FD-5706-420A-BDB7-EB36BB7FEE71@arm.com> From: "Orzel, Michal" Content-Language: en-US In-Reply-To: <0CED25FD-5706-420A-BDB7-EB36BB7FEE71@arm.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-ClientProxiedBy: FR3P281CA0049.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:4a::22) To BN9PR12MB5273.namprd12.prod.outlook.com (2603:10b6:408:11e::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN9PR12MB5273:EE_|DS0PR12MB9398:EE_ X-MS-Office365-Filtering-Correlation-Id: 517b0357-3cc4-4f3a-2ae9-08dd7c103e40 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|366016; X-Microsoft-Antispam-Message-Info: =?utf-8?B?MExnTHMyYUhMVXVpVXovNDhadEZCYXM4MURZeGJRZzZBRnBuV1ZCTXYvcWE1?= =?utf-8?B?T05ZL0xRQjdKa1l5M3QyNTBMVC91ZHFISXdrQitWSUlaWmtuWEcxNGZDUHg5?= =?utf-8?B?d0NadENPd2N2TDRoclZ1amQ1SjBKM2cxS0dKOVdoVW1yNCtZc05ITFNhNzhk?= =?utf-8?B?VkYwTkNDT2RxbU15K0FxbkNSV0hheXVrTG9pVkVLS04rWG85WnFDNXlBbEJ5?= =?utf-8?B?ODFVWk1HdXA4R05xeUFqQzlKZytUMVY0YWlYM3pWcFhKWXdSWkhvd1dkV01j?= =?utf-8?B?bjc0c2pteVdvUUZQTUFNSCthWG5FSlo2MlVUajFMWWJRQ21tQm9DWUVvbDZh?= =?utf-8?B?cmVYWG94L01oQUc1MUl0QldGakVmaDNkRDlHZmlPVHRxclRUdDV4amg5aklX?= =?utf-8?B?QW1wQXRzRVFiOTR4Rk5tNkN2U00xc21nTE55YXdQTUdpRW5ZYmxWQ0IwZi9C?= =?utf-8?B?SGU5UzVRQWY4NVZ3KytjcU9QRWFMZDVSdFRpTXE0ME8xNjdxdHY1WmFMYnFi?= =?utf-8?B?SmM1WlZTSE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?B?RGh1K3JNcjJvQmtBU1RyVkM2Mmttek1TTzd1akx4ZEZ0R3NSWDEwTjl4a3B6?= =?utf-8?B?UUppdE00SjZkcjg1c0lPQTRZK2Z6NitacmYzeE8wenBOdzc3Q3RjZjNxS3Ra?= =?utf-8?B?MG5Kb2RIWEVZU3Z0dCtadFFrRkw2c2ZURWllcFNtQWppK2UrY1V1RUIzV2Yx?= =?utf-8?B?VUR1MXEwRFArSzRJakdmbVJHd3R6ZTVQUHZmODIyUStiVnp2ZDR0M0g2Q3Bi?= =?utf-8?B?alN3cG1LdW9XQ3Bjc25UWVVqbXBkanFGWDBTZ2JHa2RDSzBaSXFoZnNXWUpz?= =?utf-8?B?L2NuOTdIQ1dHL2F2d1lHSDVDYVN4VEExZlpEOVE0SmJWQWh2M3NvaVZMQXgz?= =?utf-8?B?STdEa3BWRWh1S1ZELzd2V1pFL0ZXZ3BkZVA3b1BSVjZJQ2RhbXRKM0dzcUZz?= =?utf-8?B?WElpeGpiVDVXeU1rdFF5WWowdGk1dVdvWWcwNks2MHo0SFVjV1lJc0ordFk2?= =?utf-8?Q?LJpFMJ1bSAQ=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BN9PR12MB5273.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(376014)(1800799024)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?em9JNmVoVVY5cWhoU3N1bDZlMFp0WmtFUWdKWW5JRGhqNHY2aFpIUDRTYWhF?= =?utf-8?B?VGVVTUpoNyt0aTZnOVpzS1lCd3ZXQXR3aHVkSEN6RVZFU2dNMHduZTJ4dU9m?= =?utf-8?B?czNyWlVkcWplZEMrdnFnY3lJVEtzVk56L21KelF4aUhtTVErL3M2V3ZXM05p?= =?utf-8?B?dlZ2VkErTlBkeU9NU3c1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QYzJpdzJMZkRBZW9Y?= =?utf-8?B?SkFKQXlCNmdBb0xxeEYwaG13MWc3aXZSdmMvbVZpa0hIQjVJR0tMdkNZTlJZ?= =?utf-8?B?ZEp2MnJ5WTJKcG13YjI4bVlPa2RNZVE1M3pBME5CSDVuMXphVEt3WG5sM0o0?= =?utf-8?Q?I/lM911IjoIEiJ6sNtdyEkF1T?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 517b0357-3cc4-4f3a-2ae9-08dd7c103e40 X-MS-Exchange-CrossTenant-AuthSource: BN9PR12MB5273.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Apr 2025 11:25:36.4002 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: oZL4WPKHvUIYrS9WEKf8s5FyVfJyuKjRA3f/C4kbbNoW9n87l9V/UHGRy8IN6OQS X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB9398 On 15/04/2025 13:10, Luca Fancellu wrote: > Hi Julien, > >> On 15 Apr 2025, at 11:20, Julien Grall wrote: >> >> Hi Luca, >> >> On 15/04/2025 16:55, Luca Fancellu wrote: >>> Hi Julien, >>>>>>> +static void __init setup_mpu(void) >>>>>>> +{ >>>>>>> + register_t prenr; >>>>>>> + unsigned int i = 0; >>>>>>> + >>>>>>> + /* >>>>>>> + * MPUIR_EL2.Region[0:7] identifies the number of regions supported by >>>>>>> + * the EL2 MPU. >>>>>>> + */ >>>>>>> + max_xen_mpumap = (uint8_t)(READ_SYSREG(MPUIR_EL2) & NUM_MPU_REGIONS_MASK); >>>>>>> + >>>>>>> + /* PRENR_EL2 has the N bit set if the N region is enabled, N < 32 */ >>>>>>> + prenr = (READ_SYSREG(PRENR_EL2) & PRENR_MASK); >>>>>>> + >>>>>>> + /* >>>>>>> + * Set the bitfield for regions enabled in assembly boot-time. >>>>>>> + * This code works under the assumption that the code in head.S has >>>>>>> + * allocated and enabled regions below 32 (N < 32). >>>>>>> + >>>>>> This is a bit fragile. I think it would be better if the bitmap is set by head.S as we add the regions. Same for ... >>>>> So, I was trying to avoid that because in that case we need to place xen_mpumap out of the BSS and start >>>>> manipulating the bitmap from asm, instead I was hoping to use the C code, I understand that if someone >>>>> wants to have more than 31 region as boot region this might break, but it’s also a bit unlikely? >>>> >>>> The 31 is only part of the problem. The other problem is there is at least one other places in Xen (i.e. as early_fdt_map()) which will also create an entry in the MPU before setup_mm()/setup_mpu() is called. I am a bit concerned that the assumption is going to spread and yet we have no way to programmatically check if this will be broken. >>> If we would like to find ways, we could check eventually for clashes on enabled MPU regions; >>> so the only part where a region is created in the C world without the assistance of xen_mpumap is early_fdt_map(), >>> asserts etc could be used in one or both setup_mpu and early_fdt_map to prevent breakage. >>>>> >>>> Furthermore, right now, you are hardcoding the slot used and updating the MPU. But if you had the bitmap updated, you could just look up for a free slot. >>> of course, but still the early DTB map is temporary and it will be gone after boot, so it won’t impact much unless I’m >>> missing something. >> >> It doesn't really matter whether the region is temporary or not. My concern is you are making assumption that are difficult to track (they are not documented where a developper would most likely look at). >> >> So if we still want to hardcode the value, then this should be documented in head.S and probably in a layout.h (or similar) so there is a single place where the MPU layout is described. > > Sure, I’m fine with documenting everything, let’s see ... > >> >>>> >>>>> So I was balancing the pros to manipulate everything from the C world against the cons (boot region > 31). >>>>> Is it still your preferred way to handle everything from asm? >>>> >>>> Yes. I don't think the change in asm will be large and this would allow to remove other assumptions (like in the FDT mapping code). >>> not large, but still something to be maintained, we will need arm64/arm32 code to set/clear bits on the bitmap >>> (causing duplication with bitops.c), code to save things on the xen_mpumap, code to clean/invalidate dcache for the entries in xen_mpumap and finally we will need to keep the code aligned to the implementation of the bitmap >>> (which is fairly stable, but still needs to be taken into account). >> >> I understand the changes and risks, but I still think this is the right approach. Let see what the other maintainers think. > > what the other maintainers thinks about this one. I read the thread and my opinion is that we should do that in ASM even it if means more code and possible duplication. From maintainer perspective this is easier to handle than assumptions which are more error prone and difficult to change in the future. > >> >>>> >>>> As a side note, I noticed that the MPU entries are not cleared before we enable the MPU. Is there anything in the boot protocol that guarantee all the entries will be invalid? If not, then I think we need to clear the entries. >>>> >>>> Otherwise, your current logic doesn't work. That said, I think it would still be necessary even if we get rid of your logic because we don't know the content of the MPU entries. >>> The PRLAR.EN bit resets to zero on a warm reset, so any region will be always disabled unless programmed, I thought it is enough. >> >> This is only telling me the state PRLAR.EN when the CPU is initially turn on. This doesn't tell me the value of the bit when jumping in Xen. >> >> I am making the difference because there might be another software running at EL2 before jumping into Xen (e.g. bootloader, or even a previous Xen if we were using Kexec) which could use the MPU. >> >> So I am looking for some details on how the expected state of the system when jumping to an OS/hypervisor. For a comparison, on the MMU side, we have the Linux arm64 Image protocol that will specific how >> a bootloader needs to configure the system. > > Ok I now understand the question, so I think we still could use the Linux arm64 Image protocol, but we will need to define what we expect for the MPU, is docs/misc/arm/booting.txt > the right place for it? Shall we start a different thread? Please start a new thread for documenting booting protocol for ARMv8-R. ~Michal