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

Re: [PATCH v2 2/6] arm/mpu: Implement vmap functions for MPU


  • To: Harry Ramsey <harry.ramsey@xxxxxxx>, <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: "Orzel, Michal" <michal.orzel@xxxxxxx>
  • Date: Tue, 13 Jan 2026 11:21:20 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=arm.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0)
  • 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=RD9rrVHE8SNXkEpOMG/orsgKMfHvEtAl6NzTZVZHihg=; b=ytbe5K2fbIEO78yKcVAWT0b4//XkTfZFDiBBMvov0u1zUDTIMqKU/5Ah6VwSiNw/xTl52ga23D3wE+KAyDk9tEkoyFO0OCxa5O9yb+sWbW9rdd9MXPZCIo1Z3F2gImFpIA5YLjq+hzQNuURZjNk7gI1VbVccOcEN1/kfWIy0zEYvxrAIZKTGzlX13Y8WBe8+W9/fAP1rr3ONcaHxLkaUokLccCnLtVRcYi/0aN0ntqlVxiEWS+S9u2U5t7Upr5ppSOXmyh/YXZ7mwyka1LkwTi7TjJznGDmctfDv8UlwIwVMXDZ1nNr5P6Kh2gBsPZjed49jl3NtdqkCqDOykcSM9A==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=GWzEQWDi6gBlyXQr1RaF2qJht3tVH/9GnELItBCqk52HTz2884A0GY5jRqGT6M/6btXxmhYLKAPaoiUSjxo7fs5bZvmDQ6pfK7qNP9s/LT7hGtR+FkCu+oVDB8mc1Aa8HD2yHdAEp7bNnr8+Y8YEnPSE28uXIyRKC8GtRWK407dLp/IAFzcwLJLvPetyN7uA+zQYwr+IvgKXd7iqY+1ga9mejZ7hgsYQeDptYp08FGV4lTe5DCcHT4cakmfPQwPWZAn/0mfjqBgG4mEOd16X6ptHF0XwgWITrsks5/y6TOsz8NBqe+IiwqgB1SDFRFTBdmX6eBsEVlkwGmShMVNbGg==
  • Cc: <Luca.Fancellu@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>
  • Delivery-date: Tue, 13 Jan 2026 10:21:40 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Also, two more things here apart from my other remarks.

On 05/01/2026 12:34, Harry Ramsey wrote:
> From: Luca Fancellu <luca.fancellu@xxxxxxx>
> 
> HAS_VMAP is not enabled on MPU systems, but the vmap functions are used
> in places across common code. In order to keep the existing code and
> maintain correct functionality, implement the `vmap_contig` and `vunmap`
> functions for MPU systems.
> 
> Introduce a helper function `destroy_xen_mapping_containing` to aid with
> unmapping an entire region when only the start address is known.
> 
> Signed-off-by: Luca Fancellu <luca.fancellu@xxxxxxx>
> Signed-off-by: Harry Ramsey <harry.ramsey@xxxxxxx>
> ---
> v2:
> - Rename `destroy_entire_xen_mapping` to `destroy_xen_mapping_containing`
> - Improve code documentation.
> - Refactor nested code.
> - Fix ignored rc error code in `destroy_xen_mapping_containing`.
> ---
...
>  
> +int destroy_xen_mapping_containing(paddr_t s)
> +{
> +    int rc;
> +    uint8_t idx;
> +
> +    ASSERT(IS_ALIGNED(s, PAGE_SIZE));
> +
> +    spin_lock(&xen_mpumap_lock);
Here you take a lock...

> +
> +    rc = mpumap_contains_region(xen_mpumap, max_mpu_regions, s, s + 
> PAGE_SIZE,
> +                                &idx);
> +    if ( rc == MPUMAP_REGION_NOTFOUND )
> +    {
> +        printk(XENLOG_ERR "Cannot remove entry that does not exist");
> +        return -EINVAL;
and here you would return while still holding the lock i.e. deadlock.

> +    }
> +
> +    /* As we are unmapping entire region use MPUMAP_REGION_FOUND instead */
> +    rc = xen_mpumap_free_entry(idx, MPUMAP_REGION_FOUND);
Why don't you perform context_sync_mpu() here?

~Michal




 


Rackspace

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