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

2021-01-05 Thread Alex Bennée
Roman Bolshakov writes: > On Mon, Jan 04, 2021 at 03:23:07PM +, Alex Bennée wrote: >> >> Roman Bolshakov writes: >> >> > 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,

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

2021-01-05 Thread Roman Bolshakov
On Mon, Jan 04, 2021 at 06:02:50PM -0800, Joelle van Dyne wrote: > Tested-by: Joelle van Dyne > > It works for me. But one thing is that if you build it with the macOS > 11.x SDK it won't run on < 11.x. This is why apple recommends > something like: > > if (__builtin_available(macOS 11,

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

2021-01-05 Thread Roman Bolshakov
On Mon, Jan 04, 2021 at 08:28:08PM +, Alex Bennée wrote: > > Alexander Graf writes: > > > On 04.01.21 16:23, Alex Bennée wrote: > >> Roman Bolshakov writes: > >> > >>> Pages can't be both write and executable at the same time on Apple > >>> Silicon. macOS provides public API to switch

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

2021-01-05 Thread Roman Bolshakov
On Mon, Jan 04, 2021 at 07:39:13PM +0100, Alexander Graf wrote: > > On 04.01.21 16:23, Alex Bennée wrote: > > Roman Bolshakov writes: > > > > > 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 > > >

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

2021-01-05 Thread Roman Bolshakov
On Mon, Jan 04, 2021 at 03:23:07PM +, Alex Bennée wrote: > > Roman Bolshakov writes: > > > 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. > >

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

2021-01-04 Thread Joelle van Dyne
Tested-by: Joelle van Dyne It works for me. But one thing is that if you build it with the macOS 11.x SDK it won't run on < 11.x. This is why apple recommends something like: if (__builtin_available(macOS 11, *)) { pthread_jit_write_protect_np(); } You still need a

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

2021-01-04 Thread Alex Bennée
Alexander Graf writes: > On 04.01.21 16:23, Alex Bennée wrote: >> Roman Bolshakov writes: >> >>> 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. >>>

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

2021-01-04 Thread Alexander Graf
On 04.01.21 16:23, Alex Bennée wrote: Roman Bolshakov writes: 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.

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

2021-01-04 Thread Alex Bennée
Roman Bolshakov writes: > 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. >

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

2021-01-03 Thread Roman Bolshakov
On Sun, Jan 03, 2021 at 08:52:52AM -0800, Joelle van Dyne wrote: > MAC_OS_VERSION_11_0 is always defined. You can see in > usr/include/AvailabilityVersions.h > It's not defined on my old MPB that has Catalina (10.15.7). The last entries are: #define MAC_OS_X_VERSION_10_15 101500 #define

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

2021-01-03 Thread Joelle van Dyne
MAC_OS_VERSION_11_0 is always defined. You can see in usr/include/AvailabilityVersions.h ... #define MAC_OS_X_VERSION_10_15 101500 #define MAC_OS_X_VERSION_10_15_1101501 #define MAC_OS_X_VERSION_10_16 101600 #define MAC_OS_VERSION_11_0 11 The proper way is to do an

[PATCH v2] tcg: Fix execution on Apple Silicon

2021-01-03 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