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

[PATCH v2 2/2] gnttab: restrict GNTTABOP_cache_flush to Arm


  • To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Mon, 26 Feb 2024 11:45:35 +0100
  • Autocrypt: addr=jbeulich@xxxxxxxx; keydata= xsDiBFk3nEQRBADAEaSw6zC/EJkiwGPXbWtPxl2xCdSoeepS07jW8UgcHNurfHvUzogEq5xk hu507c3BarVjyWCJOylMNR98Yd8VqD9UfmX0Hb8/BrA+Hl6/DB/eqGptrf4BSRwcZQM32aZK 7Pj2XbGWIUrZrd70x1eAP9QE3P79Y2oLrsCgbZJfEwCgvz9JjGmQqQkRiTVzlZVCJYcyGGsD /0tbFCzD2h20ahe8rC1gbb3K3qk+LpBtvjBu1RY9drYk0NymiGbJWZgab6t1jM7sk2vuf0Py O9Hf9XBmK0uE9IgMaiCpc32XV9oASz6UJebwkX+zF2jG5I1BfnO9g7KlotcA/v5ClMjgo6Gl MDY4HxoSRu3i1cqqSDtVlt+AOVBJBACrZcnHAUSuCXBPy0jOlBhxPqRWv6ND4c9PH1xjQ3NP nxJuMBS8rnNg22uyfAgmBKNLpLgAGVRMZGaGoJObGf72s6TeIqKJo/LtggAS9qAUiuKVnygo 3wjfkS9A3DRO+SpU7JqWdsveeIQyeyEJ/8PTowmSQLakF+3fote9ybzd880fSmFuIEJldWxp Y2ggPGpiZXVsaWNoQHN1c2UuY29tPsJgBBMRAgAgBQJZN5xEAhsDBgsJCAcDAgQVAggDBBYC AwECHgECF4AACgkQoDSui/t3IH4J+wCfQ5jHdEjCRHj23O/5ttg9r9OIruwAn3103WUITZee e7Sbg12UgcQ5lv7SzsFNBFk3nEQQCACCuTjCjFOUdi5Nm244F+78kLghRcin/awv+IrTcIWF hUpSs1Y91iQQ7KItirz5uwCPlwejSJDQJLIS+QtJHaXDXeV6NI0Uef1hP20+y8qydDiVkv6l IreXjTb7DvksRgJNvCkWtYnlS3mYvQ9NzS9PhyALWbXnH6sIJd2O9lKS1Mrfq+y0IXCP10eS FFGg+Av3IQeFatkJAyju0PPthyTqxSI4lZYuJVPknzgaeuJv/2NccrPvmeDg6Coe7ZIeQ8Yj t0ARxu2xytAkkLCel1Lz1WLmwLstV30g80nkgZf/wr+/BXJW/oIvRlonUkxv+IbBM3dX2OV8 AmRv1ySWPTP7AAMFB/9PQK/VtlNUJvg8GXj9ootzrteGfVZVVT4XBJkfwBcpC/XcPzldjv+3 HYudvpdNK3lLujXeA5fLOH+Z/G9WBc5pFVSMocI71I8bT8lIAzreg0WvkWg5V2WZsUMlnDL9 mpwIGFhlbM3gfDMs7MPMu8YQRFVdUvtSpaAs8OFfGQ0ia3LGZcjA6Ik2+xcqscEJzNH+qh8V m5jjp28yZgaqTaRbg3M/+MTbMpicpZuqF4rnB0AQD12/3BNWDR6bmh+EkYSMcEIpQmBM51qM EKYTQGybRCjpnKHGOxG0rfFY1085mBDZCH5Kx0cl0HVJuQKC+dV2ZY5AqjcKwAxpE75MLFkr wkkEGBECAAkFAlk3nEQCGwwACgkQoDSui/t3IH7nnwCfcJWUDUFKdCsBH/E5d+0ZnMQi+G0A nAuWpQkjM1ASeQwSHEeAWPgskBQL
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Delivery-date: Mon, 26 Feb 2024 10:45:38 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

This special purpose operation possibly shouldn't have been a grant
table sub-op, but instead an arch-specific memory management one. No
users are known or supposed to exist outside of Arm. Along with adding
suitable #ifdef-s, move a helper function used solely here into the
first of these new #ifdef-s.

With the functionality restricted, questionable helper functions can
then also be purged from x86.

Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
---
v2: New.

--- a/xen/arch/x86/include/asm/flushtlb.h
+++ b/xen/arch/x86/include/asm/flushtlb.h
@@ -182,21 +182,6 @@ void flush_area_mask(const cpumask_t *ma
 }
 
 static inline void flush_page_to_ram(unsigned long mfn, bool sync_icache) {}
-static inline int invalidate_dcache_va_range(const void *p,
-                                             unsigned long size)
-{ return -EOPNOTSUPP; }
-static inline int clean_and_invalidate_dcache_va_range(const void *p,
-                                                       unsigned long size)
-{
-    unsigned int order = get_order_from_bytes(size);
-    /* sub-page granularity support needs to be added if necessary */
-    flush_area_local(p, FLUSH_CACHE|FLUSH_ORDER(order));
-    return 0;
-}
-static inline int clean_dcache_va_range(const void *p, unsigned long size)
-{
-    return clean_and_invalidate_dcache_va_range(p, size);
-}
 
 unsigned int guest_flush_tlb_flags(const struct domain *d);
 void guest_flush_tlb_mask(const struct domain *d, const cpumask_t *mask);
--- a/xen/common/grant_table.c
+++ b/xen/common/grant_table.c
@@ -940,42 +940,6 @@ static void reduce_status_for_pin(struct
         gnttab_clear_flags(rd, clear_flags, status);
 }
 
-static struct active_grant_entry *grant_map_exists(const struct domain *ld,
-                                                   struct grant_table *rgt,
-                                                   mfn_t mfn,
-                                                   grant_ref_t *cur_ref)
-{
-    grant_ref_t ref, max_iter;
-
-    /*
-     * The remote grant table should be locked but the percpu rwlock
-     * cannot be checked for read lock without race conditions or high
-     * overhead so we cannot use an ASSERT
-     *
-     *   ASSERT(rw_is_locked(&rgt->lock));
-     */
-
-    max_iter = min(*cur_ref + (1 << GNTTABOP_CONTINUATION_ARG_SHIFT),
-                   nr_grant_entries(rgt));
-    for ( ref = *cur_ref; ref < max_iter; ref++ )
-    {
-        struct active_grant_entry *act = active_entry_acquire(rgt, ref);
-
-        if ( act->pin && act->domid == ld->domain_id &&
-             mfn_eq(act->mfn, mfn) )
-            return act;
-        active_entry_release(act);
-    }
-
-    if ( ref < nr_grant_entries(rgt) )
-    {
-        *cur_ref = ref;
-        return NULL;
-    }
-
-    return ERR_PTR(-EINVAL);
-}
-
 union maptrack_node {
     struct {
         /* Radix tree slot pointers use two of the bits. */
@@ -3519,6 +3483,44 @@ gnttab_swap_grant_ref(XEN_GUEST_HANDLE_P
     return 0;
 }
 
+#ifdef CONFIG_ARM
+
+static struct active_grant_entry *grant_map_exists(const struct domain *ld,
+                                                   struct grant_table *rgt,
+                                                   mfn_t mfn,
+                                                   grant_ref_t *cur_ref)
+{
+    grant_ref_t ref, max_iter;
+
+    /*
+     * The remote grant table should be locked but the percpu rwlock
+     * cannot be checked for read lock without race conditions or high
+     * overhead so we cannot use an ASSERT
+     *
+     *   ASSERT(rw_is_locked(&rgt->lock));
+     */
+
+    max_iter = min(*cur_ref + (1 << GNTTABOP_CONTINUATION_ARG_SHIFT),
+                   nr_grant_entries(rgt));
+    for ( ref = *cur_ref; ref < max_iter; ref++ )
+    {
+        struct active_grant_entry *act = active_entry_acquire(rgt, ref);
+
+        if ( act->pin && act->domid == ld->domain_id &&
+             mfn_eq(act->mfn, mfn) )
+            return act;
+        active_entry_release(act);
+    }
+
+    if ( ref < nr_grant_entries(rgt) )
+    {
+        *cur_ref = ref;
+        return NULL;
+    }
+
+    return ERR_PTR(-EINVAL);
+}
+
 static int _cache_flush(const gnttab_cache_flush_t *cflush, grant_ref_t 
*cur_ref)
 {
     struct domain *d, *owner;
@@ -3633,6 +3635,8 @@ gnttab_cache_flush(XEN_GUEST_HANDLE_PARA
     return 0;
 }
 
+#endif /* CONFIG_ARM */
+
 long do_grant_table_op(
     unsigned int cmd, XEN_GUEST_HANDLE_PARAM(void) uop, unsigned int count)
 {
@@ -3776,6 +3780,7 @@ long (do_grant_table_op)(
 
     case GNTTABOP_cache_flush:
     {
+#ifdef CONFIG_ARM
         XEN_GUEST_HANDLE_PARAM(gnttab_cache_flush_t) cflush =
             guest_handle_cast(uop, gnttab_cache_flush_t);
 
@@ -3788,6 +3793,9 @@ long (do_grant_table_op)(
             uop = guest_handle_cast(cflush, void);
             opaque_out = opaque_in;
         }
+#else
+        rc = -EOPNOTSUPP;
+#endif
         break;
     }
 




 


Rackspace

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