All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christopher Clark <christopher.w.clark@gmail.com>
To: xen-devel@lists.xenproject.org
Cc: wei.liu2@citrix.com, ian.jackson@eu.citrix.com,
	jbeulich@suse.com, andrew.cooper3@citrix.com
Subject: [PATCH] fuzz, test x86_emulator: disable sse before including always_inline fns
Date: Fri, 21 Sep 2018 12:25:30 -0700	[thread overview]
Message-ID: <1537557930-3266-1-git-send-email-christopher.w.clark@gmail.com> (raw)
In-Reply-To: <5BA4C25402000078001EA77A@prv1-mh.provo.novell.com>

Compiling with _FORTIFY_SOURCE or higher levels of optimization enabled
will always_inline several library fns (memset, memcpy, ...)
(with gcc 8.2.0 and glibc 2.28).

In fuzz and x86_emulator test, the compiler is instructed not
to generate SSE instructions via: #pragma GCC target("no-sse")
because those registers are needed for use by the workload.

The combination above causes compilation failure as the inline functions
use those instructions. This is resolved by reordering the inclusion of
<stdio.h> and <string.h> to after the pragma disabling SSE generation.

Adds compile-time checks for unwanted inclusion of stdio.h, string.h

Adds necessary (previously missing) #include <stdio.h> to x86-emulate.h

Signed-off-by: Christopher Clark <christopher.clark6@baesystems.com>
---
 tools/fuzz/x86_instruction_emulator/fuzz-emul.c |  4 ++--
 tools/tests/x86_emulator/wrappers.c             |  3 ++-
 tools/tests/x86_emulator/x86-emulate.h          | 13 ++++++++++++-
 3 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/tools/fuzz/x86_instruction_emulator/fuzz-emul.c b/tools/fuzz/x86_instruction_emulator/fuzz-emul.c
index 03a2473..d0a02d5 100644
--- a/tools/fuzz/x86_instruction_emulator/fuzz-emul.c
+++ b/tools/fuzz/x86_instruction_emulator/fuzz-emul.c
@@ -6,9 +6,7 @@
 #include <stdbool.h>
 #include <stddef.h>
 #include <stdint.h>
-#include <stdio.h>
 #include <stdlib.h>
-#include <string.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <sys/mman.h>
@@ -16,6 +14,8 @@
 #include <xen/xen.h>
 
 #include "x86-emulate.h"
+#include <stdio.h>
+#include <string.h>
 #include "fuzz-emul.h"
 
 #define MSR_INDEX_MAX 16
diff --git a/tools/tests/x86_emulator/wrappers.c b/tools/tests/x86_emulator/wrappers.c
index d02013c..349b9de 100644
--- a/tools/tests/x86_emulator/wrappers.c
+++ b/tools/tests/x86_emulator/wrappers.c
@@ -1,9 +1,10 @@
 #include <stdarg.h>
-#include <stdio.h>
 
 #define WRAP(x) typeof(x) emul_##x
 #include "x86-emulate.h"
 
+#include <stdio.h>
+
 size_t emul_fwrite(const void *src, size_t sz, size_t n, FILE *f)
 {
     emul_save_fpu_state();
diff --git a/tools/tests/x86_emulator/x86-emulate.h b/tools/tests/x86_emulator/x86-emulate.h
index b249e46..8760bb8 100644
--- a/tools/tests/x86_emulator/x86-emulate.h
+++ b/tools/tests/x86_emulator/x86-emulate.h
@@ -3,12 +3,23 @@
 #include <stddef.h>
 #include <stdint.h>
 #include <stdlib.h>
-#include <string.h>
 
+/*
+ * Use of sse registers must be disabled prior to the definition of
+ * always_inline functions that would use them (memcpy, memset, etc).
+ */
+#ifdef _STRING_H
+# error "Must not include <string.h> before x86-emulate.h"
+#endif
+#ifdef _STDIO_H
+# error "Must not include <stdio.h> before x86-emulate.h"
+#endif
 #if __GNUC__ >= 6
 #pragma GCC target("no-sse")
 #endif
 
+#include <string.h>
+#include <stdio.h>
 #include <xen/xen.h>
 
 #include <xen/asm/msr-index.h>
-- 
2.1.4


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

  reply	other threads:[~2018-09-21 19:25 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-03  9:53 tools/fuzz fails due build, osstest did not notice Olaf Hering
2018-09-03 12:35 ` Jan Beulich
2018-09-04  7:32   ` Olaf Hering
2018-09-04  9:06     ` Jan Beulich
2018-09-20 18:19       ` Christopher Clark
2018-09-21 10:05         ` Jan Beulich
2018-09-21 19:25           ` Christopher Clark [this message]
     [not found]       ` <960FC0BE02000080AB59E961@prv1-mh.provo.novell.com>
     [not found]         ` <FEBAD1C002000087824A10E1@prv1-mh.provo.novell.com>
2018-09-24 12:06           ` [PATCH] fuzz, test x86_emulator: disable sse before including always_inline fns Jan Beulich
2018-09-24 23:17             ` Christopher Clark
2018-09-24 23:22               ` [PATCH v2] " Christopher Clark
2018-09-26  8:36                 ` Wei Liu
2018-09-26  8:40                   ` Wei Liu
     [not found]               ` <D1822B16020000D4AB59E961@prv1-mh.provo.novell.com>
2018-09-25  7:31                 ` [PATCH] " Jan Beulich
     [not found]                 ` <22FE05D1020000E4824A10E1@prv1-mh.provo.novell.com>
2018-09-25  9:51                   ` [PATCH v2] " Jan Beulich

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1537557930-3266-1-git-send-email-christopher.w.clark@gmail.com \
    --to=christopher.w.clark@gmail.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=ian.jackson@eu.citrix.com \
    --cc=jbeulich@suse.com \
    --cc=wei.liu2@citrix.com \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.