Re: [RFC v2 6/6] *-user: move safe-syscall.* to common-user

2021-11-10 Thread Warner Losh
On Wed, Nov 10, 2021 at 10:04 AM Richard Henderson <
richard.hender...@linaro.org> wrote:

> On 11/10/21 5:31 PM, Warner Losh wrote:
> > Move linux-user/safe-syscall.S to common-user/common-safe-syscall.S and
> > replace it with a #include "common-safe-syscall.S" so that bsd-user can
> > also use it. Also move safe-syscall.h so that it can define a few more
> > externs.
> >
> > Signed-off-by: Warner Losh 
> > ---
> >   common-user/common-safe-syscall.S  | 30 +
> >   {linux-user => common-user}/safe-syscall.h |  0
> >   linux-user/safe-syscall.S  | 31 +-
> >   linux-user/signal.c|  1 +
> >   meson.build|  1 +
> >   5 files changed, 33 insertions(+), 30 deletions(-)
> >   create mode 100644 common-user/common-safe-syscall.S
> >   rename {linux-user => common-user}/safe-syscall.h (100%)
> >
> > diff --git a/common-user/common-safe-syscall.S
> b/common-user/common-safe-syscall.S
> > new file mode 100644
> > index 00..42ea7c40ba
> > --- /dev/null
> > +++ b/common-user/common-safe-syscall.S
> > @@ -0,0 +1,30 @@
> > +/*
> > + * safe-syscall.S : include the host-specific assembly fragment
> > + * to handle signals occurring at the same time as system calls.
> > + *
> > + * Written by Peter Maydell 
> > + *
> > + * Copyright (C) 2016 Linaro Limited
> > + *
> > + * This work is licensed under the terms of the GNU GPL, version 2 or
> later.
> > + * See the COPYING file in the top-level directory.
> > + */
> > +
> > +#include "hostdep.h"
> > +#include "target_errno_defs.h"
> > +
> > +/* We have the correct host directory on our include path
> > + * so that this will pull in the right fragment for the architecture.
> > + */
> > +#ifdef HAVE_SAFE_SYSCALL
> > +#include "safe-syscall.inc.S"
> > +#endif
> > +
> > +/* We must specifically say that we're happy for the stack to not be
> > + * executable, otherwise the toolchain will default to assuming our
> > + * assembly needs an executable stack and the whole QEMU binary will
> > + * needlessly end up with one. This should be the last thing in this
> file.
> > + */
> > +#if defined(__linux__) && defined(__ELF__)
> > +.section.note.GNU-stack, "", %progbits
> > +#endif
>
> Hmm.  If we're going to split this file into safe-syscall.S and
> common-safe-syscall.S, we
> shouldn't do the ifdef thing here.  (Why it was present at all for
> linux-user is a mystery.)
>

Yea, the #ifdef dates from the earliest days of the safe syscall stuff. I
think it can be dropped,
though I'm unsure if the the whole thing should be dropped, or just the
ifdef.


> What do you have planned for bsd-user that would be more than
>
> > +#include "common-safe-syscall.S"
>
> this?
>

Yes. I had that in mind. I wasn't sure how to do this with meson directly,
or I'd have
compiled it out of common-user tree.

Warner


Re: [RFC v2 6/6] *-user: move safe-syscall.* to common-user

2021-11-10 Thread Richard Henderson

On 11/10/21 5:31 PM, Warner Losh wrote:

Move linux-user/safe-syscall.S to common-user/common-safe-syscall.S and
replace it with a #include "common-safe-syscall.S" so that bsd-user can
also use it. Also move safe-syscall.h so that it can define a few more
externs.

Signed-off-by: Warner Losh 
---
  common-user/common-safe-syscall.S  | 30 +
  {linux-user => common-user}/safe-syscall.h |  0
  linux-user/safe-syscall.S  | 31 +-
  linux-user/signal.c|  1 +
  meson.build|  1 +
  5 files changed, 33 insertions(+), 30 deletions(-)
  create mode 100644 common-user/common-safe-syscall.S
  rename {linux-user => common-user}/safe-syscall.h (100%)

diff --git a/common-user/common-safe-syscall.S 
b/common-user/common-safe-syscall.S
new file mode 100644
index 00..42ea7c40ba
--- /dev/null
+++ b/common-user/common-safe-syscall.S
@@ -0,0 +1,30 @@
+/*
+ * safe-syscall.S : include the host-specific assembly fragment
+ * to handle signals occurring at the same time as system calls.
+ *
+ * Written by Peter Maydell 
+ *
+ * Copyright (C) 2016 Linaro Limited
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */
+
+#include "hostdep.h"
+#include "target_errno_defs.h"
+
+/* We have the correct host directory on our include path
+ * so that this will pull in the right fragment for the architecture.
+ */
+#ifdef HAVE_SAFE_SYSCALL
+#include "safe-syscall.inc.S"
+#endif
+
+/* We must specifically say that we're happy for the stack to not be
+ * executable, otherwise the toolchain will default to assuming our
+ * assembly needs an executable stack and the whole QEMU binary will
+ * needlessly end up with one. This should be the last thing in this file.
+ */
+#if defined(__linux__) && defined(__ELF__)
+.section.note.GNU-stack, "", %progbits
+#endif


Hmm.  If we're going to split this file into safe-syscall.S and common-safe-syscall.S, we 
shouldn't do the ifdef thing here.  (Why it was present at all for linux-user is a mystery.)


What do you have planned for bsd-user that would be more than


+#include "common-safe-syscall.S"


this?


r~



[RFC v2 6/6] *-user: move safe-syscall.* to common-user

2021-11-10 Thread Warner Losh
Move linux-user/safe-syscall.S to common-user/common-safe-syscall.S and
replace it with a #include "common-safe-syscall.S" so that bsd-user can
also use it. Also move safe-syscall.h so that it can define a few more
externs.

Signed-off-by: Warner Losh 
---
 common-user/common-safe-syscall.S  | 30 +
 {linux-user => common-user}/safe-syscall.h |  0
 linux-user/safe-syscall.S  | 31 +-
 linux-user/signal.c|  1 +
 meson.build|  1 +
 5 files changed, 33 insertions(+), 30 deletions(-)
 create mode 100644 common-user/common-safe-syscall.S
 rename {linux-user => common-user}/safe-syscall.h (100%)

diff --git a/common-user/common-safe-syscall.S 
b/common-user/common-safe-syscall.S
new file mode 100644
index 00..42ea7c40ba
--- /dev/null
+++ b/common-user/common-safe-syscall.S
@@ -0,0 +1,30 @@
+/*
+ * safe-syscall.S : include the host-specific assembly fragment
+ * to handle signals occurring at the same time as system calls.
+ *
+ * Written by Peter Maydell 
+ *
+ * Copyright (C) 2016 Linaro Limited
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */
+
+#include "hostdep.h"
+#include "target_errno_defs.h"
+
+/* We have the correct host directory on our include path
+ * so that this will pull in the right fragment for the architecture.
+ */
+#ifdef HAVE_SAFE_SYSCALL
+#include "safe-syscall.inc.S"
+#endif
+
+/* We must specifically say that we're happy for the stack to not be
+ * executable, otherwise the toolchain will default to assuming our
+ * assembly needs an executable stack and the whole QEMU binary will
+ * needlessly end up with one. This should be the last thing in this file.
+ */
+#if defined(__linux__) && defined(__ELF__)
+.section.note.GNU-stack, "", %progbits
+#endif
diff --git a/linux-user/safe-syscall.h b/common-user/safe-syscall.h
similarity index 100%
rename from linux-user/safe-syscall.h
rename to common-user/safe-syscall.h
diff --git a/linux-user/safe-syscall.S b/linux-user/safe-syscall.S
index 42ea7c40ba..c86f0aea74 100644
--- a/linux-user/safe-syscall.S
+++ b/linux-user/safe-syscall.S
@@ -1,30 +1 @@
-/*
- * safe-syscall.S : include the host-specific assembly fragment
- * to handle signals occurring at the same time as system calls.
- *
- * Written by Peter Maydell 
- *
- * Copyright (C) 2016 Linaro Limited
- *
- * This work is licensed under the terms of the GNU GPL, version 2 or later.
- * See the COPYING file in the top-level directory.
- */
-
-#include "hostdep.h"
-#include "target_errno_defs.h"
-
-/* We have the correct host directory on our include path
- * so that this will pull in the right fragment for the architecture.
- */
-#ifdef HAVE_SAFE_SYSCALL
-#include "safe-syscall.inc.S"
-#endif
-
-/* We must specifically say that we're happy for the stack to not be
- * executable, otherwise the toolchain will default to assuming our
- * assembly needs an executable stack and the whole QEMU binary will
- * needlessly end up with one. This should be the last thing in this file.
- */
-#if defined(__linux__) && defined(__ELF__)
-.section.note.GNU-stack, "", %progbits
-#endif
+#include "common-safe-syscall.S"
diff --git a/linux-user/signal.c b/linux-user/signal.c
index ee038c2399..cfda166f9c 100644
--- a/linux-user/signal.c
+++ b/linux-user/signal.c
@@ -31,6 +31,7 @@
 #include "trace.h"
 #include "signal-common.h"
 #include "host-signal.h"
+#include "safe-syscall.h"
 
 static struct target_sigaction sigact_table[TARGET_NSIG];
 
diff --git a/meson.build b/meson.build
index 728d305403..2f3b0fb2d6 100644
--- a/meson.build
+++ b/meson.build
@@ -2873,6 +2873,7 @@ foreach target : target_dirs
   base_dir = 'linux-user'
   target_inc += include_directories('linux-user/host/' / 
config_host['ARCH'])
   target_inc += include_directories('common-user/host/' / 
config_host['ARCH'])
+  target_inc += include_directories('common-user')
 endif
 if 'CONFIG_BSD_USER' in config_target
   base_dir = 'bsd-user'
-- 
2.33.0