From patchwork Wed May 2 17:48:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 134861 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp966447lji; Wed, 2 May 2018 10:54:27 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpFS26tZJ5e1zuswovDEAUlI5Z4vPx2zLnJ3MDSgD8cHe62Bxuo+l4mcP5VNQXH9tgV0XfT X-Received: by 10.176.36.147 with SMTP id i19mr19335289uan.180.1525283667612; Wed, 02 May 2018 10:54:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525283667; cv=none; d=google.com; s=arc-20160816; b=nU0JugN5Riluer23ThBBENTditVsd/gae+wcMmjHqd+8GsqE4pHdu+089/90ImLoCV i39SEcHXEyVfQCaPs4k714rHxYkKCs09XapgEXK7qwvLM6RTPOz7LuknqyAMiYFwkD/5 io9QcPuWZc7Rhw13BJC0LsPc243bK6lAmh0BAeZJFNUkfreFINqwBCFaRLOE+Kx+ksiB 5cTeHE7HZ2gXrrK+nGKCwdKY8LIvvIJSf0MmVIupT9Rov6GSKTrA9/Rt0V7+cicwYk8s ycuuCjpQP3Sr+3/kUczMdnoP5QPMb4o7fjG9m/uMuZEk+wv+oY7hMbvh52bBjm1JUxEM LIOA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=AOQjtlSoFr9yVPo2ophFBasEpdNgtBMsCpwd0Pzzj+s=; b=wNmr5VcL2auAGlXYI+H6QSqWvtlMblWhSnLriKqWUSQoGMoYoG6zqeqdxbToUmRbve 71Y6gu3QKQe9IS2QqE/drvykdZMvpzsOhJLJ1LdzUFSrzvxRipjOYOz7v6zvpVPUSuF2 pRcHtps4WG8lbzu+ONN3Ja2WaxAKw4DW+ITlYWTM5T0mYVfM4HAiA+sXuNucLM9CKvHL Xm9x3KeVqO0iGJrZkfUJrvldhN/sG1Vxf3F5LrYI0/ZZYcN/FmDmnEuFpaU4r7pQWjOm BLjLQ7ZM0yV4tqQySOyOJw6eYpFHxwuvZy0rVlwaG2UMYdjHiDYVpbhWwbibRos8mb+g g82g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=UvM2uZVV; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id 46si6321590uav.10.2018.05.02.10.54.27 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 02 May 2018 10:54:27 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=UvM2uZVV; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:51906 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fDvxT-0002EC-2S for patch@linaro.org; Wed, 02 May 2018 13:54:27 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51760) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fDvs3-0005X3-0L for qemu-devel@nongnu.org; Wed, 02 May 2018 13:48:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fDvs1-0004DB-Tk for qemu-devel@nongnu.org; Wed, 02 May 2018 13:48:51 -0400 Received: from mail-pf0-x242.google.com ([2607:f8b0:400e:c00::242]:42989) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fDvs1-0004Cg-O6 for qemu-devel@nongnu.org; Wed, 02 May 2018 13:48:49 -0400 Received: by mail-pf0-x242.google.com with SMTP id p14so1025530pfh.9 for ; Wed, 02 May 2018 10:48:49 -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=AOQjtlSoFr9yVPo2ophFBasEpdNgtBMsCpwd0Pzzj+s=; b=UvM2uZVVjM+xcoBIlCUsYkDX+k2XqrKs8CQf6T3j2xiSh14QIySiaytVEDIos5nfVu 8pqK9+0l13MyGB5i+xEUc83IuVliwcscLmwsTJjn0BxgUp2bIcM0HT90NvJUuJo3qEDa 4VSDIDel5yGsSZRqCYcNa2aKTuQxHez8AAi40= 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=AOQjtlSoFr9yVPo2ophFBasEpdNgtBMsCpwd0Pzzj+s=; b=FaFvJXN6XpVl+07o+KemgnTcBJ71iUYKY60bHqj10IKqVDV/mnrguE6xQQxmNevWyI xOmy+3uQr7Nqf87Hk4B/iCtinNLrx7oGIZDfjyvFCWtuogQVmvfzXhUgYqHshztAhvBG 8iYOTaUtvTBTG/YzAyIziBwcCftchJihgSlGDiuA9o8klFp33+NT6fSZGS3Dlzwnqkkl UYn/xQ1SdAtgaS8NrjHjUwgz8lvuFyJ7CMEl5dj2ajX2MObF6QdYI4UL9GkC6DQEO+0x 5xnOUS1c9S2TfgVuKa+nwEjXo4A4ixgbvnUnVNaiIFS7Wh3wZjXX2X88K2Yvkxns0DQv wrsg== X-Gm-Message-State: ALQs6tDKGQCXTn9n+uzHevNAVJRtX0rcWBcl7IZkAMMp9/xx9hXsJFUy FbtmVosG9sWaz7GOLj0d3BSJfGzKfaA= X-Received: by 2002:a17:902:9a90:: with SMTP id w16-v6mr20899795plp.390.1525283328410; Wed, 02 May 2018 10:48:48 -0700 (PDT) Received: from cloudburst.twiddle.net (97-113-2-170.tukw.qwest.net. [97.113.2.170]) by smtp.gmail.com with ESMTPSA id w7sm22275533pfn.83.2018.05.02.10.48.46 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 02 May 2018 10:48:47 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 2 May 2018 10:48:42 -0700 Message-Id: <20180502174842.16253-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180502174842.16253-1-richard.henderson@linaro.org> References: <20180502174842.16253-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::242 Subject: [Qemu-devel] [PULL 5/5] tcg: workaround branch instruction overflow in tcg_out_qemu_ld/st 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: Laurent Vivier , peter.maydell@linaro.org, qemu-stable@nongnu.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Laurent Vivier ppc64 uses a BC instruction to call the tcg_out_qemu_ld/st slow path. BC instruction uses a relative address encoded on 14 bits. The slow path functions are added at the end of the generated instructions buffer, in the reverse order of the callers. So more we have slow path functions more the distance between the caller (BC) and the function increases. This patch changes the behavior to generate the functions in the same order of the callers. Cc: qemu-stable@nongnu.org Fixes: 15fa08f845 ("tcg: Dynamically allocate TCGOps") Signed-off-by: Laurent Vivier Message-Id: <20180429235840.16659-1-lvivier@redhat.com> Signed-off-by: Richard Henderson --- tcg/tcg.h | 2 +- tcg/tcg-ldst.inc.c | 8 ++++---- tcg/tcg.c | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) -- 2.14.3 diff --git a/tcg/tcg.h b/tcg/tcg.h index eb0d4f6ca7..75fbad128b 100644 --- a/tcg/tcg.h +++ b/tcg/tcg.h @@ -699,7 +699,7 @@ struct TCGContext { /* These structures are private to tcg-target.inc.c. */ #ifdef TCG_TARGET_NEED_LDST_LABELS - struct TCGLabelQemuLdst *ldst_labels; + QSIMPLEQ_HEAD(ldst_labels, TCGLabelQemuLdst) ldst_labels; #endif #ifdef TCG_TARGET_NEED_POOL_LABELS struct TCGLabelPoolData *pool_labels; diff --git a/tcg/tcg-ldst.inc.c b/tcg/tcg-ldst.inc.c index 0e14cf4357..47f41b921b 100644 --- a/tcg/tcg-ldst.inc.c +++ b/tcg/tcg-ldst.inc.c @@ -30,7 +30,7 @@ typedef struct TCGLabelQemuLdst { TCGReg datahi_reg; /* reg index for high word to be loaded or stored */ tcg_insn_unit *raddr; /* gen code addr of the next IR of qemu_ld/st IR */ tcg_insn_unit *label_ptr[2]; /* label pointers to be updated */ - struct TCGLabelQemuLdst *next; + QSIMPLEQ_ENTRY(TCGLabelQemuLdst) next; } TCGLabelQemuLdst; @@ -46,7 +46,7 @@ static bool tcg_out_ldst_finalize(TCGContext *s) TCGLabelQemuLdst *lb; /* qemu_ld/st slow paths */ - for (lb = s->ldst_labels; lb != NULL; lb = lb->next) { + QSIMPLEQ_FOREACH(lb, &s->ldst_labels, next) { if (lb->is_ld) { tcg_out_qemu_ld_slow_path(s, lb); } else { @@ -72,7 +72,7 @@ static inline TCGLabelQemuLdst *new_ldst_label(TCGContext *s) { TCGLabelQemuLdst *l = tcg_malloc(sizeof(*l)); - l->next = s->ldst_labels; - s->ldst_labels = l; + QSIMPLEQ_INSERT_TAIL(&s->ldst_labels, l, next); + return l; } diff --git a/tcg/tcg.c b/tcg/tcg.c index b5e706bc49..551caf1c53 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -3297,7 +3297,7 @@ int tcg_gen_code(TCGContext *s, TranslationBlock *tb) s->code_ptr = tb->tc.ptr; #ifdef TCG_TARGET_NEED_LDST_LABELS - s->ldst_labels = NULL; + QSIMPLEQ_INIT(&s->ldst_labels); #endif #ifdef TCG_TARGET_NEED_POOL_LABELS s->pool_labels = NULL;