From patchwork Mon Dec 19 02:16:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 635102 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp2093084pvb; Sun, 18 Dec 2022 18:25:52 -0800 (PST) X-Google-Smtp-Source: AMrXdXvJwZAlo8cIwGtlDy89oB9HSQR34XxPImQ4oFb0dqtiw1mslHa1Brb39goFMBa7YaSlI5NL X-Received: by 2002:ac8:4785:0:b0:3a9:81ba:409d with SMTP id k5-20020ac84785000000b003a981ba409dmr7570222qtq.0.1671416752541; Sun, 18 Dec 2022 18:25:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671416752; cv=none; d=google.com; s=arc-20160816; b=V6Isj5ZbbEK3HOGsEm36mY8uEgQOYMIFRNXnMNJI0npeCPXcgsi3mlAxXXPLH28XOu q3Y5+WvSH1StSs68u5y/Gn1cdo0DIfD6OURIKAC6PLpxih5eVveEsvlLrTLaRzzgNBp7 29g6dcBeRqeE+m+3Z4A+ZCa3Y1fdqXkY8wgwFg+5SObgw+Su6LuUzYFCXH4pvd0+fFfq sPuMVeyDMr4Or4z/eOH6IE7MHdD3hZDNrnrh3qg3L4/m//wstDWtChBcFfejpGNR2fe5 +NvGyqAA1T+N8DOH8TtIwMop4sL3fAO3GH5oxYyqnPrmPQMXlHR/GiJDoc6Bk/DGJgHB lRNQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature:wdcironportexception:ironport-sdr:ironport-sdr :dkim-signature; bh=cbGWpV6ehEahO/y5NqPPDmJBcvAjp+tHyZNbOtzi9j0=; b=hgopa1L7U1rGEIkHjnnu1Ivv9TxcoDW/gsXMDNm7bjx+hHjPqGn4mvIiZKrBt4q3pg s4Fp4XPUSsk094OsLyI6tvnw92Cw2367oFlxtr0jLNFnVwneVfhc9dXqe+/RNALrILHm 1/KHsoOdRSWtyxv6Jl3UzqfjoefwyA2x+itaAGXdJKYK10ftZFtpeRYraUTZa/u49Rer 5YgfVTQkobCDeN12GHSOPTqiKCWzFRE6AbQ+7n/YLzZrPTgg23J/LQxHSS2snEwD9Cq1 js8dOn8W9b7R25lrnwOzugoXiQVU7TPmRsF8EHn0652ixMvNywln41rTk5qH/9hSaQQO Cs3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=Z9LhlBR+; dkim=pass header.i=@opensource.wdc.com header.s=dkim header.b=K4mvxcpp; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=opensource.wdc.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id g12-20020ac8124c000000b0039a3df76a29si3433015qtj.107.2022.12.18.18.25.52 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 18 Dec 2022 18:25:52 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=Z9LhlBR+; dkim=pass header.i=@opensource.wdc.com header.s=dkim header.b=K4mvxcpp; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=opensource.wdc.com Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p75k0-0001cl-KX; Sun, 18 Dec 2022 21:18:56 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p75jt-0001Yw-Hm for qemu-devel@nongnu.org; Sun, 18 Dec 2022 21:18:54 -0500 Received: from esa4.hgst.iphmx.com ([216.71.154.42]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p75jr-00015O-PP for qemu-devel@nongnu.org; Sun, 18 Dec 2022 21:18:49 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1671416327; x=1702952327; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Jzu4w1v0TJpnBmXkZe8wqb1VN0yzrvZdJQ4Z2Lx9Dzs=; b=Z9LhlBR+YKhobnQzErt8/iaFtaVw5Qyog3BbO/JuSWNUd7EOIlWsdMq6 McMMRpW40Hh4djTXjuz2B159YPKPjWahuSGBXN5OJ1KtmWL/rYTG+sCxf ADfP1v0duHV/Pmp8uzbm6B/ImPuE6c7xGawB4LvlY3ioHU9isCsdt/2Fo VJSpIjofB69ElMDhRipLgkLJQmcERLMKO1t3SbaxhAd/dbS4khm1c1f/L ffn9K1GrZkyE9e2aB3oLUPhMw4EDmPRMrnma0q9yKJ0yq7mysv6z61ZXy 8rmDkWdkwWCvQ3gmUG+34+wg5wmuAVqcdZXHkByiz8eEEwkf+CuEe8Njj g==; X-IronPort-AV: E=Sophos;i="5.96,254,1665417600"; d="scan'208";a="217199386" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 19 Dec 2022 10:18:15 +0800 IronPort-SDR: kRAwKT/4j+lJYrzgWhbN6jCRW+P925NxAEhcMjK+L/Y1n/8CVF8NKbKajHzNkjh7n0RtkXl2Xs I4v4OlviFVgaGMjdwsvbNMdQB6cYQnyN2mGmF2RWUXzNnD7BLZC358Tgk20dXeStNh3hoE7QOz cFLmoHhHFe35Ils1BFd3QjCEsfKxZYHF+Eas8YWj99L51K06v+cnXPSiowP7lyomXNIk1wBV1H HKIOPIBU3G1sx3Nv1QDUz74w5//g5SfPV4CHCrLiR9Wv23SezyadcaBPFIB+V02w+I47crx2Yy r1g= Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 18 Dec 2022 17:30:47 -0800 IronPort-SDR: j++HBdJz6mdCOC+GuJ2cUL4OsbvJGIWMFdoWrgrPUruT4ZoMcmgI4rxf7IHjSMFXSB+yGWM5ua QT0GVBnN4iqRjViGIgegLL9hUJ3uOzdqkk4qxSxmsb5/Q5ffkmypfDVyhw5nQXaZCX32Zl0xqe oz69V1yFd3wPCYcZkdopMiV86NcpJren8slW3J9EFhKUmE6KTOdj5jKRdpnp3/QCm2vWLs6QBS oMsX1H0L7ibFNXD7LJHWcdTcEwc9DKRRAP+Tmkj9GcIeS53W/e1l6iLns5wPBhZv9AditV1oOs mxk= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 18 Dec 2022 18:18:15 -0800 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4Nb3K271hvz1RwqL for ; Sun, 18 Dec 2022 18:18:14 -0800 (PST) Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:content-type :mime-version:references:in-reply-to:x-mailer:message-id:date :subject:to:from; s=dkim; t=1671416294; x=1674008295; bh=Jzu4w1v 0TJpnBmXkZe8wqb1VN0yzrvZdJQ4Z2Lx9Dzs=; b=K4mvxcppjCK9Yl0hs/emQ5C qZo3AZAd4h7CtafXVRroqhKHLcHG+Cgqt6X47SsALGhKyl8TMEH++XaWLPH3BbyC rsJ3AY5rr15B+PSdpeW+JR/FZD0ipx/PTzHqIwAe77KByLkSMlmKsLPsKEDWkQTj 6vciSLRVI+ofpRIObah8Ec6M20My4lLTWoS/yJUuAbPAkOBFuBr1YvfPa6mEDU+p +zZfyWS75K9QYUlME5wj4dswWJp7rpBxYH4WEy3Cq9QLlbhGygPFBMK0Q+voaeCG rp9zmJ6ts98YNKVxrYY6ZLIlw0vwLg1PspBXi7y5G65cxeJsxiQeBbmRL1E4TBw= = X-Virus-Scanned: amavisd-new at usg-ed-osssrv.wdc.com Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id L8KYwHybRHj6 for ; Sun, 18 Dec 2022 18:18:14 -0800 (PST) Received: from toolbox.alistair23.me (unknown [10.225.167.4]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4Nb3K036bgz1RvTp; Sun, 18 Dec 2022 18:18:12 -0800 (PST) From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Richard Henderson , qemu-stable@nongnu.org, Alistair Francis , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PULL 26/45] target/riscv: Set pc_succ_insn for !rvc illegal insn Date: Mon, 19 Dec 2022 12:16:44 +1000 Message-Id: <20221219021703.20473-27-alistair.francis@opensource.wdc.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221219021703.20473-1-alistair.francis@opensource.wdc.com> References: <20221219021703.20473-1-alistair.francis@opensource.wdc.com> MIME-Version: 1.0 Received-SPF: pass client-ip=216.71.154.42; envelope-from=prvs=345d64987=alistair.francis@opensource.wdc.com; helo=esa4.hgst.iphmx.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Richard Henderson Failure to set pc_succ_insn may result in a TB covering zero bytes, which triggers an assert within the code generator. Cc: qemu-stable@nongnu.org Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1224 Signed-off-by: Richard Henderson Reviewed-by: Alistair Francis Reviewed-by: Philippe Mathieu-Daudé Message-Id: <20221203175744.151365-1-richard.henderson@linaro.org> Signed-off-by: Alistair Francis --- target/riscv/translate.c | 12 ++++-------- tests/tcg/Makefile.target | 2 ++ tests/tcg/riscv64/Makefile.target | 5 +++++ tests/tcg/riscv64/test-noc.S | 32 +++++++++++++++++++++++++++++++ 4 files changed, 43 insertions(+), 8 deletions(-) create mode 100644 tests/tcg/riscv64/test-noc.S diff --git a/target/riscv/translate.c b/target/riscv/translate.c index cd5eb25ee8..160aefc3df 100644 --- a/target/riscv/translate.c +++ b/target/riscv/translate.c @@ -1096,14 +1096,10 @@ static void decode_opc(CPURISCVState *env, DisasContext *ctx, uint16_t opcode) ctx->virt_inst_excp = false; /* Check for compressed insn */ if (insn_len(opcode) == 2) { - if (!has_ext(ctx, RVC)) { - gen_exception_illegal(ctx); - } else { - ctx->opcode = opcode; - ctx->pc_succ_insn = ctx->base.pc_next + 2; - if (decode_insn16(ctx, opcode)) { - return; - } + ctx->opcode = opcode; + ctx->pc_succ_insn = ctx->base.pc_next + 2; + if (has_ext(ctx, RVC) && decode_insn16(ctx, opcode)) { + return; } } else { uint32_t opcode32 = opcode; diff --git a/tests/tcg/Makefile.target b/tests/tcg/Makefile.target index 75257f2b29..14bc013181 100644 --- a/tests/tcg/Makefile.target +++ b/tests/tcg/Makefile.target @@ -117,6 +117,8 @@ endif %: %.c $(CC) $(CFLAGS) $(EXTRA_CFLAGS) $< -o $@ $(LDFLAGS) +%: %.S + $(CC) $(CFLAGS) $(EXTRA_CFLAGS) $< -o $@ $(LDFLAGS) else # For softmmu targets we include a different Makefile fragement as the # build options for bare programs are usually pretty different. They diff --git a/tests/tcg/riscv64/Makefile.target b/tests/tcg/riscv64/Makefile.target index b5b89dfb0e..9973ba3b5f 100644 --- a/tests/tcg/riscv64/Makefile.target +++ b/tests/tcg/riscv64/Makefile.target @@ -4,3 +4,8 @@ VPATH += $(SRC_PATH)/tests/tcg/riscv64 TESTS += test-div TESTS += noexec + +# Disable compressed instructions for test-noc +TESTS += test-noc +test-noc: LDFLAGS = -nostdlib -static +run-test-noc: QEMU_OPTS += -cpu rv64,c=false diff --git a/tests/tcg/riscv64/test-noc.S b/tests/tcg/riscv64/test-noc.S new file mode 100644 index 0000000000..e29d60c8b3 --- /dev/null +++ b/tests/tcg/riscv64/test-noc.S @@ -0,0 +1,32 @@ +#include + + .text + .globl _start +_start: + .option norvc + li a0, 4 /* SIGILL */ + la a1, sa + li a2, 0 + li a3, 8 + li a7, __NR_rt_sigaction + scall + + .option rvc + li a0, 1 + j exit + .option norvc + +pass: + li a0, 0 +exit: + li a7, __NR_exit + scall + + .data + /* struct kernel_sigaction sa = { .sa_handler = pass }; */ + .type sa, @object + .size sa, 32 +sa: + .dword pass + .zero 24 +