From patchwork Wed Jan 20 10:31:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mihai Carabas X-Patchwork-Id: 12032105 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 356B3C433DB for ; Wed, 20 Jan 2021 11:23:08 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id ABEFC2250E for ; Wed, 20 Jan 2021 11:23:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org ABEFC2250E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:34334 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l2BZq-0005Bt-Dz for qemu-devel@archiver.kernel.org; Wed, 20 Jan 2021 06:23:06 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:46454) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l2BXx-0002xv-DL for qemu-devel@nongnu.org; Wed, 20 Jan 2021 06:21:09 -0500 Received: from aserp2120.oracle.com ([141.146.126.78]:35372) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l2BXt-0002Gq-Ry for qemu-devel@nongnu.org; Wed, 20 Jan 2021 06:21:09 -0500 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 10KBEpEZ154553; Wed, 20 Jan 2021 11:21:04 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2020-01-29; bh=Kp/O3xU8k/uWK2I5pmHkAImByeza11AbiTMPXo+7mBI=; b=URic0pVh/xIl1b2txMa8SuHmGcvwop9zxidjhZ7od3gVd+NtqYGH8tbXmw4evpW3Jkbq tkpeLxqRGEFr76oO1rIyBf1YhxX2lyD8tq144yU1WuJU+jC6ucfucgIgjNz9PeiaaGRS 7KCdQV5EgIN3q0zO+eRe50cpEX0mX03IHu0ctQh/iZfefUE4v7CxxGV8gHOkelwRLfF8 J8EqmLBY59en645eKO1zv3nbjUpG0cco3YootP5g6s+kQZJMba9LtBQWaChu4vRd6+oY yG6W1vUMT6v1JP/xCrOSNmdpqipKB/eNfpyN8ZtGydlOojGdqRni1dYyPfHjPIXn5VWs oA== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by aserp2120.oracle.com with ESMTP id 3668qmsy8x-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 20 Jan 2021 11:21:04 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 10KBEl7A010918; Wed, 20 Jan 2021 11:19:03 GMT Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2106.outbound.protection.outlook.com [104.47.58.106]) by userp3020.oracle.com with ESMTP id 3668qw0cqg-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 20 Jan 2021 11:19:03 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AIX0YxBGaC6J93vupQUQyEyWyOIslR46tCcDBOTvwl+cQY1xdCZtjWPmCKSIUMebAI7wf0BMw3UsznbSvXmiUGbmC5r+WO3avcKRrC8G5gl++nvn/csSVKytiHH433jizOuyrQjMZ3BTtECUYbttuNhC95oCkpIUDMx7opEF0JVmtnPoHg+Hz1ecSnt3wE322OpuzlwMuQv5TMfsEdoNBpNDWRdLUxFbsxNFoXLwuWg/4JuEc7SJApIxkZt/2PqTKBDFykJGarNUbYvjHFIeQMhxJ+SsL8fSvnqv+l8cBQ6zJI+rtIM5XUxf+2uSJDvpma6g/f7RT0AuH2e4mOnmFg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Kp/O3xU8k/uWK2I5pmHkAImByeza11AbiTMPXo+7mBI=; b=Q0t5/6OynPwRTXXRXn0SFruxPLVV1Xy0CS/NWFtuJASOzlfC9cr1Txk+yg0ap+RFnS+dmm5vH9j3FPzI34M0Z+LSngG07IyvKNRDpus/r9hTsG767IbIKXheV34G0PctwYbZlrINZ8ZV7mONKE5bOlLL5ZHazANOjCmJbtqZuYf8OORf9kcnYOM33fOFyiZ3rX9Fzm8A/VgB4AHqjOMw9FMcv+FBOhXb1ol4vJ/znTJcugAgyU82NSXbhztc3PBDbvQL/ANN6yFkLDxZEOv6H0YAiBNVavG8+59DAcSDkZRlHxB4jVqSusunGiNDXOMT5MZob/90Zt1K5ebivgSW0w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Kp/O3xU8k/uWK2I5pmHkAImByeza11AbiTMPXo+7mBI=; b=BfcvC3UJT2zB654VdTxFiB/2RNEQHSWavmQve02AI0TDOJbpxXbuCtu7YqV0cq92oZ0R+bYMgScoBWUd++vnWLKQHKPsnSAOVLDfomkP/cGRu2Y4HxA+ww3YzuKb2Z3F07WmVaWCs3eakY+sCtajx0oJDtzlj/YNAgw9Zy2rbwY= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=oracle.com; Received: from MWHPR1001MB2285.namprd10.prod.outlook.com (2603:10b6:301:2e::32) by MWHPR10MB1342.namprd10.prod.outlook.com (2603:10b6:300:1f::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3784.12; Wed, 20 Jan 2021 11:19:00 +0000 Received: from MWHPR1001MB2285.namprd10.prod.outlook.com ([fe80::f48a:d4cb:d74c:48ba]) by MWHPR1001MB2285.namprd10.prod.outlook.com ([fe80::f48a:d4cb:d74c:48ba%6]) with mapi id 15.20.3742.014; Wed, 20 Jan 2021 11:19:00 +0000 From: Mihai Carabas To: qemu-devel@nongnu.org Subject: [PATCH v4 1/4] hw/misc/pvpanic: split-out generic and bus dependent code Date: Wed, 20 Jan 2021 12:31:54 +0200 Message-Id: <1611138717-1672-2-git-send-email-mihai.carabas@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1611138717-1672-1-git-send-email-mihai.carabas@oracle.com> References: <1611138717-1672-1-git-send-email-mihai.carabas@oracle.com> X-Originating-IP: [138.3.200.25] X-ClientProxiedBy: SN6PR16CA0062.namprd16.prod.outlook.com (2603:10b6:805:ca::39) To MWHPR1001MB2285.namprd10.prod.outlook.com (2603:10b6:301:2e::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from mihai.localdomain (138.3.200.25) by SN6PR16CA0062.namprd16.prod.outlook.com (2603:10b6:805:ca::39) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3763.10 via Frontend Transport; Wed, 20 Jan 2021 11:18:59 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d44703f9-d9a8-4535-921b-08d8bd352fa7 X-MS-TrafficTypeDiagnostic: MWHPR10MB1342: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:785; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: +8/10TKdb3gsHspImxzMzl5W5OGPPWXO64OPPQWGBXs07rRHf75euzW1nnm/7P63SWdLRgQwc+Avje+lV7DowLj5ufwcPnbZcgL6SGVMT3xYFWeoZ/xRVbliJTs50TS42l1JiktB4IGsCdcRFjQVJxU54NDg7jcQJpswcNmvimPKaU5ob0/9ByahqeUoKzPdqIu0I5rdRp17+daHFKgkXdqO8+aOHKhhPAtw+8yAaNeiizCccvFFnoGFGlHZL6oAgAuh/dqFUTFyKz5wncbxqDrQKrGngqdRmbUh/ORFXcykMeLHcUHaV6Ca1tTeXf0UqGVC+3Qu2s7LqLV00BkhnwLGi4Cu3P9QTigtFxv5CLLx8b12RGcVYZ1az12xj+r5a9Hb4jOUAGxh/cJUoVWtXUASN9URj/YoqAJa5mrZ6zpPLsBb04kOFri88vXL8Od1 X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:MWHPR1001MB2285.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(346002)(39860400002)(396003)(366004)(136003)(376002)(6486002)(16526019)(6666004)(8676002)(36756003)(2906002)(86362001)(83380400001)(107886003)(6506007)(30864003)(6916009)(316002)(8936002)(5660300002)(956004)(52116002)(66946007)(44832011)(478600001)(2616005)(6512007)(66556008)(4326008)(186003)(66476007)(26005)(41533002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: Qt4th8u7Nk0t5pHY1dG89n9OO5FSj/+uyOkAgA/xagpZhbtfdk0zTEBRW9lFzNIDVwjsH0Qfy0l0fXltmRGrosA0Bd6lvGuvCJll0fkvPJJGS1DNdhihyEDD83cB/HMUthi6l2pf9o0e8pLpcq319Ur9esT93JM831gBJNZeK8/GaIP8LCg75egnlJGynyCsM6cWGjQytoBwFh8wqkv8I5VZ6GDi+9q3Pc4upB3FGrW8KgDm2ZvLCQAu0E0+JHClP7QXhW2e/KZc4HJDGSw+WqvSsLm1RcOdgS066USdSV3yUyMzrBQma8E+MDHySQhD+CmbbejKpwNQ+Jv8ZNx1ZLyAWDbePqEzQxtTTSsMGN0Abe35p7quhXw39uWR/GtkCxcmxv4ysbKG8FXwXuVCdw3nK9T7QnOBqTbTRHwkgDz9t2/lmktAz16mC01VHr5pO5FKXEZHAeIpUlxS1chpGz7DFabS7aydn5naywmCSg7WdA4PTb4/DU0XhiMd0puHx5TQ0BvrnEYEdgp9tWLUtfXk1KG3iwlRwoe+2UfLVg+zopYflAW0yb92y8ByEUC9QS2g/YU8R3nPnnbwnCOFdQOZyH4rVmJJGLt/rVwDFuL3G+VbHAxJiVehpsABRZISmKqjSkbJnwPnsr+xlWtCkmwzk6EyVpVohfeWE9pfk6AvxIBFQ/qus+en11DnaywRU58MdzFGumZxzt4jErSVseCLQ7kRvwWFRfz8/Xf/TdysbSktBn2lZJW+7crkXnKnjx72nghY5P2Ey/LWLKqJb/AF2+8dw+P4+087zckUVwtMkJz6swO97BygyEYiYJvJZ+hrCZhR4K3DG+3Z+LPya+6jgOq5CZtS7K8IGb11LEkE5FM7TBHAdiFK/YKoa5k/DKEn9Bqg7qoF52gOyf8D0kUJfg5xGLCdoY+ZZZ1W7PbKJU/V8QMZTg5l2/ZkEAPk12JNyI1NyQ8O4OfejIzYjKCW/SxF+iCZjsdtv4ypbbAj+cEtNg+ePYRGo4zbQ3a8 X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: d44703f9-d9a8-4535-921b-08d8bd352fa7 X-MS-Exchange-CrossTenant-AuthSource: MWHPR1001MB2285.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Jan 2021 11:19:00.5571 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: QU81AiVRE3iRTcW9K0QBZPKAuZO5cRIFzDROl+lrS+c8jrE9MpXHGEfMBmXytl+qnIOQeJ2NtJ9xZl52mEPEHUOflr6uYALxZPw4myPhd0I= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR10MB1342 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9869 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 phishscore=0 adultscore=0 malwarescore=0 mlxscore=0 mlxlogscore=999 spamscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2101200066 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9869 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 priorityscore=1501 adultscore=0 impostorscore=0 mlxlogscore=999 spamscore=0 suspectscore=0 phishscore=0 clxscore=1015 bulkscore=0 mlxscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2101200066 Received-SPF: pass client-ip=141.146.126.78; envelope-from=mihai.carabas@oracle.com; helo=aserp2120.oracle.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mihai Carabas , peter.maydell@linaro.org, kraxel@redhat.com Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" To ease the PCI device addition in next patches, split the code as follows: - generic code (read/write/setup) is being kept in pvpanic.c - ISA dependent code moved to pvpanic-isa.c Also, rename: - ISA_PVPANIC_DEVICE -> PVPANIC_ISA_DEVICE. - TYPE_PVPANIC -> TYPE_PVPANIC_ISA. - MemoryRegion io -> mr. - pvpanic_ioport_* in pvpanic_*. Update the build system with the new files and config structure. Signed-off-by: Mihai Carabas Reviewed-by: Peter Maydell --- hw/i386/Kconfig | 2 +- hw/misc/Kconfig | 6 ++- hw/misc/meson.build | 3 +- hw/misc/pvpanic-isa.c | 94 +++++++++++++++++++++++++++++++++++++++++++++++ hw/misc/pvpanic.c | 85 +++--------------------------------------- include/hw/misc/pvpanic.h | 23 +++++++++++- tests/qtest/meson.build | 2 +- 7 files changed, 130 insertions(+), 85 deletions(-) create mode 100644 hw/misc/pvpanic-isa.c diff --git a/hw/i386/Kconfig b/hw/i386/Kconfig index eea059f..7f91f30 100644 --- a/hw/i386/Kconfig +++ b/hw/i386/Kconfig @@ -14,7 +14,7 @@ config PC imply ISA_DEBUG imply PARALLEL imply PCI_DEVICES - imply PVPANIC + imply PVPANIC_ISA imply QXL imply SEV imply SGA diff --git a/hw/misc/Kconfig b/hw/misc/Kconfig index cf18ac0..23bc978 100644 --- a/hw/misc/Kconfig +++ b/hw/misc/Kconfig @@ -121,9 +121,13 @@ config IOTKIT_SYSCTL config IOTKIT_SYSINFO bool -config PVPANIC +config PVPANIC_COMMON + bool + +config PVPANIC_ISA bool depends on ISA_BUS + select PVPANIC_COMMON config AUX bool diff --git a/hw/misc/meson.build b/hw/misc/meson.build index 607cd38..edaaec2 100644 --- a/hw/misc/meson.build +++ b/hw/misc/meson.build @@ -13,6 +13,7 @@ softmmu_ss.add(when: 'CONFIG_EMC141X', if_true: files('emc141x.c')) softmmu_ss.add(when: 'CONFIG_UNIMP', if_true: files('unimp.c')) softmmu_ss.add(when: 'CONFIG_EMPTY_SLOT', if_true: files('empty_slot.c')) softmmu_ss.add(when: 'CONFIG_LED', if_true: files('led.c')) +softmmu_ss.add(when: 'CONFIG_PVPANIC_COMMON', if_true: files('pvpanic.c')) # ARM devices softmmu_ss.add(when: 'CONFIG_PL310', if_true: files('arm_l2x0.c')) @@ -98,7 +99,7 @@ softmmu_ss.add(when: 'CONFIG_IOTKIT_SYSINFO', if_true: files('iotkit-sysinfo.c') softmmu_ss.add(when: 'CONFIG_ARMSSE_CPUID', if_true: files('armsse-cpuid.c')) softmmu_ss.add(when: 'CONFIG_ARMSSE_MHU', if_true: files('armsse-mhu.c')) -softmmu_ss.add(when: 'CONFIG_PVPANIC', if_true: files('pvpanic.c')) +softmmu_ss.add(when: 'CONFIG_PVPANIC_ISA', if_true: files('pvpanic-isa.c')) softmmu_ss.add(when: 'CONFIG_AUX', if_true: files('auxbus.c')) softmmu_ss.add(when: 'CONFIG_ASPEED_SOC', if_true: files('aspeed_scu.c', 'aspeed_sdmc.c', 'aspeed_xdma.c')) softmmu_ss.add(when: 'CONFIG_MSF2', if_true: files('msf2-sysreg.c')) diff --git a/hw/misc/pvpanic-isa.c b/hw/misc/pvpanic-isa.c new file mode 100644 index 0000000..27113ab --- /dev/null +++ b/hw/misc/pvpanic-isa.c @@ -0,0 +1,94 @@ +/* + * QEMU simulated pvpanic device. + * + * Copyright Fujitsu, Corp. 2013 + * + * Authors: + * Wen Congyang + * Hu Tao + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + * + */ + +#include "qemu/osdep.h" +#include "qemu/log.h" +#include "qemu/module.h" +#include "sysemu/runstate.h" + +#include "hw/nvram/fw_cfg.h" +#include "hw/qdev-properties.h" +#include "hw/misc/pvpanic.h" +#include "qom/object.h" +#include "hw/isa/isa.h" + +OBJECT_DECLARE_SIMPLE_TYPE(PVPanicISAState, PVPANIC_ISA_DEVICE) + +/* + * PVPanicISAState for ISA device and + * use ioport. + */ +struct PVPanicISAState { + ISADevice parent_obj; + + uint16_t ioport; + PVPanicState pvpanic; +}; + +static void pvpanic_isa_initfn(Object *obj) +{ + PVPanicISAState *s = PVPANIC_ISA_DEVICE(obj); + + pvpanic_setup_io(&s->pvpanic, DEVICE(s), 1); +} + +static void pvpanic_isa_realizefn(DeviceState *dev, Error **errp) +{ + ISADevice *d = ISA_DEVICE(dev); + PVPanicISAState *s = PVPANIC_ISA_DEVICE(dev); + PVPanicState *ps = &s->pvpanic; + FWCfgState *fw_cfg = fw_cfg_find(); + uint16_t *pvpanic_port; + + if (!fw_cfg) { + return; + } + + pvpanic_port = g_malloc(sizeof(*pvpanic_port)); + *pvpanic_port = cpu_to_le16(s->ioport); + fw_cfg_add_file(fw_cfg, "etc/pvpanic-port", pvpanic_port, + sizeof(*pvpanic_port)); + + isa_register_ioport(d, &ps->mr, s->ioport); +} + +static Property pvpanic_isa_properties[] = { + DEFINE_PROP_UINT16(PVPANIC_IOPORT_PROP, PVPanicISAState, ioport, 0x505), + DEFINE_PROP_UINT8("events", PVPanicISAState, pvpanic.events, PVPANIC_PANICKED | PVPANIC_CRASHLOADED), + DEFINE_PROP_END_OF_LIST(), +}; + +static void pvpanic_isa_class_init(ObjectClass *klass, void *data) +{ + DeviceClass *dc = DEVICE_CLASS(klass); + + dc->realize = pvpanic_isa_realizefn; + device_class_set_props(dc, pvpanic_isa_properties); + set_bit(DEVICE_CATEGORY_MISC, dc->categories); +} + +static TypeInfo pvpanic_isa_info = { + .name = TYPE_PVPANIC_ISA_DEVICE, + .parent = TYPE_ISA_DEVICE, + .instance_size = sizeof(PVPanicISAState), + .instance_init = pvpanic_isa_initfn, + .class_init = pvpanic_isa_class_init, +}; + +static void pvpanic_register_types(void) +{ + type_register_static(&pvpanic_isa_info); +} + +type_init(pvpanic_register_types) diff --git a/hw/misc/pvpanic.c b/hw/misc/pvpanic.c index 35d6797..e2cb4a5 100644 --- a/hw/misc/pvpanic.c +++ b/hw/misc/pvpanic.c @@ -22,18 +22,6 @@ #include "hw/misc/pvpanic.h" #include "qom/object.h" -/* The bit of supported pv event, TODO: include uapi header and remove this */ -#define PVPANIC_F_PANICKED 0 -#define PVPANIC_F_CRASHLOADED 1 - -/* The pv event value */ -#define PVPANIC_PANICKED (1 << PVPANIC_F_PANICKED) -#define PVPANIC_CRASHLOADED (1 << PVPANIC_F_CRASHLOADED) - -typedef struct PVPanicState PVPanicState; -DECLARE_INSTANCE_CHECKER(PVPanicState, ISA_PVPANIC_DEVICE, - TYPE_PVPANIC) - static void handle_event(int event) { static bool logged; @@ -54,90 +42,29 @@ static void handle_event(int event) } } -#include "hw/isa/isa.h" - -struct PVPanicState { - ISADevice parent_obj; - - MemoryRegion io; - uint16_t ioport; - uint8_t events; -}; - /* return supported events on read */ -static uint64_t pvpanic_ioport_read(void *opaque, hwaddr addr, unsigned size) +static uint64_t pvpanic_read(void *opaque, hwaddr addr, unsigned size) { PVPanicState *pvp = opaque; return pvp->events; } -static void pvpanic_ioport_write(void *opaque, hwaddr addr, uint64_t val, +static void pvpanic_write(void *opaque, hwaddr addr, uint64_t val, unsigned size) { handle_event(val); } static const MemoryRegionOps pvpanic_ops = { - .read = pvpanic_ioport_read, - .write = pvpanic_ioport_write, + .read = pvpanic_read, + .write = pvpanic_write, .impl = { .min_access_size = 1, .max_access_size = 1, }, }; -static void pvpanic_isa_initfn(Object *obj) -{ - PVPanicState *s = ISA_PVPANIC_DEVICE(obj); - - memory_region_init_io(&s->io, OBJECT(s), &pvpanic_ops, s, "pvpanic", 1); -} - -static void pvpanic_isa_realizefn(DeviceState *dev, Error **errp) -{ - ISADevice *d = ISA_DEVICE(dev); - PVPanicState *s = ISA_PVPANIC_DEVICE(dev); - FWCfgState *fw_cfg = fw_cfg_find(); - uint16_t *pvpanic_port; - - if (!fw_cfg) { - return; - } - - pvpanic_port = g_malloc(sizeof(*pvpanic_port)); - *pvpanic_port = cpu_to_le16(s->ioport); - fw_cfg_add_file(fw_cfg, "etc/pvpanic-port", pvpanic_port, - sizeof(*pvpanic_port)); - - isa_register_ioport(d, &s->io, s->ioport); -} - -static Property pvpanic_isa_properties[] = { - DEFINE_PROP_UINT16(PVPANIC_IOPORT_PROP, PVPanicState, ioport, 0x505), - DEFINE_PROP_UINT8("events", PVPanicState, events, PVPANIC_PANICKED | PVPANIC_CRASHLOADED), - DEFINE_PROP_END_OF_LIST(), -}; - -static void pvpanic_isa_class_init(ObjectClass *klass, void *data) +void pvpanic_setup_io(PVPanicState *s, DeviceState *dev, unsigned size) { - DeviceClass *dc = DEVICE_CLASS(klass); - - dc->realize = pvpanic_isa_realizefn; - device_class_set_props(dc, pvpanic_isa_properties); - set_bit(DEVICE_CATEGORY_MISC, dc->categories); + memory_region_init_io(&s->mr, OBJECT(dev), &pvpanic_ops, s, "pvpanic", size); } - -static TypeInfo pvpanic_isa_info = { - .name = TYPE_PVPANIC, - .parent = TYPE_ISA_DEVICE, - .instance_size = sizeof(PVPanicState), - .instance_init = pvpanic_isa_initfn, - .class_init = pvpanic_isa_class_init, -}; - -static void pvpanic_register_types(void) -{ - type_register_static(&pvpanic_isa_info); -} - -type_init(pvpanic_register_types) diff --git a/include/hw/misc/pvpanic.h b/include/hw/misc/pvpanic.h index ae0c818..abc9dde 100644 --- a/include/hw/misc/pvpanic.h +++ b/include/hw/misc/pvpanic.h @@ -17,13 +17,32 @@ #include "qom/object.h" -#define TYPE_PVPANIC "pvpanic" +#define TYPE_PVPANIC_ISA_DEVICE "pvpanic" #define PVPANIC_IOPORT_PROP "ioport" +/* The bit of supported pv event, TODO: include uapi header and remove this */ +#define PVPANIC_F_PANICKED 0 +#define PVPANIC_F_CRASHLOADED 1 + +/* The pv event value */ +#define PVPANIC_PANICKED (1 << PVPANIC_F_PANICKED) +#define PVPANIC_CRASHLOADED (1 << PVPANIC_F_CRASHLOADED) + +/* + * PVPanicState for any device type + */ +typedef struct PVPanicState PVPanicState; +struct PVPanicState { + MemoryRegion mr; + uint8_t events; +}; + +void pvpanic_setup_io(PVPanicState *s, DeviceState *dev, unsigned size); + static inline uint16_t pvpanic_port(void) { - Object *o = object_resolve_path_type("", TYPE_PVPANIC, NULL); + Object *o = object_resolve_path_type("", TYPE_PVPANIC_ISA_DEVICE, NULL); if (!o) { return 0; } diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build index 16d0462..0e85343 100644 --- a/tests/qtest/meson.build +++ b/tests/qtest/meson.build @@ -33,7 +33,7 @@ qtests_i386 = \ (config_host.has_key('CONFIG_LINUX') and \ config_all_devices.has_key('CONFIG_ISA_IPMI_BT') ? ['ipmi-bt-test'] : []) + \ (config_all_devices.has_key('CONFIG_WDT_IB700') ? ['wdt_ib700-test'] : []) + \ - (config_all_devices.has_key('CONFIG_PVPANIC') ? ['pvpanic-test'] : []) + \ + (config_all_devices.has_key('CONFIG_PVPANIC_ISA') ? ['pvpanic-test'] : []) + \ (config_all_devices.has_key('CONFIG_HDA') ? ['intel-hda-test'] : []) + \ (config_all_devices.has_key('CONFIG_I82801B11') ? ['i82801b11-test'] : []) + \ (config_all_devices.has_key('CONFIG_IOH3420') ? ['ioh3420-test'] : []) + \ From patchwork Wed Jan 20 10:31:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mihai Carabas X-Patchwork-Id: 12032059 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CE74FC433E0 for ; Wed, 20 Jan 2021 11:20:34 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 4469623159 for ; Wed, 20 Jan 2021 11:20:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4469623159 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:55800 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l2BXM-0002L5-Vi for qemu-devel@archiver.kernel.org; Wed, 20 Jan 2021 06:20:33 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:46148) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l2BW4-0001UI-CE for qemu-devel@nongnu.org; Wed, 20 Jan 2021 06:19:12 -0500 Received: from aserp2130.oracle.com ([141.146.126.79]:56330) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l2BW1-0001c7-Fh for qemu-devel@nongnu.org; Wed, 20 Jan 2021 06:19:12 -0500 Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 10KBEf6M154161; Wed, 20 Jan 2021 11:19:04 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2020-01-29; bh=nMuJGYplbqwl3yID8sz4vM50zHbeOjhk02m5j6liDZA=; b=uw+sGH3RZYz3xJs4E18LfTmEuAmylvywOFuumpP2bAcuTJkMnJHWLCPOeULPl5vrnuXi 7c0iKjcvLPDeSppK2AuEWTQjFurarvbcelxOVem2jhg7QbF1kDoE85SfVt1aBcoIkIyG 2xt3epdLLrFYx4S+ovkYgucDj5UzBAiXcau65/bGo0jdoPKFG6UnTkpDKdfwfCBUWu/h y69XLxSgRxg1E0mNOemrMX/FcXDKRr+o1pMtt8eRPap6SqLlzMvCFGzvNy4zkgIrlgPy Eq6N7rqHFjqq3QiBpvKPzZ9uXhzgbORi67Q923eMLE7KJwksYAiqcd6fF5Y7VxPmEKAf MA== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by aserp2130.oracle.com with ESMTP id 3668qr9ype-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 20 Jan 2021 11:19:04 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 10KBEl7B010918; Wed, 20 Jan 2021 11:19:03 GMT Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2106.outbound.protection.outlook.com [104.47.58.106]) by userp3020.oracle.com with ESMTP id 3668qw0cqg-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 20 Jan 2021 11:19:03 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TBGtj9P9sHx/MT8naT9waXOsZJiv+zDKwXrnoQyv/s52avCUA+9Eoxsei77n+u9nGz4XMlWETVRgh9ayXWMSgOpPnF1CLS6P+i7VBHg5/TSFwU+VyNKmvVJkFNRTATqk6/Z9KMyZXkYQc8XGNAMh+5QfHgd05IvgAmONG4F1Ud7PAQOVaRCrLUY/0IKMfUXvQeN0dieNde3k4lYOw9RxCEqCJovXkeC+II+o5U2bXZwsl9VEisuTTXbJE4V4/tUGI4NeQ4CpXAfS6h3QuK52TErChDezHl4rQ7cwf77f8Wy4HxediqS+jgUyhMe6PGVv29GldBQSzgTSsnYWptniog== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=nMuJGYplbqwl3yID8sz4vM50zHbeOjhk02m5j6liDZA=; b=DqOtS22/4VEXMWFpkx02Q9osz3WOMxrqzvAJUC3e09U4/yW1K88Or96aLaLzGMoUT7Do76fQWKfODw2PZJmh8r4d5Elyy34/UxUiUDduYvrg/g1s7PH3D7xbjXVGsvqmm3jlepwnzCXtuYDePiqcNoJDyCbphtJH2q70NWhpakBWtUDOa1Jmb+2fBv1LTHoyKv2Yu/GHb/+d0EtqCI+u0rb5dIXfBwqGXHkG1vQmVlZNrZeg1WfOfJNPTysyUKmSgOVtRnRcnJ3IcJ9YwM1aPoGHRsk9xJBtdwDn/XTRFJ1gRgArfwbhHZUadrrYPV17ay7xqRlSFweiFbxFkr9oAQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=nMuJGYplbqwl3yID8sz4vM50zHbeOjhk02m5j6liDZA=; b=q1JI6ntR/zwAjsbC1SgT72C91jELPNqtgEPQmPAsYvH4x9MYe5zyyGWmsvDFYI7RN6BIBpgoifQQc4ju5yzv0Qj4RN0xmN/d3v3o6Yjv91V/MSy+KHd47trNeMotOG+QUfvGDtEVJh9c/RkJ3GirxYQaOp54uLObhtRUE4sFTmI= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=oracle.com; Received: from MWHPR1001MB2285.namprd10.prod.outlook.com (2603:10b6:301:2e::32) by MWHPR10MB1342.namprd10.prod.outlook.com (2603:10b6:300:1f::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3784.12; Wed, 20 Jan 2021 11:19:02 +0000 Received: from MWHPR1001MB2285.namprd10.prod.outlook.com ([fe80::f48a:d4cb:d74c:48ba]) by MWHPR1001MB2285.namprd10.prod.outlook.com ([fe80::f48a:d4cb:d74c:48ba%6]) with mapi id 15.20.3742.014; Wed, 20 Jan 2021 11:19:02 +0000 From: Mihai Carabas To: qemu-devel@nongnu.org Subject: [PATCH v4 2/4] hw/misc/pvpanic: add PCI interface support Date: Wed, 20 Jan 2021 12:31:55 +0200 Message-Id: <1611138717-1672-3-git-send-email-mihai.carabas@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1611138717-1672-1-git-send-email-mihai.carabas@oracle.com> References: <1611138717-1672-1-git-send-email-mihai.carabas@oracle.com> X-Originating-IP: [138.3.200.25] X-ClientProxiedBy: SN6PR16CA0062.namprd16.prod.outlook.com (2603:10b6:805:ca::39) To MWHPR1001MB2285.namprd10.prod.outlook.com (2603:10b6:301:2e::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from mihai.localdomain (138.3.200.25) by SN6PR16CA0062.namprd16.prod.outlook.com (2603:10b6:805:ca::39) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3763.10 via Frontend Transport; Wed, 20 Jan 2021 11:19:00 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ea081683-2988-4633-2ea4-08d8bd353093 X-MS-TrafficTypeDiagnostic: MWHPR10MB1342: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:227; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Yj+oAv//gJsa8yU+Aozx5DfN5wTDA1u7rM5YPX15urlkM/JbqJQ6sED31ia+E8tXZhR05rehXyxGkLqBhCTbinWEVKileMkYNd45xIzGpYAy0uSbos1XPay0q+mcce89rJ62oPCaz5toNO91oZBh5+ZvCm1LdOCaFHI4OQW2Y4Cc9baebSbjxHg1xdTjSD6CH9u0jKbbqo3JbS/9WqidtVZByHum1ZRLMI4j2vEQ3byOmaGKSoi5ANdlAakOM+PnNu1USMEV3pQb1Ew75rAE3OgqctEgAJbAYpdXLPLWzD29/IwNstZsPt8ra4npHucMWzXUPQTMj8VpDTvpaTgg1bsPwBGwglYbsTwO4OT02SKPiZmmmbMONmtqRKk3L0YDWfRMbcwM+XBmwAlKB+XHfw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:MWHPR1001MB2285.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(346002)(39860400002)(396003)(366004)(136003)(376002)(6486002)(16526019)(6666004)(8676002)(36756003)(2906002)(86362001)(83380400001)(107886003)(6506007)(6916009)(316002)(8936002)(5660300002)(956004)(52116002)(66946007)(44832011)(478600001)(2616005)(6512007)(66556008)(4326008)(186003)(66476007)(26005); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: 4ka+5ns4/mWvZZ2eOSQV16WuF+IXBg9H9HAIW3+Gqo+KMO04HMC3thkkQMv89KyR1KUgP1f7jzh6KCLgyayzcewzvTGlm1FUmhUlwUP0q5umeYtaohtA4AyFocRqaDfPU6H47HH6xFGe9P1rneAipE+JVRhXljf5CX/5DUsKTrzSdxUBUy9hbK0lw2Fgbmq6hj3jb/5433fLHF9qhEm0G10p/pNqB9s1YG0/tcGbx66Net6cVDFWbHOCsv8vfo0QVjy21z7Iw/Rd141pLt+Oh5RswTYOScij9+v9evNaDBm7bYbUtEttzLKVal4b0qaNNfLRf5tKS9UVZby2ucSSdEPhCsAn8dy4wxZAoiewlTY2MYeVxmKEIjDAv328Fnc6Wz8+0Tk0jTclyO60B75k7OYx3QJML7q4ppF41tnf4jC+2vAove7ZQoEPYzCd9uTCeCozqyGpOTsGtp2jL5Bs95A8ePNbwmhGbNHCrDy/XvOuGwZ8yt2f4tbVQo3C3GHwo0Gw4ywyjk0H1tXm6w4kHkbnY/+ZWWBfz188oSFbGFom/eL58o8uoEIOpYh80RJQydxXtGQEqtbHbFvXkUmfWccdxHy9cIORfFzKzWcsA3pephvwx+bzuxMZ6yklUfGr0sgYPJmqjk7Tu5Yo+m7SkXIzXidwCtWVknNWv8l2Li0UBPoTErG36a4lRVn2HowwpTBgW7hnX/MN6k3+UTEek7EIRVxqayTNTN/o3fIU8H3gsE793SLhBP7+1JzObh0+z1mJ+lA3920ILR+2FgvXmsl9Pr+JJwb7Ulp0EOQoMsH7DdbVEVNj/uydVr/LtL9+Y1VDH+wJZWH+UWZGT8XxcJmZLdSohDLVLajpWy55MbPl4qgzhkvjPBPs0mbrgbntHILJkSpa9iSr5tgn2HeHl24K7zfO69qtZNd885t0zC9XjpUP1lVJk35N7f3/HPDWUXD00x3ccwhbfk4hJFN1PZvefcigqfyu2zaa+Ob6tDg= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: ea081683-2988-4633-2ea4-08d8bd353093 X-MS-Exchange-CrossTenant-AuthSource: MWHPR1001MB2285.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Jan 2021 11:19:01.9992 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: P3P2b5g1KxNiQNFgPDHsEVxkstEPfwv+Myof9VubgK4Tg18eev9XefLCOnP8ncnQGf+/lOlnMn6a4lJjD6vJX++c0j1YELnVRINYj9rhGuw= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR10MB1342 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9869 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 phishscore=0 adultscore=0 malwarescore=0 mlxscore=0 mlxlogscore=999 spamscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2101200066 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9869 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 mlxscore=0 suspectscore=0 lowpriorityscore=0 bulkscore=0 adultscore=0 spamscore=0 phishscore=0 priorityscore=1501 impostorscore=0 malwarescore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2101200066 Received-SPF: pass client-ip=141.146.126.79; envelope-from=mihai.carabas@oracle.com; helo=aserp2130.oracle.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mihai Carabas , peter.maydell@linaro.org, kraxel@redhat.com Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Add PCI interface support for PVPANIC device. Create a new file pvpanic-pci.c where the PCI specific routines reside and update the build system with the new files and config structure. Signed-off-by: Mihai Carabas Reviewed-by: Gerd Hoffmann Reviewed-by: Peter Maydell --- docs/specs/pci-ids.txt | 1 + hw/misc/Kconfig | 6 +++ hw/misc/meson.build | 1 + hw/misc/pvpanic-pci.c | 94 +++++++++++++++++++++++++++++++++++++++++++++++ include/hw/misc/pvpanic.h | 1 + include/hw/pci/pci.h | 1 + 6 files changed, 104 insertions(+) create mode 100644 hw/misc/pvpanic-pci.c diff --git a/docs/specs/pci-ids.txt b/docs/specs/pci-ids.txt index abbdbca..5e407a6 100644 --- a/docs/specs/pci-ids.txt +++ b/docs/specs/pci-ids.txt @@ -64,6 +64,7 @@ PCI devices (other than virtio): 1b36:000d PCI xhci usb host adapter 1b36:000f mdpy (mdev sample device), linux/samples/vfio-mdev/mdpy.c 1b36:0010 PCIe NVMe device (-device nvme) +1b36:0011 PCI PVPanic device (-device pvpanic-pci) All these devices are documented in docs/specs. diff --git a/hw/misc/Kconfig b/hw/misc/Kconfig index 23bc978..19c216f 100644 --- a/hw/misc/Kconfig +++ b/hw/misc/Kconfig @@ -124,6 +124,12 @@ config IOTKIT_SYSINFO config PVPANIC_COMMON bool +config PVPANIC_PCI + bool + default y if PCI_DEVICES + depends on PCI + select PVPANIC_COMMON + config PVPANIC_ISA bool depends on ISA_BUS diff --git a/hw/misc/meson.build b/hw/misc/meson.build index edaaec2..6292839 100644 --- a/hw/misc/meson.build +++ b/hw/misc/meson.build @@ -100,6 +100,7 @@ softmmu_ss.add(when: 'CONFIG_ARMSSE_CPUID', if_true: files('armsse-cpuid.c')) softmmu_ss.add(when: 'CONFIG_ARMSSE_MHU', if_true: files('armsse-mhu.c')) softmmu_ss.add(when: 'CONFIG_PVPANIC_ISA', if_true: files('pvpanic-isa.c')) +softmmu_ss.add(when: 'CONFIG_PVPANIC_PCI', if_true: files('pvpanic-pci.c')) softmmu_ss.add(when: 'CONFIG_AUX', if_true: files('auxbus.c')) softmmu_ss.add(when: 'CONFIG_ASPEED_SOC', if_true: files('aspeed_scu.c', 'aspeed_sdmc.c', 'aspeed_xdma.c')) softmmu_ss.add(when: 'CONFIG_MSF2', if_true: files('msf2-sysreg.c')) diff --git a/hw/misc/pvpanic-pci.c b/hw/misc/pvpanic-pci.c new file mode 100644 index 0000000..d629639 --- /dev/null +++ b/hw/misc/pvpanic-pci.c @@ -0,0 +1,94 @@ +/* + * QEMU simulated PCI pvpanic device. + * + * Copyright (C) 2020 Oracle + * + * Authors: + * Mihai Carabas + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + * + */ + +#include "qemu/osdep.h" +#include "qemu/log.h" +#include "qemu/module.h" +#include "sysemu/runstate.h" + +#include "hw/nvram/fw_cfg.h" +#include "hw/qdev-properties.h" +#include "migration/vmstate.h" +#include "hw/misc/pvpanic.h" +#include "qom/object.h" +#include "hw/pci/pci.h" + +OBJECT_DECLARE_SIMPLE_TYPE(PVPanicPCIState, PVPANIC_PCI_DEVICE) + +/* + * PVPanicPCIState for PCI device + */ +typedef struct PVPanicPCIState { + PCIDevice dev; + PVPanicState pvpanic; +} PVPanicPCIState; + +static const VMStateDescription vmstate_pvpanic_pci = { + .name = "pvpanic-pci", + .version_id = 1, + .minimum_version_id = 1, + .fields = (VMStateField[]) { + VMSTATE_PCI_DEVICE(dev, PVPanicPCIState), + VMSTATE_END_OF_LIST() + } +}; + +static void pvpanic_pci_realizefn(PCIDevice *dev, Error **errp) +{ + PVPanicPCIState *s = PVPANIC_PCI_DEVICE(dev); + PVPanicState *ps = &s->pvpanic; + + pvpanic_setup_io(&s->pvpanic, DEVICE(s), 2); + + pci_register_bar(dev, 0, PCI_BASE_ADDRESS_SPACE_MEMORY, &ps->mr); +} + +static Property pvpanic_pci_properties[] = { + DEFINE_PROP_UINT8("events", PVPanicPCIState, pvpanic.events, PVPANIC_PANICKED | PVPANIC_CRASHLOADED), + DEFINE_PROP_END_OF_LIST(), +}; + +static void pvpanic_pci_class_init(ObjectClass *klass, void *data) +{ + DeviceClass *dc = DEVICE_CLASS(klass); + PCIDeviceClass *pc = PCI_DEVICE_CLASS(klass); + + device_class_set_props(dc, pvpanic_pci_properties); + + pc->realize = pvpanic_pci_realizefn; + pc->vendor_id = PCI_VENDOR_ID_REDHAT; + pc->device_id = PCI_DEVICE_ID_REDHAT_PVPANIC; + pc->revision = 1; + pc->class_id = PCI_CLASS_SYSTEM_OTHER; + dc->vmsd = &vmstate_pvpanic_pci; + + set_bit(DEVICE_CATEGORY_MISC, dc->categories); +} + +static TypeInfo pvpanic_pci_info = { + .name = TYPE_PVPANIC_PCI_DEVICE, + .parent = TYPE_PCI_DEVICE, + .instance_size = sizeof(PVPanicPCIState), + .class_init = pvpanic_pci_class_init, + .interfaces = (InterfaceInfo[]) { + { INTERFACE_CONVENTIONAL_PCI_DEVICE }, + { } + } +}; + +static void pvpanic_register_types(void) +{ + type_register_static(&pvpanic_pci_info); +} + +type_init(pvpanic_register_types); diff --git a/include/hw/misc/pvpanic.h b/include/hw/misc/pvpanic.h index abc9dde..ca3c5bb 100644 --- a/include/hw/misc/pvpanic.h +++ b/include/hw/misc/pvpanic.h @@ -18,6 +18,7 @@ #include "qom/object.h" #define TYPE_PVPANIC_ISA_DEVICE "pvpanic" +#define TYPE_PVPANIC_PCI_DEVICE "pvpanic-pci" #define PVPANIC_IOPORT_PROP "ioport" diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h index 259f9c9..66db084 100644 --- a/include/hw/pci/pci.h +++ b/include/hw/pci/pci.h @@ -107,6 +107,7 @@ extern bool pci_available; #define PCI_DEVICE_ID_REDHAT_PCIE_BRIDGE 0x000e #define PCI_DEVICE_ID_REDHAT_MDPY 0x000f #define PCI_DEVICE_ID_REDHAT_NVME 0x0010 +#define PCI_DEVICE_ID_REDHAT_PVPANIC 0x0011 #define PCI_DEVICE_ID_REDHAT_QXL 0x0100 #define FMT_PCIBUS PRIx64 From patchwork Wed Jan 20 10:31:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mihai Carabas X-Patchwork-Id: 12032057 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 67E51C433DB for ; Wed, 20 Jan 2021 11:20:34 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id AD61222AAA for ; Wed, 20 Jan 2021 11:20:33 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AD61222AAA Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:55742 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l2BXL-0002Jh-Ra for qemu-devel@archiver.kernel.org; Wed, 20 Jan 2021 06:20:31 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:46144) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l2BW4-0001UF-D8 for qemu-devel@nongnu.org; Wed, 20 Jan 2021 06:19:12 -0500 Received: from userp2130.oracle.com ([156.151.31.86]:56006) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l2BW2-0001cl-4O for qemu-devel@nongnu.org; Wed, 20 Jan 2021 06:19:11 -0500 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 10KBFWXr004401; Wed, 20 Jan 2021 11:19:06 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2020-01-29; bh=3jkOSU73no9c1wvY97sdyMJOwxj1A1nBsaPRtYSJqiU=; b=hLHTFJ7GTmPSLfHeSNfI6UB92RmQNAJxMEOKTIzPvbCGJEo4ghPWq2bKyK5HZ2Mo9QjJ 8Qk+RWL0uwjCJEUfiQhzcUi9teri9RrEWtS3znB/r4/2stRt/UVHdqKxBQ96FyR6YEVp SDduxtP8W3bqjzo2Yabm/S0zTT38cI0KRVQelCJGjqLaW9Bl446We2Kkqtn8P3n62m4c yHerou1Q9zgYclIiz1yC1+2yM0AHoNG0a2+GgsXIEOxIEA2QqkJn88oF4g9XVJsD6s8Y hNTtcIDUL1EZmcIf8vfbeGLIh8O8EgQoA0CyO/+7AIM2pIjzvE13NjHS2Bbh9gTc5vK2 hQ== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2130.oracle.com with ESMTP id 3668qa9yt3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 20 Jan 2021 11:19:06 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 10KBFfTl046064; Wed, 20 Jan 2021 11:19:05 GMT Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2108.outbound.protection.outlook.com [104.47.58.108]) by userp3030.oracle.com with ESMTP id 3668rcvsuc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 20 Jan 2021 11:19:05 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=a+yW6xgiCT4zmyoU3xiVpbZgUpGnUQxfg2l4c/c5EPtmMM0POShIIsMSym9cQ+azzi7xM1Y5jKz2sdkMUO1hh2ppFSZ4+M5Hv7JUHvj1h4AHpprKx8uPVC3USwjK0sjY5N9Pnhlu0gBF1EnJjjknN7suOLeoni8W72gP48GBK5atYx+PKDSGmJEinYeEETqEIdO3J5c1hHp9x/1bOLc6K5WOpYq4wD7Y3GI98z5rOVXiBJlFyzvYmiqc7nVxjeNFE8TTs3tWW4tfdgKjJMtTEJsUh3e5/El6uOu1PsanC5llsijAdcZEghofeLHtSj91yHhkKr01u/O5Ddsz8FvVdQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=3jkOSU73no9c1wvY97sdyMJOwxj1A1nBsaPRtYSJqiU=; b=YMxYtlT8+fLG5j7VyHhp9f6I0Fg9Gs1JXJ9WBh1AuvcBT8MGimZCubjayKrTHB7LXv8KGwSGWXs8i+/lNrJrjKaleRU+utkoU2SUg8Cg+Q7za4aDWcCylPXgFGbNAG1DtetDDCUwt/s43aOYM5Rn3JUJq4WU2eDiTl4/LyRQJU0GBiKPwQaFoqj9Qk7XZfdWwn1ZR0smpvT4genxDzVb39s7MiCu7pGMwpEFYH6kRPzEgKHKhjs7ViBQwziYnZc0JqLv1fQ9RtGFBEk1T3M8KvAJC/nv6xBveujLqBw1jFDlPmk4vOh0Ug+SWr6fTfYZRsmphu62q4rtplJmUlI+wQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=3jkOSU73no9c1wvY97sdyMJOwxj1A1nBsaPRtYSJqiU=; b=ND+hlOQgb0w4SeB2H7AfegVp/NiLOKL8Ob52N79Xq6KBPINdfEa6wCKlCfXDXX0TsJDondDl6uy7A40gbPU2/FvwNna1GqgDz+P+KBFKlOrH/kQryG3wewrZrePRV27zCt5ZWAK/Wnxr8Cqbf4Y+POaxyczYHYK+8W/l6FlND7s= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=oracle.com; Received: from MWHPR1001MB2285.namprd10.prod.outlook.com (2603:10b6:301:2e::32) by MWHPR10MB1342.namprd10.prod.outlook.com (2603:10b6:300:1f::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3784.12; Wed, 20 Jan 2021 11:19:03 +0000 Received: from MWHPR1001MB2285.namprd10.prod.outlook.com ([fe80::f48a:d4cb:d74c:48ba]) by MWHPR1001MB2285.namprd10.prod.outlook.com ([fe80::f48a:d4cb:d74c:48ba%6]) with mapi id 15.20.3742.014; Wed, 20 Jan 2021 11:19:03 +0000 From: Mihai Carabas To: qemu-devel@nongnu.org Subject: [PATCH v4 3/4] pvpanic : update pvpanic spec document Date: Wed, 20 Jan 2021 12:31:56 +0200 Message-Id: <1611138717-1672-4-git-send-email-mihai.carabas@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1611138717-1672-1-git-send-email-mihai.carabas@oracle.com> References: <1611138717-1672-1-git-send-email-mihai.carabas@oracle.com> X-Originating-IP: [138.3.200.25] X-ClientProxiedBy: SN6PR16CA0062.namprd16.prod.outlook.com (2603:10b6:805:ca::39) To MWHPR1001MB2285.namprd10.prod.outlook.com (2603:10b6:301:2e::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from mihai.localdomain (138.3.200.25) by SN6PR16CA0062.namprd16.prod.outlook.com (2603:10b6:805:ca::39) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3763.10 via Frontend Transport; Wed, 20 Jan 2021 11:19:02 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 00d0995c-36af-46ab-8fb8-08d8bd35316d X-MS-TrafficTypeDiagnostic: MWHPR10MB1342: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8273; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: BGtKKGanrx3Ghhm0lyYyRi0+nHZLB75QiuqorN0W8nMTD3dJ4XZWUa3g/MWrIk/2dNJPyRe3NXr3A7FfaS6UtUTlTCeMXp7PJUF7lZJUsUXOODDOUvt9H95wF4oR7zAoTvokylEPq+4eBkrX2MUXiIlKk9/IfnNkbE3L913rm7Y3JGcFfN1AegrwOUaxgtewbxZ4oLiUCWX3x1q3igKaUA7rO+70gozyzz3lO5DYdpqrOYCM9/tgHX+bQ8WhZoq/+LkgSCMDwl10+Kr3BaeJ6QW1yR75kQT0VRXAs6H3q52rNlvBG4kO6YZGoS3knIFi+8oJPUAMyQ0zyM+6DzqlnTOLmoIU1Cy4XhVA1/48iEQvQS8kTzLdhplTQ2eGvhStqT1u8uAQ6/F148vpA9lICw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:MWHPR1001MB2285.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(346002)(39860400002)(396003)(366004)(136003)(376002)(6486002)(16526019)(6666004)(8676002)(36756003)(2906002)(86362001)(83380400001)(107886003)(6506007)(6916009)(316002)(8936002)(5660300002)(956004)(52116002)(66946007)(44832011)(478600001)(2616005)(6512007)(66556008)(4326008)(186003)(66476007)(26005); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: P/nX7d5ulfTjZlzUQlaW7PbVQrDjkVwaCW3+jBlIoeewjFfWCo4K108K7b9fTEU5PCajodMZVZm2t109TfiUIrRh6yLD6JFMM5nxulZaNmStPFxYUtrJAAgjiuViWPlNFuq48ZDJENuBkXjMZC2ObOiBs7RIpXZtAVgWcwQaB4S9cGcUV4acBKmBJw87qjPE+5R85IqVwqRYpyjhOuZvKIBXuZSZkygXRS/jPgdnRFwgq0yd9UGDmCwRyeuz4cP1YuDPCVsneiMMb2H38YcN12EJIEmpaCiuwEgoxocow357JFct+rVnr232As4CFAaDyoaRxdFnR1ArVy/jGNbhael5aX/uAtUXoYeq7KUgHUVE4m5ZzXo3spUsHAn5DZPNA1QowVPKkT3jTZ1mxbIEeq1zjJ/MyLCCdNxJOKa/vcvP26p8wlJSj+4Bw9/7GalA2W2E7CVCor7xEG/e+hzX65glP7LqkMdWodLQRzCqOYt2ZrV7LN8a3VR/L2pbYq5TPNLdj3523bjlHOZZfbk+rvFpSGmwf5t0Luww9dqMjmJDOnfW75+C4vxwa9/4gAWy6na/AYGTR64OyO7wPr2JaNSVHNfvafYRxdluNnSuxduYhg21Wdn/Yq3yzK1MA6OPvRNXLT5aOS+Q8ZCqY1UOrIFDgRycLkG1wXi/mirX5oDc+CYeLvaWRsVFEEu0vR5bqkas3KYzcsD/08Ob29Sc/0VQSb3G82N8csw3c5ERri8nTuG4EJoRbuCrIuqss95qdKbVHeB39W1Ad0poMzsqkb41/ON2B4RjZlZYmKCJgMhISBgpvrpmhRdhVBS7XVmp1SVdqoExXDF4ErVjEtxfeeOL6PmI8fRRGgydhojuHiCFrMP0Vt+KdpecqmChWSWanEfz8xU0rnqRf0A/iGNVmEjnD3vj/t+bRSQoe+TdTanByTyXI7ep6zsPWiZQhn27sQHf8DznCeUsf9/v1J6o6EcI2khz5391pclkOn8sQLo= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 00d0995c-36af-46ab-8fb8-08d8bd35316d X-MS-Exchange-CrossTenant-AuthSource: MWHPR1001MB2285.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Jan 2021 11:19:03.7212 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: OPieN3V7BJkCMALIC0unUWCPS+ZvTkgScCyIzWOcQcew2SrtA1MnENKbjP4L3T57MqA+SbEa79g6erOYe03TzNh4Aw+/hxMhqpmyIa/Tru4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR10MB1342 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9869 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 mlxscore=0 spamscore=0 suspectscore=0 phishscore=0 adultscore=0 mlxlogscore=999 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2101200066 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9869 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 spamscore=0 impostorscore=0 mlxscore=0 priorityscore=1501 phishscore=0 mlxlogscore=999 lowpriorityscore=0 malwarescore=0 adultscore=0 clxscore=1015 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2101200066 Received-SPF: pass client-ip=156.151.31.86; envelope-from=mihai.carabas@oracle.com; helo=userp2130.oracle.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mihai Carabas , peter.maydell@linaro.org, kraxel@redhat.com Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Add pvpanic PCI device support details in docs/specs/pvpanic.txt. Signed-off-by: Mihai Carabas Reviewed-by: Peter Maydell --- docs/specs/pvpanic.txt | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/docs/specs/pvpanic.txt b/docs/specs/pvpanic.txt index a90fbca..8afcde1 100644 --- a/docs/specs/pvpanic.txt +++ b/docs/specs/pvpanic.txt @@ -1,7 +1,7 @@ PVPANIC DEVICE ============== -pvpanic device is a simulated ISA device, through which a guest panic +pvpanic device is a simulated device, through which a guest panic event is sent to qemu, and a QMP event is generated. This allows management apps (e.g. libvirt) to be notified and respond to the event. @@ -9,6 +9,9 @@ The management app has the option of waiting for GUEST_PANICKED events, and/or polling for guest-panicked RunState, to learn when the pvpanic device has fired a panic event. +The pvpanic device can be implemented as an ISA device (using IOPORT) or as a +PCI device. + ISA Interface ------------- @@ -24,6 +27,14 @@ bit 1: a guest panic has happened and will be handled by the guest; the host should record it or report it, but should not affect the execution of the guest. +PCI Interface +------------- + +The PCI interface is similar to the ISA interface except that it uses an MMIO +address space provided by its BAR0, 1 byte long. Any machine with a PCI bus +can enable a pvpanic device by adding '-device pvpanic-pci' to the command +line. + ACPI Interface -------------- From patchwork Wed Jan 20 10:31:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mihai Carabas X-Patchwork-Id: 12032103 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 19A77C433E0 for ; Wed, 20 Jan 2021 11:23:04 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 7C8F72250E for ; Wed, 20 Jan 2021 11:23:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7C8F72250E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:34082 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l2BZm-00055r-It for qemu-devel@archiver.kernel.org; Wed, 20 Jan 2021 06:23:02 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:46158) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l2BW5-0001UW-MW for qemu-devel@nongnu.org; Wed, 20 Jan 2021 06:19:13 -0500 Received: from aserp2120.oracle.com ([141.146.126.78]:34112) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l2BW3-0001e6-CP for qemu-devel@nongnu.org; Wed, 20 Jan 2021 06:19:13 -0500 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 10KBExBV154620; Wed, 20 Jan 2021 11:19:09 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2020-01-29; bh=rCHHXbAp55ez5jmCCjUYEeruZ/HR+xMgHAD+Ph8lUlc=; b=Vj8BCIH01SoPk+IL06F4vxad+GcddW5+ocwicSrl6coWqk5tC9cZF2PiKpJwb4JK3WsQ qnvUx+FCqkv3KdhjfGR27EfsjNYwjwbClI/SikltRIEcoSqby+yZ925PKQnEbrf+obJX 3wodfVyjuJrN2bvco+oDoowf7VoIxEWsrw6iAYhqcw5sbGLvs1h8uhKV9SWFllxr9/Kx R4zfskCRahgDVzeNiooIHJBXvvTXjkpM5p6rErgwjUAEH/ZNRjY7eC4dBf7O7t5ymR8X tejMDWJPn1u5H77QPvheIQXa5I0X5YRK8rFdpwo6BewkuaLosBR/HTjgHM0Jb97MoFOy tQ== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by aserp2120.oracle.com with ESMTP id 3668qmsy2q-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 20 Jan 2021 11:19:09 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 10KBElV3010856; Wed, 20 Jan 2021 11:19:08 GMT Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2102.outbound.protection.outlook.com [104.47.58.102]) by userp3020.oracle.com with ESMTP id 3668qw0cuu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 20 Jan 2021 11:19:08 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nLzYJX81S8sXHth4RP0Zal5YPi2JAcSRj3yHrpQeoUL/Uf2kOIryolTeR39OF4ro7cEdq2b+BhinbP+/Cy3dNU0901OSvJ/zZlOfE6NcKZ9QrfFNfcGiEy3x2fuoWYhBPPHwTbJwIkCl97dAQVx58DqLpVFaSQLKE6cwuaKRymyr7FrmRqfI4ztOhHsP/Wt7CXzxutgvrM4fMzLDxNHKRvaFC1nnKZTQjiLq6IzJtPX3Hd8Meq/0lhNjA6/b8WE3gRz24iy94qNzRs6NSju2R6w1H2AuISSbcJCA0CCRBA3FKz8sTuWZSVEVYjHsUxDt8yt3EJGmSkmY65nMNODZ2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=rCHHXbAp55ez5jmCCjUYEeruZ/HR+xMgHAD+Ph8lUlc=; b=S8mbvcwMwQnGitdiX3fq8CUhA8B8z8ZVjrgdNCj4rsg3/yXi0yH2RMv962upLoa9C+eflsiivHrjAB8pF5ItH6UVYvHhGjGu2NixyYwgN5FDyLAje2+Ea7DtYvW8ybxlDwX7FpqYqKL+upRNVotwdApSo0Tz4SPAkkXpikkHgYA6FAe4dAG+Cg38qlKQlh3Hkvhm2zph6jdxP9r5IYVsjldsVaZY28TrIjHt+4XPCVEbq0Azp+EKiLrdC50YevyOrFFJo3JsxoGTp7go8tVhsZLslBVi+Ot5QD6eodK3rgk1ycqCJMFLsHAzQLMUGKZb5lWHZYgUOXAJybed2z8HcA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=rCHHXbAp55ez5jmCCjUYEeruZ/HR+xMgHAD+Ph8lUlc=; b=cP3FiRN2nOznrnJzWvLXLiVLzjk3YwVZPb3Gbw+HgzG6Gf8HKzcW4fkgsscWOTTs8BIw0Wxbz0hdbWtVCsx9Fz41757WVgprQuXNmgQXFA5hjAEjt/f43XKTGJM20WAyCJvXYvnNNHuqWoT1Nsi5SoqcgBH+GdeBqHqXvgKQKEM= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=oracle.com; Received: from MWHPR1001MB2285.namprd10.prod.outlook.com (2603:10b6:301:2e::32) by MWHPR10MB1342.namprd10.prod.outlook.com (2603:10b6:300:1f::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3784.12; Wed, 20 Jan 2021 11:19:06 +0000 Received: from MWHPR1001MB2285.namprd10.prod.outlook.com ([fe80::f48a:d4cb:d74c:48ba]) by MWHPR1001MB2285.namprd10.prod.outlook.com ([fe80::f48a:d4cb:d74c:48ba%6]) with mapi id 15.20.3742.014; Wed, 20 Jan 2021 11:19:06 +0000 From: Mihai Carabas To: qemu-devel@nongnu.org Subject: [PATCH v4 4/4] tests/qtest: add a test case for pvpanic-pci Date: Wed, 20 Jan 2021 12:31:57 +0200 Message-Id: <1611138717-1672-5-git-send-email-mihai.carabas@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1611138717-1672-1-git-send-email-mihai.carabas@oracle.com> References: <1611138717-1672-1-git-send-email-mihai.carabas@oracle.com> X-Originating-IP: [138.3.200.25] X-ClientProxiedBy: SN6PR16CA0062.namprd16.prod.outlook.com (2603:10b6:805:ca::39) To MWHPR1001MB2285.namprd10.prod.outlook.com (2603:10b6:301:2e::32) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from mihai.localdomain (138.3.200.25) by SN6PR16CA0062.namprd16.prod.outlook.com (2603:10b6:805:ca::39) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3763.10 via Frontend Transport; Wed, 20 Jan 2021 11:19:04 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 786b6e64-4537-4014-5487-08d8bd353284 X-MS-TrafficTypeDiagnostic: MWHPR10MB1342: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3826; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: SKcd3nwiufktJeKBwQ5JUzF9E7eP+I+38V4fQMd8yJk4k5ZnS8+LaOnXW6qP6OrHMt4+4FZ7CpLxq9jh97mz7at9ucCARyrXaVNbUGHTL7+PO94rotb7qxXMavfjuyr7hdZ4W4t+/T6KZdGXVauio8B3povP/nqxd0AsXXKR1a//S45rQ6b8QUWQ1N3oMMpYV17vVy4iJWO3DRYSfZ7spp66q3fRmDfs50TdbqKyKPuObKfa17kX1l8SOSd8qJwy3hx9xvWpGB8eInUuTx0hbbHtUT1kDol1DA432yMDHwAsmTYQYoF9YwFK0fcTYcLjq8KN2r78DQm00Xltwjg0YTH78hTRqDSo4w/2S2aO5LRTxtEUg1Bzf/meAjVSPxj5PpkZYqG5DF7YOTpFCWBnwQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:MWHPR1001MB2285.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(346002)(39860400002)(396003)(366004)(136003)(376002)(6486002)(16526019)(6666004)(8676002)(36756003)(2906002)(86362001)(107886003)(6506007)(6916009)(316002)(8936002)(5660300002)(956004)(52116002)(66946007)(44832011)(478600001)(2616005)(6512007)(66556008)(4326008)(186003)(66476007)(26005); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: Qom3B4bpbWlUI+PfGvYtmFijM3hZWPQ25AdR9DmEDuyAFWR9JULU+FjlpdmkvHHE+juNOmV1Z0j3TRS6mGz0I6CPmQLiAT8JkBUOA6OifMhQ6TCr3uF0jodWsfJX8sB9JMbzmJ5VwoSkhEFOrlSvyCynbLNa45ZCSZWfAVe73R4jV8F6A5BohjPrnK3dlpykMHzUfnZ7Fhpif1fhwqlkRbzScHj/+eZgjRKu4I3UzQhAw+eduVt2Ux9XHsb/G11JSLpv8DyNVreir4C8Y+ny7y+NIqjJb+z+YVvvWo0HqbdJHWlwGD1LP7DOj0IN62gu9c1jtjeKAU5ccOXQQpLCOrY+ENKSCldfbWBGbjkGJE+fspptDhulZL34a+FtZjRjuUhY7HBwWU0mv3Wk9Seef6NtjdlzvCvZGqGkJbAUiutORnJ83AVtEF6H8kejaCZD8lbkXLl0XiLmiOlfyWGxuS1Qm2XT3C9WgWmSXYipKSGJ1tlPgu99P/4fFdEbHud4UECoXzrv3WfyV02qznMXaS7o3T9/iCi47bXEQHm0ti+UwcO2vN7hXLeRnKdlvHPzjaWiFqCRWaTgqRVgtxeyBdDaWEYcvQrxdHoWLqnu3yHTfxIbfWLpF6h2TFsEYfk73vlTvsrjGvVjNRUoMT+SQh5L8yEXwXePN85RFoaT3JCzevgJ9la/CghNYq/b87rKjISdH2klcjnIOZw/V7/kl7mvRQpAoMBGZ+tHJrP7IDETpoeiooNk+wJUGYeXPkZJ/yY8XorpWPL5vzSr80/6n5wjairBZoSuXmDmjRfzqCYq4GB+d64sZBxI6rTmi95P5qkfTxjmvo7DfKXqalGIgDFIqZyW0MrWQAwKntS/0W3g7GX7xuwEpr6dmCBq/+b9DX0xf+sIF8vXrKMzfyYFs8CUcZ86iALUijDBxThVLyDdJid8dj9JRh9JKF4u9B4ehhqKrJ53IP5GQgXPi3+vsSH3dalwJVLuLq13pZRQ5k0= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 786b6e64-4537-4014-5487-08d8bd353284 X-MS-Exchange-CrossTenant-AuthSource: MWHPR1001MB2285.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Jan 2021 11:19:06.4846 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: fcOihH5uBJVJCGnwK+HJ9/jwA7jTzTaCxjCcvtTXaHVamZ5k+6PsVOi5reT4eAeVMCkw8V1SLxzQ3AwaeQUbgtxHL6ji4oVgqmGJ0bcHzq8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR10MB1342 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9869 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 phishscore=0 adultscore=0 malwarescore=0 mlxscore=0 mlxlogscore=999 spamscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2101200066 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9869 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 priorityscore=1501 adultscore=0 impostorscore=0 mlxlogscore=999 spamscore=0 suspectscore=0 phishscore=0 clxscore=1015 bulkscore=0 mlxscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2101200066 Received-SPF: pass client-ip=141.146.126.78; envelope-from=mihai.carabas@oracle.com; helo=aserp2120.oracle.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mihai Carabas , peter.maydell@linaro.org, kraxel@redhat.com Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Add a test case for pvpanic-pci device. The scenario is the same as pvpanic ISA device, but is using the PCI bus. Signed-off-by: Mihai Carabas Acked-by: Thomas Huth Reviewed-by: Peter Maydell --- tests/qtest/meson.build | 1 + tests/qtest/pvpanic-pci-test.c | 94 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 95 insertions(+) create mode 100644 tests/qtest/pvpanic-pci-test.c diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build index 0e85343..12e456c 100644 --- a/tests/qtest/meson.build +++ b/tests/qtest/meson.build @@ -20,6 +20,7 @@ endif qtests_pci = \ (config_all_devices.has_key('CONFIG_VGA') ? ['display-vga-test'] : []) + \ + (config_all_devices.has_key('CONFIG_PVPANIC_PCI') ? ['pvpanic-pci-test'] : []) + \ (config_all_devices.has_key('CONFIG_IVSHMEM_DEVICE') ? ['ivshmem-test'] : []) qtests_i386 = \ diff --git a/tests/qtest/pvpanic-pci-test.c b/tests/qtest/pvpanic-pci-test.c new file mode 100644 index 0000000..3379970 --- /dev/null +++ b/tests/qtest/pvpanic-pci-test.c @@ -0,0 +1,94 @@ +/* + * QTest testcase for PV Panic PCI device + * + * Copyright (C) 2020 Oracle + * + * Authors: + * Mihai Carabas + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + * + */ + +#include "qemu/osdep.h" +#include "libqos/libqtest.h" +#include "qapi/qmp/qdict.h" +#include "libqos/pci.h" +#include "libqos/pci-pc.h" +#include "hw/pci/pci_regs.h" + +static void test_panic_nopause(void) +{ + uint8_t val; + QDict *response, *data; + QTestState *qts; + QPCIBus *pcibus; + QPCIDevice *dev; + QPCIBar bar; + + qts = qtest_init("-device pvpanic-pci -action panic=none"); + pcibus = qpci_new_pc(qts, NULL); + dev = qpci_device_find(pcibus, QPCI_DEVFN(0x4, 0x0)); + qpci_device_enable(dev); + bar = qpci_iomap(dev, 0, NULL); + + qpci_memread(dev, bar, 0, &val, sizeof(val)); + g_assert_cmpuint(val, ==, 3); + + val = 1; + qpci_memwrite(dev, bar, 0, &val, sizeof(val)); + + response = qtest_qmp_eventwait_ref(qts, "GUEST_PANICKED"); + g_assert(qdict_haskey(response, "data")); + data = qdict_get_qdict(response, "data"); + g_assert(qdict_haskey(data, "action")); + g_assert_cmpstr(qdict_get_str(data, "action"), ==, "run"); + qobject_unref(response); + + qtest_quit(qts); +} + +static void test_panic(void) +{ + uint8_t val; + QDict *response, *data; + QTestState *qts; + QPCIBus *pcibus; + QPCIDevice *dev; + QPCIBar bar; + + qts = qtest_init("-device pvpanic-pci -action panic=pause"); + pcibus = qpci_new_pc(qts, NULL); + dev = qpci_device_find(pcibus, QPCI_DEVFN(0x4, 0x0)); + qpci_device_enable(dev); + bar = qpci_iomap(dev, 0, NULL); + + qpci_memread(dev, bar, 0, &val, sizeof(val)); + g_assert_cmpuint(val, ==, 3); + + val = 1; + qpci_memwrite(dev, bar, 0, &val, sizeof(val)); + + response = qtest_qmp_eventwait_ref(qts, "GUEST_PANICKED"); + g_assert(qdict_haskey(response, "data")); + data = qdict_get_qdict(response, "data"); + g_assert(qdict_haskey(data, "action")); + g_assert_cmpstr(qdict_get_str(data, "action"), ==, "pause"); + qobject_unref(response); + + qtest_quit(qts); +} + +int main(int argc, char **argv) +{ + int ret; + + g_test_init(&argc, &argv, NULL); + qtest_add_func("/pvpanic-pci/panic", test_panic); + qtest_add_func("/pvpanic-pci/panic-nopause", test_panic_nopause); + + ret = g_test_run(); + + return ret; +}