From nobody Tue Apr 15 03:09:24 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1544758058052676.3784561539829; Thu, 13 Dec 2018 19:27:38 -0800 (PST) Received: from localhost ([::1]:59095 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gXe8R-0004ED-Sc for importer@patchew.org; Thu, 13 Dec 2018 22:27:31 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58816) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gXe0t-0005yg-E2 for qemu-devel@nongnu.org; Thu, 13 Dec 2018 22:19:44 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gXe0s-0006rv-3x for qemu-devel@nongnu.org; Thu, 13 Dec 2018 22:19:43 -0500 Received: from mail-ot1-x330.google.com ([2607:f8b0:4864:20::330]:43030) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gXe0r-0006qJ-UU for qemu-devel@nongnu.org; Thu, 13 Dec 2018 22:19:42 -0500 Received: by mail-ot1-x330.google.com with SMTP id a11so4088270otr.10 for ; Thu, 13 Dec 2018 19:19:41 -0800 (PST) Received: from cloudburst.twiddle.net ([187.217.227.243]) by smtp.gmail.com with ESMTPSA id g138sm2367537oib.26.2018.12.13.19.19.39 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Dec 2018 19:19:40 -0800 (PST) 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 :mime-version:content-transfer-encoding; bh=tf1fH1QCj4h1v07jYuR/vhe6G4F8YsGZZLEPQJ0aYfc=; b=HIX62xd2a5FwMiSyE4lcp4d4VWKWA2uwIaP5XzRBVoZsQjt0a0FapI2VKyqLVrgJMe DrBQUNf8qA9kh0W9OlZDygFButgmx0By76HPYauKp5V9rr1g7KJyo1r8H271Wd3gmluJ IbfkC77Y6t+xNR5WPclO2A4Kb6CGJspNAgLi4= 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:mime-version:content-transfer-encoding; bh=tf1fH1QCj4h1v07jYuR/vhe6G4F8YsGZZLEPQJ0aYfc=; b=lBlH9YZs87Oag8vphhlF2tdv+6x506YqVCpqK3X3+lewitdYQfC/tCWWoPWCP6JayY 5c6erMR/I2eUBm/9J9520YegqOefdrBqamtXacMmNh+noeDPW+FfnimETfUz5nfIem82 Jsg1v6KzpMjmvMEd5BGzk1Q6u9fWKDAhhGrYhs77sGjLwEUTz2lCFhMQxRwOUXSX/lHj iEFLpsNpMtbc+lka8d5fFAMlDVqV5WhaSfcAMYgE0BmwEY86x4RpIxYRe9yUpqK7XO/x fRAjWFpqH0/nnOIzY4biGqK9OwqUx0mNyHvXYnLypoLFKTYn51sCvutVTJfCl0HpU61s OJQQ== X-Gm-Message-State: AA+aEWatZyUIcb5zHt7XhykgcGe3H3fIUDKg7kmfvPA5vaFB7oPH4OWX BqPuO4Je6Yv506feiEJD64Z22eTAzOO2GQ== X-Google-Smtp-Source: AFSGD/XTJsXf240qDroztBrvbM4V4C3CX/cyUIU4e1Oa/SAjn8UO1R6pJBDSy0qqNZlsYwXGMXjsFA== X-Received: by 2002:a9d:d83:: with SMTP id 3mr885668ots.361.1544757580915; Thu, 13 Dec 2018 19:19:40 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Thu, 13 Dec 2018 21:19:04 -0600 Message-Id: <20181214031923.29527-15-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20181214031923.29527-1-richard.henderson@linaro.org> References: <20181214031923.29527-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::330 Subject: [Qemu-devel] [PULL 13/32] tcg/aarch64: Return false on failure from patch_reloc 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) This does require an extra two checks within the slow paths to replace the assert that we're moving. Reviewed-by: Alex Benn=C3=A9e Signed-off-by: Richard Henderson --- tcg/aarch64/tcg-target.inc.c | 37 ++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/tcg/aarch64/tcg-target.inc.c b/tcg/aarch64/tcg-target.inc.c index 16f08c59c4..0562e0aa40 100644 --- a/tcg/aarch64/tcg-target.inc.c +++ b/tcg/aarch64/tcg-target.inc.c @@ -78,20 +78,26 @@ static const int tcg_target_call_oarg_regs[1] =3D { #define TCG_REG_GUEST_BASE TCG_REG_X28 #endif =20 -static inline void reloc_pc26(tcg_insn_unit *code_ptr, tcg_insn_unit *targ= et) +static inline bool reloc_pc26(tcg_insn_unit *code_ptr, tcg_insn_unit *targ= et) { ptrdiff_t offset =3D target - code_ptr; - tcg_debug_assert(offset =3D=3D sextract64(offset, 0, 26)); - /* read instruction, mask away previous PC_REL26 parameter contents, - set the proper offset, then write back the instruction. */ - *code_ptr =3D deposit32(*code_ptr, 0, 26, offset); + if (offset =3D=3D sextract64(offset, 0, 26)) { + /* read instruction, mask away previous PC_REL26 parameter content= s, + set the proper offset, then write back the instruction. */ + *code_ptr =3D deposit32(*code_ptr, 0, 26, offset); + return true; + } + return false; } =20 -static inline void reloc_pc19(tcg_insn_unit *code_ptr, tcg_insn_unit *targ= et) +static inline bool reloc_pc19(tcg_insn_unit *code_ptr, tcg_insn_unit *targ= et) { ptrdiff_t offset =3D target - code_ptr; - tcg_debug_assert(offset =3D=3D sextract64(offset, 0, 19)); - *code_ptr =3D deposit32(*code_ptr, 5, 19, offset); + if (offset =3D=3D sextract64(offset, 0, 19)) { + *code_ptr =3D deposit32(*code_ptr, 5, 19, offset); + return true; + } + return false; } =20 static inline bool patch_reloc(tcg_insn_unit *code_ptr, int type, @@ -101,15 +107,12 @@ static inline bool patch_reloc(tcg_insn_unit *code_pt= r, int type, switch (type) { case R_AARCH64_JUMP26: case R_AARCH64_CALL26: - reloc_pc26(code_ptr, (tcg_insn_unit *)value); - break; + return reloc_pc26(code_ptr, (tcg_insn_unit *)value); case R_AARCH64_CONDBR19: - reloc_pc19(code_ptr, (tcg_insn_unit *)value); - break; + return reloc_pc19(code_ptr, (tcg_insn_unit *)value); default: - tcg_abort(); + g_assert_not_reached(); } - return true; } =20 #define TCG_CT_CONST_AIMM 0x100 @@ -1387,7 +1390,8 @@ static void tcg_out_qemu_ld_slow_path(TCGContext *s, = TCGLabelQemuLdst *lb) TCGMemOp opc =3D get_memop(oi); TCGMemOp size =3D opc & MO_SIZE; =20 - reloc_pc19(lb->label_ptr[0], s->code_ptr); + bool ok =3D reloc_pc19(lb->label_ptr[0], s->code_ptr); + tcg_debug_assert(ok); =20 tcg_out_mov(s, TCG_TYPE_PTR, TCG_REG_X0, TCG_AREG0); tcg_out_mov(s, TARGET_LONG_BITS =3D=3D 64, TCG_REG_X1, lb->addrlo_reg); @@ -1409,7 +1413,8 @@ static void tcg_out_qemu_st_slow_path(TCGContext *s, = TCGLabelQemuLdst *lb) TCGMemOp opc =3D get_memop(oi); TCGMemOp size =3D opc & MO_SIZE; =20 - reloc_pc19(lb->label_ptr[0], s->code_ptr); + bool ok =3D reloc_pc19(lb->label_ptr[0], s->code_ptr); + tcg_debug_assert(ok); =20 tcg_out_mov(s, TCG_TYPE_PTR, TCG_REG_X0, TCG_AREG0); tcg_out_mov(s, TARGET_LONG_BITS =3D=3D 64, TCG_REG_X1, lb->addrlo_reg); --=20 2.17.2