From nobody Thu Dec 18 22:22:59 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.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=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1584985314; cv=none; d=zohomail.com; s=zohoarc; b=mwu3+aaXP2hmPvJKpLjRCwyo0DiJgpyO3wSr4xqRappq632WEc3BcG2OkLBXC3K2gYO/oxnUX6d+smzeMFV6J+OzIoxRhZEOWvmofLTArefU/iSrNXycyD0puFIFjjhfvAyIiAnCTyEwYQxe7PMUJF16D+5m2GTO0ipK3D+htZc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584985314; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=P717LorGeXb892L2rPZftLo69BBrecynggE4xn2hmr0=; b=g1XR4O3JMoeaJy5D3Fzh/P1ocPVubEkbp4EK7WQhQFvsxvbkF9NSNyz8i660HQ7IFRwTRcO52ZeNxILxLbF48G0Qdkb4falzj112c46LtVc2xecpCdnonQ11YixtlUx0NMVavdJAo4co4SL2bLAFQeZHfeYvXrfzuBiM0GFDyBU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass 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 1584985314754224.58121716886353; Mon, 23 Mar 2020 10:41:54 -0700 (PDT) Received: from localhost ([::1]:37630 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jGR5F-00063T-Dn for importer@patchew.org; Mon, 23 Mar 2020 13:41:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52225) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jGR3h-0004OK-Ku for qemu-devel@nongnu.org; Mon, 23 Mar 2020 13:40:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jGR3g-0003hV-Ih for qemu-devel@nongnu.org; Mon, 23 Mar 2020 13:40:17 -0400 Received: from mail-wm1-x344.google.com ([2a00:1450:4864:20::344]:39028) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jGR3g-0003fe-5u for qemu-devel@nongnu.org; Mon, 23 Mar 2020 13:40:16 -0400 Received: by mail-wm1-x344.google.com with SMTP id a9so436401wmj.4 for ; Mon, 23 Mar 2020 10:40:14 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id o9sm25145282wrw.20.2020.03.23.10.40.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Mar 2020 10:40:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=P717LorGeXb892L2rPZftLo69BBrecynggE4xn2hmr0=; b=RR3hgNfbENzWCdCJP17GedyzqJeSMjgzBerbhmsLVmpiNXXbm62VCqcogTQdbHt0/m l3+J5ZziKVyAWOb25wOOf0s9UTRsDwGT6lNjeef4bZWNWO/sVx0Kf/xkVA9Xm/2js3az lyu6ofMag9bqCdLMf214FHZ333eMJjvIQDLX/MEnTlt6ze0caVaYAL234fLOgsbglvyf 6tAhY+qraEemNKpBwg8BWQUDRVakng5bNBPQnnnw+Coa+Lp+v77uHMBB2e6lcpdCtouY DWr9hCR15FfV91LygBcd2aEUTSImfwnd+OSyvtUfYRiHMPKZtxhkndwOZ3V1VTl5+f7q qwsw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=P717LorGeXb892L2rPZftLo69BBrecynggE4xn2hmr0=; b=UZmZXECaw1dMAXRW+L6Url+6Y460+4Awa/iyi8Z8cP6hcBaaTfXzn8bdeBUKMZOC72 2x++vnQ4DNa/1t2XOueZhr0RXVW/UigPDQGLSEbgjrS43mImsqHsfAMAMkIP39FriQKJ 8Y3lZBHyPSk0OpiR82t99c9JtH8KBUbqDsxQ0hTTN2C7QsEAoFpWQcv2fxWWwCz16/ZQ 2n11o7jT0XtjXa+YNZHd1tF1IMoy3nzaY8x7NHJQEdxE+s++ktHrAdxO8Y4IWvwA9Qla rbf5269HsPXPu6txi8KzEP7iwdbV+wPiINrJYefBfEevfzI37yqr51fbj0Na4xIrh8sl BW+w== X-Gm-Message-State: ANhLgQ3UDVrvfysYdGzjh4exZchRHdMwCmkzpvZoPGrYbdDMSsMHN5WB qf8dwHlauDEJDLa3A/1EwyWsATj5JnOe+Q== X-Google-Smtp-Source: ADFU+vuS1DVLUB7gaYFecguqL6bB913zJn/KrOk9izmSV4Ljjbzn7E8FsoyvzXYGTBR//v1RcVzs1A== X-Received: by 2002:a1c:4c1a:: with SMTP id z26mr422398wmf.11.1584985213048; Mon, 23 Mar 2020 10:40:13 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 3/5] target/arm: Rearrange disabled check for watchpoints Date: Mon, 23 Mar 2020 17:40:04 +0000 Message-Id: <20200323174006.8468-4-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200323174006.8468-1-peter.maydell@linaro.org> References: <20200323174006.8468-1-peter.maydell@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: 2a00:1450:4864:20::344 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) From: Richard Henderson Coverity rightly notes that ctz32(bas) on 0 will return 32, which makes the len calculation a BAD_SHIFT. A value of 0 in DBGWCR_EL1.BAS is reserved. Simply move the existing check we have for this case. Reported-by: Coverity (CID 1421964) Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-id: 20200320160622.8040-2-richard.henderson@linaro.org Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- target/arm/helper.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/target/arm/helper.c b/target/arm/helper.c index d2ec2c53510..b7b6887241d 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -6340,17 +6340,18 @@ void hw_watchpoint_update(ARMCPU *cpu, int n) int bas =3D extract64(wcr, 5, 8); int basstart; =20 - if (bas =3D=3D 0) { - /* This must act as if the watchpoint is disabled */ - return; - } - if (extract64(wvr, 2, 1)) { /* Deprecated case of an only 4-aligned address. BAS[7:4] are * ignored, and BAS[3:0] define which bytes to watch. */ bas &=3D 0xf; } + + if (bas =3D=3D 0) { + /* This must act as if the watchpoint is disabled */ + return; + } + /* The BAS bits are supposed to be programmed to indicate a contig= uous * range of bytes. Otherwise it is CONSTRAINED UNPREDICTABLE wheth= er * we fire for each byte in the word/doubleword addressed by the W= VR. --=20 2.20.1