All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] x86emul: replace _BYTES_PER_LONG
@ 2025-03-31 15:52 Jan Beulich
  2025-03-31 15:54 ` Andrew Cooper
  2025-04-03 13:00 ` Anthony PERARD
  0 siblings, 2 replies; 3+ messages in thread
From: Jan Beulich @ 2025-03-31 15:52 UTC (permalink / raw)
  To: xen-devel@lists.xenproject.org
  Cc: Andrew Cooper, Roger Pau Monné, Anthony PERARD

We can now easily use __SIZEOF_LONG__ instead. For this to also work in
the test harness, move hvmloader's STR() to common-macros.h.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
---
Quite likely libxl{,u}_internal.h's STRINGIFY() could then also be
replaced.

--- a/xen/arch/x86/x86_emulate/private.h
+++ b/xen/arch/x86/x86_emulate/private.h
@@ -633,11 +633,9 @@ amd_like(const struct x86_emulate_ctxt *
 #if defined(__x86_64__)
 #define _LO32 "k"          /* force 32-bit operand */
 #define _STK  "%%rsp"      /* stack pointer */
-#define _BYTES_PER_LONG "8"
 #elif defined(__i386__)
 #define _LO32 ""           /* force 32-bit operand */
 #define _STK  "%%esp"      /* stack pointer */
-#define _BYTES_PER_LONG "4"
 #endif
 
 /* Before executing instruction: restore necessary bits in EFLAGS. */
@@ -651,7 +649,7 @@ amd_like(const struct x86_emulate_ctxt *
 "pushf; "                                                       \
 "notl %"_LO32 _tmp"; "                                          \
 "andl %"_LO32 _tmp",("_STK"); "                                 \
-"andl %"_LO32 _tmp",2*"_BYTES_PER_LONG"("_STK"); "              \
+"andl %"_LO32 _tmp", 2 * " STR(__SIZEOF_LONG__) "("_STK"); "    \
 "pop  %"_tmp"; "                                                \
 "orl  %"_LO32 _tmp",("_STK"); "                                 \
 "popf; "                                                        \
--- a/tools/firmware/hvmloader/util.h
+++ b/tools/firmware/hvmloader/util.h
@@ -21,9 +21,6 @@ enum {
 /* Cause xs_wire.h to give us xsd_errors[]. */
 #define EINVAL EINVAL
 
-#define __STR(...) #__VA_ARGS__
-#define STR(...) __STR(__VA_ARGS__)
-
 /* GDT selector values. */
 #define SEL_CODE16          0x0008
 #define SEL_DATA16          0x0010
--- a/tools/include/xen-tools/common-macros.h
+++ b/tools/include/xen-tools/common-macros.h
@@ -88,6 +88,9 @@
     (type *)((char *)mptr__ - offsetof(type, member));  \
 })
 
+#define __STR(...) #__VA_ARGS__
+#define STR(...) __STR(__VA_ARGS__)
+
 #define __AC(X, Y)   (X ## Y)
 #define _AC(X, Y)    __AC(X, Y)
 


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] x86emul: replace _BYTES_PER_LONG
  2025-03-31 15:52 [PATCH] x86emul: replace _BYTES_PER_LONG Jan Beulich
@ 2025-03-31 15:54 ` Andrew Cooper
  2025-04-03 13:00 ` Anthony PERARD
  1 sibling, 0 replies; 3+ messages in thread
From: Andrew Cooper @ 2025-03-31 15:54 UTC (permalink / raw)
  To: Jan Beulich, xen-devel@lists.xenproject.org
  Cc: Roger Pau Monné, Anthony PERARD

On 31/03/2025 4:52 pm, Jan Beulich wrote:
> We can now easily use __SIZEOF_LONG__ instead. For this to also work in
> the test harness, move hvmloader's STR() to common-macros.h.
>
> Signed-off-by: Jan Beulich <jbeulich@suse.com>

Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] x86emul: replace _BYTES_PER_LONG
  2025-03-31 15:52 [PATCH] x86emul: replace _BYTES_PER_LONG Jan Beulich
  2025-03-31 15:54 ` Andrew Cooper
@ 2025-04-03 13:00 ` Anthony PERARD
  1 sibling, 0 replies; 3+ messages in thread
From: Anthony PERARD @ 2025-04-03 13:00 UTC (permalink / raw)
  To: Jan Beulich; +Cc: xen-devel, Andrew Cooper, Roger Pau Monné

On Mon, Mar 31, 2025 at 05:52:27PM +0200, Jan Beulich wrote:
> We can now easily use __SIZEOF_LONG__ instead. For this to also work in
> the test harness, move hvmloader's STR() to common-macros.h.
> 
> Signed-off-by: Jan Beulich <jbeulich@suse.com>

Acked-by: Anthony PERARD <anthony.perard@vates.tech>

> Quite likely libxl{,u}_internal.h's STRINGIFY() could then also be
> replaced.

Sounds good. It seems the different between STR() and TOSTRING() is that
a comma can be use as well with STR, so not really a useful difference.

Thanks,

-- 

Anthony Perard | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-04-03 13:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-31 15:52 [PATCH] x86emul: replace _BYTES_PER_LONG Jan Beulich
2025-03-31 15:54 ` Andrew Cooper
2025-04-03 13:00 ` Anthony PERARD

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.