From nobody Tue Feb 10 03:16:01 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.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 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1566251797; cv=none; d=zoho.com; s=zohoarc; b=Wb/qiKnpIxS/ujl+UTD10HajajWGmCBI/X6b6SIzzw2vUNvJsN+7ADKKcXG2J/nw3OEOu8R/dfyYoHg/4KIJqWIeo5734wwbxsQ57SES2QQT99l3C52Ue8bXd27J5EjKqQq00KDlekRzvNrbnbxKpUzRaCJoEGpcTb4lav9G044= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1566251797; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=PE2YkC2uYnkrGF/f+RQwnN2RH8jlq2MEkPtJdHa8VHQ=; b=C0233m7nY8Rp2qHSp5X6heZ4LXk5mcIzJtT+UODoNSAOjqwflKTvjGcTHKi5cf13SrD0ifj9KrkR4OeU1ReQtehFZiby6nU6dNb4JgHUo7uGOSb2I4SiTOWnkjFW7uklgaHYFg6WV/nI/9ZotFQodxjYrLFBgZdZSw62GcURD0Q= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1566251797494212.8304742727007; Mon, 19 Aug 2019 14:56:37 -0700 (PDT) Received: from localhost ([::1]:59258 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1hzpdf-0007g1-1h for importer@patchew.org; Mon, 19 Aug 2019 17:56:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59189) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1hzpMK-000265-G6 for qemu-devel@nongnu.org; Mon, 19 Aug 2019 17:38:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hzpMJ-0006Nu-0i for qemu-devel@nongnu.org; Mon, 19 Aug 2019 17:38:36 -0400 Received: from mail-pg1-x544.google.com ([2607:f8b0:4864:20::544]:43141) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hzpMI-0006N6-O6 for qemu-devel@nongnu.org; Mon, 19 Aug 2019 17:38:34 -0400 Received: by mail-pg1-x544.google.com with SMTP id k3so1921599pgb.10 for ; Mon, 19 Aug 2019 14:38:34 -0700 (PDT) Received: from localhost.localdomain (97-113-7-119.tukw.qwest.net. [97.113.7.119]) by smtp.gmail.com with ESMTPSA id d2sm13446951pjs.21.2019.08.19.14.38.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Aug 2019 14:38:32 -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=PE2YkC2uYnkrGF/f+RQwnN2RH8jlq2MEkPtJdHa8VHQ=; b=t8oNyn9ZZ3RCoFQiIKX4jSToehRsZPBSpTvpY9Z9O0ijBgjNpKVTXyQQZIj+0WQ1I9 vNssbEbg6nKXjvsygAhI5ZFYDHFXOe/jw8E/zmSjoiCT3D6DbkmJ4SI65C+i5glaquEj exzjnem76xrCYZdKpZsexjc6bFARf8cGzp0Ys+IWQ4ZDKMUoDuTLzxjLI8XxjQg7Dn42 yKjbV5ycXhFT1NOZUC1RmQa75ErVhGNizoUDdc0h4aJVW9h/kehjv0qgQYEsVChuRj/P e1hZc6hrr8YwFEFpq5wuuDR3YzMk2wA64D2E/2ta6lMlYUWOosLaFXvWmKHn/LUU9cbw 3R8A== 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=PE2YkC2uYnkrGF/f+RQwnN2RH8jlq2MEkPtJdHa8VHQ=; b=Mntx5l6WZZJc3V55U2SjLpD4yf9VtVXzSRn0cXCc5bty1YgreuVXxwuPJmUe8i2Xuz rfI0Jgw5TXDxhAoSWs1XU0Ms13/6tNOfnhDz341fGJGp+ToV5cNCyIn3SU8Qvmtg4c1E KpIkLkBoMbsLdl11Fc22uMIzbbDag0oSYC8fZu1H8QEyOMG9Uuj2afN8EGV7J0fjVeAH KYupepGBc/KtvZKsR/BPkF1YWhADDNUFT1YfDjA3hzibQdqVbhjaoUI8MZ/Vm7UjDber ffVPrEfS3fRXJycFWdqPRAnvDL/VEv4lQKY6e/6hHdA14qr9BFc+mLS3IAq3pGeqdFlk inrw== X-Gm-Message-State: APjAAAVukD9mKDTPKCsh8DZmgd8AAmvkTy3tyeZIYxV6cZJm/mJwLiXH pyCIyZzvNbTNzjKU8BhE4AbrY6nqEXw= X-Google-Smtp-Source: APXvYqxgALNgiwL5LxxNgNOjY3hpHYZNCkpg62IU22V2zRzmwICq2jve7P0gWxDoK0UpD2P8UXDpPQ== X-Received: by 2002:a62:1703:: with SMTP id 3mr22426920pfx.118.1566250713399; Mon, 19 Aug 2019 14:38:33 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 19 Aug 2019 14:37:16 -0700 Message-Id: <20190819213755.26175-30-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190819213755.26175-1-richard.henderson@linaro.org> References: <20190819213755.26175-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::544 Subject: [Qemu-devel] [PATCH v2 29/68] target/arm: Diagnose too few registers in list for LDM/STM X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, qemu-arm@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This has been a TODO item for quite a while. The minimum bit count for A32 and T16 is 1, and for T32 is 2. Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell --- target/arm/translate.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/target/arm/translate.c b/target/arm/translate.c index 29e2eae441..1792bb7abd 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -9733,7 +9733,7 @@ static void op_addr_block_post(DisasContext *s, arg_l= dst_block *a, } } =20 -static bool op_stm(DisasContext *s, arg_ldst_block *a) +static bool op_stm(DisasContext *s, arg_ldst_block *a, int min_n) { int i, j, n, list, mem_idx; bool user =3D a->u; @@ -9749,7 +9749,9 @@ static bool op_stm(DisasContext *s, arg_ldst_block *a) =20 list =3D a->list; n =3D ctpop16(list); - /* TODO: test invalid n =3D=3D 0 case */ + if (n < min_n) { + return false; + } =20 addr =3D op_addr_block_pre(s, a, n); mem_idx =3D get_mem_index(s); @@ -9782,7 +9784,8 @@ static bool op_stm(DisasContext *s, arg_ldst_block *a) =20 static bool trans_STM(DisasContext *s, arg_ldst_block *a) { - return op_stm(s, a); + /* BitCount(list) < 1 is UNPREDICTABLE */ + return op_stm(s, a, 1); } =20 static bool trans_STM_t32(DisasContext *s, arg_ldst_block *a) @@ -9791,10 +9794,11 @@ static bool trans_STM_t32(DisasContext *s, arg_ldst= _block *a) if (a->w && (a->list & (1 << a->rn))) { return false; } - return op_stm(s, a); + /* BitCount(list) < 2 is UNPREDICTABLE */ + return op_stm(s, a, 2); } =20 -static bool do_ldm(DisasContext *s, arg_ldst_block *a) +static bool do_ldm(DisasContext *s, arg_ldst_block *a, int min_n) { int i, j, n, list, mem_idx; bool loaded_base; @@ -9821,7 +9825,9 @@ static bool do_ldm(DisasContext *s, arg_ldst_block *a) =20 list =3D a->list; n =3D ctpop16(list); - /* TODO: test invalid n =3D=3D 0 case */ + if (n < min_n) { + return false; + } =20 addr =3D op_addr_block_pre(s, a, n); mem_idx =3D get_mem_index(s); @@ -9888,7 +9894,8 @@ static bool trans_LDM_a32(DisasContext *s, arg_ldst_b= lock *a) if (ENABLE_ARCH_7 && a->w && (a->list & (1 << a->rn))) { return false; } - return do_ldm(s, a); + /* BitCount(list) < 1 is UNPREDICTABLE */ + return do_ldm(s, a, 1); } =20 static bool trans_LDM_t32(DisasContext *s, arg_ldst_block *a) @@ -9897,7 +9904,8 @@ static bool trans_LDM_t32(DisasContext *s, arg_ldst_b= lock *a) if (a->w && (a->list & (1 << a->rn))) { return false; } - return do_ldm(s, a); + /* BitCount(list) < 2 is UNPREDICTABLE */ + return do_ldm(s, a, 2); } =20 /* --=20 2.17.1