From patchwork Fri Nov 3 08:40:44 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 10039691 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 CB16B6032D for ; Fri, 3 Nov 2017 08:43:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B24A32953B for ; Fri, 3 Nov 2017 08:43:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A72C92955B; Fri, 3 Nov 2017 08:43:56 +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_SIGNED, 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 2A0452953B for ; Fri, 3 Nov 2017 08:43:56 +0000 (UTC) Received: from localhost ([::1]:35421 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eAXZz-0003t5-GU for patchwork-qemu-devel@patchwork.kernel.org; Fri, 03 Nov 2017 04:43:55 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48437) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eAXX6-00029t-Og for qemu-devel@nongnu.org; Fri, 03 Nov 2017 04:40:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eAXX3-0002Q6-0Q for qemu-devel@nongnu.org; Fri, 03 Nov 2017 04:40:56 -0400 Received: from mail-wm0-x241.google.com ([2a00:1450:400c:c09::241]:54219) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eAXX2-0002PT-Q2 for qemu-devel@nongnu.org; Fri, 03 Nov 2017 04:40:52 -0400 Received: by mail-wm0-x241.google.com with SMTP id r196so3507748wmf.2 for ; Fri, 03 Nov 2017 01:40:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=4BDSQzsdDM7Bh+3NBnayvPVdSEpTsHHmQGK53JqNFC4=; b=AM9RR2qA8miT1hG3oIA0PZdDE9bn6aPP0aHlIy9+NWIPylrHqWZhKFidf7AfV7IAGA aOPPLEpdUdIPkjixXsj977JK9MiUhyQAwA3wQ75zL5dojLwCi+Fjg+A1lIZVnmKObq8v nXNP2T7IPLFXubQwvQYBw5NIToD00kKmTzJVQ= 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=4BDSQzsdDM7Bh+3NBnayvPVdSEpTsHHmQGK53JqNFC4=; b=m+MMn6CQrJNkRW8p1gdXo97VXA/RCo6Lm0msl82I4AV5s3phZol6+/nKIjbXNFM08G 6vq14FdukTgPdlY/Oml1mStzIZ6AAVwHeuLflDlxKXIA7uoWIERqaJBZyfxroYyFAVjC OG9fct0jwCXq+WkuFsyCum6wtI5KEcipU5c2SclmoT7Qb6gicAyGv70Gl7rKPxGL1SaM MesHk1BmggmA9yo+rBBrla79hQU60Mr2tcO9ddr4UA+hBqPtdSVX0jdHwFyfUaLxWw0j ZAxCB/yASipT3UxYqpo7PENtfUdpUhOZzMqFPqD84nzuoTXisdG0dlXeDXEByK0K+aNX 9nUQ== X-Gm-Message-State: AMCzsaXMkfoyUbBlQpVNeYPM0f1S9ga8js/g4FwKQOUcbbeFRek55zsU hBg3MmG/vS3jUrI4uaKi8rMpGWlZuJA= X-Google-Smtp-Source: ABhQp+QCV9z6bRWjXhli95LM+0x4WEIBLO2pgoLBz1W1ss5+vdGHvEfmHlSfghv0F5rnMZclj32vkg== X-Received: by 10.28.239.2 with SMTP id n2mr3363577wmh.140.1509698451521; Fri, 03 Nov 2017 01:40:51 -0700 (PDT) Received: from cloudburst.twiddle.net.ASUS (p57A4515F.dip0.t-ipconnect.de. [87.164.81.95]) by smtp.gmail.com with ESMTPSA id e6sm12548347wrg.53.2017.11.03.01.40.50 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 03 Nov 2017 01:40:50 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Fri, 3 Nov 2017 09:40:44 +0100 Message-Id: <20171103084046.12821-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171103084046.12821-1-richard.henderson@linaro.org> References: <20171103084046.12821-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::241 Subject: [Qemu-devel] [PULL 1/3] tcg: Allow constant pool entries in the prologue 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: peter.maydell@linaro.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Both ARMv6 and AArch64 currently may drop complex guest_base values into the constant pool. But generic code wasn't expecting that, and the pool is not emitted. Correct that. Tested-by: Emilio G. Cota Tested-by: Laurent Desnogues Reported-by: Laurent Desnogues Signed-off-by: Richard Henderson --- tcg/tcg.c | 49 ++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 42 insertions(+), 7 deletions(-) diff --git a/tcg/tcg.c b/tcg/tcg.c index 683ff4abb7..c22f1c4441 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -771,12 +771,32 @@ void tcg_prologue_init(TCGContext *s) /* Put the prologue at the beginning of code_gen_buffer. */ buf0 = s->code_gen_buffer; + total_size = s->code_gen_buffer_size; s->code_ptr = buf0; s->code_buf = buf0; + s->data_gen_ptr = NULL; s->code_gen_prologue = buf0; + /* Compute a high-water mark, at which we voluntarily flush the buffer + and start over. The size here is arbitrary, significantly larger + than we expect the code generation for any one opcode to require. */ + s->code_gen_highwater = s->code_gen_buffer + (total_size - TCG_HIGHWATER); + +#ifdef TCG_TARGET_NEED_POOL_LABELS + s->pool_labels = NULL; +#endif + /* Generate the prologue. */ tcg_target_qemu_prologue(s); + +#ifdef TCG_TARGET_NEED_POOL_LABELS + /* Allow the prologue to put e.g. guest_base into a pool entry. */ + { + bool ok = tcg_out_pool_finalize(s); + tcg_debug_assert(ok); + } +#endif + buf1 = s->code_ptr; flush_icache_range((uintptr_t)buf0, (uintptr_t)buf1); @@ -785,21 +805,36 @@ void tcg_prologue_init(TCGContext *s) s->code_gen_ptr = buf1; s->code_gen_buffer = buf1; s->code_buf = buf1; - total_size = s->code_gen_buffer_size - prologue_size; + total_size -= prologue_size; s->code_gen_buffer_size = total_size; - /* Compute a high-water mark, at which we voluntarily flush the buffer - and start over. The size here is arbitrary, significantly larger - than we expect the code generation for any one opcode to require. */ - s->code_gen_highwater = s->code_gen_buffer + (total_size - TCG_HIGHWATER); - tcg_register_jit(s->code_gen_buffer, total_size); #ifdef DEBUG_DISAS if (qemu_loglevel_mask(CPU_LOG_TB_OUT_ASM)) { qemu_log_lock(); qemu_log("PROLOGUE: [size=%zu]\n", prologue_size); - log_disas(buf0, prologue_size); + if (s->data_gen_ptr) { + size_t code_size = s->data_gen_ptr - buf0; + size_t data_size = prologue_size - code_size; + size_t i; + + log_disas(buf0, code_size); + + for (i = 0; i < data_size; i += sizeof(tcg_target_ulong)) { + if (sizeof(tcg_target_ulong) == 8) { + qemu_log("0x%08" PRIxPTR ": .quad 0x%016" PRIx64 "\n", + (uintptr_t)s->data_gen_ptr + i, + *(uint64_t *)(s->data_gen_ptr + i)); + } else { + qemu_log("0x%08" PRIxPTR ": .long 0x%08x\n", + (uintptr_t)s->data_gen_ptr + i, + *(uint32_t *)(s->data_gen_ptr + i)); + } + } + } else { + log_disas(buf0, prologue_size); + } qemu_log("\n"); qemu_log_flush(); qemu_log_unlock();