Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20180208182528.GG1627@brightrain.aerifal.cx>
Date: Thu, 8 Feb 2018 13:25:28 -0500
From: Rich Felker <dalias@...c.org>
To: musl@...ts.openwall.com
Subject: Re: [PATCH 00/25] Update for linux v4.14 and v4.15

On Wed, Feb 07, 2018 at 02:10:15AM +0100, Szabolcs Nagy wrote:
> includes v4.14 patches from
> http://www.openwall.com/lists/musl/2017/11/27/2
> and cosmetic bits/termios.h fix from
> http://www.openwall.com/lists/musl/2017/11/27/3
> and a number of elf.h updates.
> 
> build tested on most targets.
> 
> last patch is aarch64 sve sigcontext stuff, which is a bit ugly to
> copy into musl headers, but requiring linux asm/sigcontext.h for
> that does not work as it conflicts with musl signal.h
> 
> [...]
> 
> >From efd536020b2c739a843bd2eaa69697e4d896478b Mon Sep 17 00:00:00 2001
> From: Szabolcs Nagy <nsz@...t70.net>
> Date: Sun, 26 Nov 2017 23:20:38 +0000
> Subject: [PATCH 06/25] signal.h: add missing SIGTRAP and SIGSYS si_codes
> 
> SYS_SECCOMP new in commit a0727e8ce513fe6890416da960181ceb10fbfae6
> TRAP_BRANCH and TRAP_HWBKPT new in commit
> da654b74bda14c45a7d98c731bf3c1a43b6b74e2
> ---
>  include/signal.h | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/include/signal.h b/include/signal.h
> index 2c8b3d55..1db5af5f 100644
> --- a/include/signal.h
> +++ b/include/signal.h
> @@ -231,6 +231,8 @@ int sigrelse(int);
>  void (*sigset(int, void (*)(int)))(int);
>  #define TRAP_BRKPT 1
>  #define TRAP_TRACE 2
> +#define TRAP_BRANCH 3
> +#define TRAP_HWBKPT 4
>  #define POLL_IN 1
>  #define POLL_OUT 2
>  #define POLL_MSG 3
> @@ -241,6 +243,7 @@ void (*sigset(int, void (*)(int)))(int);
>  #define SS_DISABLE    2
>  #define SS_AUTODISARM (1U << 31)
>  #define SS_FLAG_BITS SS_AUTODISARM
> +#define SYS_SECCOMP 1
>  #endif

SYS_ is not reserved namespace. This needs to go in the next
conditional block I think. Unless other changes are needed I can just
amend this when merging.

> >From 0bfeb4f4e717349eaf473e08bc5998958cfc0b33 Mon Sep 17 00:00:00 2001
> From: Szabolcs Nagy <nsz@...t70.net>
> Date: Sun, 26 Nov 2017 23:58:25 +0000
> Subject: [PATCH 09/25] sys/{mman,shm}.h: add {MAP,SHM}_HUGE_ macros from linux
>  uapi
> 
> *_HUGE_SHIFT, *_HUGE_2MB, *_HUGE_1GB are documented in the man page,
> so add all of the *_HUGE_* macros from linux uapi.
> 
> if MAP_HUGETLB is set, top bits of the mmap flags encode the page size.
> see the linux commit aafd4562dfee81a40ba21b5ea3cf5e06664bc7f6
> 
> if SHM_HUGETLB is set, top bits of the shmget flags encode the page size.
> see the linux commit 4da243ac1cf6aeb30b7c555d56208982d66d6d33
> 
> *_HUGE_16GB is defined unsigned to avoid signed left shift ub.
> ---
>  include/sys/mman.h | 13 +++++++++++++
>  include/sys/shm.h  | 13 +++++++++++++
>  2 files changed, 26 insertions(+)
> 
> diff --git a/include/sys/mman.h b/include/sys/mman.h
> index 12318782..d13d4ca3 100644
> --- a/include/sys/mman.h
> +++ b/include/sys/mman.h
> @@ -35,6 +35,19 @@ extern "C" {
>  #define MAP_HUGETLB    0x40000
>  #define MAP_FILE       0
>  
> +#define MAP_HUGE_SHIFT 26
> +#define MAP_HUGE_MASK  0x3f
> +#define MAP_HUGE_64KB  (16 << 26)
> +#define MAP_HUGE_512KB (19 << 26)
> +#define MAP_HUGE_1MB   (20 << 26)
> +#define MAP_HUGE_2MB   (21 << 26)
> +#define MAP_HUGE_8MB   (23 << 26)
> +#define MAP_HUGE_16MB  (24 << 26)
> +#define MAP_HUGE_256MB (28 << 26)
> +#define MAP_HUGE_1GB   (30 << 26)
> +#define MAP_HUGE_2GB   (31 << 26)
> +#define MAP_HUGE_16GB  (34U << 26)

This is a huge shame and waste of precious flag bits, but nothing we
can change. :( :( :(

> >From 88d285105bfe57315d021c88abf98aba44b6b094 Mon Sep 17 00:00:00 2001
> From: Szabolcs Nagy <nsz@...t70.net>
> Date: Fri, 2 Feb 2018 20:10:09 +0000
> Subject: [PATCH 12/25] add MAP_SYNC and MAP_SHARED_VALIDATE from linux v4.15
> 
> for synchronous page faults, new in linux commit
> 1c9725974074a047f6080eecc62c50a8e840d050 and
> b6fb293f2497a9841d94f6b57bd2bb2cd222da43
> note that only targets that use asm-generic/mman.h have this new
> flag defined, so undef it on other targets (mips*, powerpc*).
> ---
>  arch/mips/bits/mman.h      | 1 +
>  arch/mips64/bits/mman.h    | 1 +
>  arch/mipsn32/bits/mman.h   | 1 +
>  arch/powerpc/bits/mman.h   | 1 +
>  arch/powerpc64/bits/mman.h | 1 +
>  include/sys/mman.h         | 2 ++
>  6 files changed, 7 insertions(+)
> 
> diff --git a/arch/mips/bits/mman.h b/arch/mips/bits/mman.h
> index c68aea88..9027bb63 100644
> --- a/arch/mips/bits/mman.h
> +++ b/arch/mips/bits/mman.h
> @@ -18,6 +18,7 @@
>  #define MAP_STACK      0x40000
>  #undef MAP_HUGETLB
>  #define MAP_HUGETLB    0x80000
> +#undef MAP_SYNC

This might have been less ugly only defining it in the archs that have
it for now, but your way will probably be less ugly going forward. I
don't think it needs to be changed.

> diff --git a/arch/aarch64/bits/signal.h b/arch/aarch64/bits/signal.h
> index 5eb3d91f..56e4ff83 100644
> --- a/arch/aarch64/bits/signal.h
> +++ b/arch/aarch64/bits/signal.h
> @@ -25,6 +25,7 @@ typedef struct sigcontext {
>  #define FPSIMD_MAGIC 0x46508001
>  #define ESR_MAGIC 0x45535201
>  #define EXTRA_MAGIC 0x45585401
> +#define SVE_MAGIC 0x53564501
>  struct _aarch64_ctx {
>  	unsigned int magic;
>  	unsigned int size;
> @@ -45,6 +46,44 @@ struct extra_context {
>  	unsigned int size;
>  	unsigned int __reserved[3];
>  };
> +struct sve_context {
> +	struct _aarch64_ctx head;
> +	unsigned short vl;
> +	unsigned short __reserved[3];
> +};
> +#define SVE_VQ_BYTES		16
> +#define SVE_VQ_MIN		1
> +#define SVE_VQ_MAX		512
> +#define SVE_VL_MIN		(SVE_VQ_MIN * SVE_VQ_BYTES)
> +#define SVE_VL_MAX		(SVE_VQ_MAX * SVE_VQ_BYTES)
> +#define SVE_NUM_ZREGS		32
> +#define SVE_NUM_PREGS		16
> +#define sve_vl_valid(vl) \
> +	((vl) % SVE_VQ_BYTES == 0 && (vl) >= SVE_VL_MIN && (vl) <= SVE_VL_MAX)
> +#define sve_vq_from_vl(vl)	((vl) / SVE_VQ_BYTES)
> +#define sve_vl_from_vq(vq)	((vq) * SVE_VQ_BYTES)
> +#define SVE_SIG_ZREG_SIZE(vq)	((unsigned)(vq) * SVE_VQ_BYTES)
> +#define SVE_SIG_PREG_SIZE(vq)	((unsigned)(vq) * (SVE_VQ_BYTES / 8))
> +#define SVE_SIG_FFR_SIZE(vq)	SVE_SIG_PREG_SIZE(vq)
> +#define SVE_SIG_REGS_OFFSET					\
> +	((sizeof(struct sve_context) + (SVE_VQ_BYTES - 1))	\
> +		/ SVE_VQ_BYTES * SVE_VQ_BYTES)
> +#define SVE_SIG_ZREGS_OFFSET	SVE_SIG_REGS_OFFSET
> +#define SVE_SIG_ZREG_OFFSET(vq, n) \
> +	(SVE_SIG_ZREGS_OFFSET + SVE_SIG_ZREG_SIZE(vq) * (n))
> +#define SVE_SIG_ZREGS_SIZE(vq) \
> +	(SVE_SIG_ZREG_OFFSET(vq, SVE_NUM_ZREGS) - SVE_SIG_ZREGS_OFFSET)
> +#define SVE_SIG_PREGS_OFFSET(vq) \
> +	(SVE_SIG_ZREGS_OFFSET + SVE_SIG_ZREGS_SIZE(vq))
> +#define SVE_SIG_PREG_OFFSET(vq, n) \
> +	(SVE_SIG_PREGS_OFFSET(vq) + SVE_SIG_PREG_SIZE(vq) * (n))
> +#define SVE_SIG_PREGS_SIZE(vq) \
> +	(SVE_SIG_PREG_OFFSET(vq, SVE_NUM_PREGS) - SVE_SIG_PREGS_OFFSET(vq))
> +#define SVE_SIG_FFR_OFFSET(vq) \
> +	(SVE_SIG_PREGS_OFFSET(vq) + SVE_SIG_PREGS_SIZE(vq))
> +#define SVE_SIG_REGS_SIZE(vq) \
> +	(SVE_SIG_FFR_OFFSET(vq) + SVE_SIG_FFR_SIZE(vq) - SVE_SIG_REGS_OFFSET)
> +#define SVE_SIG_CONTEXT_SIZE(vq) (SVE_SIG_REGS_OFFSET + SVE_SIG_REGS_SIZE(vq))
>  #else
>  typedef struct {
>  	long double __regs[18+256];

This is a lot of messy code-like machinery to be adding to a header,
but maybe it's also needed? :(

Rich

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.