From nobody Tue Nov 26 12:25:19 2024 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=1707909672; cv=none; d=zohomail.com; s=zohoarc; b=dWDrlIrwSXMbonICMcER+cNoXoruOHY5d/J2XD89s08c7NlqZJLdhszBIueCoZYSqt++ddHhCVmhTeVl5B+120h7NC5eJyAZ2YV5UrpsPMRcDi9tHfibyQ4UeNIwEGKOg8+AVV+ta0KfOAxO3nGi4pn7RT2itpbMmslUyQlLgag= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1707909672; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=/2s6lqYMeUV26bl5P/Tb03gTeEl6FUUCG2Fkw3zLptU=; b=kQKIDexfrBIRry06N4+1ZKn/o9jamvSGmFt6lit2GcDr4HAwyaqBZOqK9Q2b3E8GIr3H+mnW5PDULUQNTcxJg9fQHzY7Vf/dhDZvbOfUYq54A9iS327FNFegpn9dshMIcILDhz7rWGyXZasJ/Eq163AbpkJfaqJ77hYOiEylfZw= 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 1707909672421135.70671608734222; Wed, 14 Feb 2024 03:21:12 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1raDFD-0005GP-Py; Wed, 14 Feb 2024 06:16:04 -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 1raDEg-0004BF-An for qemu-devel@nongnu.org; Wed, 14 Feb 2024 06:15:33 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1raDEe-0007Et-MV for qemu-devel@nongnu.org; Wed, 14 Feb 2024 06:15:30 -0500 Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-327-k1Ih44GXOB-bYZ2UjcLdYQ-1; Wed, 14 Feb 2024 06:15:26 -0500 Received: by mail-ej1-f70.google.com with SMTP id a640c23a62f3a-a3d4cfc543fso24535566b.2 for ; Wed, 14 Feb 2024 03:15:26 -0800 (PST) Received: from redhat.com ([2.52.26.67]) by smtp.gmail.com with ESMTPSA id d20-20020a1709064c5400b00a3c598d6b74sm2212621ejw.54.2024.02.14.03.15.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 03:15:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1707909328; 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=/2s6lqYMeUV26bl5P/Tb03gTeEl6FUUCG2Fkw3zLptU=; b=Oab3fYzCqQnYKh4EtL5CQJEpharT/DRwwkjiCAogS7l7hlztTLmAi+f0V9vsRilEpoLHgy SYg2l1OcOcSxp4C3lVpdvHu6aDb0cSfGBke84f0OUFafsthSYff0Wu4K6rGZms6/Bk/Z7X VMAlUVG5vhbAQv9k2/TXNo3yvCdIHfs= X-MC-Unique: k1Ih44GXOB-bYZ2UjcLdYQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707909325; x=1708514125; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=/2s6lqYMeUV26bl5P/Tb03gTeEl6FUUCG2Fkw3zLptU=; b=srgHPzSDbgSLOSuLaPLqpiCJIMsNqXjozQitVlQkZiuRFoKsw77jrKaDo3cJowXynd QUTBFh7fHhKXyLgrqmmJNsSxFdo7rX7eEhiwwY+oQKtaULMOx3PNO5DbxqIwlqCvhaRh uX9RErzWT/GSyHL5gOGq0da/yqOiZvaV2CdTIEgJt5Nx2rqAIOECpWEoV0I06ssLckMq Jb3GjByirsNEdLSg98Df1pPCOT/EP/tTwSjgKp21UbTdK1oG37qz6So0CWFn8nBGHHIk pNX0wQGZy2uy6Kiq5P4csOUZ2ZW09YLA3afWlyM21fM8eWmgCbrA01wnKRTnDWxPfuOR C+ZQ== X-Gm-Message-State: AOJu0Yw5vt+kjrUa9k3BXSFQcIq7vfVFuA+fByuhLmjTTMyjbEbMy2vQ rYmpB+v2G9Ly2cwEuOQlVprh3qBuUI0YJrEdQqBf7Pm6qQkdtOmTbzLCa0izRv/g6bxkgczciu0 xbEnn0gxhi1qV7KFVbOHPvKI8+llqjAXgaYlOIsC02Ui/zsY8CEZ1FQmBKoSPGRb/+V/9vdczzO 5hX9GY8TTUNH6eoAQzdnbZ9ZO2rgQO4w== X-Received: by 2002:a17:906:395:b0:a3d:6a0b:5bf0 with SMTP id b21-20020a170906039500b00a3d6a0b5bf0mr21769eja.63.1707909324990; Wed, 14 Feb 2024 03:15:24 -0800 (PST) X-Google-Smtp-Source: AGHT+IEHiSpQ4mN/0FBoiB+JLxMHGoDiBgllu+o+cXzcDQ2WFpm11bWh7Vi843TAF3hGxz08Y3Egfg== X-Received: by 2002:a17:906:395:b0:a3d:6a0b:5bf0 with SMTP id b21-20020a170906039500b00a3d6a0b5bf0mr21748eja.63.1707909324709; Wed, 14 Feb 2024 03:15:24 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCXCzDaXBDA5RBi4ZChqZjr8oY05sR7JSAaUPHISUk+BH2cnub0GJ9rz4OYDdNwcW3OPM0QBqBRCVjGoka09boS+BfLVvkoRbrbiJGjVUAZ5Z7O1dG3BjQA+pUuuZcp/nsrr+zVpLRPdgIoj+5S6sQk3e8+fUhy3wd0WjwHy++aALl5FtGq0SigzAh+USs/UOJjYFBaxUmJ1xMWDsUqcxvUgWHuKrl7A Date: Wed, 14 Feb 2024 06:15:20 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Ira Weiny , Huai-Cheng Kuo , Dave Jiang , Fan Ni , Jonathan Cameron Subject: [PULL 40/60] cxl/cdat: Fix header sum value in CDAT checksum Message-ID: <64fdad5e67587e88c2f1d8f294e89403856a4a31.1707909001.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: 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.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.504, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, 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-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1707909674589100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Ira Weiny 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-b148b40707= d7@intel.com/ Fixes: aba578bdace5 ("hw/cxl/cdat: CXL CDAT Data Object Exchange implementa= tion") Cc: Huai-Cheng Kuo Signed-off-by: Ira Weiny Reviewed-by: Dave Jiang Reviewed-by: Fan Ni Signed-off-by: Jonathan Cameron Message-Id: <20240126120132.24248-5-Jonathan.Cameron@huawei.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/cxl/cxl-cdat.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/hw/cxl/cxl-cdat.c b/hw/cxl/cxl-cdat.c index 24829cf242..2fea975671 100644 --- a/hw/cxl/cxl-cdat.c +++ b/hw/cxl/cxl-cdat.c @@ -49,6 +49,7 @@ static void ct3_build_cdat(CDATObject *cdat, Error **errp) g_autofree CDATTableHeader *cdat_header =3D NULL; g_autofree CDATEntry *cdat_st =3D NULL; uint8_t sum =3D 0; + uint8_t *hdr_buf; int ent, i; =20 /* Use default table if fopen =3D=3D NULL */ @@ -95,8 +96,12 @@ static void ct3_build_cdat(CDATObject *cdat, Error **err= p) /* For now, no runtime updates */ cdat_header->sequence =3D 0; cdat_header->length +=3D sizeof(CDATTableHeader); - sum +=3D cdat_header->revision + cdat_header->sequence + - cdat_header->length; + + hdr_buf =3D (uint8_t *)cdat_header; + for (i =3D 0; i < sizeof(*cdat_header); i++) { + sum +=3D hdr_buf[i]; + } + /* Sum of all bytes including checksum must be 0 */ cdat_header->checksum =3D ~sum + 1; =20 --=20 MST