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 1544758426003693.2040181499125; Thu, 13 Dec 2018 19:33:46 -0800 (PST) Received: from localhost ([::1]:59127 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gXeEP-0001Rf-0C for importer@patchew.org; Thu, 13 Dec 2018 22:33:41 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58868) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gXe12-00067K-DK for qemu-devel@nongnu.org; Thu, 13 Dec 2018 22:19:55 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gXe0x-00076F-CH for qemu-devel@nongnu.org; Thu, 13 Dec 2018 22:19:50 -0500 Received: from mail-oi1-x229.google.com ([2607:f8b0:4864:20::229]:32912) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gXe0v-0006zo-5X for qemu-devel@nongnu.org; Thu, 13 Dec 2018 22:19:46 -0500 Received: by mail-oi1-x229.google.com with SMTP id c206so3495243oib.0 for ; Thu, 13 Dec 2018 19:19:45 -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.43 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Dec 2018 19:19:43 -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=ROFG7TZHTA0dfs36r/Nwv/zpP8/0UI1AqpPTTpG4eqc=; b=ZKkFHlI3FXq8FiQvHfkPS0rWeeFJmlEq+BSxeUuZAyzITTkPU3SeDDhMoLZgiyJWbZ 2Gt4DjfKU5QGRVudOh7s/SsLUtu38pTPNh8zKXGPRMy0komTnsQmmMBrN1hKDWYvQ7Rh 6T8Dmq0iGK+AIrixMiZnU9n09ouROrKny6iO4= 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=ROFG7TZHTA0dfs36r/Nwv/zpP8/0UI1AqpPTTpG4eqc=; b=VeXvNtROsF3pSZi2UymEUxVPVDX9mdzYq40gzcz3l7DqulMcwN0Xkj8sea99QB3PrG 49FLp54lYuqGXmxMBZD8+KphfrlE1uagEMwrY0/qIpOfbAoTyh0DCYe0VjeYkD3vVrwg 2Dmx/APT1rbmROwyfhNG3qKQvs6ylovghMf+cyY4/mJ96FVXmczvDywdQyTFwp4nz1Es q5pHyrRsjvJL2ZSf74+oMBbHgaSfjHZ9T1yv09mR14XMx/1gxSYOnRsGYrv9kO2I9OAl dpWocY7+aYIhuBCiNxWKztnmnKrDiZC00nfcjS2WKL12uzR/r44+5X5mYx+zkQ+WWEyu RE6A== X-Gm-Message-State: AA+aEWbH6Bg+DetegoTYpieSzZdC0l02v+QJlsjD7iBnVKR3ClS4k+wW 3i4hdk1YF4FfTnnW1lS4ATKXp9g5mnoGgw== X-Google-Smtp-Source: AFSGD/Vlrkk8R9LqCSne2BtQAbvRb789LfCB+RXCfO+yhYp3gs63vB6eDLyYaZPuqlAYdDzt4l3Xyg== X-Received: by 2002:aca:b7c2:: with SMTP id h185mr852319oif.298.1544757584135; Thu, 13 Dec 2018 19:19:44 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Thu, 13 Dec 2018 21:19:07 -0600 Message-Id: <20181214031923.29527-18-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::229 Subject: [Qemu-devel] [PULL 16/32] tcg/s390x: 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. Also add two checks within existing functions that lacked any kind of assert for out of range branch. Reviewed-by: Alex Benn=C3=A9e Signed-off-by: Richard Henderson --- tcg/s390/tcg-target.inc.c | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/tcg/s390/tcg-target.inc.c b/tcg/s390/tcg-target.inc.c index 68a4c60394..39ecf609a1 100644 --- a/tcg/s390/tcg-target.inc.c +++ b/tcg/s390/tcg-target.inc.c @@ -377,23 +377,29 @@ static bool patch_reloc(tcg_insn_unit *code_ptr, int = type, =20 switch (type) { case R_390_PC16DBL: - assert(pcrel2 =3D=3D (int16_t)pcrel2); - tcg_patch16(code_ptr, pcrel2); + if (pcrel2 =3D=3D (int16_t)pcrel2) { + tcg_patch16(code_ptr, pcrel2); + return true; + } break; case R_390_PC32DBL: - assert(pcrel2 =3D=3D (int32_t)pcrel2); - tcg_patch32(code_ptr, pcrel2); + if (pcrel2 =3D=3D (int32_t)pcrel2) { + tcg_patch32(code_ptr, pcrel2); + return true; + } break; case R_390_20: - assert(value =3D=3D sextract64(value, 0, 20)); - old =3D *(uint32_t *)code_ptr & 0xf00000ff; - old |=3D ((value & 0xfff) << 16) | ((value & 0xff000) >> 4); - tcg_patch32(code_ptr, old); + if (value =3D=3D sextract64(value, 0, 20)) { + old =3D *(uint32_t *)code_ptr & 0xf00000ff; + old |=3D ((value & 0xfff) << 16) | ((value & 0xff000) >> 4); + tcg_patch32(code_ptr, old); + return true; + } break; default: g_assert_not_reached(); } - return true; + return false; } =20 /* parse target specific constraints */ @@ -1334,6 +1340,7 @@ static void tgen_compare_branch(TCGContext *s, S390Op= code opc, int cc, =20 if (l->has_value) { off =3D l->u.value_ptr - s->code_ptr; + tcg_debug_assert(off =3D=3D (int16_t)off); } else { tcg_out_reloc(s, s->code_ptr + 1, R_390_PC16DBL, l, 2); } @@ -1350,6 +1357,7 @@ static void tgen_compare_imm_branch(TCGContext *s, S3= 90Opcode opc, int cc, =20 if (l->has_value) { off =3D l->u.value_ptr - s->code_ptr; + tcg_debug_assert(off =3D=3D (int16_t)off); } else { tcg_out_reloc(s, s->code_ptr + 1, R_390_PC16DBL, l, 2); } @@ -1615,7 +1623,9 @@ static void tcg_out_qemu_ld_slow_path(TCGContext *s, = TCGLabelQemuLdst *lb) TCGMemOpIdx oi =3D lb->oi; TCGMemOp opc =3D get_memop(oi); =20 - patch_reloc(lb->label_ptr[0], R_390_PC16DBL, (intptr_t)s->code_ptr, 2); + bool ok =3D patch_reloc(lb->label_ptr[0], R_390_PC16DBL, + (intptr_t)s->code_ptr, 2); + tcg_debug_assert(ok); =20 tcg_out_mov(s, TCG_TYPE_PTR, TCG_REG_R2, TCG_AREG0); if (TARGET_LONG_BITS =3D=3D 64) { @@ -1636,7 +1646,9 @@ static void tcg_out_qemu_st_slow_path(TCGContext *s, = TCGLabelQemuLdst *lb) TCGMemOpIdx oi =3D lb->oi; TCGMemOp opc =3D get_memop(oi); =20 - patch_reloc(lb->label_ptr[0], R_390_PC16DBL, (intptr_t)s->code_ptr, 2); + bool ok =3D patch_reloc(lb->label_ptr[0], R_390_PC16DBL, + (intptr_t)s->code_ptr, 2); + tcg_debug_assert(ok); =20 tcg_out_mov(s, TCG_TYPE_PTR, TCG_REG_R2, TCG_AREG0); if (TARGET_LONG_BITS =3D=3D 64) { --=20 2.17.2