Received: by 2002:a05:7412:b130:b0:e2:908c:2ebd with SMTP id az48csp909907rdb; Fri, 17 Nov 2023 17:14:43 -0800 (PST) X-Google-Smtp-Source: AGHT+IFIbnqJg9b3idU+W1GcUsGomu4fYNKAHqAT8SYJlC330gQrTH1OLaskRWkGnHigBYcsX3G5 X-Received: by 2002:a05:6808:128d:b0:3b5:37c6:6dcb with SMTP id a13-20020a056808128d00b003b537c66dcbmr1538378oiw.21.1700270083518; Fri, 17 Nov 2023 17:14:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700270083; cv=none; d=google.com; s=arc-20160816; b=Z/CZZb/FQtijIr6Gkn+fCKW00J3i3ZANuUNEJIEzd4qE0FHe6DnQPg+hmV8HmWE14W 7j4B74IbVx+IpvJkWVxMMd7OdH8hmIKBviIcy2XCCkKJ9P9RmhXJUsnrw9yBMhGkLt8y QdAL3vvCz44ywao/LfKwkOynI5J/nLi59xXojmGgSS8/qpbjvQyTiYYA81mMkzkz9FMN 0F8a8ibFPGA6dTpWXhjlVRF0SoXjEsPrSNJZkuyy2Qv6Isb6Wbk1K1fvhxtmQNGnrIf4 VPJmi+rlHFB1oA3Bph20fyOztKetyCcKJyrxxBKeiI7Tzh6YmqVrye6zhyPU6oF7ycO6 pkBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=Q6xCC07oZ+T+o8DRW0SnQandj30KOMt2Z6Zo4VPRT1Y=; fh=6sXSOTQ6/qs+hWC19t6eM8N4NOFX3L8BU/9i2yXjIN0=; b=YsMdxCmbHp4w9YwjgM6nraj5twvsMxzygG0GsCPr4xfDyf8ndwMMbkeC17FZFTxFyB vwbtWiDHzwNe66+uqY7yCy9geElxl3NztcSuui9nk2KHEbIj27p4VN9zQ4JNse/O3GR+ lzdVuLQR5z3P+/WgqHwysvYIJ7cld0D6GlrQHYRr1l/KacqtIFqOKt8J2AzkhMsbRCeI U+sQrBZDIaMxYm+mTc4avNGcFJwsXUUhWtDjVBXifL5fyDGJ3PHRFm+u1/a49kNcXxUn bZdplqngbp5RYl0lKyhk7nm/5zIT42tFrrENGdmEER3Uk9WGFrNk//N986mDQQvC1Cdm 0hTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=gFzeXnYt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id t10-20020a056a0021ca00b006c0fef93179si3297390pfj.223.2023.11.17.17.14.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Nov 2023 17:14:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=gFzeXnYt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 6363E80408DF; Fri, 17 Nov 2023 17:14:42 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346415AbjKRBOi (ORCPT + 99 others); Fri, 17 Nov 2023 20:14:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35930 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232799AbjKRBOg (ORCPT ); Fri, 17 Nov 2023 20:14:36 -0500 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.120]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1FCC310C6; Fri, 17 Nov 2023 17:14:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1700270073; x=1731806073; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=KY6Trv4Z4Ss7v75GlFvhDLJZq876VbvgUNG6vb3DWIM=; b=gFzeXnYtXbjujeTjB6gX5FivL0L7eIpuJZvHETJsDJeP7zA/40WyKDCV hndJP5ouy1wCCL20QRpv1cdkqU6vTGzrp1w15sExF0ehs6YURAvbdXGTE Sxvi8FTparggQCslUevKnOpOdLS+0Xlwd/tIg0qqd3x8u7MtLLWH/DNpI +wzfyX2Iv8Pfxk1dprR2nIKXO9gsvyIKDQPY3Zj7syqK0TgqFKY8DH4RF fH/mC5KmnfTkTdgfGdZ+eLeXm7COXKc5Qcw9WMJ7J4KwQ7/Entiv5d93K 1VfkECdcs1d9GkhOMXq/lA8kG3xrh5uGRfiuY8wXcueLXIUhI0YCMHwgI g==; X-IronPort-AV: E=McAfee;i="6600,9927,10897"; a="390256200" X-IronPort-AV: E=Sophos;i="6.04,206,1695711600"; d="scan'208";a="390256200" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Nov 2023 17:14:32 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10897"; a="889406632" X-IronPort-AV: E=Sophos;i="6.04,206,1695711600"; d="scan'208";a="889406632" Received: from iweiny-mobl.amr.corp.intel.com (HELO localhost) ([10.213.174.178]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Nov 2023 17:14:32 -0800 From: Ira Weiny Date: Fri, 17 Nov 2023 17:14:22 -0800 Subject: [PATCH 2/2] cxl/cdat: Fix header sum value in CDAT checksum MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20231117-fix-cdat-cs-v1-2-ffc2b116ca6c@intel.com> References: <20231117-fix-cdat-cs-v1-0-ffc2b116ca6c@intel.com> In-Reply-To: <20231117-fix-cdat-cs-v1-0-ffc2b116ca6c@intel.com> To: Jonathan Cameron , Fan Ni Cc: linux-cxl@vger.kernel.org, linux-kernel@vger.kernel.org, Ira Weiny X-Mailer: b4 0.13-dev-c6835 X-Developer-Signature: v=1; a=ed25519-sha256; t=1700270069; l=1439; i=ira.weiny@intel.com; s=20221211; h=from:subject:message-id; bh=KY6Trv4Z4Ss7v75GlFvhDLJZq876VbvgUNG6vb3DWIM=; b=jqARDpOM2gS8EEBlFN8o2CMOCfoDHYZeJn8FlrS/jOBezFk9NeTm3Ih2OGwCpc9eqw4o6Ot6H sFV4Ip8Qwq5DcoH5VG9rx9ZA6g71CcZmoBxyXb7bMpnPabn40NVNd1X X-Developer-Key: i=ira.weiny@intel.com; a=ed25519; pk=noldbkG+Wp1qXRrrkfY1QJpDf7QsOEthbOT7vm0PqsE= X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Fri, 17 Nov 2023 17:14:42 -0800 (PST) The addition of the DCD support for CXL type-3 devices extended the CDAT table large enough that the checksum being returned was incorrect.[1] This was because the checksum value was using the header length field rather than each of the 4 bytes of the length field. This was previously not seen because the length of the CDAT data was less than 256 thus resulting in an equivalent checksum value. Properly calculate the checksum for the CDAT header. [1] https://lore.kernel.org/all/20231116-fix-cdat-devm-free-v1-1-b148b40707d7@intel.com/ Signed-off-by: Ira Weiny --- hw/cxl/cxl-cdat.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/hw/cxl/cxl-cdat.c b/hw/cxl/cxl-cdat.c index 24829cf2428d..d93e2e4e64f2 100644 --- a/hw/cxl/cxl-cdat.c +++ b/hw/cxl/cxl-cdat.c @@ -95,8 +95,15 @@ static void ct3_build_cdat(CDATObject *cdat, Error **errp) /* For now, no runtime updates */ cdat_header->sequence = 0; cdat_header->length += sizeof(CDATTableHeader); - sum += cdat_header->revision + cdat_header->sequence + - cdat_header->length; + + do { + uint8_t *buf = (uint8_t *)cdat_header; + + for (i = 0; i < sizeof(*cdat_header); i++) { + sum += buf[i]; + } + } while (0); + /* Sum of all bytes including checksum must be 0 */ cdat_header->checksum = ~sum + 1; -- 2.41.0