[PATCH 2/3] hw/xen: Replace target_ulong by agnostic target_long_bits()

Philippe Mathieu-Daudé posted 3 patches 1 week ago
There is a newer version of this series
[PATCH 2/3] hw/xen: Replace target_ulong by agnostic target_long_bits()
Posted by Philippe Mathieu-Daudé 1 week ago
Both are equivalent:

  target_long_bits()

  sizeof(target_u?long) * BITS_PER_BYTE

Prefer the former which is target-agnostic.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 hw/xen/xen-hvm-common.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/hw/xen/xen-hvm-common.c b/hw/xen/xen-hvm-common.c
index 258014370e1..b40ae0b3af0 100644
--- a/hw/xen/xen-hvm-common.c
+++ b/hw/xen/xen-hvm-common.c
@@ -2,8 +2,8 @@
 #include "qemu/units.h"
 #include "qemu/bitops.h"
 #include "qemu/error-report.h"
+#include "qemu/target-info.h"
 #include "qapi/error.h"
-#include "exec/target_long.h"
 #include "exec/target_page.h"
 #include "trace.h"
 
@@ -455,7 +455,7 @@ static void handle_ioreq(XenIOState *state, ioreq_t *req)
                        req->addr, req->data, req->count, req->size);
 
     if (!req->data_is_ptr && (req->dir == IOREQ_WRITE) &&
-            (req->size < sizeof (target_ulong))) {
+            (req_size_bits < target_long_bits())) {
         req->data &= MAKE_64BIT_MASK(0, req_size_bits);
     }
 
-- 
2.51.0


Re: [PATCH 2/3] hw/xen: Replace target_ulong by agnostic target_long_bits()
Posted by Edgar E. Iglesias 1 day, 9 hours ago
On Wed, Oct 22, 2025 at 04:01:12PM +0200, Philippe Mathieu-Daudé wrote:
> Both are equivalent:
> 
>   target_long_bits()
> 
>   sizeof(target_u?long) * BITS_PER_BYTE
> 
> Prefer the former which is target-agnostic.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>

Reviewed-by: Edgar E. Iglesias <edgar.iglesias@amd.com>



> ---
>  hw/xen/xen-hvm-common.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/hw/xen/xen-hvm-common.c b/hw/xen/xen-hvm-common.c
> index 258014370e1..b40ae0b3af0 100644
> --- a/hw/xen/xen-hvm-common.c
> +++ b/hw/xen/xen-hvm-common.c
> @@ -2,8 +2,8 @@
>  #include "qemu/units.h"
>  #include "qemu/bitops.h"
>  #include "qemu/error-report.h"
> +#include "qemu/target-info.h"
>  #include "qapi/error.h"
> -#include "exec/target_long.h"
>  #include "exec/target_page.h"
>  #include "trace.h"
>  
> @@ -455,7 +455,7 @@ static void handle_ioreq(XenIOState *state, ioreq_t *req)
>                         req->addr, req->data, req->count, req->size);
>  
>      if (!req->data_is_ptr && (req->dir == IOREQ_WRITE) &&
> -            (req->size < sizeof (target_ulong))) {
> +            (req_size_bits < target_long_bits())) {
>          req->data &= MAKE_64BIT_MASK(0, req_size_bits);
>      }
>  
> -- 
> 2.51.0
> 
Re: [PATCH 2/3] hw/xen: Replace target_ulong by agnostic target_long_bits()
Posted by Pierrick Bouvier 1 day, 13 hours ago
On 2025-10-22 16:01, Philippe Mathieu-Daudé wrote:
> Both are equivalent:
> 
>    target_long_bits()
> 
>    sizeof(target_u?long) * BITS_PER_BYTE
> 
> Prefer the former which is target-agnostic.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>   hw/xen/xen-hvm-common.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>