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

[xen staging] x86/HVM: fully switch emulate.c to use xvmalloc_array()



commit 688845071db7a70f5e8742d15815195c240fc8e3
Author:     Jan Beulich <jbeulich@xxxxxxxx>
AuthorDate: Tue Jul 29 11:27:48 2025 +0200
Commit:     Jan Beulich <jbeulich@xxxxxxxx>
CommitDate: Tue Jul 29 11:27:48 2025 +0200

    x86/HVM: fully switch emulate.c to use xvmalloc_array()
    
    Use the more "modern" forms consistently, thus doing away with
    effectively open-coding xmalloc_array() at the same time. While there
    is a difference in generated code, as xmalloc_bytes() forces
    SMP_CACHE_BYTES alignment, if code really cared about such higher than
    default alignment, it should request so explicitly.
    
    Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
    Acked-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
---
 xen/arch/x86/hvm/emulate.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/xen/arch/x86/hvm/emulate.c b/xen/arch/x86/hvm/emulate.c
index 19e809de66..f1412d8c49 100644
--- a/xen/arch/x86/hvm/emulate.c
+++ b/xen/arch/x86/hvm/emulate.c
@@ -17,6 +17,7 @@
 #include <xen/paging.h>
 #include <xen/trace.h>
 #include <xen/vm_event.h>
+#include <xen/xvmalloc.h>
 
 #include <asm/altp2m.h>
 #include <asm/event.h>
@@ -2050,7 +2051,7 @@ static int cf_check hvmemul_rep_movs(
         dgpa -= bytes - bytes_per_rep;
 
     /* Allocate temporary buffer. Fall back to slow emulation if this fails. */
-    buf = xmalloc_bytes(bytes);
+    buf = xvmalloc_array(char, bytes);
     if ( buf == NULL )
         return X86EMUL_UNHANDLEABLE;
 
@@ -2060,7 +2061,7 @@ static int cf_check hvmemul_rep_movs(
 
         if ( rc != X86EMUL_OKAY)
         {
-            xfree(buf);
+            xvfree(buf);
             return rc;
         }
 
@@ -2082,7 +2083,7 @@ static int cf_check hvmemul_rep_movs(
     if ( rc == HVMTRANS_okay )
         rc = hvm_copy_to_guest_phys(dgpa, buf, bytes, curr);
 
-    xfree(buf);
+    xvfree(buf);
 
     switch ( rc )
     {
@@ -2162,7 +2163,7 @@ static int cf_check hvmemul_rep_stos(
         for ( ; ; )
         {
             bytes = *reps * bytes_per_rep;
-            buf = xmalloc_bytes(bytes);
+            buf = xvmalloc_array(char, bytes);
             if ( buf || *reps <= 1 )
                 break;
             *reps >>= 1;
@@ -2191,7 +2192,7 @@ static int cf_check hvmemul_rep_stos(
 
             default:
                 ASSERT_UNREACHABLE();
-                xfree(buf);
+                xvfree(buf);
                 return X86EMUL_UNHANDLEABLE;
             }
 
@@ -2202,7 +2203,7 @@ static int cf_check hvmemul_rep_stos(
         rc = hvm_copy_to_guest_phys(gpa, buf, bytes, curr);
 
         if ( buf != p_data )
-            xfree(buf);
+            xvfree(buf);
 
         switch ( rc )
         {
--
generated by git-patchbot for /home/xen/git/xen.git#staging



 


Rackspace

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