[PATCH] x86/emul: Fix test harness build with blk.c moved out of x86_emulate.c

Andrew Cooper posted 1 patch 1 year ago
Test gitlab-ci passed
Patches applied successfully (tree, apply log)
git fetch https://gitlab.com/xen-project/patchew/xen tags/patchew/20230403122535.724250-1-andrew.cooper3@citrix.com
tools/tests/x86_emulator/x86-emulate.h | 6 ++++++
xen/arch/x86/x86_emulate/x86_emulate.c | 6 ------
2 files changed, 6 insertions(+), 6 deletions(-)
[PATCH] x86/emul: Fix test harness build with blk.c moved out of x86_emulate.c
Posted by Andrew Cooper 1 year ago
Trying to build the test harness fails with:

  x86_emulate/blk.c: In function 'x86_emul_blk':
  x86_emulate/blk.c:74:15: error: expected ':' or ')' before 'ASM_FLAG_OUT'
     74 |               ASM_FLAG_OUT(, "; setz %[zf]")
        |               ^~~~~~~~~~~~

This is because ASM_FLAG_OUT() is still local to x86_emulate.c.  Move it into
x86-emulate.h instead so it ends up in all files including private.h.  The
main Xen build gets this macro from compiler.h.

Fixes: c80243f94386 ("x86emul: move x86_emul_blk() to separate source file")
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
CC: Jan Beulich <JBeulich@suse.com>
CC: Roger Pau Monné <roger.pau@citrix.com>
CC: Wei Liu <wl@xen.org>
---
 tools/tests/x86_emulator/x86-emulate.h | 6 ++++++
 xen/arch/x86/x86_emulate/x86_emulate.c | 6 ------
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/tools/tests/x86_emulator/x86-emulate.h b/tools/tests/x86_emulator/x86-emulate.h
index 0ae528a741ed..942b4cdd47d1 100644
--- a/tools/tests/x86_emulator/x86-emulate.h
+++ b/tools/tests/x86_emulator/x86-emulate.h
@@ -65,6 +65,12 @@
 #define AC_(n,t) (n##t)
 #define _AC(n,t) AC_(n,t)
 
+#ifdef __GCC_ASM_FLAG_OUTPUTS__
+# define ASM_FLAG_OUT(yes, no) yes
+#else
+# define ASM_FLAG_OUT(yes, no) no
+#endif
+
 #define hweight32 __builtin_popcount
 #define hweight64 __builtin_popcountll
 
diff --git a/xen/arch/x86/x86_emulate/x86_emulate.c b/xen/arch/x86/x86_emulate/x86_emulate.c
index b84e9ee54dae..5a0ec5900a93 100644
--- a/xen/arch/x86/x86_emulate/x86_emulate.c
+++ b/xen/arch/x86/x86_emulate/x86_emulate.c
@@ -132,12 +132,6 @@ static const uint8_t sse_prefix[] = { 0x66, 0xf3, 0xf2 };
         (void *)(((long)__##var + __alignof(type) - __alignof(__##var))   \
                  & -__alignof(type))
 
-#ifdef __GCC_ASM_FLAG_OUTPUTS__
-# define ASM_FLAG_OUT(yes, no) yes
-#else
-# define ASM_FLAG_OUT(yes, no) no
-#endif
-
 /* MXCSR bit definitions. */
 #define MXCSR_MM  (1U << 17)
 
-- 
2.30.2


Re: [PATCH] x86/emul: Fix test harness build with blk.c moved out of x86_emulate.c
Posted by Jan Beulich 1 year ago
On 03.04.2023 14:25, Andrew Cooper wrote:
> Trying to build the test harness fails with:
> 
>   x86_emulate/blk.c: In function 'x86_emul_blk':
>   x86_emulate/blk.c:74:15: error: expected ':' or ')' before 'ASM_FLAG_OUT'
>      74 |               ASM_FLAG_OUT(, "; setz %[zf]")
>         |               ^~~~~~~~~~~~
> 
> This is because ASM_FLAG_OUT() is still local to x86_emulate.c.  Move it into
> x86-emulate.h instead so it ends up in all files including private.h.  The
> main Xen build gets this macro from compiler.h.
> 
> Fixes: c80243f94386 ("x86emul: move x86_emul_blk() to separate source file")
> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>

Reviewed-by: Jan Beulich <jbeulich@suse.com>

Locally I actually have this exact same change, but in the MCOMMIT patch
(which predates the splitting work by quite a bit).

Jan