Re: [PATCH v3] tcg: Fix execution on Apple Silicon

2021-02-02 Thread Roman Bolshakov
On Fri, Jan 29, 2021 at 07:27:57PM -1000, Richard Henderson wrote: > On 1/29/21 10:50 AM, Roman Bolshakov wrote: > > > > I thought you already added MAP_JIT in 6f70ddee19e. It's getting enabled > > on my M1 laptop. Was it intended or not? > > > > /* Applicable to both iOS and macOS (Apple Sil

Re: [PATCH v3] tcg: Fix execution on Apple Silicon

2021-01-29 Thread Richard Henderson
On 1/29/21 10:50 AM, Roman Bolshakov wrote: > On Fri, Jan 29, 2021 at 10:18:58AM -1000, Richard Henderson wrote: >> On 1/21/21 8:34 AM, Richard Henderson wrote: >>> On 1/12/21 5:28 PM, Roman Bolshakov wrote: @@ -1083,6 +1083,12 @@ static bool alloc_code_gen_buffer_anon(size_t size, int p

Re: [PATCH v3] tcg: Fix execution on Apple Silicon

2021-01-29 Thread Roman Bolshakov
On Fri, Jan 29, 2021 at 10:18:58AM -1000, Richard Henderson wrote: > On 1/21/21 8:34 AM, Richard Henderson wrote: > > On 1/12/21 5:28 PM, Roman Bolshakov wrote: > >> @@ -1083,6 +1083,12 @@ static bool alloc_code_gen_buffer_anon(size_t size, > >> int prot, > >> { > >> void *buf; > >> > >> +

Re: [PATCH v3] tcg: Fix execution on Apple Silicon

2021-01-29 Thread Richard Henderson
On 1/21/21 8:34 AM, Richard Henderson wrote: > On 1/12/21 5:28 PM, Roman Bolshakov wrote: >> @@ -1083,6 +1083,12 @@ static bool alloc_code_gen_buffer_anon(size_t size, >> int prot, >> { >> void *buf; >> >> +#if defined(MAC_OS_VERSION_11_0) && \ >> +MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_O

Re: [PATCH v3] tcg: Fix execution on Apple Silicon

2021-01-21 Thread Richard Henderson
On 1/12/21 5:28 PM, Roman Bolshakov wrote: > @@ -1083,6 +1083,12 @@ static bool alloc_code_gen_buffer_anon(size_t size, > int prot, > { > void *buf; > > +#if defined(MAC_OS_VERSION_11_0) && \ > +MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_VERSION_11_0 > +if (__builtin_available(macOS 11

Re: [PATCH v3] tcg: Fix execution on Apple Silicon

2021-01-13 Thread Joelle van Dyne
No because of macOS weirdness you still have to map with RWX and MAP_JIT before you can use this. Split w^x is only useful in iOS where they don’t provide this functionality. -j On Wednesday, January 13, 2021, Richard Henderson < richard.hender...@linaro.org> wrote: > On 1/12/21 5:28 PM, Roman B

Re: [PATCH v3] tcg: Fix execution on Apple Silicon

2021-01-13 Thread Richard Henderson
On 1/12/21 5:28 PM, Roman Bolshakov wrote: > Pages can't be both write and executable at the same time on Apple > Silicon. macOS provides public API to switch write protection [1] for > JIT applications, like TCG. So... considering that split w^x is now upstream, can we just call this once per thr

[PATCH v3] tcg: Fix execution on Apple Silicon

2021-01-12 Thread Roman Bolshakov
Pages can't be both write and executable at the same time on Apple Silicon. macOS provides public API to switch write protection [1] for JIT applications, like TCG. 1. https://developer.apple.com/documentation/apple_silicon/porting_just-in-time_compilers_to_apple_silicon Signed-off-by: Roman Bol