From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,MAILING_LIST_MULTI, NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E430DC433E9 for ; Thu, 21 Jan 2021 20:04:52 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0186623A5C for ; Thu, 21 Jan 2021 20:04:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0186623A5C Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=csgraf.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:45342 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l2gCI-0000EO-UM for qemu-devel@archiver.kernel.org; Thu, 21 Jan 2021 15:04:50 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:39340) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l2g8z-00063X-2a for qemu-devel@nongnu.org; Thu, 21 Jan 2021 15:01:26 -0500 Received: from mail.csgraf.de ([188.138.100.120]:51082 helo=zulu616.server4you.de) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l2g8w-0003qA-MB for qemu-devel@nongnu.org; Thu, 21 Jan 2021 15:01:24 -0500 Received: from macbook.alex.local (dynamic-095-117-099-148.95.117.pool.telefonica.de [95.117.99.148]) by csgraf.de (Postfix) with ESMTPSA id 402ED39001A8; Thu, 21 Jan 2021 21:01:20 +0100 (CET) Subject: Re: [PATCH v4] tcg: Toggle page execution for Apple Silicon To: Richard Henderson , qemu-devel@nongnu.org References: <20210121184752.1395873-1-richard.henderson@linaro.org> From: Alexander Graf Message-ID: <6d5d9d93-30b6-2f71-e71b-94bd8f18198a@csgraf.de> Date: Thu, 21 Jan 2021 21:01:16 +0100 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.16; rv:78.0) Gecko/20100101 Thunderbird/78.6.1 MIME-Version: 1.0 In-Reply-To: <20210121184752.1395873-1-richard.henderson@linaro.org> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Content-Language: en-US Received-SPF: pass client-ip=188.138.100.120; envelope-from=agraf@csgraf.de; helo=zulu616.server4you.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, NICE_REPLY_A=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, WEIRD_PORT=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Roman Bolshakov , j@getutm.app Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" On 21.01.21 19:47, Richard Henderson wrote: > From: 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 Bolshakov > Message-Id: <20210113032806.18220-1-r.bolshakov@yadro.com> > [rth: Inline the qemu_thread_jit_* functions; > drop the MAP_JIT change for a follow-on patch.] > Signed-off-by: Richard Henderson > --- > > Supercedes: <20210113032806.18220-1-r.bolshakov@yadro.com> > > This is the version of Roman's patch that I'm queuing to tcg-next. > What's missing from the full "Fix execution" patch is setting MAP_JIT > for !splitwx in alloc_code_gen_buffer(). This patch segfaults in tcg_out32() for me if I add the MAP_JIT flag manually to the mmap call: (lldb) bt * thread #3, stop reason = EXC_BAD_ACCESS (code=2, address=0x118000000)   * frame #0: 0x0000000100297e8c qemu-system-x86_64`tcg_prologue_init [inlined] tcg_out32(s=0x0000000100bb64c0, v=2847570941) at tcg.c:250:24 [opt]     frame #1: 0x0000000100297e7c qemu-system-x86_64`tcg_prologue_init [inlined] tcg_out_insn_3314(s=0x0000000100bb64c0, insn=2847539200, r1=TCG_REG_X29, r2=TCG_REG_X30, rn=TCG_REG_SP, ofs=-96, pre=true, w=true) at tcg-target.c.inc:666 [opt]     frame #2: 0x0000000100297e7c qemu-system-x86_64`tcg_prologue_init [inlined] tcg_target_qemu_prologue(s=0x0000000100bb64c0) at tcg-target.c.inc:2858 [opt]     frame #3: 0x0000000100297e7c qemu-system-x86_64`tcg_prologue_init(s=0x0000000100bb64c0) at tcg.c:1116 [opt]     frame #4: 0x00000001002d7ab8 qemu-system-x86_64`tcg_exec_init(tb_size=, splitwx=) at translate-all.c:1349:5 [opt]     frame #5: 0x000000010028d690 qemu-system-x86_64`tcg_init(ms=) at tcg-all.c:113:5 [opt]     frame #6: 0x000000010007d540 qemu-system-x86_64`accel_init_machine(accel=0x00000001020c9ec0, ms=0x00000001020c6880) at accel.c:55:11 [opt]     frame #7: 0x00000001002b90f0 qemu-system-x86_64`do_configure_accelerator(opaque=0x000000016ff12ea0, opts=0x00000001020c9e30, errp=0x0000000100bc18e0) at vl.c:2148:11 [opt]     frame #8: 0x0000000100482c00 qemu-system-x86_64`qemu_opts_foreach(list=, func=(qemu-system-x86_64`do_configure_accelerator at vl.c:2125), opaque=0x000000016ff12ea0, errp=0x0000000100bc18e0) at qemu-option.c:1147:14 [opt]     frame #9: 0x00000001002b6d48 qemu-system-x86_64`qemu_init [inlined] configure_accelerators(progname=) at vl.c:2216:10 [opt]     frame #10: 0x00000001002b6bd8 qemu-system-x86_64`qemu_init(argc=, argv=, envp=) at vl.c:3484 [opt]     frame #11: 0x0000000100007aac qemu-system-x86_64`qemu_main(argc=3, argv=0x000000016fdff848, envp=) at main.c:49:5 [opt]     frame #12: 0x000000010001dd34 qemu-system-x86_64`call_qemu_main(opaque=0x0000000000000000) at cocoa.m:1714:14 [opt]     frame #13: 0x0000000100477c1c qemu-system-x86_64`qemu_thread_start(args=) at qemu-thread-posix.c:521:9 [opt]     frame #14: 0x000000019846106c libsystem_pthread.dylib`_pthread_start + 320 Alex