From patchwork Wed Jun 7 22:52:12 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pranith Kumar X-Patchwork-Id: 9772977 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 61C0960350 for ; Wed, 7 Jun 2017 22:53:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 37C6E283BD for ; Wed, 7 Jun 2017 22:53:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2C8082849E; Wed, 7 Jun 2017 22:53:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id BDEF6283BD for ; Wed, 7 Jun 2017 22:53:36 +0000 (UTC) Received: from localhost ([::1]:46397 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dIjpY-0002jR-00 for patchwork-qemu-devel@patchwork.kernel.org; Wed, 07 Jun 2017 18:53:36 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34786) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dIjoI-0002gX-7f for qemu-devel@nongnu.org; Wed, 07 Jun 2017 18:52:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dIjoG-0000hz-PZ for qemu-devel@nongnu.org; Wed, 07 Jun 2017 18:52:18 -0400 Received: from mail-yw0-x244.google.com ([2607:f8b0:4002:c05::244]:36822) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dIjoG-0000hu-Ks for qemu-devel@nongnu.org; Wed, 07 Jun 2017 18:52:16 -0400 Received: by mail-yw0-x244.google.com with SMTP id h82so1308775ywb.3 for ; Wed, 07 Jun 2017 15:52:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=4F1VFv9tf3JI3ADe829J8LzJ9fOLNrJEUBhgHXR4yV8=; b=cAj3wYaQ7xaOk8RoZsVkYT0xb+z1IDPCdvbd4ihz0Iz8IVY93gVVN/U7lElO1Ht5P+ cXUGd6UanjnxZT8JQq0pNSkjm5bMN+JVfMcnf/LRSPPLPi99+pgIQj/XYLAAOMecWPuP WJuxd32t8EYF2rhTXjeM5iccumaFmJ4iaI5HVRK0Z9ZYxe8uLLqw2pyEDysCC74LFF2P 9HJSvIYvuvXJfJKj9sFTr8pRcd9SUKk01WVCna6r5uHgsLNo0aRvDo2lUu8e3KzzRFjA TJlWY4uMv7nD/V3NU/9ulMKmY3oDrkukYErtdZXDk5lICFjx0vhBGC/JX9MtztrjP1F2 TrCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=4F1VFv9tf3JI3ADe829J8LzJ9fOLNrJEUBhgHXR4yV8=; b=tB3qOmNuGdHp3x9oTVWlQEkj9vc6aIWh0F9ohMGo0of7Mf8ZfxrW1ru9YVd/Z9OflB RvBV1HQbxSDguzhjxBYoV69x38nGLqGFoPWtqo9uceI3QcK4xUg75+EmXGF+86ANR2MY jJFnigSR6TaoR0WzyCQNEUJkFB7mFPo3SYI6ZV8l6UeQ36Wld0rppHiM+iT1DGc4UBH7 j3SHF2nvaGG1Tje22H1iRCVQtavRcBKxl1y0nu69VkMft8cm309vepD5RHBdMVvCLptp mntSE47lQMExJ8dBRy3ybnTCylVtQcPA9vffNA+YxvgSWunyDHhY4JrkLmw5PBUHFAjj YKUA== X-Gm-Message-State: AODbwcDwUaD860BeR7ChX7czRMT8oQLoHA8IwvPMvsILVZSVCQGq0W6D l7tZSbdwlmKc6Q== X-Received: by 10.129.99.194 with SMTP id x185mr9339732ywb.80.1496875935900; Wed, 07 Jun 2017 15:52:15 -0700 (PDT) Received: from localhost.localdomain (c-73-207-178-95.hsd1.ga.comcast.net. [73.207.178.95]) by smtp.gmail.com with ESMTPSA id u187sm1269123ywd.22.2017.06.07.15.52.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 07 Jun 2017 15:52:15 -0700 (PDT) From: Pranith Kumar To: alex.bennee@linaro.org Date: Wed, 7 Jun 2017 18:52:12 -0400 Message-Id: <20170607225212.23714-4-bobby.prani@gmail.com> X-Mailer: git-send-email 2.13.0 In-Reply-To: <20170607225212.23714-1-bobby.prani@gmail.com> References: <20170607225212.23714-1-bobby.prani@gmail.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4002:c05::244 Subject: [Qemu-devel] [RFC PATCH 3/3] tcg/aarch64: Remove code buffer size limitation X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-devel@nongnu.org, rth@twiddle.net Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP This enables indirect jump on aarch64 hosts. Tested by booting an x86 guest on aarch64 host. Signed-off-by: Pranith Kumar --- include/exec/exec-all.h | 6 +----- tcg/aarch64/tcg-target.inc.c | 25 ++++++------------------- translate-all.c | 2 -- 3 files changed, 7 insertions(+), 26 deletions(-) diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h index 724ec73dce..a6bd3c7d1e 100644 --- a/include/exec/exec-all.h +++ b/include/exec/exec-all.h @@ -301,9 +301,8 @@ static inline void tlb_flush_by_mmuidx_all_cpus_synced(CPUState *cpu, #define CODE_GEN_AVG_BLOCK_SIZE 150 #endif -#if defined(_ARCH_PPC) \ +#if defined(_ARCH_PPC) || defined(__sparc__) \ || defined(__x86_64__) || defined(__i386__) \ - || defined(__sparc__) || defined(__aarch64__) \ || defined(__s390x__) || defined(__mips__) \ || defined(CONFIG_TCG_INTERPRETER) /* NOTE: Direct jump patching must be atomic to be thread-safe. */ @@ -398,9 +397,6 @@ static inline void tb_set_jmp_target1(uintptr_t jmp_addr, uintptr_t addr) atomic_set((int32_t *)jmp_addr, disp / 2); /* no need to flush icache explicitly */ } -#elif defined(__aarch64__) -void aarch64_tb_set_jmp_target(uintptr_t jmp_addr, uintptr_t addr); -#define tb_set_jmp_target1 aarch64_tb_set_jmp_target #elif defined(__sparc__) || defined(__mips__) void tb_set_jmp_target1(uintptr_t jmp_addr, uintptr_t addr); #else diff --git a/tcg/aarch64/tcg-target.inc.c b/tcg/aarch64/tcg-target.inc.c index e488aacadb..cc81a0d5ff 100644 --- a/tcg/aarch64/tcg-target.inc.c +++ b/tcg/aarch64/tcg-target.inc.c @@ -865,15 +865,6 @@ static inline void tcg_out_call(TCGContext *s, tcg_insn_unit *target) } } -void aarch64_tb_set_jmp_target(uintptr_t jmp_addr, uintptr_t addr) -{ - tcg_insn_unit *code_ptr = (tcg_insn_unit *)jmp_addr; - tcg_insn_unit *target = (tcg_insn_unit *)addr; - - reloc_pc26_atomic(code_ptr, target); - flush_icache_range(jmp_addr, jmp_addr + 4); -} - static inline void tcg_out_goto_label(TCGContext *s, TCGLabel *l) { if (!l->has_value) { @@ -1385,16 +1376,12 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, break; case INDEX_op_goto_tb: -#ifndef USE_DIRECT_JUMP -#error "USE_DIRECT_JUMP required for aarch64" -#endif - /* consistency for USE_DIRECT_JUMP */ - tcg_debug_assert(s->tb_jmp_insn_offset != NULL); - s->tb_jmp_insn_offset[a0] = tcg_current_code_size(s); - /* actual branch destination will be patched by - aarch64_tb_set_jmp_target later, beware retranslation. */ - tcg_out_goto_noaddr(s); - s->tb_jmp_reset_offset[a0] = tcg_current_code_size(s); + { + intptr_t offset = tcg_pcrel_diff(s, (s->tb_jmp_target_addr + a0)) >> 2; + tcg_out_insn(s, 3305, LDR, offset, TCG_REG_TMP); + tcg_out_callr(s, TCG_REG_TMP); + s->tb_jmp_reset_offset[a0] = tcg_current_code_size(s); + } break; case INDEX_op_goto_ptr: diff --git a/translate-all.c b/translate-all.c index 966747ad60..e4cd849931 100644 --- a/translate-all.c +++ b/translate-all.c @@ -521,8 +521,6 @@ static inline PageDesc *page_find(tb_page_addr_t index) # define MAX_CODE_GEN_BUFFER_SIZE (2ul * 1024 * 1024 * 1024) #elif defined(__powerpc__) # define MAX_CODE_GEN_BUFFER_SIZE (32u * 1024 * 1024) -#elif defined(__aarch64__) -# define MAX_CODE_GEN_BUFFER_SIZE (128ul * 1024 * 1024) #elif defined(__s390x__) /* We have a +- 4GB range on the branches; leave some slop. */ # define MAX_CODE_GEN_BUFFER_SIZE (3ul * 1024 * 1024 * 1024)