Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp652421pxb; Tue, 5 Apr 2022 17:23:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxWQz+bjIR0iXNbaTFVnNOlU5ItABmCG1IJCrec80RBrWpiiASDzeyr8qhUkJX//rA2bVHi X-Received: by 2002:a17:907:3e16:b0:6df:b4f0:5cc2 with SMTP id hp22-20020a1709073e1600b006dfb4f05cc2mr5975792ejc.285.1649204503531; Tue, 05 Apr 2022 17:21:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649204503; cv=none; d=google.com; s=arc-20160816; b=I2cSSvdIOuevK/8MnpYOM2q/EaS1UzW0HQ0G7G+YRc/UdaAj3jXmWnf0DAGqtwGm7m dh1BsjW8dN4F6hi8810Bakfr4Bvl4wHDhRFI1wW78Id1v0RUR2fyqxcY39bNd9XQlmTo GPfu6MfknOZSmBLBsQ3fyDRK8ykJ5lft6WBlQMN2M37ufQmXVc6CafJlejmQ0zf9YFgR bEjvaNfWYihOXkhG5C0+MTei/ew9//QqksZZkHEuFaVH1q7jlUA9/nYFKsBuHCcnP8u+ czjNJwKx1SRpXW4kOkeuvZJcYAQtGf9xIG5YPRJ9p0FKrj8aqDtyz0XfHWxn/3vSPvc3 vXsg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=RsZTUY8CeHhtq43Rxpd1Es2G8F0qc5j/xrcoN1fDBy0=; b=tp+T7pyWUywUhh7nRu9buGr3OPQjEdlhg/ClrzKwRdK1HjXoBabDS6GXXUjOH2BH5r gPcCrprc3cJvxZfMBYX8zKaFLnpBFIkhrEnXye4u6uYUkOvChnMvHV7KfVbUnvRog4vB AveU1nbJHaeByI5q+un8MEr2aqHvbJ8Clxg+m2R0Ijiit+wD28cfBPH5/k0uYiZzZFvh p17BYKieXRLz/QTMJZAxIEyU2jilJOSoWyF2bZVW0Jjppzkbqlgdbv+hMJSc/zdQ9ma1 Awz8zH8L+5vNVma0Y2VFvO3Jv3M7n3Gl4iiEPW9euhfHwDzpXZhl5or90W2iQQaTJ1WA gKeQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=s0GuW3v2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s18-20020a170906501200b006e7f908e9d6si4552781ejj.615.2022.04.05.17.21.11; Tue, 05 Apr 2022 17:21:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=s0GuW3v2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1385395AbiDEMc4 (ORCPT + 99 others); Tue, 5 Apr 2022 08:32:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52796 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236233AbiDEJAO (ORCPT ); Tue, 5 Apr 2022 05:00:14 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D8802275C4; Tue, 5 Apr 2022 01:53:35 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 87711B81A0C; Tue, 5 Apr 2022 08:53:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D3046C385A0; Tue, 5 Apr 2022 08:53:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649148813; bh=4GVNTj2YOOxt86du6z4LnhR8s7JceT8i+SaFiQdlXpA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=s0GuW3v2QaRwBWJ9JEQ/SKueWhWsBxUbQUdYuH0aNcDF/5YLgzfs2Z0Bhinfuqc2b s6CNylSOlETRwvP32CPlP3M8Gpdd/EciXEh0ECUSpH145RZv4lH8+jMdZqThZj+Kmn twW6fAQCsK4dJoIhaRxJHDFtldqLdBXIX+bVKwpg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jonathan Cameron , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Ben Widawsky , Dan Williams , Sasha Levin Subject: [PATCH 5.16 0490/1017] cxl/regs: Fix size of CXL Capability Header Register Date: Tue, 5 Apr 2022 09:23:23 +0200 Message-Id: <20220405070408.843606996@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070354.155796697@linuxfoundation.org> References: <20220405070354.155796697@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,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 From: Jonathan Cameron [ Upstream commit 74b0fe80409733055971bbfaf33c80a33fddeeb3 ] In CXL 2.0, 8.2.5.1 CXL Capability Header Register: this register is given as 32 bits. 8.2.3 which covers the CXL 2.0 Component registers, including the CXL Capability Header Register states that access restrictions specified in Section 8.2.2 apply. 8.2.2 includes: * A 32 bit register shall be accessed as a 4 Byte quantity. ... If these rules are not followed, the behavior is undefined. Discovered during review of CXL QEMU emulation. Alex Bennée pointed out there was a comment saying that 4 byte registers must be read with a 4 byte read, but 8 byte reads were being emulated. https://lore.kernel.org/qemu-devel/87bkzyd3c7.fsf@linaro.org/ Fixing that, led to this code failing. Whilst a given hardware implementation 'might' work with an 8 byte read, it should not be relied upon. The QEMU emulation v5 will return 0 and log the wrong access width. The code moved, so one fixes tag for where this will directly apply and also a reference to the earlier introduction of the code for backports. Fixes: 0f06157e0135 ("cxl/core: Move register mapping infrastructure") Fixes: 08422378c4ad ("cxl/pci: Add HDM decoder capabilities") Signed-off-by: Jonathan Cameron Cc: Alex Bennée Reviewed-by: Ben Widawsky Link: https://lore.kernel.org/r/20220201153437.2873-1-Jonathan.Cameron@huawei.com Signed-off-by: Dan Williams Signed-off-by: Sasha Levin --- drivers/cxl/core/regs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/cxl/core/regs.c b/drivers/cxl/core/regs.c index b8aa583a7642..2e7027a3fef3 100644 --- a/drivers/cxl/core/regs.c +++ b/drivers/cxl/core/regs.c @@ -35,7 +35,7 @@ void cxl_probe_component_regs(struct device *dev, void __iomem *base, struct cxl_component_reg_map *map) { int cap, cap_count; - u64 cap_array; + u32 cap_array; *map = (struct cxl_component_reg_map) { 0 }; @@ -45,7 +45,7 @@ void cxl_probe_component_regs(struct device *dev, void __iomem *base, */ base += CXL_CM_OFFSET; - cap_array = readq(base + CXL_CM_CAP_HDR_OFFSET); + cap_array = readl(base + CXL_CM_CAP_HDR_OFFSET); if (FIELD_GET(CXL_CM_CAP_HDR_ID_MASK, cap_array) != CM_CAP_HDR_CAP_ID) { dev_err(dev, -- 2.34.1