From nobody Mon Feb 9 09:33:25 2026 Delivered-To: importer@patchew.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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1660767334; cv=none; d=zohomail.com; s=zohoarc; b=CUFmEMFfVQsF1H3aD4FeBiZA8CUyGV46XA+C2moFpntVT0DeTREgN89pu7vRu/mTDnMuGv4VKZUExsFEOkCZ4Ao1i761rlDANs3Ag4zDhfji2fHQBnMl+MB/DK2zr4JRHvXAht1phtvF17zR3m9z+5ZPuq7iscT7ax1qc6qu2c8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1660767334; h=Content-Type:Cc: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=nWQVRRhfHKdS6zw8hDv8H7vDo6NdB5TZvkd9lopLAgA=; b=ImbCwfGsqGBskqRyLNNz65MD7edb7PwuixkjR3rTlntq0i1AENKsXx7/4hLwzNm9KPUYSXnEpp5QZue+RWHd0pmWygAIFmzJOX8FxUYEwpzW1mRYz8LH0R5sOgC5IFuqqo8VRBzz7eXBpnLh0ZuGOXc/eOqBqvbbo4ntM7q668E= 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) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1660767334316775.3524298088483; Wed, 17 Aug 2022 13:15:34 -0700 (PDT) Received: from localhost ([::1]:44422 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oOPRs-00010x-O1 for importer@patchew.org; Wed, 17 Aug 2022 16:15:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60170) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oOPJu-0004xW-B6 for qemu-devel@nongnu.org; Wed, 17 Aug 2022 16:07:18 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:24182) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oOPJs-0000V3-Ke for qemu-devel@nongnu.org; Wed, 17 Aug 2022 16:07:17 -0400 Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-456-XgS5EuIkOqG2RoxaaBFjlA-1; Wed, 17 Aug 2022 16:06:18 -0400 Received: by mail-wm1-f70.google.com with SMTP id b4-20020a05600c4e0400b003a5a96f1756so1563004wmq.0 for ; Wed, 17 Aug 2022 13:06:18 -0700 (PDT) Received: from redhat.com ([2.55.4.37]) by smtp.gmail.com with ESMTPSA id p6-20020a05600c05c600b003a604a29a34sm2713392wmd.35.2022.08.17.13.06.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Aug 2022 13:06:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1660766836; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=nWQVRRhfHKdS6zw8hDv8H7vDo6NdB5TZvkd9lopLAgA=; b=QNF5K9fewWniNuopJnfQITZwfMLy82JFNwH383MMS6MjkjNjTX4tqZshYNk1eTr3blVX5A 7ZPGQeyyIGEhMTdYiOwPHyB6lWnWIygfwxw4WsQy0954hUFJ64gWPOSu8aamJLqaByXIoe 2+mpHaEZ0qZLZN48NMwtsPY6agPANsw= X-MC-Unique: XgS5EuIkOqG2RoxaaBFjlA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc; bh=nWQVRRhfHKdS6zw8hDv8H7vDo6NdB5TZvkd9lopLAgA=; b=7IVB5s3PAcEWfxXlUM5CHYJbV0G1Rrj4XL6ZzuZ8CIQfa1RsrqZRUBTh78RX+g+8hO uWVc6Co4kLlpF4bQfXwBy2r+grTyxHNTPaHP72BW4HWFWOreA081rUlZsssacnS94tdM KPeV48MGQKwipe+b6MX2IjePE7M+0Kn3brDRr1tY1t4nrvIozr/YGL1zAO8YZoUh0DNW ZDGbSsbstAwwvcjeyVnt8EC14rSSQ/CnASdBe/1BTHEnoPhQgrgeFqEzDYd+H64ENCqV b5KjzpGdBAUIlGtDNcR52JniYW3tWWGgaevP0G/p7ExC2i7qdTGK2Rc5a7vka0Ml6MjJ 2ZCQ== X-Gm-Message-State: ACgBeo0QeQW9ynHiTOdOEHZnLOnOv9X2sgqhe2aP+K5+QhXiNu19dJJa l8CtBxyDBz/Of7+pWq7qkBfP6rrFqh4oazItt06RbKF4Rk7D2f8mcGaUEMpg7yWaNgqM9iZMMxD Rosv8Nw58AZJfbf+Kk7qXdjkwGyRawuOeQjQcNl536jModzS5q7OXbiqtf1g9 X-Received: by 2002:adf:edc6:0:b0:224:f767:31ae with SMTP id v6-20020adfedc6000000b00224f76731aemr11630479wro.433.1660766777354; Wed, 17 Aug 2022 13:06:17 -0700 (PDT) X-Google-Smtp-Source: AA6agR4VnM+aT9P8WjIz6X+gXyHhhk8kf9SEJuku/ndTC/6PdOI+QVFEevF0XfPijKqLvl+e+Yy1gQ== X-Received: by 2002:adf:edc6:0:b0:224:f767:31ae with SMTP id v6-20020adfedc6000000b00224f76731aemr11630462wro.433.1660766777044; Wed, 17 Aug 2022 13:06:17 -0700 (PDT) Date: Wed, 17 Aug 2022 16:06:13 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Jonathan Cameron , Ben Widawsky Subject: [PULL 07/12] hw/cxl: Fix wrong query of target ports Message-ID: <20220817200536.350795-8-mst@redhat.com> References: <20220817200536.350795-1-mst@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20220817200536.350795-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent 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; Received-SPF: pass client-ip=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1660767336303100002 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Jonathan Cameron Two issues were present in this code: 1) Check on which register to look in was inverted. 2) Both branches use the _LO register. Whilst here moved to extract32() rather than hand rolling the field extraction as simpler and hopefully less error prone. Fixes Coverity CID: 1488873 Reported-by: Peter Maydell Signed-off-by: Jonathan Cameron Message-Id: <20220808122051.14822-3-Jonathan.Cameron@huawei.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/cxl/cxl-host.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/hw/cxl/cxl-host.c b/hw/cxl/cxl-host.c index faa68ef038..1adf61231a 100644 --- a/hw/cxl/cxl-host.c +++ b/hw/cxl/cxl-host.c @@ -104,7 +104,6 @@ static bool cxl_hdm_find_target(uint32_t *cache_mem, hw= addr addr, uint32_t ctrl; uint32_t ig_enc; uint32_t iw_enc; - uint32_t target_reg; uint32_t target_idx; =20 ctrl =3D cache_mem[R_CXL_HDM_DECODER0_CTRL]; @@ -116,14 +115,13 @@ static bool cxl_hdm_find_target(uint32_t *cache_mem, = hwaddr addr, iw_enc =3D FIELD_EX32(ctrl, CXL_HDM_DECODER0_CTRL, IW); target_idx =3D (addr / cxl_decode_ig(ig_enc)) % (1 << iw_enc); =20 - if (target_idx > 4) { - target_reg =3D cache_mem[R_CXL_HDM_DECODER0_TARGET_LIST_LO]; - target_reg >>=3D target_idx * 8; + if (target_idx < 4) { + *target =3D extract32(cache_mem[R_CXL_HDM_DECODER0_TARGET_LIST_LO], + target_idx * 8, 8); } else { - target_reg =3D cache_mem[R_CXL_HDM_DECODER0_TARGET_LIST_LO]; - target_reg >>=3D (target_idx - 4) * 8; + *target =3D extract32(cache_mem[R_CXL_HDM_DECODER0_TARGET_LIST_HI], + (target_idx - 4) * 8, 8); } - *target =3D target_reg & 0xff; =20 return true; } --=20 MST