From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CFC47C05027 for ; Fri, 20 Jan 2023 14:25:16 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pIsKB-0000X5-Ee; Fri, 20 Jan 2023 09:24:59 -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 1pIsK9-0000WQ-Ir for qemu-devel@nongnu.org; Fri, 20 Jan 2023 09:24:57 -0500 Received: from frasgout.his.huawei.com ([185.176.79.56]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pIsK6-0006aF-Nq for qemu-devel@nongnu.org; Fri, 20 Jan 2023 09:24:57 -0500 Received: from lhrpeml500005.china.huawei.com (unknown [172.18.147.200]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4Nz1r44bMyz67Qtq; Fri, 20 Jan 2023 22:20:52 +0800 (CST) 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.34; Fri, 20 Jan 2023 14:24:50 +0000 To: , Michael Tsirkin CC: Ben Widawsky , , , Ira Weiny , Dave Jiang , , Mike Maslenkin Subject: [PATCH v2 0/7] hw/cxl: RAS error emulation and injection Date: Fri, 20 Jan 2023 14:24:43 +0000 Message-ID: <20230120142450.16089-1-Jonathan.Cameron@huawei.com> X-Mailer: git-send-email 2.37.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.122.247.231] X-ClientProxiedBy: lhrpeml500006.china.huawei.com (7.191.161.198) To lhrpeml500005.china.huawei.com (7.191.163.240) X-CFilter-Loop: Reflected 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 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: , Reply-to: Jonathan Cameron From: Jonathan Cameron via Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org v2: Thanks to Mike Maslenkin for review. - Fix wrong parameter type to ct3d_qmp_cor_err_to_cxl() - Rework use of CXLError local variable in ct3d_reg_write() to improve code readability. CXL error reporting is complex. This series only covers the protocol related errors reported via PCIE AER - Ira Weiny has posted support for Event log based injection and I will post an update of Poison list injection shortly. My proposal is to upstream this one first, followed by Ira's Event Log series, then finally the Poison List handling. That is based on likely order of Linux kernel support (the support for this type of error reporting went in during the recent merge window, the others are still under review). Note we may propose other non error related features in between! The current revisions of all the error injection can be found at: https://gitlab.com/jic23/qemu/-/tree/cxl-2023-01-11 In order to test the kernel support for RAS error handling, I previously provided this series via gitlab, enabling David Jiang's kernel patches to be tested. Now that Linux kernel support is upstream, this series is proposing the support for upstream inclusion in QEMU. Note that support for Multiple Header Recording has been added to QEMU the meantime and a kernel patch to use that feature sent out. https://lore.kernel.org/linux-cxl/20230113154058.16227-1-Jonathan.Cameron@huawei.com/T/#t There are two generic PCI AER precursor feature additions. 1) The PCI_ERR_UCOR_MASK register has not been implemented until now and is necessary for correct emulation. 2) The routing for AER errors, via existing AER error injection, only covered one of two paths given in the PCIe base specification, unfortunately not the one used by the Linux kernel CXL support. The use of MSI for the CXL root ports, both makes sense from the point of view of how it may well be implemented, and works around the documented lack of PCI interrupt routing in i386/q35. I have a hack that lets us correctly route those interrupts but don't currently plan to post it. The actual CXL error injection uses a new QMP interface as documented in the final patch description. The existing AER error injection internals are reused though it's HMP interface is not. Injection via QMP: { "execute": "qmp_capabilities" } ... { "execute": "cxl-inject-uncorrectable-errors", "arguments": { "path": "/machine/peripheral/cxl-pmem0", "errors": [ { "type": "cache-address-parity", "header": [ 3, 4] }, { "type": "cache-data-parity", "header": [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31] }, { "type": "internal", "header": [ 1, 2, 4] } ] }} ... { "execute": "cxl-inject-correctable-error", "arguments": { "path": "/machine/peripheral/cxl-pmem0", "type": "physical", "header": [ 3, 4] } } Based on top of: https://lore.kernel.org/all/20230112102644.27830-1-Jonathan.Cameron@huawei.com/ [PATCH v2 0/8] hw/cxl: CXL emulation cleanups and minor fixes for upstream Jonathan Cameron (7): hw/pci/aer: Implement PCI_ERR_UNCOR_MASK register hw/pci/aer: Add missing routing for AER errors hw/pci-bridge/cxl_root_port: Wire up AER hw/pci-bridge/cxl_root_port: Wire up MSI hw/mem/cxl-type3: Add AER extended capability hw/pci/aer: Make PCIE AER error injection facility available for other emulation to use. hw/mem/cxl_type3: Add CXL RAS Error Injection Support. hw/cxl/cxl-component-utils.c | 4 +- hw/mem/cxl_type3.c | 303 +++++++++++++++++++++++++++++++++ hw/mem/cxl_type3_stubs.c | 10 ++ hw/mem/meson.build | 2 + hw/pci-bridge/cxl_root_port.c | 64 +++++++ hw/pci/pci-internal.h | 1 - hw/pci/pcie_aer.c | 14 +- include/hw/cxl/cxl_component.h | 26 +++ include/hw/cxl/cxl_device.h | 11 ++ include/hw/pci/pcie_aer.h | 1 + include/hw/pci/pcie_regs.h | 3 + qapi/cxl.json | 113 ++++++++++++ qapi/meson.build | 1 + qapi/qapi-schema.json | 1 + 14 files changed, 551 insertions(+), 3 deletions(-) create mode 100644 hw/mem/cxl_type3_stubs.c create mode 100644 qapi/cxl.json -- 2.37.2 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8E8A5C05027 for ; Fri, 20 Jan 2023 14:25:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230333AbjATOZf (ORCPT ); Fri, 20 Jan 2023 09:25:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55582 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231192AbjATOZe (ORCPT ); Fri, 20 Jan 2023 09:25:34 -0500 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A7567CD20A for ; Fri, 20 Jan 2023 06:25:12 -0800 (PST) Received: from lhrpeml500005.china.huawei.com (unknown [172.18.147.200]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4Nz1r44bMyz67Qtq; Fri, 20 Jan 2023 22:20:52 +0800 (CST) 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.34; Fri, 20 Jan 2023 14:24:50 +0000 From: Jonathan Cameron To: , Michael Tsirkin CC: Ben Widawsky , , , Ira Weiny , Dave Jiang , , Mike Maslenkin Subject: [PATCH v2 0/7] hw/cxl: RAS error emulation and injection Date: Fri, 20 Jan 2023 14:24:43 +0000 Message-ID: <20230120142450.16089-1-Jonathan.Cameron@huawei.com> X-Mailer: git-send-email 2.37.2 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.122.247.231] X-ClientProxiedBy: lhrpeml500006.china.huawei.com (7.191.161.198) To lhrpeml500005.china.huawei.com (7.191.163.240) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-cxl@vger.kernel.org v2: Thanks to Mike Maslenkin for review. - Fix wrong parameter type to ct3d_qmp_cor_err_to_cxl() - Rework use of CXLError local variable in ct3d_reg_write() to improve code readability. CXL error reporting is complex. This series only covers the protocol related errors reported via PCIE AER - Ira Weiny has posted support for Event log based injection and I will post an update of Poison list injection shortly. My proposal is to upstream this one first, followed by Ira's Event Log series, then finally the Poison List handling. That is based on likely order of Linux kernel support (the support for this type of error reporting went in during the recent merge window, the others are still under review). Note we may propose other non error related features in between! The current revisions of all the error injection can be found at: https://gitlab.com/jic23/qemu/-/tree/cxl-2023-01-11 In order to test the kernel support for RAS error handling, I previously provided this series via gitlab, enabling David Jiang's kernel patches to be tested. Now that Linux kernel support is upstream, this series is proposing the support for upstream inclusion in QEMU. Note that support for Multiple Header Recording has been added to QEMU the meantime and a kernel patch to use that feature sent out. https://lore.kernel.org/linux-cxl/20230113154058.16227-1-Jonathan.Cameron@huawei.com/T/#t There are two generic PCI AER precursor feature additions. 1) The PCI_ERR_UCOR_MASK register has not been implemented until now and is necessary for correct emulation. 2) The routing for AER errors, via existing AER error injection, only covered one of two paths given in the PCIe base specification, unfortunately not the one used by the Linux kernel CXL support. The use of MSI for the CXL root ports, both makes sense from the point of view of how it may well be implemented, and works around the documented lack of PCI interrupt routing in i386/q35. I have a hack that lets us correctly route those interrupts but don't currently plan to post it. The actual CXL error injection uses a new QMP interface as documented in the final patch description. The existing AER error injection internals are reused though it's HMP interface is not. Injection via QMP: { "execute": "qmp_capabilities" } ... { "execute": "cxl-inject-uncorrectable-errors", "arguments": { "path": "/machine/peripheral/cxl-pmem0", "errors": [ { "type": "cache-address-parity", "header": [ 3, 4] }, { "type": "cache-data-parity", "header": [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31] }, { "type": "internal", "header": [ 1, 2, 4] } ] }} ... { "execute": "cxl-inject-correctable-error", "arguments": { "path": "/machine/peripheral/cxl-pmem0", "type": "physical", "header": [ 3, 4] } } Based on top of: https://lore.kernel.org/all/20230112102644.27830-1-Jonathan.Cameron@huawei.com/ [PATCH v2 0/8] hw/cxl: CXL emulation cleanups and minor fixes for upstream Jonathan Cameron (7): hw/pci/aer: Implement PCI_ERR_UNCOR_MASK register hw/pci/aer: Add missing routing for AER errors hw/pci-bridge/cxl_root_port: Wire up AER hw/pci-bridge/cxl_root_port: Wire up MSI hw/mem/cxl-type3: Add AER extended capability hw/pci/aer: Make PCIE AER error injection facility available for other emulation to use. hw/mem/cxl_type3: Add CXL RAS Error Injection Support. hw/cxl/cxl-component-utils.c | 4 +- hw/mem/cxl_type3.c | 303 +++++++++++++++++++++++++++++++++ hw/mem/cxl_type3_stubs.c | 10 ++ hw/mem/meson.build | 2 + hw/pci-bridge/cxl_root_port.c | 64 +++++++ hw/pci/pci-internal.h | 1 - hw/pci/pcie_aer.c | 14 +- include/hw/cxl/cxl_component.h | 26 +++ include/hw/cxl/cxl_device.h | 11 ++ include/hw/pci/pcie_aer.h | 1 + include/hw/pci/pcie_regs.h | 3 + qapi/cxl.json | 113 ++++++++++++ qapi/meson.build | 1 + qapi/qapi-schema.json | 1 + 14 files changed, 551 insertions(+), 3 deletions(-) create mode 100644 hw/mem/cxl_type3_stubs.c create mode 100644 qapi/cxl.json -- 2.37.2