From nobody Fri May 3 22:51:32 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1660748382; cv=none; d=zohomail.com; s=zohoarc; b=QEJgffkMTUGe7IIWYJhdJGvt2zyXaysac/1C/aoTGndKf+vsBzawdpKCQVBLwZ1EvASFuAPTvQDEFmfbHyL6eVGxswyX4CFuVW1H4wVI7IofDTcU+DRu+IAhHmv8Kny9n5CSiWbwIRWtWLH1NMMJI5MXihdDyZ50JD6kx/8k1b4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1660748382; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=pFNRoyvWQFryE2iIdclrADWzwW6LLHRcsZm1U/BvIOE=; b=nKqwVPV672bK2uYz+xMtGp9aPdOMkBknB2A8ks84meI7RWpUW5pDoBQfdMuCss7xJrMUrqkz5OlOE11PYB/Lqy0XlD6hkXoiJTnWVVaaK0pZhiO20VFAd4ocCgKi6qGZjZ4kDHxmB94AW76xFTWNwftZKDwQyqEErfO20jFzI8c= ARC-Authentication-Results: i=1; mx.zohomail.com; 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 1660748382236872.6421409846498; Wed, 17 Aug 2022 07:59:42 -0700 (PDT) Received: from localhost ([::1]:40242 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oOKWC-0001ye-8z for importer@patchew.org; Wed, 17 Aug 2022 10:59:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36740) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oOKV9-0000d4-6O for qemu-devel@nongnu.org; Wed, 17 Aug 2022 10:58:35 -0400 Received: from frasgout.his.huawei.com ([185.176.79.56]:2680) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oOKV7-0000mP-Iz for qemu-devel@nongnu.org; Wed, 17 Aug 2022 10:58:34 -0400 Received: from fraeml709-chm.china.huawei.com (unknown [172.18.147.226]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4M7B3G11lSz67bZ4; Wed, 17 Aug 2022 22:58:18 +0800 (CST) Received: from lhrpeml500005.china.huawei.com (7.191.163.240) by fraeml709-chm.china.huawei.com (10.206.15.37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Wed, 17 Aug 2022 16:58:31 +0200 Received: from SecurePC-101-06.china.huawei.com (10.122.247.231) by lhrpeml500005.china.huawei.com (7.191.163.240) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Wed, 17 Aug 2022 15:58:31 +0100 To: , "Michael S . Tsirkin" , "Peter Maydell" , Igor Mammedov CC: , , "Shameerali Kolothum Thodi" , Ben Widawsky , Paolo Bonzini Subject: [PATCH 1/3] hw/cxl: Add stub write function for RO MemoryRegionOps entries. Date: Wed, 17 Aug 2022 15:57:57 +0100 Message-ID: <20220817145759.32603-2-Jonathan.Cameron@huawei.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220817145759.32603-1-Jonathan.Cameron@huawei.com> References: <20220817145759.32603-1-Jonathan.Cameron@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.122.247.231] X-ClientProxiedBy: lhrpeml100002.china.huawei.com (7.191.160.241) To lhrpeml500005.china.huawei.com (7.191.163.240) X-CFilter-Loop: Reflected 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=185.176.79.56; envelope-from=jonathan.cameron@huawei.com; helo=frasgout.his.huawei.com X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, 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" Reply-to: Jonathan Cameron From: Jonathan Cameron via X-ZM-MESSAGEID: 1660748383459100001 Content-Type: text/plain; charset="utf-8" There is no checking on the availability of a write callback. Hence QEMU crashes if a write does occur to one of these regions. Discovered whilst chasing a Linux kernel bug that incorrectly wrote into one of these regions. Fixes: 6364adacdf ("hw/cxl/device: Implement the CAP array (8.2.8.1-2)") Reported-by: Bobo WL Signed-off-by: Jonathan Cameron --- hw/cxl/cxl-device-utils.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/hw/cxl/cxl-device-utils.c b/hw/cxl/cxl-device-utils.c index 687759b301..83ce7a8270 100644 --- a/hw/cxl/cxl-device-utils.c +++ b/hw/cxl/cxl-device-utils.c @@ -141,9 +141,15 @@ static uint64_t mdev_reg_read(void *opaque, hwaddr off= set, unsigned size) return retval; } =20 +static void ro_reg_write(void *opaque, hwaddr offset, uint64_t value, + unsigned size) +{ + /* Many register sets are read only */ +} + static const MemoryRegionOps mdev_ops =3D { .read =3D mdev_reg_read, - .write =3D NULL, /* memory device register is read only */ + .write =3D ro_reg_write, .endianness =3D DEVICE_LITTLE_ENDIAN, .valid =3D { .min_access_size =3D 1, @@ -173,7 +179,7 @@ static const MemoryRegionOps mailbox_ops =3D { =20 static const MemoryRegionOps dev_ops =3D { .read =3D dev_reg_read, - .write =3D NULL, /* status register is read only */ + .write =3D ro_reg_write, .endianness =3D DEVICE_LITTLE_ENDIAN, .valid =3D { .min_access_size =3D 1, @@ -188,7 +194,7 @@ static const MemoryRegionOps dev_ops =3D { =20 static const MemoryRegionOps caps_ops =3D { .read =3D caps_reg_read, - .write =3D NULL, /* caps registers are read only */ + .write =3D ro_reg_write, .endianness =3D DEVICE_LITTLE_ENDIAN, .valid =3D { .min_access_size =3D 1, --=20 2.32.0 From nobody Fri May 3 22:51:32 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1660748604; cv=none; d=zohomail.com; s=zohoarc; b=lTawQfCCQlXoq2Krw4bGpBlUnocdpUdSBp+iECXZgTmPnOSQ9Ic9x+EHx1/zUikwftA11ejFTjzYuUAoEM6eYV0wvwXai34bpQ0ascS66CJjl7Ac6OwRYG0GbFgbXuqDPRQRDKHNv4mv+fXZGEli6cyyla1PzPooZpP1ZuzKp7E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1660748604; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=dEsmWQafgoafbKaABW44+rAdgZL1zGA4DKbJKYY1y64=; b=Nvld5Qh3aJN5UHGPfJPkUaYsqpGZ2gf8D/i/18lZwuaAPdxWeMzhDKARfbhIYDztF4M4iY6H3jnvuSbW3YVFgtsev+eOX1f05k32Cg0R83Ms+LEzx7Up5uTIMX0ibPm9lsoCLQV2bMRf5HOry6Lv/kixaSSr47MNScaXILWAoG0= ARC-Authentication-Results: i=1; mx.zohomail.com; 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 1660748604635561.0761601328412; Wed, 17 Aug 2022 08:03:24 -0700 (PDT) Received: from localhost ([::1]:39208 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oOKZn-0005AB-Ef for importer@patchew.org; Wed, 17 Aug 2022 11:03:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36830) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oOKVe-0001jb-TT for qemu-devel@nongnu.org; Wed, 17 Aug 2022 10:59:06 -0400 Received: from frasgout.his.huawei.com ([185.176.79.56]:2681) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oOKVd-0000ti-C2 for qemu-devel@nongnu.org; Wed, 17 Aug 2022 10:59:06 -0400 Received: from fraeml705-chm.china.huawei.com (unknown [172.18.147.226]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4M7B3s0bgkz67PFb; Wed, 17 Aug 2022 22:58:49 +0800 (CST) Received: from lhrpeml500005.china.huawei.com (7.191.163.240) by fraeml705-chm.china.huawei.com (10.206.15.54) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2375.24; Wed, 17 Aug 2022 16:59:02 +0200 Received: from SecurePC-101-06.china.huawei.com (10.122.247.231) by lhrpeml500005.china.huawei.com (7.191.163.240) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Wed, 17 Aug 2022 15:59:01 +0100 To: , "Michael S . Tsirkin" , "Peter Maydell" , Igor Mammedov CC: , , "Shameerali Kolothum Thodi" , Ben Widawsky , Paolo Bonzini Subject: [PATCH 2/3] hw/cxl: Fix Get LSA input payload size which should be 8 bytes. Date: Wed, 17 Aug 2022 15:57:58 +0100 Message-ID: <20220817145759.32603-3-Jonathan.Cameron@huawei.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220817145759.32603-1-Jonathan.Cameron@huawei.com> References: <20220817145759.32603-1-Jonathan.Cameron@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.122.247.231] X-ClientProxiedBy: lhrpeml500003.china.huawei.com (7.191.162.67) To lhrpeml500005.china.huawei.com (7.191.163.240) X-CFilter-Loop: Reflected 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=185.176.79.56; envelope-from=jonathan.cameron@huawei.com; helo=frasgout.his.huawei.com X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, 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" Reply-to: Jonathan Cameron From: Jonathan Cameron via X-ZM-MESSAGEID: 1660748606560100001 Content-Type: text/plain; charset="utf-8" Get LSA needs 4 byte offset and 4 byte length arguments. CXL rev 2.0 Table 178. Fixes: 3ebe676a34 ("hw/cxl/device: Implement get/set Label Storage Area (LS= A)") Signed-off-by: Jonathan Cameron --- hw/cxl/cxl-mailbox-utils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/cxl/cxl-mailbox-utils.c b/hw/cxl/cxl-mailbox-utils.c index bb66c765a5..3cea8b17a8 100644 --- a/hw/cxl/cxl-mailbox-utils.c +++ b/hw/cxl/cxl-mailbox-utils.c @@ -406,7 +406,7 @@ static struct cxl_cmd cxl_cmd_set[256][256] =3D { cmd_identify_memory_device, 0, 0 }, [CCLS][GET_PARTITION_INFO] =3D { "CCLS_GET_PARTITION_INFO", cmd_ccls_get_partition_info, 0, 0 }, - [CCLS][GET_LSA] =3D { "CCLS_GET_LSA", cmd_ccls_get_lsa, 0, 0 }, + [CCLS][GET_LSA] =3D { "CCLS_GET_LSA", cmd_ccls_get_lsa, 8, 0 }, [CCLS][SET_LSA] =3D { "CCLS_SET_LSA", cmd_ccls_set_lsa, ~0, IMMEDIATE_CONFIG_CHANGE | IMMEDIATE_DATA_CHANGE }, }; --=20 2.32.0 From nobody Fri May 3 22:51:32 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1660748571; cv=none; d=zohomail.com; s=zohoarc; b=j/To+H4GnKvxbyuT+1fN0MAxgd9TXr34SuEGrbMbYXFr5EEWIhfclmzrwk0s1HJpCpqEoFPnbp/6K1OPgoviZhzdZ5xn7GII4QNG3BUwpyC7WKro7L2fl+dhecNKmszmyPgsOIlY9oYP+fdvSS44eH8Idiq9p8qa1Vjq+t2/0SU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1660748571; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=MFZhoYJvo56/ywJ6HT9CRO/7Fuf2Ur/V2Oux0Un+cho=; b=mCSAy5erT+qWgELvodQ8yDYFFm/7g6yaGCkdoajQd+o0Vmi4nGqP40KqIIiCcAXqZZFj+JAdm8C5W9CWSG6d73SVVJCVvQ1Vq25B+BAfWeZT/qd01PxQoWx3S3ldzciALITgAfiPxzL9Q7oZBzyLkmLaZi/ND5Tv0A1KU/ZYIso= ARC-Authentication-Results: i=1; mx.zohomail.com; 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 1660748571571136.85996941967142; Wed, 17 Aug 2022 08:02:51 -0700 (PDT) Received: from localhost ([::1]:56038 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oOKZF-00049J-9m for importer@patchew.org; Wed, 17 Aug 2022 11:02:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36914) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oOKW9-0002Rt-9p for qemu-devel@nongnu.org; Wed, 17 Aug 2022 10:59:37 -0400 Received: from frasgout.his.huawei.com ([185.176.79.56]:2682) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oOKW7-0000un-OW for qemu-devel@nongnu.org; Wed, 17 Aug 2022 10:59:37 -0400 Received: from fraeml701-chm.china.huawei.com (unknown [172.18.147.200]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4M79z30yLsz67MSg; Wed, 17 Aug 2022 22:54:39 +0800 (CST) Received: from lhrpeml500005.china.huawei.com (7.191.163.240) by fraeml701-chm.china.huawei.com (10.206.15.50) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2375.24; Wed, 17 Aug 2022 16:59:33 +0200 Received: from SecurePC-101-06.china.huawei.com (10.122.247.231) by lhrpeml500005.china.huawei.com (7.191.163.240) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Wed, 17 Aug 2022 15:59:32 +0100 To: , "Michael S . Tsirkin" , "Peter Maydell" , Igor Mammedov CC: , , "Shameerali Kolothum Thodi" , Ben Widawsky , Paolo Bonzini Subject: [PATCH 3/3] hw/cxl: Correctly handle variable sized mailbox input payloads. Date: Wed, 17 Aug 2022 15:57:59 +0100 Message-ID: <20220817145759.32603-4-Jonathan.Cameron@huawei.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220817145759.32603-1-Jonathan.Cameron@huawei.com> References: <20220817145759.32603-1-Jonathan.Cameron@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.122.247.231] X-ClientProxiedBy: lhrpeml100002.china.huawei.com (7.191.160.241) To lhrpeml500005.china.huawei.com (7.191.163.240) X-CFilter-Loop: Reflected 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=185.176.79.56; envelope-from=jonathan.cameron@huawei.com; helo=frasgout.his.huawei.com X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, 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" Reply-to: Jonathan Cameron From: Jonathan Cameron via X-ZM-MESSAGEID: 1660748573215100001 Content-Type: text/plain; charset="utf-8" A placeholder of ~0 is used to indicate variable payload size. Whilst the checks for output payload correctly took this into account, those for input payload did not. This results in failure of the Set LSA command. Fixes: 464e14ac43 ("hw/cxl/device: Implement basic mailbox (8.2.8.4)") Signed-off-by: Jonathan Cameron --- hw/cxl/cxl-mailbox-utils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/cxl/cxl-mailbox-utils.c b/hw/cxl/cxl-mailbox-utils.c index 3cea8b17a8..bc1bb18844 100644 --- a/hw/cxl/cxl-mailbox-utils.c +++ b/hw/cxl/cxl-mailbox-utils.c @@ -425,7 +425,7 @@ void cxl_process_mailbox(CXLDeviceState *cxl_dstate) cxl_cmd =3D &cxl_cmd_set[set][cmd]; h =3D cxl_cmd->handler; if (h) { - if (len =3D=3D cxl_cmd->in) { + if (len =3D=3D cxl_cmd->in || cxl_cmd->in =3D=3D ~0) { cxl_cmd->payload =3D cxl_dstate->mbox_reg_state + A_CXL_DEV_CMD_PAYLOAD; ret =3D (*h)(cxl_cmd, cxl_dstate, &len); --=20 2.32.0