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

[xen master] xen/cache-col: Remove bogus cast in domain_llc_coloring_free()



commit 6031cd215cba2b6a80b7f2a3d87f8bfddf2e170d
Author:     Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
AuthorDate: Thu Jul 24 10:51:01 2025 +0100
Commit:     Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
CommitDate: Tue Jul 29 17:25:54 2025 +0100

    xen/cache-col: Remove bogus cast in domain_llc_coloring_free()
    
    Using:
    
      xfree(__va(__pa(d->llc_colors)));
    
    is an extraordinarily expensive way of writing:
    
      xfree((void *)d->llc_colours);
    
    Combined with the comment indicating that this was intention, the patch 
should
    have been rejected outright.
    
    Correct the type of d->llc_colours by removing the bogus const on it, and
    remove the cast when freeing it.
    
    No functional change.
    
    Fixes: 6985aa5e0c3c ("xen: extend domctl interface for cache coloring")
    Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
    Reviewed-by: Stefano Stabellini <sstabellini@xxxxxxxxxx>
---
 xen/common/llc-coloring.c | 7 ++-----
 xen/include/xen/sched.h   | 2 +-
 2 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/xen/common/llc-coloring.c b/xen/common/llc-coloring.c
index a572f77a09..bd1f634f0b 100644
--- a/xen/common/llc-coloring.c
+++ b/xen/common/llc-coloring.c
@@ -309,11 +309,8 @@ int domain_set_llc_colors(struct domain *d,
 
 void domain_llc_coloring_free(struct domain *d)
 {
-    if ( !llc_coloring_enabled || d->llc_colors == default_colors )
-        return;
-
-    /* free pointer-to-const using __va(__pa()) */
-    xfree(__va(__pa(d->llc_colors)));
+    if ( d->llc_colors != default_colors )
+        xfree(d->llc_colors);
 }
 
 int __init domain_set_llc_colors_from_str(struct domain *d, const char *str)
diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h
index fe53d4fab7..df23411869 100644
--- a/xen/include/xen/sched.h
+++ b/xen/include/xen/sched.h
@@ -649,7 +649,7 @@ struct domain
 
 #ifdef CONFIG_LLC_COLORING
     unsigned int num_llc_colors;
-    const unsigned int *llc_colors;
+    unsigned int *llc_colors;
 #endif
 
     /* Console settings. */
--
generated by git-patchbot for /home/xen/git/xen.git#master



 


Rackspace

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