From patchwork Tue Feb 8 07:22:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elena Ufimtseva X-Patchwork-Id: 12738322 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 81743C433F5 for ; Tue, 8 Feb 2022 08:35:38 +0000 (UTC) Received: from localhost ([::1]:43480 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nHLyK-0006NN-RD for qemu-devel@archiver.kernel.org; Tue, 08 Feb 2022 03:35:37 -0500 Received: from eggs.gnu.org ([209.51.188.92]:54002) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nHKpt-0001xM-93 for qemu-devel@nongnu.org; Tue, 08 Feb 2022 02:22:49 -0500 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]:41988) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nHKpk-0001vF-St for qemu-devel@nongnu.org; Tue, 08 Feb 2022 02:22:47 -0500 Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 2183uKZp026741; Tue, 8 Feb 2022 07:22:35 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-transfer-encoding : content-type : mime-version; s=corp-2021-07-09; bh=cArrDJ+HuxvseF230tWDHY1+lCkYH+jYAhnBaj1w0Ks=; b=RAWKqFnA3gFfSTjeYxBugsoLA2SB42fsbwRLH9pnuELZZCfF9FIzwy0Gza4iE89bi4/b xHDk6QwVeBgJ/d9Yf8873qIDL3vKsEkYyrfV++v5Qs0SWNVtXbyjM1ZKL5LdhTnT9tAy RIb7EIHp7zYzey0WITTumgAeqiMXYnK6VlQmwZ9cU3l5XY2/94a6onnOYtl3HYIi2gCU z25t8WOUEeB4aFMpSNxYm89jznS2j1yeDwTURPESJdwxhEiHPZx+TajWUvwUW2ncyPgM W6CqLxsLANxtb/5xrQ0SPZHlTTTwXHnRwDHmW7mRUBOzKxxsbnQjDyvp6Uaq5UOe+Frp aQ== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by mx0b-00069f02.pphosted.com with ESMTP id 3e3h28ge7g-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 08 Feb 2022 07:22:35 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 2187BlYn093365; Tue, 8 Feb 2022 07:22:34 GMT Received: from nam10-mw2-obe.outbound.protection.outlook.com (mail-mw2nam10lp2104.outbound.protection.outlook.com [104.47.55.104]) by userp3030.oracle.com with ESMTP id 3e1ebykknc-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 08 Feb 2022 07:22:33 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=goq+0qG9rhsKJtJH01YGlC9LbLRLm20TZQjjvRm0C1WGFyiL+bZLj8YWTkNQGK8Gn4eXO4wPpecku4dVMRVhlTMteMQruUKFtpsFjR5IgQWjggw1drzjGYWj6EBifp9z1cl9lG/8wW0YQRxGA3S1TN7AQHvAKMuxH3L4zU+ZGWW9YPIHqDMzL1RiJCUO1ofl9FR3FhpanHfcTFJNm0MQZDNQ8jjlsiTJWikMlAcC1E7HHpFr3LnAZcfTBpIuYUvgbLaXFcdR3Jxc9rQPNzBsv6wyLDf7Y7e/TAwEbwgvno/9k5NyarBJciLUdMg/KpiiY+FpZur2VMO1BpCm1z38iA== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=cArrDJ+HuxvseF230tWDHY1+lCkYH+jYAhnBaj1w0Ks=; b=XcjRu3o0g9Y5kXYrC7FIAZ8TJ/Xox+18L5eNjg6NOIL39yBO+V9i474aHa5OHNPI2VihHzSMu2WiMRxLZcAykKX4by/j+vgO4MwFdDOqs4asJpxbBCAccRUC4a0672BT4Qsh9ltbb19AWx9eOHVpLvciV+oR8uKzn4kWIO5WuDhHrI2YjbUZvqKxRy9vMnQfCNnJHYLXAzC7EDYEauseIydvWVXpwd3fY/UoLHx19P4gTDigO3kDCC3ChjpiIa42TttPj1a8QjFkwFnDDcYyXiRnUCFp9aFGP7fJsqf45vwPvK3N7S2PiZxZHImNIpghosebXlvuyqiwdQUoJmr81w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; 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=cArrDJ+HuxvseF230tWDHY1+lCkYH+jYAhnBaj1w0Ks=; b=alAQjQHnrH1zdTMuO05IgicLxzaxHTb/UR8Jwly5Zc42qyZqYoZTxfXdURH1Xj9YEy5yOpP7IFe5+GVIsFu8cz7QaRNejNbXHPrqH/CAEQlFexOALifANJ5t+GbKbmfjxtI3WoON5e+mHzZFERREbUJRUh5WbiardUUChV7YGqo= Received: from BYAPR10MB2869.namprd10.prod.outlook.com (2603:10b6:a03:85::17) by SN4PR10MB5608.namprd10.prod.outlook.com (2603:10b6:806:20b::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.18; Tue, 8 Feb 2022 07:22:30 +0000 Received: from BYAPR10MB2869.namprd10.prod.outlook.com ([fe80::4bd:1cfa:5aee:6c81]) by BYAPR10MB2869.namprd10.prod.outlook.com ([fe80::4bd:1cfa:5aee:6c81%3]) with mapi id 15.20.4951.019; Tue, 8 Feb 2022 07:22:30 +0000 From: Elena Ufimtseva To: qemu-devel@nongnu.org Subject: [RFC 1/8] ioregionfd: introduce a syscall and memory API Date: Mon, 7 Feb 2022 23:22:15 -0800 Message-Id: <6001ed71ebe40c88e9d903bf0983884f522b2dea.1644302411.git.elena.ufimtseva@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: X-ClientProxiedBy: BY5PR16CA0006.namprd16.prod.outlook.com (2603:10b6:a03:1a0::19) To BYAPR10MB2869.namprd10.prod.outlook.com (2603:10b6:a03:85::17) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 00b67e84-db89-421b-7d15-08d9ead3c463 X-MS-TrafficTypeDiagnostic: SN4PR10MB5608:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:166; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: livXpfPaiz4Lhdc3+9BMC+lmBl7GBm9FUHt/uCOqhtt3wy26uxogIcm+o0pRk4a3bR40W4gpYiqOJ92+pNsX2ci+5MkdOuZD+UqJhO+drdVmLNP9uLN0y7ysWBpnf5xuTWgQnfvMM+SmQ3MzMTBbm1u9NVKsXdj71wNfQ7F/zjwzyw5x1z9hFkL0Yf8XY1vmsvwGiLDpI0BvxWEcXFAmcH0xQgj+HrjOiW9Dl1l/lEQUHedCaV1OETyJBn1MqrzVokaHnktaJynhQGprKg9PVLTMtAZ/HJEC336XhjK6gdKytJPagFqQhKr4/I8X4mqQIag/KC0pyU55A3qP93cm/o8oRxIzSHO2amIJIZniLA9ZBsw/yxYDT6DZQ3mdPWQyW62W4oQft6gE/u6mLSkuApoKbXcygI3z9320zUpiZJGT/b2thgkNldIL6Am6AP6V6xCoVj/eP6otTi4qSuC9DxPwpfKBO6KSdmUTr8ntr6wfvIcSN88U68Zx19wtkefQHnOtpbw/EMAOOwspSSetsU8Dcb1xc2AuAGpUz7bds0Ev0A1hraBLeOGjokbX7R+r0JHB6KcSIKUSyzohcYy+W7l6pG+gbfJyvLsavcqrGYCwJ5BUGBHB7I7qjhmODW3HEZ7gK/sG1jjRGef4Yp9GDw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR10MB2869.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(366004)(6512007)(36756003)(83380400001)(186003)(38100700002)(86362001)(5660300002)(7416002)(2616005)(30864003)(6486002)(44832011)(508600001)(6666004)(8676002)(4326008)(52116002)(2906002)(66946007)(66476007)(6506007)(66556008)(6916009)(316002)(8936002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 8pdG7PN1ZMq2WNuMPFjh/+cgBaxmD3rU6rDGGuOEFz4j43WwN5mU74DdHOIOwpnGawIcdQ55GwO7Q3y7NeGtrD0dPGQSu4+m/xTVdlwXJAJZcr66qHYsuSqjqpN2d6wHYKlECIQ3KLLCnxJ1evWVxm1YW0W3E77H9DUCLCH+zts61OTjsv5XSuaidMZ52ST3eus+8a8kbLV75apHOJJGW+Vcdbj+tqjOSGV2aGGSVBQCsEf8W3fg6ssH+DioOcs6XCvyxbqyDuONewullJ1qRjjTfsMOS01EluNFJh8jOeUpxBQl/qiMA2coYpgUtJ7xlCsNWWURMzf14cZ/zyK9HgzH9eW2zNFOrEATGF85n2KqLiXoH45dlW3cDSXyYnOsX5Krn33z10VBlodpK+H26FJfQxEv4ndIreFPHZTOGdM8zXZh0dvmASzodUm8MNV8CqLWO41tjd8QoAMSY+eVips+AVPduzqkwQhN6m7ikAu8HiPnWtVcoNRWvfp0Pc+HBpK9WvQOwjyKg6qS5NNnwQYrBBR2k+N3HPZfwGDaVShfm63rZgH6GwtO1iTwfzXsz4tirJ0kq3sjtr+SIMH4Tv3MOOHSHaEPACebB3dqe/gwV6RwWqc249Inn5H7UOUuwefvo5mCtw69DrAPsnb884SBgCnZjWB9+xb6N9EcU9h4W9ikGZmxF29sNicqDLivoUNA3fgcth9ZJJwM0xzST2eztgLlEjc900Ch4zuc1AppXIRX50AqArDV4vjpkf8oL8Wujzzqq4xM7vLyWr3YiCyZf2lUigEYyhPZ6GOkg8nZaYhqzInbJG6y/5u4lvCyVIY4DCenJFvouXg5yju46ut2RCp5Xym7flLMxxaKLVPwpwn4J9mNIy9oo/0T9VouIBR83r86Tu+5vWkcgpgisEFZBe/B7qarUL9eDPxASSUKDLj0mx6BKMdInBZX/TT3mK8Mevu+xLSBXqVCrgSDUb5uTDXxrzuOpKNhr2dGd2vpPq+dw6wIMdAQF350QxgU/19GKp9BlyqxSkWoSvHHKJIarXoUehMv5pzwJibiHW4lj5DAwXw1SkNanN2jXsWZy2kOYvTRE7TyUy+Bpcy2NeKhqJZwBONPMppmiExkj1EP25hqcBPd26bHQ188LyyjffnWMM4kkEAW2RYZZfqKI7004LBa6y6yOqn7d6ChldHddgpxYyoB3TR0Nq2WNvNox73N2Gd0V/7DMclUtLdgQrcwu6QLQzpPRaA4vegaOlEIbyJdQM6vKnMJtNA8X4O/7UVkgvor0pYnexWyrxJhTRR5Jw/BRWpoGtEsprkjYp8hSEcwYZrTWki7r7e8fwpyCcRQ4IjyY25eabt40k5y3CFwyVEqIyGMBnq7yWcayZsiD5D8iOaZg4IpDaPx0K2K80xTHWUUkGpsMmLSXYG0hBYFsv3gcsvQh1KSRmniGZTuAvL2TFHdR4HHtYSn5MJ2SgQlVhO4226VNARDez9jrZIX9vEMrTfSYZ1pEU0YVSBdgvPmSgCo7OeIdwVI0rHZcjuvN4Yo3rXveUwKbOPlw+34S9y7bLh6AdDrzwcg4DnBa4mEmC3NAO7GKqkaYCV4kq+6M4azYv8lIwgOiFYxAco2X7hA36PRSyLVQ/RrITn8cebbj04dsTmgMgGFMEi4s8cSAh5Nl5pYMBsoZRnoNDVLLmBRIQXrUJHstCZXb/8F/4dSIII+2bN/lFxdjyVrySV47RsLrLt/4YQNp8WIQQ== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 00b67e84-db89-421b-7d15-08d9ead3c463 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB2869.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Feb 2022 07:22:30.5207 (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: 8OCcG4yAQFG3AJr2xFUVaZi18o0SC3r5UiESW3DKObQfIOSr3ap5UrweA9STUG/9+5szkUjLB5C2oB2q27dwrMD2D/zg2eCeurcKMryurkg= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN4PR10MB5608 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10251 signatures=673430 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 bulkscore=0 suspectscore=0 mlxlogscore=999 mlxscore=0 adultscore=0 malwarescore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2201110000 definitions=main-2202080038 X-Proofpoint-ORIG-GUID: WYHFq-mHuo6mOQbmCQUbTQaoMW81sFNX X-Proofpoint-GUID: WYHFq-mHuo6mOQbmCQUbTQaoMW81sFNX Received-SPF: pass client-ip=205.220.165.32; envelope-from=elena.ufimtseva@oracle.com; helo=mx0a-00069f02.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=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: , Cc: eduardo@habkost.net, john.g.johnson@oracle.com, cohuck@redhat.com, jag.raman@oracle.com, john.levon@nutanix.com, eblake@redhat.com, david@redhat.com, armbru@redhat.com, peterx@redhat.com, mst@redhat.com, berrange@redhat.com, stefanha@redhat.com, pbonzini@redhat.com, philmd@redhat.com Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Elena Ufimtseva --- include/exec/memory.h | 50 +++++++++++++++ include/sysemu/kvm.h | 15 +++++ linux-headers/linux/kvm.h | 25 ++++++++ accel/kvm/kvm-all.c | 132 ++++++++++++++++++++++++++++++++++++++ accel/stubs/kvm-stub.c | 1 + 5 files changed, 223 insertions(+) diff --git a/include/exec/memory.h b/include/exec/memory.h index 20f1b27377..2ce7f35cc2 100644 --- a/include/exec/memory.h +++ b/include/exec/memory.h @@ -712,6 +712,7 @@ void ram_discard_manager_unregister_listener(RamDiscardManager *rdm, typedef struct CoalescedMemoryRange CoalescedMemoryRange; typedef struct MemoryRegionIoeventfd MemoryRegionIoeventfd; +typedef struct MemoryRegionIoregionfd MemoryRegionIoregionfd; /** MemoryRegion: * @@ -756,6 +757,8 @@ struct MemoryRegion { const char *name; unsigned ioeventfd_nb; MemoryRegionIoeventfd *ioeventfds; + unsigned ioregionfd_nb; + MemoryRegionIoregionfd *ioregionfds; RamDiscardManager *rdm; /* Only for RAM */ }; @@ -974,6 +977,38 @@ struct MemoryListener { */ void (*eventfd_del)(MemoryListener *listener, MemoryRegionSection *section, bool match_data, uint64_t data, EventNotifier *e); + /** + * @ioregionfd_add: + * + * Called during an address space update transaction, + * for a section of the address space that has had a new ioregionfd + * registration since the last transaction. + * + * @listener: The #MemoryListener. + * @section: The new #MemoryRegionSection. + * @data: The @data parameter for the new ioregionfd. + * @fd: The file descriptor parameter for the new ioregionfd. + */ + void (*ioregionfd_add)(MemoryListener *listener, + MemoryRegionSection *section, + uint64_t data, int fd); + + /** + * @ioregionfd_del: + * + * Called during an address space update transaction, + * for a section of the address space that has dropped an ioregionfd + * registration since the last transaction. + * + * @listener: The #MemoryListener. + * @section: The new #MemoryRegionSection. + * @data: The @data parameter for the dropped ioregionfd. + * @fd: The file descriptor parameter for the dropped ioregionfd. + */ + void (*ioregionfd_del)(MemoryListener *listener, + MemoryRegionSection *section, + uint64_t data, int fd); + /** * @coalesced_io_add: @@ -1041,6 +1076,8 @@ struct AddressSpace { int ioeventfd_nb; struct MemoryRegionIoeventfd *ioeventfds; + int ioregionfd_nb; + struct MemoryRegionIoregionfd *ioregionfds; QTAILQ_HEAD(, MemoryListener) listeners; QTAILQ_ENTRY(AddressSpace) address_spaces_link; }; @@ -2175,6 +2212,19 @@ void memory_region_del_eventfd(MemoryRegion *mr, uint64_t data, EventNotifier *e); +void memory_region_add_ioregionfd(MemoryRegion *mr, + hwaddr addr, + unsigned size, + uint64_t data, + int fd, + bool pio); + +void memory_region_del_ioregionfd(MemoryRegion *mr, + hwaddr addr, + unsigned size, + uint64_t data, + int fd); + /** * memory_region_add_subregion: Add a subregion to a container. * diff --git a/include/sysemu/kvm.h b/include/sysemu/kvm.h index 7b22aeb6ae..fea77b5185 100644 --- a/include/sysemu/kvm.h +++ b/include/sysemu/kvm.h @@ -46,6 +46,7 @@ extern bool kvm_readonly_mem_allowed; extern bool kvm_direct_msi_allowed; extern bool kvm_ioeventfd_any_length_allowed; extern bool kvm_msi_use_devid; +extern bool kvm_ioregionfds_allowed; #define kvm_enabled() (kvm_allowed) /** @@ -167,6 +168,15 @@ extern bool kvm_msi_use_devid; */ #define kvm_msi_devid_required() (kvm_msi_use_devid) +/** + * kvm_ioregionfds_enabled: + * + * Returns: true if we can use ioregionfd to receive the MMIO/PIO + * dispatches from KVM (ie the kernel supports ioregionfd and we are running + * with a configuration where it is meaningful to use them). + */ +#define kvm_ioregionfds_enabled() (kvm_ioregionfds_allowed) + #else #define kvm_enabled() (0) @@ -184,12 +194,14 @@ extern bool kvm_msi_use_devid; #define kvm_direct_msi_enabled() (false) #define kvm_ioeventfd_any_length_enabled() (false) #define kvm_msi_devid_required() (false) +#define kvm_ioregionfds_enabled (false) #endif /* CONFIG_KVM_IS_POSSIBLE */ struct kvm_run; struct kvm_lapic_state; struct kvm_irq_routing_entry; +struct kvm_ioregion; typedef struct KVMCapabilityInfo { const char *name; @@ -548,4 +560,7 @@ bool kvm_cpu_check_are_resettable(void); bool kvm_arch_cpu_check_are_resettable(void); bool kvm_dirty_ring_enabled(void); + +int kvm_set_ioregionfd(struct kvm_ioregion *ioregionfd); + #endif diff --git a/linux-headers/linux/kvm.h b/linux-headers/linux/kvm.h index bcaf66cc4d..1ad444a74e 100644 --- a/linux-headers/linux/kvm.h +++ b/linux-headers/linux/kvm.h @@ -776,6 +776,29 @@ struct kvm_ioeventfd { __u8 pad[36]; }; +enum { + kvm_ioregion_flag_nr_pio, + kvm_ioregion_flag_nr_posted_writes, + kvm_ioregion_flag_nr_deassign, + kvm_ioregion_flag_nr_max, +}; + +#define KVM_IOREGION_PIO (1 << kvm_ioregion_flag_nr_pio) +#define KVM_IOREGION_POSTED_WRITES (1 << kvm_ioregion_flag_nr_posted_writes) +#define KVM_IOREGION_DEASSIGN (1 << kvm_ioregion_flag_nr_deassign) + +#define KVM_IOREGION_VALID_FLAG_MASK ((1 << kvm_ioregion_flag_nr_max) - 1) + +struct kvm_ioregion { + __u64 guest_paddr; /* guest physical address */ + __u64 memory_size; /* bytes */ + __u64 user_data; + __s32 read_fd; + __s32 write_fd; + __u32 flags; + __u8 pad[28]; +}; + #define KVM_X86_DISABLE_EXITS_MWAIT (1 << 0) #define KVM_X86_DISABLE_EXITS_HLT (1 << 1) #define KVM_X86_DISABLE_EXITS_PAUSE (1 << 2) @@ -933,6 +956,7 @@ struct kvm_ppc_resize_hpt { #define KVM_CAP_PIT_STATE2 35 #endif #define KVM_CAP_IOEVENTFD 36 +#define KVM_CAP_IOREGIONFD 206 #define KVM_CAP_SET_IDENTITY_MAP_ADDR 37 #ifdef __KVM_HAVE_XEN_HVM #define KVM_CAP_XEN_HVM 38 @@ -1372,6 +1396,7 @@ struct kvm_vfio_spapr_tce { struct kvm_userspace_memory_region) #define KVM_SET_TSS_ADDR _IO(KVMIO, 0x47) #define KVM_SET_IDENTITY_MAP_ADDR _IOW(KVMIO, 0x48, __u64) +#define KVM_SET_IOREGION _IOW(KVMIO, 0x49, struct kvm_ioregion) /* enable ucontrol for s390 */ struct kvm_s390_ucas_mapping { diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c index eecd8031cf..dda04a0ae1 100644 --- a/accel/kvm/kvm-all.c +++ b/accel/kvm/kvm-all.c @@ -168,6 +168,7 @@ bool kvm_vm_attributes_allowed; bool kvm_direct_msi_allowed; bool kvm_ioeventfd_any_length_allowed; bool kvm_msi_use_devid; +bool kvm_ioregionfds_allowed; static bool kvm_immediate_exit; static hwaddr kvm_max_slot_size = ~0; @@ -384,6 +385,18 @@ err: return ret; } +int kvm_set_ioregionfd(struct kvm_ioregion *ioregionfd) +{ + KVMState *s = kvm_state; + int ret = -1; + + ret = kvm_vm_ioctl(s, KVM_SET_IOREGION, ioregionfd); + if (ret < 0) { + error_report("Failed SET_IOREGION syscall ret is %d", ret); + } + return ret; +} + static int do_kvm_destroy_vcpu(CPUState *cpu) { KVMState *s = kvm_state; @@ -1635,6 +1648,104 @@ static void kvm_io_ioeventfd_del(MemoryListener *listener, } } +static void kvm_mem_ioregionfd_add(MemoryListener *listener, + MemoryRegionSection *section, + uint64_t data, + int fd) +{ + + struct kvm_ioregion ioregionfd; + int r = -1; + + ioregionfd.guest_paddr = section->offset_within_address_space; + ioregionfd.memory_size = int128_get64(section->size); + ioregionfd.user_data = data; + ioregionfd.read_fd = fd; + ioregionfd.write_fd = fd; + ioregionfd.flags = 0; + memset(&ioregionfd.pad, 0, sizeof(ioregionfd.pad)); + + r = kvm_set_ioregionfd(&ioregionfd); + if (r < 0) { + fprintf(stderr, "%s: error adding ioregionfd: %s (%d)\n,", + __func__, strerror(-r), -r); + abort(); + } +} + +static void kvm_mem_ioregionfd_del(MemoryListener *listener, + MemoryRegionSection *section, + uint64_t data, + int fd) + +{ + struct kvm_ioregion ioregionfd; + int r = -1; + + ioregionfd.guest_paddr = section->offset_within_address_space; + ioregionfd.memory_size = int128_get64(section->size); + ioregionfd.user_data = data; + ioregionfd.read_fd = fd; + ioregionfd.write_fd = fd; + ioregionfd.flags = KVM_IOREGION_DEASSIGN; + memset(&ioregionfd.pad, 0, sizeof(ioregionfd.pad)); + + r = kvm_set_ioregionfd(&ioregionfd); + if (r < 0) { + fprintf(stderr, "%s: error deleting ioregionfd: %s (%d)\n,", + __func__, strerror(-r), -r); + abort(); + } +} + +static void kvm_io_ioregionfd_add(MemoryListener *listener, + MemoryRegionSection *section, + uint64_t data, + int fd) +{ + struct kvm_ioregion ioregionfd; + int r = -1; + + ioregionfd.guest_paddr = section->offset_within_address_space; + ioregionfd.memory_size = int128_get64(section->size); + ioregionfd.user_data = data; + ioregionfd.read_fd = fd; + ioregionfd.write_fd = fd; + ioregionfd.flags = KVM_IOREGION_PIO; + memset(&ioregionfd.pad, 0, sizeof(ioregionfd.pad)); + + r = kvm_set_ioregionfd(&ioregionfd); + if (r < 0) { + fprintf(stderr, "%s: error adding pio ioregionfd: %s (%d)\n,", + __func__, strerror(-r), -r); + abort(); + } +} + +static void kvm_io_ioregionfd_del(MemoryListener *listener, + MemoryRegionSection *section, + uint64_t data, + int fd) +{ + struct kvm_ioregion ioregionfd; + int r = -1; + + ioregionfd.guest_paddr = section->offset_within_address_space; + ioregionfd.memory_size = int128_get64(section->size); + ioregionfd.user_data = data; + ioregionfd.read_fd = fd; + ioregionfd.write_fd = fd; + ioregionfd.flags = KVM_IOREGION_DEASSIGN | KVM_IOREGION_PIO; + memset(&ioregionfd.pad, 0, sizeof(ioregionfd.pad)); + + r = kvm_set_ioregionfd(&ioregionfd); + if (r < 0) { + fprintf(stderr, "%s: error deleting pio ioregionfd: %s (%d)\n,", + __func__, strerror(-r), -r); + abort(); + } +} + void kvm_memory_listener_register(KVMState *s, KVMMemoryListener *kml, AddressSpace *as, int as_id, const char *name) { @@ -1679,6 +1790,12 @@ static MemoryListener kvm_io_listener = { .priority = 10, }; +static MemoryListener kvm_ioregion_listener = { + .ioregionfd_add = kvm_io_ioregionfd_add, + .ioregionfd_del = kvm_io_ioregionfd_del, + .priority = 10, +}; + int kvm_set_irq(KVMState *s, int irq, int level) { struct kvm_irq_level event; @@ -2564,6 +2681,9 @@ static int kvm_init(MachineState *ms) kvm_ioeventfd_any_length_allowed = (kvm_check_extension(s, KVM_CAP_IOEVENTFD_ANY_LENGTH) > 0); + kvm_ioregionfds_allowed = + (kvm_check_extension(s, KVM_CAP_IOREGIONFD) > 0); + kvm_state = s; ret = kvm_arch_init(ms, s); @@ -2585,6 +2705,12 @@ static int kvm_init(MachineState *ms) s->memory_listener.listener.eventfd_add = kvm_mem_ioeventfd_add; s->memory_listener.listener.eventfd_del = kvm_mem_ioeventfd_del; } + + if (kvm_ioregionfds_allowed) { + s->memory_listener.listener.ioregionfd_add = kvm_mem_ioregionfd_add; + s->memory_listener.listener.ioregionfd_del = kvm_mem_ioregionfd_del; + } + s->memory_listener.listener.coalesced_io_add = kvm_coalesce_mmio_region; s->memory_listener.listener.coalesced_io_del = kvm_uncoalesce_mmio_region; @@ -2594,6 +2720,12 @@ static int kvm_init(MachineState *ms) memory_listener_register(&kvm_io_listener, &address_space_io); } + + if (kvm_ioregionfds_allowed) { + memory_listener_register(&kvm_ioregion_listener, + &address_space_io); + } + memory_listener_register(&kvm_coalesced_pio_listener, &address_space_io); diff --git a/accel/stubs/kvm-stub.c b/accel/stubs/kvm-stub.c index 5319573e00..d6caea8174 100644 --- a/accel/stubs/kvm-stub.c +++ b/accel/stubs/kvm-stub.c @@ -29,6 +29,7 @@ bool kvm_gsi_direct_mapping; bool kvm_allowed; bool kvm_readonly_mem_allowed; bool kvm_ioeventfd_any_length_allowed; +bool kvm_ioregionfds_allowed; bool kvm_msi_use_devid; void kvm_flush_coalesced_mmio_buffer(void) From patchwork Tue Feb 8 07:22:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Elena Ufimtseva X-Patchwork-Id: 12738324 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 A1D3BC433F5 for ; Tue, 8 Feb 2022 08:41:57 +0000 (UTC) Received: from localhost ([::1]:49588 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nHM4S-0002Fo-CL for qemu-devel@archiver.kernel.org; Tue, 08 Feb 2022 03:41:56 -0500 Received: from eggs.gnu.org ([209.51.188.92]:53930) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nHKpp-0001tB-DQ for qemu-devel@nongnu.org; Tue, 08 Feb 2022 02:22:45 -0500 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]:43644) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nHKpk-0001vL-Su for qemu-devel@nongnu.org; Tue, 08 Feb 2022 02:22:45 -0500 Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 2183uMge026751; Tue, 8 Feb 2022 07:22:36 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 : content-transfer-encoding : mime-version; s=corp-2021-07-09; bh=3qOq5mZ4G71cNTPBvjnfP3oyZPu1Ssv9WF0WuWKLEmA=; b=mTRC50PVSj/USLDTe7B7OwNeSq2PB3BFa2+Iqq6VFWmVu1fPt+bjkwTQC0Vqkhk9B950 5IyBfgCo1LGN3RmdtLixNdtH0jF8xFmx/azRHcLfsU9NUmXehLYxjMOj19x3s6rH4TMO 3Ay47RoqrXhFT/e8jXTk3x/N4mO6+nmaTiNyv2DVH5+33Br7DiWAFgNmsaNQRIAqdqAE HbVUa5XmBeriEV6h0gicg6aBLGqs/bFiR+ip4zVQn3GUdox+NrBRRaOQfuznYndUyp1H tjED0vM9xnc9BO6sp8Kr4fLe0DwFRtpeUWfEjEkPpAS4P+U9YvLVK5KVIArFG0tzdD0j ig== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by mx0b-00069f02.pphosted.com with ESMTP id 3e3h28ge7j-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 08 Feb 2022 07:22:36 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 2187BlYq093365; Tue, 8 Feb 2022 07:22:35 GMT Received: from nam10-mw2-obe.outbound.protection.outlook.com (mail-mw2nam10lp2104.outbound.protection.outlook.com [104.47.55.104]) by userp3030.oracle.com with ESMTP id 3e1ebykknc-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 08 Feb 2022 07:22:34 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QmmICvMtG2uWkvt/ksH1S7D6nT/zODY5FYt+KJiZMfDEGzpwn4ftbL79CfvbFVt2cTeb+MYcFX4K2WunYTN6rp3iLkYiklwuuMPihcMNqLY4EH0phVQrcAgJC9xUlV3Ol0/94CYbjmAV9EvEEsk8HiC29tk5dQ5TavaNG3jQH1U9TKxZhnHAoV5uQJRTIRPEik9++QaExE3O/7ZMWSDFCAn2KO7J5sBGLAoIIhcWd81naXZy5+wiCI+eKNz8u0/QsfygwyQJL7vNFe+euUzMCul/IGZbQl7QUnHJPtGLctUf3G0ZsdXENMLe3y5tZ9KKXAYDF5mMuGZrvYpQpjSxBw== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=3qOq5mZ4G71cNTPBvjnfP3oyZPu1Ssv9WF0WuWKLEmA=; b=LD8UyV8ola9MhL3Nyoi7rooM8rcKGIBRi6XuhbxJBj/9647Cf8V/wYg6P9Kd20fRMcSp80UkCfdcxapLDShBjoSC95d9SFT27hmClwKMuOa7cew2GaYe1HoNeqmsmuqgXxXlVN7zTBKb/9ayLqjSZNsw9gwuLrtKYXgqSpzZwH0ewxR+wcPgQrLxj/yr/Un+/BD4lXc/oEBU8qdEfe/Vhv3rH478caF1KWQ72UHIxMWa8pEZvD2fQbbST3BVraKkVnid/MBNAfUcxO5CEY/nEr68QDB7zWPJ6J3X95xiDHuG45VtTULNoDZkWtyJQEPm0uqA++TKn95WizPMGG1RJA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; 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=3qOq5mZ4G71cNTPBvjnfP3oyZPu1Ssv9WF0WuWKLEmA=; b=kCG7nJkHsTJXrYZRQmhIAyqQ9/Je8CFiAM2eHDrfZeOggj2/nwn/7G4Qsg4H0+Z2zuEhATUnnyLVdb2EXoyAmBO+j+7LPSMCVRQS0U8EaPfZTdhKMIJ0O5MmVRatMeiePwtPh365Eyx1rI2ZIvDpqnnOyq7qkVrumV53ENnG6CM= Received: from BYAPR10MB2869.namprd10.prod.outlook.com (2603:10b6:a03:85::17) by SN4PR10MB5608.namprd10.prod.outlook.com (2603:10b6:806:20b::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.18; Tue, 8 Feb 2022 07:22:31 +0000 Received: from BYAPR10MB2869.namprd10.prod.outlook.com ([fe80::4bd:1cfa:5aee:6c81]) by BYAPR10MB2869.namprd10.prod.outlook.com ([fe80::4bd:1cfa:5aee:6c81%3]) with mapi id 15.20.4951.019; Tue, 8 Feb 2022 07:22:31 +0000 From: Elena Ufimtseva To: qemu-devel@nongnu.org Subject: [RFC 2/8] multiprocess: place RemoteObject definition in a header file Date: Mon, 7 Feb 2022 23:22:16 -0800 Message-Id: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: X-ClientProxiedBy: BY5PR16CA0006.namprd16.prod.outlook.com (2603:10b6:a03:1a0::19) To BYAPR10MB2869.namprd10.prod.outlook.com (2603:10b6:a03:85::17) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 3ca95996-5a02-4ce4-c328-08d9ead3c4ed X-MS-TrafficTypeDiagnostic: SN4PR10MB5608:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3826; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: kNU5Jhhl2/ZiQrNF+96T+47oI/nj7fB227SDSz82ljLj7HSFoKTtvj9Lctb1l4G9ZOgd6/hKXKRcBK7y3IF9wbhjTXiuqJN//bD5r02IM3YVJ0xP6QgUNU0rowmQC59z4KbZ1RUkXOfvdkU/2h0n4wDx9x5FrXp96UmhoiOXaH036lOzlvYK7Z42egN/Mh+4Zg48W0mGAsiQiTdoEC6U7IPtICZeOl9PYNDrskdzSjQm22xJ0SvBUJbonNMPkIByJYGEJXc4pyeKtT+YVKWisjlW9vr5prP+8PDTySjVHEoM9Ss230NMzWzfd93+BmX9/lsmY+KpDY7eB4DAVZ4Dpkega86fMN7IpE5ex0/jwtpvrDVBvGDCRzgDFx6MXV9IYudoYXceWK3DlcbXBBCSfW/lQVfS/Egqp6LNZk27G90eVEvXxhsq+S4OBlsYqAwwKoydYn2hd/G8IOU0kpj9DwEpQnOhbx/lwfIsH3KH0WBWFDp3MKM2kcHpi0jV8I+AMQcH5zlLJ/lAuK+5PoVeFJSAbnuEURGPeUfPH1GFo5Nv2CP/biXYmiRtZj92igGC8PIR5VzKapyheN/IWGwuMVnutDd/VL590LJBBkds/g8xo3yxiI2EYglAKrTbGI9erXWIR73ljIkEEmkzqAgQCQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR10MB2869.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(366004)(6512007)(36756003)(83380400001)(186003)(38100700002)(86362001)(5660300002)(7416002)(2616005)(6486002)(44832011)(508600001)(6666004)(8676002)(4326008)(52116002)(2906002)(66946007)(66476007)(6506007)(66556008)(6916009)(316002)(8936002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?fq6YUR257YYKfqP0cMOXf2nVz12J?= =?utf-8?q?TZGIsXeWtYrH4Pcl5xa+iRMoTMMcF6mU+IJaldkTSTCgoryzRW6k3DCjtpboYLlmK?= =?utf-8?q?cz/YFxb5fUBGhoEGjjxbhVyPPQMI+QxZCtwtmZ0ygmCNpwJMTlzpwrtKJAYd2treX?= =?utf-8?q?iV41O0vSpztuy99pTXs7MS3VCVnPu7iG9hjyeZXukb73Ep7WVkwvamfPYEj4DqRLy?= =?utf-8?q?ikfJt6DFjaWogFQuL5T3GlDYolzXKW4hSEfM594wmNOjwt3lJpU9OW+FA8minikjx?= =?utf-8?q?sNrofgmJh6OCkANkDE1FEjqBQVXBE+42Hx4JhGWovjj2wViJ5Qd0ldXYeMjMzIdB+?= =?utf-8?q?X+8yNkqKBiwJgr5gNF5osrptY7QEG/mMn+6F8Ew0+Zcn/3s3YPAVALf95FqMtJXgB?= =?utf-8?q?v2G2ZGKWMbmU+55LwBUXvvWQ6gd3fEkt9OOt8JBlvBmVp4znP3ZRFZq/8EwX9sAR2?= =?utf-8?q?BrUJp9YXLdsBU6yIiz1MbLlOMkJGeZ6xec6bRTcPZH6g7UMR++h7MUwNB24MLjKCv?= =?utf-8?q?f1nXxAthePb+XaGPQ6RMAkOJ5vADoPtINqBZp8bDjPTDlL/z/8a0YknYg6q46rB0x?= =?utf-8?q?GH4SqDEHm/tf+IzD2dZDAqRiZrzwVETI5pxqoAHZum1W2X3AuYL6AGAS9njvXth7+?= =?utf-8?q?PqARmsVxgG/2o9HBEyexDpvwqnCJqIqkxIWGBHPntJxppeBL0nrY78zjOzVdfhohV?= =?utf-8?q?wSq/IhzQSJfMcpCDUF3j8S8VvJUSMZfudE+/MtjyGnX41wU+JZ+pG+p/tVGkfDAkF?= =?utf-8?q?dRItpD7vNP4sYHw4FkM6NAn34GKYcC72xKIyh/IRUm0OPwXp/lt06AnRxKXKZk9wV?= =?utf-8?q?JAFaMklRttUaWwbMlkqcKiPjV0uBr10JxMhgRWDj3m5FbUH71JYR5NmxuYQsCndny?= =?utf-8?q?Va63I9weDbIA9lWCwIOjPHjaZRvc0bamBZ0po2dixSCmtH8SC0UWkU5tCk5g4I5iZ?= =?utf-8?q?XPWt5aiiDoQtlu9+BgbxXR+6Nc+Rb8Iu3DvmpV+OVaulXO3tLgfNWYSq8fT+0dwcX?= =?utf-8?q?O0IqYQCa0KbqRfH4vsTZHQtBWUUczAWHe2tomGTzswRi8iC0Ucc1f5noz1l8GdLKC?= =?utf-8?q?9MIW87KRWOCgFFBEZUSEr94pFjF7u4O/+ufZXXeCmw6DUThxPif057ShyExCzJytW?= =?utf-8?q?9Vht7Qo0GnY0FkGi0iitskafR5disaKixzC3luaGIXydJrGer9WO5ad56SF6CfqZQ?= =?utf-8?q?Hq12XodOEikwyNrlnbGwJ7s6IK6dERO2M/dYV0mcpyyboChq2FPDvTG9swnjbd4BG?= =?utf-8?q?s4Ah9saXFcxenuYvQRort9O4Pqae+IdpwivDqFAB0RAg3yWAEqsKhwyUiYpuel0/f?= =?utf-8?q?4718WTgNueklJSOANOeJrk/3VsAGWPtX7gpWS3HutCyEPQY700fp44b7RA9Qut7yo?= =?utf-8?q?oy9Cy5vKnSovddxPS4tJhDMD8g5bFl0vWxVI8pW6Npf7JkvTSmguwYKXJIXEA17WV?= =?utf-8?q?oO/8LEdTKQ17zQnVbAeD3ynuNRzAXbrjYYH7UEDeGh2t8QTzWMddK/UaNTdms2rwc?= =?utf-8?q?sF0WpvlLu5agooQtKbe3bZ5U3BhOKGSsAwUgycO1Pu2t36zGe/4/I1K7Nys7F5cqp?= =?utf-8?q?IPvQk6m4sB3sEIpE7atI/tYLNI1qek1bzZMhyz+L2/rnqYbPBO1fB7IF3K9MH3fif?= =?utf-8?q?GBztr/LJ8n7orvMnDcGQuZMAW014DrFw=3D=3D?= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3ca95996-5a02-4ce4-c328-08d9ead3c4ed X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB2869.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Feb 2022 07:22:31.3801 (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: lAn/39647rI2e1nXB3zLfCMauT+SFFcEb01G6ANkVPDQsNrK+bj8dGlE76emioryhVI3o98Q9iVfu4L/3AnXJT6uOOpvMJhbJiVsRTIr1N0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN4PR10MB5608 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10251 signatures=673430 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 bulkscore=0 suspectscore=0 mlxlogscore=999 mlxscore=0 adultscore=0 malwarescore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2201110000 definitions=main-2202080038 X-Proofpoint-ORIG-GUID: iAR7BhY1oItpOOkCoLga7cDiHCdTmGNi X-Proofpoint-GUID: iAR7BhY1oItpOOkCoLga7cDiHCdTmGNi Received-SPF: pass client-ip=205.220.165.32; envelope-from=elena.ufimtseva@oracle.com; helo=mx0a-00069f02.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=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: , Cc: eduardo@habkost.net, john.g.johnson@oracle.com, cohuck@redhat.com, jag.raman@oracle.com, john.levon@nutanix.com, eblake@redhat.com, david@redhat.com, armbru@redhat.com, peterx@redhat.com, mst@redhat.com, berrange@redhat.com, stefanha@redhat.com, pbonzini@redhat.com, philmd@redhat.com Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" This will be needed later. No functional changes. Signed-off-by: Elena Ufimtseva --- include/hw/remote/remote.h | 28 ++++++++++++++++++++++++++++ hw/remote/remote-obj.c | 16 +--------------- MAINTAINERS | 1 + 3 files changed, 30 insertions(+), 15 deletions(-) create mode 100644 include/hw/remote/remote.h diff --git a/include/hw/remote/remote.h b/include/hw/remote/remote.h new file mode 100644 index 0000000000..a2d23178b9 --- /dev/null +++ b/include/hw/remote/remote.h @@ -0,0 +1,28 @@ +/* + * RemoteObject header. + * + * Copyright © 2018, 2022 Oracle and/or its affiliates. + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + * + */ +#ifndef REMOTE_H +#define REMOTE_H + +struct RemoteObject { + /* private */ + Object parent; + + Notifier machine_done; + + int32_t fd; + char *devid; + + QIOChannel *ioc; + + DeviceState *dev; + DeviceListener listener; +}; + +#endif diff --git a/hw/remote/remote-obj.c b/hw/remote/remote-obj.c index 4f21254219..f0da696662 100644 --- a/hw/remote/remote-obj.c +++ b/hw/remote/remote-obj.c @@ -23,6 +23,7 @@ #include "hw/pci/pci.h" #include "qemu/sockets.h" #include "monitor/monitor.h" +#include "hw/remote/remote.h" #define TYPE_REMOTE_OBJECT "x-remote-object" OBJECT_DECLARE_TYPE(RemoteObject, RemoteObjectClass, REMOTE_OBJECT) @@ -34,21 +35,6 @@ struct RemoteObjectClass { unsigned int max_devs; }; -struct RemoteObject { - /* private */ - Object parent; - - Notifier machine_done; - - int32_t fd; - char *devid; - - QIOChannel *ioc; - - DeviceState *dev; - DeviceListener listener; -}; - static void remote_object_set_fd(Object *obj, const char *str, Error **errp) { RemoteObject *o = REMOTE_OBJECT(obj); diff --git a/MAINTAINERS b/MAINTAINERS index 7543eb4d59..3c60a29760 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -3453,6 +3453,7 @@ F: hw/remote/proxy-memory-listener.c F: include/hw/remote/proxy-memory-listener.h F: hw/remote/iohub.c F: include/hw/remote/iohub.h +F: include/hw/remote/remote.h EBPF: M: Jason Wang From patchwork Tue Feb 8 07:22:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elena Ufimtseva X-Patchwork-Id: 12738392 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 E942EC433F5 for ; Tue, 8 Feb 2022 09:31:11 +0000 (UTC) Received: from localhost ([::1]:51568 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nHMq3-0003AV-2B for qemu-devel@archiver.kernel.org; Tue, 08 Feb 2022 04:31:07 -0500 Received: from eggs.gnu.org ([209.51.188.92]:53942) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nHKpp-0001tl-Nm for qemu-devel@nongnu.org; Tue, 08 Feb 2022 02:22:46 -0500 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]:44924) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nHKpk-0001vT-Sv for qemu-devel@nongnu.org; Tue, 08 Feb 2022 02:22:45 -0500 Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 2186dmkm012748; Tue, 8 Feb 2022 07:22:37 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-transfer-encoding : content-type : mime-version; s=corp-2021-07-09; bh=75zix5pcvfxhTthaVfOaxCn0SeQx/g1fvHEB8BH4CLw=; b=tvBj6tpv5Ez3Ql/XGhZq9Q3t5ZDX98Kn8cEMPVsu+B5Y73rU+UhT6fZiFCGDNWJ05Tau NjQzb7mRCP78E4rJppjtDY2yL8eO/4Yq4iO52UQjulpU85mW0BbevalfcNwaK8nVnnrQ puSSsamcQkMxfFjiUGx6TomHHJxvidBudRYxadM+TfCxzZxIuhsgWsPT1A6fXlR+HbFf oB6cve7gIPc5JasgLJtOsUchp/R6UVNp98RfOhQmlsB6SixhkJAVbeXRBP9sdZygdZo6 5b3uAuhK2ygZ2AWOiCsRiN4r0szsIsYgsrMATGSzHdiTK1vMsIV4MoM6m6/ezVput8vJ Og== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by mx0b-00069f02.pphosted.com with ESMTP id 3e3fpggk45-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 08 Feb 2022 07:22:37 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 2187BlYr093365; Tue, 8 Feb 2022 07:22:35 GMT Received: from nam10-mw2-obe.outbound.protection.outlook.com (mail-mw2nam10lp2104.outbound.protection.outlook.com [104.47.55.104]) by userp3030.oracle.com with ESMTP id 3e1ebykknc-4 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 08 Feb 2022 07:22:35 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Zw3W9LjKeigtk1gGUy1Z7cSibqnT+8Xs+14aNMxcKS/l7Eul88YG8V891GWpbTvixGuh6K7ZO2OuScJOL6K9P19RSAG0ByoaF95QxLDlXsciE2wiDFMFGdAQXXrqR307p35PgvzCUwhdVIXqvW+BPvW4XVhvYkSvo6oy7pK0KUm0NmkQbGcxjUeI2OpBINcFZ+QJ94hhJFB0yaCvEgsVgD85kYPI0eK8/rVqEdKRslrgIob3BoGKeKcU8q0iucZalmBbJEaMzbFAu4mzo2zfhGCRfYa5xWUkWO14RoXKBHY1rFY20gLGrit+99gFAS47QkSUuGHjJ+ZNAmsdfSzE5Q== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=75zix5pcvfxhTthaVfOaxCn0SeQx/g1fvHEB8BH4CLw=; b=iGge5IMXYc8RV5DnXbmpAh8L40ithpFOizh0pOpAkjJjzfzAYDYn3dNlMKWBa9ptUUCgNlvTOpFhv//ShAryz739Jd4GcH+yfP2F2ckyCye6Z2BCP/mTrtrJ2mh3HnP7rL4b+tDspyKaAovNGhNxLsgP8JyxZqMiCU2+V2hx7rkITuLQrJvs0DmccYY6eXVF1ihP2tRrUKls/e+SDzUodhIf5ZABT9lJDFPrAwSCR2Vevw+Xl/uxyyYC12jCS2JMPLf1J8L/seO8T0mweR804LHKjyNCnhRxouwN1c22QislsL04hF2A8yYBK8nuA7dI6Hy1wz5bIywBX1aXMKG+Cg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; 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=75zix5pcvfxhTthaVfOaxCn0SeQx/g1fvHEB8BH4CLw=; b=syQQIQ4Sjm7Km4V1Z9PI5r8G9Bou26+VomWzec186jSOR1JFHHI7FE4dKNbeS9vuVU5QzMDJ1UJe0a4exwJPugCVro+wEl+y00oezzhvWclx38ujO3jQx9VxMD7PSYoXc9nrFFNDZXDEWS+CKIO+30Ax5ucwzb/WbT0cWQKmVY0= Received: from BYAPR10MB2869.namprd10.prod.outlook.com (2603:10b6:a03:85::17) by SN4PR10MB5608.namprd10.prod.outlook.com (2603:10b6:806:20b::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.18; Tue, 8 Feb 2022 07:22:32 +0000 Received: from BYAPR10MB2869.namprd10.prod.outlook.com ([fe80::4bd:1cfa:5aee:6c81]) by BYAPR10MB2869.namprd10.prod.outlook.com ([fe80::4bd:1cfa:5aee:6c81%3]) with mapi id 15.20.4951.019; Tue, 8 Feb 2022 07:22:32 +0000 From: Elena Ufimtseva To: qemu-devel@nongnu.org Subject: [RFC 3/8] ioregionfd: introduce memory API functions Date: Mon, 7 Feb 2022 23:22:17 -0800 Message-Id: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: X-ClientProxiedBy: BY5PR16CA0006.namprd16.prod.outlook.com (2603:10b6:a03:1a0::19) To BYAPR10MB2869.namprd10.prod.outlook.com (2603:10b6:a03:85::17) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 0d460a26-0e76-447b-f2ca-08d9ead3c5a2 X-MS-TrafficTypeDiagnostic: SN4PR10MB5608:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:67; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: sws4Y1rFvuvw+MR/Vm72p+1NYhZ1Fa06BsKHK2b8v5q5s9x5JSDCphykJBxcIlMe0zANDUBXb9uEgDJKV+NG7Jz8FsF5+IoM7tfS+0FXe0EWClajkreO3VGM2YLDVneDOpN0G2Cw7niPn+fVQgb4dY2zoxP9TZGY7Sio9KnVu2dDR8zpqAQUrzEq3kwreCndtTeS8xILgjiTJJWLjvTvqVOVoSo85CbQriofIYmo+Ck1dhrbTrMtyKB/Df5ndesTIv5VR4IoIBeEoy2Wxw23kADI7QXvPk/Rs3kPMdR6OwDYKlTqYcgylJlHjQS5fPt/xOtnEwJ52G/UTHyFEVjl4YAAVCdth4E6YLufAUsWZETQtMCQqC8e4F/HJ8IeE6UAKipAL0tjrxROKQnwvYBCEJtU94+ihx7/LtEUC9HHSK7Rl+t/ZIFwlazgS9npXJ4UbLqw1KxWbmEwumqvp5t3th1aaWjYeSbJcpvd1tvLty+GPlEXjvg8jM0mQ/xxguO1DSlmPeeQ0DN67e8n2nM8YgJcRe1/IBI39uN8Swub6Z0Lv2JeuW1lwVYeDog7t76i7lnlAveh+ZsDDmJ753lsE3GINfnVjL8CpIFk/jiF+lOXreTMr7YbS5wGbHvZ33nTncA6dUU+gPlpyy3bPxfeZA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR10MB2869.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(366004)(6512007)(36756003)(83380400001)(186003)(38100700002)(86362001)(5660300002)(7416002)(2616005)(6486002)(44832011)(508600001)(6666004)(8676002)(4326008)(52116002)(2906002)(66946007)(66476007)(6506007)(66556008)(6916009)(316002)(8936002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: WRYzITfucctitW+2dN38A+RTxXl5zUVAWi7cIrNyvba1+Ll51t5Fg6wlUUOhe25eKX43gNVwB4PlW/wQCdaxm2w5rZ6b+AtqDcr0AsTYtzAPwkGzFqSu9Os4sqGDv9gw5TaB4jL5Q5bATd1ZUpwsOEFjZdyXpJvpH//YV7/vxi0C7caPhhPykDfqMMtZd1uPxE1/jBIZd1bo686pubjG7VeYZcq+nGx2LMDsM1DxrxSmHIxKPP8zlumge1ToA0q5GvdG+oSTQtIv1cxOtbo41o6lO49GMF0lWPksnkdmFtCk5FaNm4VrRumJN+bFUQK5nH+6E96F8Q1ZM6Gnsfp8ayVf6yOYYFKvfabxdaDtuQtJc1vmG6faMmeM3X9bTH3iPk5MNAUdCJlr0+/gkzCwDw+UFQ/A//tD9hzpQ1uwEORDT4Sa0B9MBavodtfdjcL8fiLget9R4nfL/zFNhtfrlS2lYRosMVfry0ENLFDnEkaRhlmI+0MF1D1yO4PgBd8G9bOR5JLlU5qBJkIU7PClnv0gh5XJS3t5SRV4nqj5Ir96A0zijhuIPq/ycTDEmGtIfxT7ayYt2ildKnzY214die0BnF31YbnEHjvYDnRQHxIcksafP+CjESmVii3dvW2U4jU8r2wC1HJnTGBjp1Ddv9qeEnzzkZwRT2ofGPiA9/PB37PrDjHnNDdERv7aV2rBqStlI6Ls6oudOkPqGdGs9h0Xx7CR4fItRS8BHh2Wl0dL0kiefdxN8FQzyOdU5Wf3iXm6f18aeikmi6rX+Tw/cqcCkXZMeHtTKg/aMTcKCxihN1wOjyV/SXkerXRftFso4nufA9S9V7O5t8F25Mr8eZSYRUuybWBYU7njC+Wqm6/8ndfTV4LlY4b4kAT02IDF6BcdxK1q0CzC54GFAjTFclv0YYP+QCP4Z9GOHcg5p8rhDzeCZPEvaRyomxrTu2HLweuRIcwEFrHdfJC5oUvewy+QYnshsX5zPmuSTlOjj++PLGdsLO9gacZNYq2FN7Lyn9hjcplgnyvRGt31RQzSTzZbg3sodb/tO+dZVuCn895ZEQjA/nWvstwV4pvsL3Bu7CpnJLE30fCkmw0q3ZrGfwG2564NEbkoapTg7W1EDBD01nOv1/PdDN65WnQn7hJApTfjCJXFg3Gtcme9yFt3gseR12ssXtPb57FEjIb53lO20lbKO9svIPMB3XjOc/7x1YWoh4jqxJIFPy8ZtTCll/mUfCd6pBRDIRNESYv/kuMD/rZxPX731c2ska4FMdZ0BaOc/sWiRD9YVNTkED7fq+CksUbnV0zbVc5v8udFZ9gL/Xxy4cxcpTqSyvm4Fph25qYzkN5l+3Hl35OgS+a+CokI7N3SvB6Da69jdbH3j0u2P1+7k/Sp58iPXID/PHUmCH9/QfKs5ALGGqwxtCM6KP7/5FiT4x1YGhhQfrpoI0ly/E6Cra7wUJVtXOWfXNusVRjcyqtMyWUsFQoH3eZ5aschUughVH3GjVXm52owl9Bds+b9/aIqfxr1Jy5jf+XloByX8MJ539FQr2ptWEnCj0iFsUs/JAO8WYhEC3HcLJM5ZTSAfByQXy6tLD9XeU4NINiCsTRhfBAPICG5QOpMNaShs/5Pzw+iTOsKJ2akNIL31AUS4P1e2KfZAx/WLy0y7tEPBZYW+osa49iYywj+PxZp0I9AI5Hts510HCvOGZf0ZJSCgnofZ840lWGe+u77Tz5kx/Cp67LaK69Yg05Udw== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0d460a26-0e76-447b-f2ca-08d9ead3c5a2 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB2869.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Feb 2022 07:22:32.5987 (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: xIn8hh64K7SFOpD+oqvy5feUh84Rlz4OEKQSIabKdjk2+G/0HZwM+NDfQCsk2nZreOQN0IA+74vJlFrIfSPiSgyyA9L8hKliqUo9gPKKlQQ= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN4PR10MB5608 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10251 signatures=673430 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 bulkscore=0 suspectscore=0 mlxlogscore=999 mlxscore=0 adultscore=0 malwarescore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2201110000 definitions=main-2202080038 X-Proofpoint-GUID: 5LOI8oXfCN9dGdeZH-tHL0b4qVRj60cF X-Proofpoint-ORIG-GUID: 5LOI8oXfCN9dGdeZH-tHL0b4qVRj60cF Received-SPF: pass client-ip=205.220.165.32; envelope-from=elena.ufimtseva@oracle.com; helo=mx0a-00069f02.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=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: , Cc: eduardo@habkost.net, john.g.johnson@oracle.com, cohuck@redhat.com, jag.raman@oracle.com, john.levon@nutanix.com, eblake@redhat.com, david@redhat.com, armbru@redhat.com, peterx@redhat.com, mst@redhat.com, berrange@redhat.com, stefanha@redhat.com, pbonzini@redhat.com, philmd@redhat.com Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Similar to ioeventfd, introduce the ioregionfd functions to add and delete ioregionfds. Signed-off-by: Elena Ufimtseva --- softmmu/memory.c | 207 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 207 insertions(+) diff --git a/softmmu/memory.c b/softmmu/memory.c index 7340e19ff5..3618c5d1cf 100644 --- a/softmmu/memory.c +++ b/softmmu/memory.c @@ -40,6 +40,7 @@ static unsigned memory_region_transaction_depth; static bool memory_region_update_pending; static bool ioeventfd_update_pending; unsigned int global_dirty_tracking; +static bool ioregionfd_update_pending; static QTAILQ_HEAD(, MemoryListener) memory_listeners = QTAILQ_HEAD_INITIALIZER(memory_listeners); @@ -170,6 +171,13 @@ struct MemoryRegionIoeventfd { EventNotifier *e; }; +struct MemoryRegionIoregionfd { + AddrRange addr; + uint64_t data; + int fd; + bool pio; +}; + static bool memory_region_ioeventfd_before(MemoryRegionIoeventfd *a, MemoryRegionIoeventfd *b) { @@ -214,6 +222,33 @@ static bool memory_region_ioeventfd_equal(MemoryRegionIoeventfd *a, return false; } +static bool memory_region_ioregionfd_before(MemoryRegionIoregionfd *a, + MemoryRegionIoregionfd *b) +{ + if (int128_lt(a->addr.start, b->addr.start)) { + return true; + } else if (int128_gt(a->addr.start, b->addr.start)) { + return false; + } else if (int128_lt(a->addr.size, b->addr.size)) { + return true; + } else if (int128_gt(a->addr.size, b->addr.size)) { + return false; + } + return false; +} + +static bool memory_region_ioregionfd_equal(MemoryRegionIoregionfd *a, + MemoryRegionIoregionfd *b) +{ + if (int128_eq(a->addr.start, b->addr.start) && + (!int128_nz(a->addr.size) || !int128_nz(b->addr.size) || + (int128_eq(a->addr.size, b->addr.size) && + (a->fd == b->fd)))) + return true; + + return false; +} + /* Range of memory in the global map. Addresses are absolute. */ struct FlatRange { MemoryRegion *mr; @@ -800,6 +835,52 @@ static void address_space_add_del_ioeventfds(AddressSpace *as, } } +static void address_space_add_del_ioregionfds(AddressSpace *as, + MemoryRegionIoregionfd *fds_new, + unsigned fds_new_nb, + MemoryRegionIoregionfd *fds_old, + unsigned fds_old_nb) +{ + unsigned iold, inew; + MemoryRegionIoregionfd *fd; + MemoryRegionSection section; + + iold = inew = 0; + while (iold < fds_old_nb || inew < fds_new_nb) { + if (iold < fds_old_nb + && (inew == fds_new_nb + || memory_region_ioregionfd_before(&fds_old[iold], + &fds_new[inew]))) { + fd = &fds_old[iold]; + section = (MemoryRegionSection) { + .fv = address_space_to_flatview(as), + .offset_within_address_space = int128_get64(fd->addr.start), + .size = fd->addr.size, + }; + MEMORY_LISTENER_CALL(as, ioregionfd_del, Forward, §ion, + fd->data, fd->fd); + ++iold; + + } else if (inew < fds_new_nb + && (iold == fds_old_nb + || memory_region_ioregionfd_before(&fds_new[inew], + &fds_old[iold]))) { + fd = &fds_new[inew]; + section = (MemoryRegionSection) { + .fv = address_space_to_flatview(as), + .offset_within_address_space = int128_get64(fd->addr.start), + .size = fd->addr.size, + }; + MEMORY_LISTENER_CALL(as, ioregionfd_add, Reverse, §ion, + fd->data, fd->fd); + ++inew; + } else { + ++iold; + ++inew; + } + } +} + FlatView *address_space_get_flatview(AddressSpace *as) { FlatView *view; @@ -814,6 +895,52 @@ FlatView *address_space_get_flatview(AddressSpace *as) return view; } +static void address_space_update_ioregionfds(AddressSpace *as) +{ + FlatView *view; + FlatRange *fr; + unsigned ioregionfd_nb = 0; + unsigned ioregionfd_max; + MemoryRegionIoregionfd *ioregionfds; + AddrRange tmp; + unsigned i; + + /* + * It is likely that the number of ioregionfds hasn't changed much, so use + * the previous size as the starting value, with some headroom to avoid + * gratuitous reallocations. + */ + ioregionfd_max = QEMU_ALIGN_UP(as->ioregionfd_nb, 4); + ioregionfds = g_new(MemoryRegionIoregionfd, ioregionfd_max); + + view = address_space_get_flatview(as); + FOR_EACH_FLAT_RANGE(fr, view) { + for (i = 0; i < fr->mr->ioregionfd_nb; ++i) { + tmp = addrrange_shift(fr->mr->ioregionfds[i].addr, + int128_sub(fr->addr.start, + int128_make64(fr->offset_in_region))); + if (addrrange_intersects(fr->addr, tmp)) { + ++ioregionfd_nb; + if (ioregionfd_nb > ioregionfd_max) { + ioregionfd_max = MAX(ioregionfd_max * 2, 4); + ioregionfds = g_realloc(ioregionfds, + ioregionfd_max * sizeof(*ioregionfds)); + } + ioregionfds[ioregionfd_nb - 1] = fr->mr->ioregionfds[i]; + ioregionfds[ioregionfd_nb - 1].addr = tmp; + } + } + } + + address_space_add_del_ioregionfds(as, ioregionfds, ioregionfd_nb, + as->ioregionfds, as->ioregionfd_nb); + + g_free(as->ioregionfds); + as->ioregionfds = ioregionfds; + as->ioregionfd_nb = ioregionfd_nb; + flatview_unref(view); +} + static void address_space_update_ioeventfds(AddressSpace *as) { FlatView *view; @@ -1102,15 +1229,22 @@ void memory_region_transaction_commit(void) QTAILQ_FOREACH(as, &address_spaces, address_spaces_link) { address_space_set_flatview(as); address_space_update_ioeventfds(as); + address_space_update_ioregionfds(as); } memory_region_update_pending = false; ioeventfd_update_pending = false; + ioregionfd_update_pending = false; MEMORY_LISTENER_CALL_GLOBAL(commit, Forward); } else if (ioeventfd_update_pending) { QTAILQ_FOREACH(as, &address_spaces, address_spaces_link) { address_space_update_ioeventfds(as); } ioeventfd_update_pending = false; + } else if (ioregionfd_update_pending) { + QTAILQ_FOREACH(as, &address_spaces, address_spaces_link) { + address_space_update_ioregionfds(as); + } + ioregionfd_update_pending = false; } } } @@ -1757,6 +1891,7 @@ static void memory_region_finalize(Object *obj) memory_region_clear_coalescing(mr); g_free((char *)mr->name); g_free(mr->ioeventfds); + g_free(mr->ioregionfds); } Object *memory_region_owner(MemoryRegion *mr) @@ -2434,6 +2569,42 @@ void memory_region_clear_flush_coalesced(MemoryRegion *mr) static bool userspace_eventfd_warning; +void memory_region_add_ioregionfd(MemoryRegion *mr, + hwaddr addr, + unsigned size, + uint64_t data, + int fd, + bool pio) +{ + MemoryRegionIoregionfd mriofd = { + .addr.start = int128_make64(addr), + .addr.size = int128_make64(size), + .data = data, + .fd = fd, + }; + unsigned i; + + if (kvm_enabled() && !kvm_ioregionfds_enabled()) { + error_report("KVM does not support KVM_CAP_IOREGIONFD"); + } + + memory_region_transaction_begin(); + for (i = 0; i < mr->ioregionfd_nb; ++i) { + if (memory_region_ioregionfd_before(&mriofd, &mr->ioregionfds[i])) { + break; + } + } + ++mr->ioregionfd_nb; + mr->ioregionfds = g_realloc(mr->ioregionfds, + sizeof(*mr->ioregionfds) * mr->ioregionfd_nb); + memmove(&mr->ioregionfds[i + 1], &mr->ioregionfds[i], + sizeof(*mr->ioregionfds) * (mr->ioregionfd_nb - 1 - i)); + mr->ioregionfds[i] = mriofd; + + memory_region_transaction_commit(); + ioregionfd_update_pending = true; +} + void memory_region_add_eventfd(MemoryRegion *mr, hwaddr addr, unsigned size, @@ -2511,6 +2682,38 @@ void memory_region_del_eventfd(MemoryRegion *mr, memory_region_transaction_commit(); } +void memory_region_del_ioregionfd(MemoryRegion *mr, + hwaddr addr, + unsigned size, + uint64_t data, + int fd) +{ + MemoryRegionIoregionfd mriofd = { + .addr.start = int128_make64(addr), + .addr.size = int128_make64(size), + .data = data, + .fd = fd, + }; + unsigned i; + + memory_region_transaction_begin(); + for (i = 0; i < mr->ioregionfd_nb; ++i) { + if (memory_region_ioregionfd_equal(&mriofd, &mr->ioregionfds[i])) { + break; + } + } + assert(i != mr->ioregionfd_nb); + memmove(&mr->ioregionfds[i], &mr->ioregionfds[i + 1], + sizeof(*mr->ioregionfds) * (mr->ioregionfd_nb - (i + 1))); + --mr->ioregionfd_nb; + mr->ioregionfds = g_realloc(mr->ioregionfds, + sizeof(*mr->ioregionfds) * + mr->ioregionfd_nb + 1); + memory_region_transaction_commit(); + + ioregionfd_update_pending = true; +} + static void memory_region_update_container_subregions(MemoryRegion *subregion) { MemoryRegion *mr = subregion->container; @@ -2956,11 +3159,14 @@ void address_space_init(AddressSpace *as, MemoryRegion *root, const char *name) as->current_map = NULL; as->ioeventfd_nb = 0; as->ioeventfds = NULL; + as->ioregionfd_nb = 0; + as->ioregionfds = NULL; QTAILQ_INIT(&as->listeners); QTAILQ_INSERT_TAIL(&address_spaces, as, address_spaces_link); as->name = g_strdup(name ? name : "anonymous"); address_space_update_topology(as); address_space_update_ioeventfds(as); + address_space_update_ioregionfds(as); } static void do_address_space_destroy(AddressSpace *as) @@ -2970,6 +3176,7 @@ static void do_address_space_destroy(AddressSpace *as) flatview_unref(as->current_map); g_free(as->name); g_free(as->ioeventfds); + g_free(as->ioregionfds); memory_region_unref(as->root); } From patchwork Tue Feb 8 07:22:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Elena Ufimtseva X-Patchwork-Id: 12738404 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 9EBB8C433F5 for ; Tue, 8 Feb 2022 09:36:45 +0000 (UTC) Received: from localhost ([::1]:59268 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nHMvU-0000I2-3U for qemu-devel@archiver.kernel.org; Tue, 08 Feb 2022 04:36:44 -0500 Received: from eggs.gnu.org ([209.51.188.92]:53950) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nHKpp-0001uD-Vv for qemu-devel@nongnu.org; Tue, 08 Feb 2022 02:22:46 -0500 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]:45736) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nHKpk-0001vX-Sw for qemu-devel@nongnu.org; Tue, 08 Feb 2022 02:22:45 -0500 Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 2186sIuw007544; Tue, 8 Feb 2022 07:22:38 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 : content-transfer-encoding : mime-version; s=corp-2021-07-09; bh=iBM/s0NYQU/Tz6e/qw94tUQAQt2gq4sv8WKe7gDuVmI=; b=jGJPpJpJDXh84w0Bi0ukzGY4roJwDyq1Mi0BaSMdQczecIyb1RzYZwgPgvo2ZXf6Ic6t lP5RYIe76qpMlUXu83KDVRD7mUhSiriqZfv6I6vi/D0hew4kg/9r4LUk4zL73Rrh0STq R8yj2BGhb/VAiK7cmNDXOjqKSwBzj2wSAZCh540HEfcN4OevCAH2ivmYVhCMxAoa5mHc xtEzHJiuedSIFCuEwOqBq2/H+4ATSK69frXvC6xuRUX7HN29OiZxAZ61GDFPl05e3uAd /50OH99kAztNe/u4bTt9Ak4snkrWgdL0KSXowbIuNVeEnlKg/qni4JJNo0vCVwL/oMZj Ow== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by mx0b-00069f02.pphosted.com with ESMTP id 3e368tsxcs-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 08 Feb 2022 07:22:37 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 2187BlYs093365; Tue, 8 Feb 2022 07:22:36 GMT Received: from nam10-mw2-obe.outbound.protection.outlook.com (mail-mw2nam10lp2104.outbound.protection.outlook.com [104.47.55.104]) by userp3030.oracle.com with ESMTP id 3e1ebykknc-5 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 08 Feb 2022 07:22:36 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bJHnTlRD49C2fh5ICrZiLYjwCGfo7rikrv+a3C5XaybxPRDCRHeiKDD9fFd64aVuZ0qwBNfuwj8o19eZ1IqhhBpTn22OylEq9CSgnLPjS/YJZpP0wiaIwgxqqmW4HWnwhTJodLD5fW1PAuFxkqJE3Fhau1446h4qAHavUQxJj1/R38Aggxt44a5cH3FDSzxYNgi4RY4UixvKqVJQr9LqO96C03K4NdvF/bQLfR4kD56cGHmSnc/N3YPLACsdayruKvmlEbaQ1ON8AlKqVd4grMPP10H2utaXd5NHH/qPSYtoa6RksKhSvFQxCGW/7I8x2yMuAmckos984hJ0LHrX1g== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=iBM/s0NYQU/Tz6e/qw94tUQAQt2gq4sv8WKe7gDuVmI=; b=kCVGb2+vRRyNqR/lEgL/iB9a8GnipDkMsN56ll8uHb0sE3NRCCwg43nJtQrx50bsS/nOmkN4Q4UfnuA8xCJQI8eyVpqvTWn85ZOGKIgFEUz/MKUoA+1JrDt8xcthn/unISdx+PmiblHwRrfPcjnGYw/xM4VEteTvArzvL3qX+6dF06i4mSnstvptZxfY96ycffLGBXAhDyC8E5LSR1uhZn6d+A40KyXJvyjoqdploBfCtUJajqkSfebpA/sS/A+gfwoTd7wwqRcjy6uFOLEmkRpNtBrgmYG1DMbCwPBuiLGxWITF83GUY5mD+eVuh7ZLSAZ24iRVCxSJzSJghKMZcg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; 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=iBM/s0NYQU/Tz6e/qw94tUQAQt2gq4sv8WKe7gDuVmI=; b=CIZcGrutAYAyue7hMHYQuH3lfnfc2SlftZsgbMu20Jc3rhrqbkCDES7L7hbfNUursJhCnSSjLqUS/cd5npn+WjYzYQ09zeDQ7gAio4kHz/SlXmb58lbgx/eGhTCWSIulBETEg3Fz+1YIZJN/D9x/BD0dlOPWaiyLef9QZMKO3Y4= Received: from BYAPR10MB2869.namprd10.prod.outlook.com (2603:10b6:a03:85::17) by SN4PR10MB5608.namprd10.prod.outlook.com (2603:10b6:806:20b::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.18; Tue, 8 Feb 2022 07:22:33 +0000 Received: from BYAPR10MB2869.namprd10.prod.outlook.com ([fe80::4bd:1cfa:5aee:6c81]) by BYAPR10MB2869.namprd10.prod.outlook.com ([fe80::4bd:1cfa:5aee:6c81%3]) with mapi id 15.20.4951.019; Tue, 8 Feb 2022 07:22:33 +0000 From: Elena Ufimtseva To: qemu-devel@nongnu.org Subject: [RFC 4/8] ioregionfd: Introduce IORegionDFObject type Date: Mon, 7 Feb 2022 23:22:18 -0800 Message-Id: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: X-ClientProxiedBy: BY5PR16CA0006.namprd16.prod.outlook.com (2603:10b6:a03:1a0::19) To BYAPR10MB2869.namprd10.prod.outlook.com (2603:10b6:a03:85::17) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 9d7f8f36-ad9e-4112-7632-08d9ead3c609 X-MS-TrafficTypeDiagnostic: SN4PR10MB5608:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:418; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: WuDSssitUMg2fZGT8BeDIhoH3FM208SqsffF54fN+1Vik7Pcna11YHvrtOlKz2LmVuUByRXkRTDW2Qg3o2CTe4903bmab9hEaPEN5eR+rNvT8NIh38IPPU+SYZBjIt60vfEt82HwfWzZPbn7d2nt6CXKuXP8BWAZtEI7nn3WRfDwm1gZ+QwBVQGTfz7XFFZo9NhQp8b4UOAVr7pBQWPVPSfZ6MoNiNQvXlnY2mDIddgtRF/heAxX8AXbz8svgNJW/XOPzW2vAlY++hiviDoaFXstl7c+LYvGvYa2XQ/RpQzo7BpFYFnzOII1YuHQEjnyBfwNcB2P4soFS6zYtCrGtgAEd5O0uuFuKo5oV7dk6EDNQkHlN8twuaEAFZRVfxyYJ3iMWfU9YTzvqJJHcVF/OENmTzRaXtDQ2iqMF5xA3D78D/gR1WiETlfh9GtkmMwTaq3CkqbB7XscKcHIhyJ6YhJp6A47co57eNfAACV/tnJ1EMcaihOcPxpmxXvpTs21WMRc2pGag5Tupm137ODTw+mSHEuHDVKkfyNTY0JcZS+uJoHllxiDShAi+2bIUzZelN2gDvUIRSHEEb2a+ImG9Jyp0s4JGl/kvv1Sd20O7Lh37melW2fUK6yC7rhOyfIV6omigzLEKULc1hedaxgNCw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR10MB2869.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(366004)(6512007)(36756003)(83380400001)(186003)(38100700002)(86362001)(5660300002)(7416002)(2616005)(30864003)(6486002)(44832011)(508600001)(6666004)(8676002)(4326008)(52116002)(2906002)(66946007)(66476007)(6506007)(66556008)(6916009)(316002)(8936002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?yKpH8gJKd179TEuAXHdIMBl42Hh/?= =?utf-8?q?m26mLZVd1VSETmUAC3li18BXlTQ+uD7JdBgLvrnND0IX2ycNqUuZ0hIN/CHEwMgdC?= =?utf-8?q?TBB95No40univBTzPG02f/WGj/3kC80BWGyQdxToOHGvwye0AEcpaTaE2+d0Ek5My?= =?utf-8?q?16BmdqLArU+JaBEgoBajw2sEkL1yoItlA/80L+AAs4ZADGO/cyCxq/YLzVVgELkpO?= =?utf-8?q?zM/cqntjtlSaO590Qliu9PnV0C6xta5Qv/heUqUv01npdqqGzGiK7A5QYYR7rdMSm?= =?utf-8?q?cW7QwwR20OH0WrtCRoFVg6aHo+Zdmh1GC1U6tSdH6K4KiXKSqB3jJpovW2D/Rkld+?= =?utf-8?q?BpM5t/aAWBjxh+AKdK54QAvExsuhBMQPlNLYzdCinK7jlsbPOP8+O57KzYT+JGorH?= =?utf-8?q?TWxShlmwCaZt5imCfLxS4ddX/hF6hFH1EMuvd73uSD1u85h4P5gofh0ljga8LSa8S?= =?utf-8?q?A3HJjVhFcXo1Hypfay0CP3W9oGD7pAsaZdwLgnWMrIW6zwCGCKQT5PMiBxHx8TQop?= =?utf-8?q?ENII57dd5UATQNm7i6WGlnnDd1BYHihmeubZSyKFqFo2pKSrMTK1ymc/it4QovHlK?= =?utf-8?q?to9HOGiQyXNv/Ev2M+zAtVI2fUlvxWcrMtovw8jDBErlV2ti4cpPXf/PiuDU3VAto?= =?utf-8?q?9jQhrREcFQKht93+5hUi00wMbE921WiUkS1zc5uhrzIqbjqTnYqCIidP+viuWQ/Nr?= =?utf-8?q?rbt+f14GcR2SsFR5obA/U5xmbzI3e1c4dOJTDG/XGIvbKwibPQ05WNSF/FrNfr0sK?= =?utf-8?q?Et2QUQIYwjLvekr3ZZRYgpaKYwsu034Xnui+xVf4S5EYqTBg3kDRuhEmCpOkiQ4UC?= =?utf-8?q?/q6sgwwpc8jAInG7beAsa4hlIAKhlk8YKdm8dq1cPwUZaFGB0t39Jxo1tHlvRm3XT?= =?utf-8?q?xMsGnAZsx0G7/CXj/SIEO/nfKaJcc7MIwlbHkYwOiw02G1V0Hj7TJD6mjXYTemMaz?= =?utf-8?q?7mcUUZZzYoebM8ymcc+cVBlDVldZ5pE4NsVrkbqtdR3m7RNYCBqX3NlSzs6Vs/jmI?= =?utf-8?q?iUi9BFavG35xszG5HlZHYvbNx9T+ocgGIC5SU9K9MStRxQ4t2ytEW57KDdeyCz/Yr?= =?utf-8?q?wgr3DNLHhvWHJh+wJpHrQKPkuRNmjv4W1k9Serm5CuTKzHZ9dvR6gR25yJoqV7ohr?= =?utf-8?q?Pyac66iRKScHmmn2Smj7bZZv5hKEc4Cm2FJjxIbywORSK8nrWAvVEl5F8AnuuDcBt?= =?utf-8?q?pJzfOFWvyIUxymMyCcBAruU2I0DMk464I/zH73x39TgxQbbH7njwnimHFfJBc05HC?= =?utf-8?q?nm2KYEahprWEFD19b5BBRMeFefihYuAEnRlM9xPDoGCIJkEyQIcfDXVyGEH/Lw3ka?= =?utf-8?q?s5i2QlEjLwMxm2tL7Yj6hVz3ZFoRCLPju803NNcnXNQhdq8jAEZby2gsGazXq6/mf?= =?utf-8?q?r6PYCNaKCDKycckX6SY+kzbLq4U2hEpZgieQ6rjjtgX4gjA7AAT2uc5y/OX+G/NV2?= =?utf-8?q?egyLH/2y86wKk5S2Wh5VOy2mthy+rlgXeQz4ATg9CXV/eMSntsjDosS0Bfw2NBcDz?= =?utf-8?q?bq3ucTBtZB6j0l0MVzrhzZN4+YIktwlRGDFrCi6nrQM2IAOkOMWzZyUxGLyc+4IHn?= =?utf-8?q?vMWt+45qCQAuMuEEtvCf4qR9zrV0MZPnou3sszcYCP3+9z2Q9GyyXmSSMiBupIgCs?= =?utf-8?q?vxivLTCF7I9MnPtmauU7tLwOZIKawIqg=3D=3D?= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9d7f8f36-ad9e-4112-7632-08d9ead3c609 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB2869.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Feb 2022 07:22:33.2862 (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: LlTexBSAn6oNJKjgrqvAPPMROjEQeunDKBYPpGgFm+c/y/tWRTXmeBOKWMRKetBF2gtzskoRJZkyo4Hlpe1defGFBBEuDvKzrvaf8b8++hU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN4PR10MB5608 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10251 signatures=673430 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 bulkscore=0 suspectscore=0 mlxlogscore=999 mlxscore=0 adultscore=0 malwarescore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2201110000 definitions=main-2202080038 X-Proofpoint-ORIG-GUID: Yg0mxHAGpBvuAm2XZuQvRy4tuL2CoUCr X-Proofpoint-GUID: Yg0mxHAGpBvuAm2XZuQvRy4tuL2CoUCr Received-SPF: pass client-ip=205.220.165.32; envelope-from=elena.ufimtseva@oracle.com; helo=mx0a-00069f02.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=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: , Cc: eduardo@habkost.net, john.g.johnson@oracle.com, cohuck@redhat.com, jag.raman@oracle.com, john.levon@nutanix.com, eblake@redhat.com, david@redhat.com, armbru@redhat.com, peterx@redhat.com, mst@redhat.com, berrange@redhat.com, stefanha@redhat.com, pbonzini@redhat.com, philmd@redhat.com Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Elena Ufimtseva --- meson.build | 15 ++- qapi/qom.json | 32 +++++- include/hw/remote/ioregionfd.h | 40 +++++++ hw/remote/ioregionfd.c | 196 +++++++++++++++++++++++++++++++++ Kconfig.host | 3 + MAINTAINERS | 2 + hw/remote/Kconfig | 4 + hw/remote/meson.build | 1 + meson_options.txt | 2 + scripts/meson-buildoptions.sh | 3 + 10 files changed, 294 insertions(+), 4 deletions(-) create mode 100644 include/hw/remote/ioregionfd.h create mode 100644 hw/remote/ioregionfd.c diff --git a/meson.build b/meson.build index 96de1a6ef9..6483e754bd 100644 --- a/meson.build +++ b/meson.build @@ -258,6 +258,17 @@ if targetos != 'linux' and get_option('multiprocess').enabled() endif multiprocess_allowed = targetos == 'linux' and not get_option('multiprocess').disabled() +# TODO: drop this limitation +if not multiprocess_allowed and not get_option('ioregionfd').disabled() + error('To enable ioregiofd support, enable mutliprocess option.') +endif +ioregionfd_allowed = multiprocess_allowed and not get_option('ioregionfd').disabled() +if ioregionfd_allowed + config_host += { 'CONFIG_IOREGIONFD': 'y' } +else + config_host += { 'CONFIG_IOREGIONFD': 'n' } +endif + libm = cc.find_library('m', required: false) threads = dependency('threads') util = cc.find_library('util', required: false) @@ -1837,7 +1848,8 @@ host_kconfig = \ (have_virtfs ? ['CONFIG_VIRTFS=y'] : []) + \ ('CONFIG_LINUX' in config_host ? ['CONFIG_LINUX=y'] : []) + \ ('CONFIG_PVRDMA' in config_host ? ['CONFIG_PVRDMA=y'] : []) + \ - (multiprocess_allowed ? ['CONFIG_MULTIPROCESS_ALLOWED=y'] : []) + (multiprocess_allowed ? ['CONFIG_MULTIPROCESS_ALLOWED=y'] : []) + \ + (ioregionfd_allowed ? ['CONFIG_IOREGIONFD=y'] : []) ignored = [ 'TARGET_XML_FILES', 'TARGET_ABI_DIR', 'TARGET_ARCH' ] @@ -3315,6 +3327,7 @@ summary_info += {'target list': ' '.join(target_dirs)} if have_system summary_info += {'default devices': get_option('default_devices')} summary_info += {'out of process emulation': multiprocess_allowed} + summary_info += {'ioregionfd support': ioregionfd_allowed} endif summary(summary_info, bool_yn: true, section: 'Targets and accelerators') diff --git a/qapi/qom.json b/qapi/qom.json index eeb5395ff3..439fb94c93 100644 --- a/qapi/qom.json +++ b/qapi/qom.json @@ -689,6 +689,29 @@ 'data': { 'chardev': 'str', '*log': 'str' } } +## +# @IORegionFDObjectProperties: +# +# Describes ioregionfd for the device +# +# @devid: the id of the device to be associated with the ioregionfd +# +# @iofd: File descriptor +# +# @bar: BAR number to use with ioregionfd +# +# @start: offset from the BAR start address of ioregionfd +# +# @size: size of the ioregionfd +## +# Since: 2.9 +{ 'struct': 'IORegionFDObjectProperties', + 'data': { 'devid': 'str', + 'iofd': 'str', + 'bar': 'int', + '*start': 'int', + '*size':'int' } } + ## # @RemoteObjectProperties: # @@ -842,8 +865,10 @@ 'tls-creds-psk', 'tls-creds-x509', 'tls-cipher-suites', - { 'name': 'x-remote-object', 'features': [ 'unstable' ] } - ] } + { 'name': 'x-remote-object', 'features': [ 'unstable' ] }, + { 'name' :'ioregionfd-object', + 'if': 'CONFIG_IOREGIONFD' } + ] } ## # @ObjectOptions: @@ -905,7 +930,8 @@ 'tls-creds-psk': 'TlsCredsPskProperties', 'tls-creds-x509': 'TlsCredsX509Properties', 'tls-cipher-suites': 'TlsCredsProperties', - 'x-remote-object': 'RemoteObjectProperties' + 'x-remote-object': 'RemoteObjectProperties', + 'ioregionfd-object': 'IORegionFDObjectProperties' } } ## diff --git a/include/hw/remote/ioregionfd.h b/include/hw/remote/ioregionfd.h new file mode 100644 index 0000000000..c8a8b32ee0 --- /dev/null +++ b/include/hw/remote/ioregionfd.h @@ -0,0 +1,40 @@ +/* + * Ioregionfd headers + * + * Copyright © 2018, 2022 Oracle and/or its affiliates. + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + * + */ + +#ifndef IOREGIONFD_H +#define IOREGIONFD_H + +#define PCI_BARS_NR 6 + +typedef struct { + uint64_t val; + bool memory; +} IORegionFDOp; + +typedef struct { + int fd; + char *devid; + uint32_t bar; + uint32_t start; + uint32_t size; + bool memory; +} IORegionFD; + +struct IORegionFDObject { + /* private */ + Object parent; + + IORegionFD ioregfd; + QTAILQ_ENTRY(IORegionFDObject) next; +}; + +typedef struct IORegionFDObject IORegionFDObject; + +#endif /* IOREGIONFD_H */ diff --git a/hw/remote/ioregionfd.c b/hw/remote/ioregionfd.c new file mode 100644 index 0000000000..ae95f702a6 --- /dev/null +++ b/hw/remote/ioregionfd.c @@ -0,0 +1,196 @@ +/* + * Memory manager for remote device + * + * Copyright © 2018, 2021 Oracle and/or its affiliates. + * + * 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 "sysemu/kvm.h" +#include "linux/kvm.h" + +#include "exec/memory.h" +#include "qapi/error.h" +#include "qemu/error-report.h" +#include "qom/object_interfaces.h" +#include "exec/confidential-guest-support.h" +#include "io/channel.h" +#include "qemu/sockets.h" +#include "qemu/cutils.h" +#include "io/channel-socket.h" +#include "monitor/monitor.h" +#include "hw/remote/ioregionfd.h" +#include "hw/pci/pci.h" +#include "qapi/qapi-visit-qom.h" +#include "hw/remote/remote.h" + +#define TYPE_IOREGIONFD_OBJECT "ioregionfd-object" +OBJECT_DECLARE_TYPE(IORegionFDObject, IORegionFDObjectClass, IOREGIONFD_OBJECT) + +struct IORegionFDObjectClass { + ObjectClass parent_class; + + unsigned int nr_ioregfds; + unsigned int max_ioregfds; +}; + +static void ioregionfd_object_init(Object *obj) +{ + IORegionFDObjectClass *k = IOREGIONFD_OBJECT_GET_CLASS(obj); + + if (k->nr_ioregfds >= k->max_ioregfds) { + error_report("Reached max number of ioregions: %u", k->max_ioregfds); + return; + } +} + +static void ioregionfd_object_set_fd(Object *obj, const char *str, + Error **errp) +{ + IORegionFDObject *o = IOREGIONFD_OBJECT(obj); + int fd = -1; + + fd = monitor_fd_param(monitor_cur(), str, errp); + if (fd == -1) { + error_prepend(errp, "Could not parse ioregionfd fd %s:", str); + return; + } + o->ioregfd.fd = fd; +} + +static void ioregionfd_object_set_devid(Object *obj, const char *str, + Error **errp) +{ + IORegionFDObject *o = IOREGIONFD_OBJECT(obj); + + g_free(o->ioregfd.devid); + + o->ioregfd.devid = g_strdup(str); +} + +static char *ioregionfd_object_get_devid(Object *obj, Error **errp) +{ + IORegionFDObject *o = IOREGIONFD_OBJECT(obj); + + return g_strdup(o->ioregfd.devid); +} + +static void ioregionfd_object_set_bar(Object *obj, Visitor *v, + const char *name, void *opaque, + Error **errp) +{ + IORegionFDObject *o = IOREGIONFD_OBJECT(obj); + uint32_t value; + + if (!visit_type_uint32(v, name, &value, errp)) { + return; + } + + if (value > PCI_BARS_NR) { + error_setg(errp, "BAR number cannot be larger than %d", PCI_BARS_NR); + return; + } + + o->ioregfd.bar = value; +} + +static void ioregionfd_object_set_start(Object *obj, Visitor *v, + const char *name, void *opaque, + Error **errp) +{ + IORegionFDObject *o = IOREGIONFD_OBJECT(obj); + int64_t value; + + if (!visit_type_int(v, name, &value, errp)) { + return; + } + + if (value < 0) { + error_setg(errp, "BAR start %"PRId64" must be > 0", value); + return; + } + + if (value > UINT32_MAX) { + error_setg(errp, "BAR start %"PRId64" is too big", value); + o->ioregfd.start = 0; + return; + } + + o->ioregfd.start = value; +} + +static void ioregionfd_object_set_size(Object *obj, Visitor *v, + const char *name, void *opaque, + Error **errp) +{ + IORegionFDObject *o = IOREGIONFD_OBJECT(obj); + int64_t value; + + if (!visit_type_int(v, name, &value, errp)) { + return; + } + + if (value < 0) { + error_setg(errp, "Invalid BAR size %"PRId64, value); + return; + } + + if (value > UINT32_MAX) { + error_setg(errp, "BAR size %"PRId64" is too big", value); + o->ioregfd.size = 0; + return; + } + + + o->ioregfd.size = value; +} + +static void ioregionfd_object_class_init(ObjectClass *klass, void *data) +{ + IORegionFDObjectClass *k = IOREGIONFD_OBJECT_CLASS(klass); + + k->nr_ioregfds = 0; + k->max_ioregfds = 1; + + object_class_property_add_str(klass, "devid", ioregionfd_object_get_devid, + ioregionfd_object_set_devid); + object_class_property_add_str(klass, "iofd", NULL, + ioregionfd_object_set_fd); + object_class_property_add(klass, "bar", "uint32", NULL, + ioregionfd_object_set_bar, NULL, NULL); + object_class_property_add(klass, "start", "uint64", NULL, + ioregionfd_object_set_start, NULL, NULL); + object_class_property_add(klass, "size", "uint64", NULL, + ioregionfd_object_set_size, NULL, NULL); +} + +/* Assume that Object user released all allocated structures. */ +static void ioregionfd_object_finalize(Object *obj) +{ + IORegionFDObject *o = IOREGIONFD_OBJECT(obj); + g_free(o->ioregfd.devid); +} + +static const TypeInfo ioregionfd_object_info = { + .name = TYPE_IOREGIONFD_OBJECT, + .parent = TYPE_OBJECT, + .instance_size = sizeof(IORegionFDObject), + .instance_init = ioregionfd_object_init, + .instance_finalize = ioregionfd_object_finalize, + .class_size = sizeof(IORegionFDObjectClass), + .class_init = ioregionfd_object_class_init, + .interfaces = (InterfaceInfo[]) { + { TYPE_USER_CREATABLE }, + { } + } +}; + +static void register_types(void) +{ + type_register_static(&ioregionfd_object_info); +} + +type_init(register_types); diff --git a/Kconfig.host b/Kconfig.host index 60b9c07b5e..af01b75770 100644 --- a/Kconfig.host +++ b/Kconfig.host @@ -45,3 +45,6 @@ config MULTIPROCESS_ALLOWED config FUZZ bool select SPARSE_MEM + +config IOREGIONFD + bool diff --git a/MAINTAINERS b/MAINTAINERS index 3c60a29760..d29fa8a7de 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -3454,6 +3454,8 @@ F: include/hw/remote/proxy-memory-listener.h F: hw/remote/iohub.c F: include/hw/remote/iohub.h F: include/hw/remote/remote.h +F: include/hw/remote/ioregionfd.h +F: hw/remote/ioregionfd.c EBPF: M: Jason Wang diff --git a/hw/remote/Kconfig b/hw/remote/Kconfig index 08c16e235f..caff3427e7 100644 --- a/hw/remote/Kconfig +++ b/hw/remote/Kconfig @@ -2,3 +2,7 @@ config MULTIPROCESS bool depends on PCI && PCI_EXPRESS && KVM select REMOTE_PCIHOST +config IOREGIONFD + bool + default n + depends on MULTIPROCESS diff --git a/hw/remote/meson.build b/hw/remote/meson.build index e6a5574242..b190c520c4 100644 --- a/hw/remote/meson.build +++ b/hw/remote/meson.build @@ -6,6 +6,7 @@ remote_ss.add(when: 'CONFIG_MULTIPROCESS', if_true: files('message.c')) remote_ss.add(when: 'CONFIG_MULTIPROCESS', if_true: files('remote-obj.c')) remote_ss.add(when: 'CONFIG_MULTIPROCESS', if_true: files('proxy.c')) remote_ss.add(when: 'CONFIG_MULTIPROCESS', if_true: files('iohub.c')) +specific_ss.add(when: 'CONFIG_IOREGIONFD', if_true: files('ioregionfd.c')) specific_ss.add(when: 'CONFIG_MULTIPROCESS', if_true: files('memory.c')) specific_ss.add(when: 'CONFIG_MULTIPROCESS', if_true: files('proxy-memory-listener.c')) diff --git a/meson_options.txt b/meson_options.txt index e392323732..52b338c1b8 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -66,6 +66,8 @@ option('cfi_debug', type: 'boolean', value: 'false', description: 'Verbose errors in case of CFI violation') option('multiprocess', type: 'feature', value: 'auto', description: 'Out of process device emulation support') +option('ioregionfd', type: 'feature', value: 'auto', + description: 'Fast-path IO/MMIO support') option('attr', type : 'feature', value : 'auto', description: 'attr/xattr support') diff --git a/scripts/meson-buildoptions.sh b/scripts/meson-buildoptions.sh index 7a17ff4218..1cbd2984f5 100644 --- a/scripts/meson-buildoptions.sh +++ b/scripts/meson-buildoptions.sh @@ -98,6 +98,7 @@ meson_options_help() { printf "%s\n" ' Xen PCI passthrough support' printf "%s\n" ' xkbcommon xkbcommon support' printf "%s\n" ' zstd zstd compression support' + printf "%s\n" ' ioregionfd ioregionfd support' } _meson_option_parse() { case $1 in @@ -270,6 +271,8 @@ _meson_option_parse() { --disable-xkbcommon) printf "%s" -Dxkbcommon=disabled ;; --enable-zstd) printf "%s" -Dzstd=enabled ;; --disable-zstd) printf "%s" -Dzstd=disabled ;; + --enable-ioregionfd) printf "%s" -Dioregionfd=enabled ;; + --disable-ioregionfd) printf "%s" -Dioregionfd=disabled ;; *) return 1 ;; esac } From patchwork Tue Feb 8 07:22:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elena Ufimtseva X-Patchwork-Id: 12738410 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 F3B18C433F5 for ; Tue, 8 Feb 2022 09:48:29 +0000 (UTC) Received: from localhost ([::1]:47132 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nHN6q-0003rq-LP for qemu-devel@archiver.kernel.org; Tue, 08 Feb 2022 04:48:28 -0500 Received: from eggs.gnu.org ([209.51.188.92]:54000) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nHKpt-0001xL-8B for qemu-devel@nongnu.org; Tue, 08 Feb 2022 02:22:49 -0500 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]:46560) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nHKpl-0001vb-3X for qemu-devel@nongnu.org; Tue, 08 Feb 2022 02:22:47 -0500 Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 2186sIux007544; Tue, 8 Feb 2022 07:22:39 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-transfer-encoding : content-type : mime-version; s=corp-2021-07-09; bh=h9ObOmoSV7GEHpOqL8fbNqZo3ChyoR3Cn/AmxxbVev0=; b=Ya/jl81kJ292TkCuIfirSIey0Xu3Zr5a9ds5C9ijSDJsuqwrDRSdCONEl25yk54BZihd u5umDjOt56jrTQjflbHDfqGL6vnvYa6qmwQuNHsjzAazVo4FolPQXtfeXBblc5fYDl18 n5HoajXt8ZpYoPp0ln8JK03C732T3zk6LvEY4lpsmVxfkqBEreU8p3YkiaKIoeoLdMwq Wdg5kHlvaCrZO8j/U9A8wxa3FiCxwL+KiF2uJDYQYitXL6Wyq6/Aze79nebnow+c4C/l FqpezBfqoaZ0HudOaC8+h+EInf34ff3L9KL7BcFznBgjydc9YXw4EIbSc9eMFcwih6r8 ug== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by mx0b-00069f02.pphosted.com with ESMTP id 3e368tsxcv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 08 Feb 2022 07:22:38 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 2187BlYt093365; Tue, 8 Feb 2022 07:22:37 GMT Received: from nam10-mw2-obe.outbound.protection.outlook.com (mail-mw2nam10lp2104.outbound.protection.outlook.com [104.47.55.104]) by userp3030.oracle.com with ESMTP id 3e1ebykknc-6 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 08 Feb 2022 07:22:37 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=US2GvwLRpql4kv5eiZ0WOcAjDJ+krMQfQ/OkPxnbGKdF+KFbl/T4GHjWk/98ivL9d2YIDrtZx86lOnWQLioGKrwJ4PfYUGmNSDZIjDtdi27iBTdCy88TkcCYFSUQii4hE77L92uHpXmMZa8RRPGP+eyfEbhsGpNmMhPSuYciXd9mIgwPlSMy+rXxfdTe4lD7v3Px+Rrmcyl1BqsfQ9VATYAAHeL6GPBPU2Wv51hDcRoLMzbwQnciYdQmRntHA/1p26VNnVxqvFJ5zkCrYjO/yARqKXFiX/L37Y5bjHySUuL6UtyzquymJJlT9fci9C0ltzYvU/HPX7B3VOKxJkZc0g== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=h9ObOmoSV7GEHpOqL8fbNqZo3ChyoR3Cn/AmxxbVev0=; b=bOOPP0ApSkd8e/iWJLRVpFGN+x1TONByvCD2W0XsTPiOG6/wVx+TzvkwDM3qs6iMHBD1h322o/PxS4hKsgrH8ASCseFbAEBIfUgvg5o9pA4bV9EmpB5NUnvH9YfPt1K7UkaSEHTTXLQDjrO/r9GZX9+4FVnxRuJaz/ZbH/ooUPectU/ya6fkDVklMZA8HhdYSWBd8rqRs2GYWSKTW9U9nQ9WXvaNcoTicj9jbTmNccaC/MHMWYI7MR9j+s5rGFVTNgmDxa3peK/tgDYOK4gZgU50ygZRpkRpZDrNxLcgfG+ykPArMV5dduSQ0IHnKL2k9vV7u6LIFMDe9NEJOokpCw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; 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=h9ObOmoSV7GEHpOqL8fbNqZo3ChyoR3Cn/AmxxbVev0=; b=ih/V9Tobue19mTMWZokc0+48+p6X92urRsoYsyNIjZEnl9193UE86amagHsyCyCeSMFaIOnbKCAt8G2hoPM+C3HM31JsBIej0oxGM4NJw+IxX7BKyibViVlde7sP/i8VnRnKZ9+xVoiH4mAFIno81IV9NtIYaaJ/NonrPlGmPh0= Received: from BYAPR10MB2869.namprd10.prod.outlook.com (2603:10b6:a03:85::17) by SN4PR10MB5608.namprd10.prod.outlook.com (2603:10b6:806:20b::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.18; Tue, 8 Feb 2022 07:22:34 +0000 Received: from BYAPR10MB2869.namprd10.prod.outlook.com ([fe80::4bd:1cfa:5aee:6c81]) by BYAPR10MB2869.namprd10.prod.outlook.com ([fe80::4bd:1cfa:5aee:6c81%3]) with mapi id 15.20.4951.019; Tue, 8 Feb 2022 07:22:34 +0000 From: Elena Ufimtseva To: qemu-devel@nongnu.org Subject: [RFC 5/8] multiprocess: prepare ioregionfds for remote device Date: Mon, 7 Feb 2022 23:22:19 -0800 Message-Id: <7b0f00218f64b5b4445837c0edaed2b97a020213.1644302411.git.elena.ufimtseva@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: X-ClientProxiedBy: BY5PR16CA0006.namprd16.prod.outlook.com (2603:10b6:a03:1a0::19) To BYAPR10MB2869.namprd10.prod.outlook.com (2603:10b6:a03:85::17) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 75856efe-8c84-461b-9356-08d9ead3c6ab X-MS-TrafficTypeDiagnostic: SN4PR10MB5608:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:530; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: GBnye1zN+oyq7G5PlOOn5od81ijb1TUd/0dlr4sw5/piAQSL6tBW47tBh14ADS7JWJDdgWo3DUimUJDFQ4M2WV+kwJi1Xe+2EFdTNclA/bazUD3iqN+HGIU1pXWa4MGnnyZeFUbFwJmrdr7tXwdQmw5NYvmwszW1VR6WQzNFM9BdQO9sQjHtF3p+3M32aj7RfhnRRBqBUjEMw4ekqblHOku52aFcG8SJuMIO9HHpRIbtULlJztY5MZDSRoUXQBn9ZlwERq6pG8qO8PRIcgHFRkGxhmNGTJlnjIzZV0vmwQz2PT3CvU/bw6rDtpwg9Zuzc0foM2coXnTjx1yjYm4eNA6qkFh/oXlx1jqGpkoq1Dhh3izA2EFaOuRTVa0KaiN+P6nLE290JgSLWQFpuv5ySo0IG0r01bqDQQ0BhmvloYfW/Pqt11EbuskVmP4nX51bebGoYnQsk29Pkt5MxtyrUABFRKu6ZtJF0TdPZZ9C2qXK2qK8S9q91CwtJpK4j6JYptjRqF1aDbgzE0a6RyxR9+7mZkAkqFX3X2JrwJBx+0wMFnDVM+EY09O9nWhFrnnitGIxfT6vxeyILDR9QqPBKxhU9LVU7MBNJM+pPu9TGdmYWWMGG6I80BySNm+Lalhrfp13yOeSP2JaONuXWM+VCQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR10MB2869.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(366004)(6512007)(36756003)(83380400001)(186003)(38100700002)(86362001)(5660300002)(7416002)(2616005)(6486002)(44832011)(508600001)(6666004)(8676002)(4326008)(52116002)(2906002)(66946007)(66476007)(6506007)(66556008)(6916009)(316002)(8936002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: In8xl1bAIA6HiNFyy9LkedkaqdMIgxBQ+Ea5WQGNSYznF/Rk6yhEqjrw2hEtK6s0OVwkAJ7rBCdwN4V1tT0gpnXYa3KX1YRaO6ndSLYU8cJkaH6IjxwnwMx4zpQQ9ElxMaSlZ4O1vr1HxTk9lZZ1p07BNUsbqfWarRp4rWZj/Xs98BjVQUdQoN5wRfDsDCJhFZXKXeX6QsG35kD55UfVpJ9XbGR/01TsE6t6tTIf/jeDLtK34S/NR4Dv2oLj3ZwJtnm4PvjfDirPANtJvoXQkHEFUKq0iwKfWNkRhTZ8l2foMI4iNmLre0v5xg3Q70UC2M/Jcsgp4sbZXZ27jhA6MUJAxGqYPp0tsNlPIMJJY3aBfm8r6Y5onOkShteB5T0g03RAWbBUO6eDPSwq+gNSZiMm612tQWE5bVAp5lJ8jpopOOw3E97G5G4V40DZhv8xPDyF0inFAmO1T+z06F1HW838vfDJicwjFNj2WWqoMTBlVjKtsAPoJFF48GPrVOuTfRw9rD3B1lYfpV9iVHr9Eyz6UR0BSp2/KVqFVRV7TKO3S5EWBXeqm4aFu6x3U9vS3t1GMbp55irvLptAyPF/R/wU3QeZyz6yvS5NoP6jAErtfOQLV5nmnQkYqizBBkZOMD7+BqPhjZpBxJDQmHaW4sO+8gjgw+hqWMHLd11ET4l3AnmPVnixibjcHP/a1tIr5xeCEaejHiZzM8GMLr7L5ZoPoGstZpMJ48jFv74pGaHjkEDXoTTQX4YA64wmVHJ516jHwXXy6xwqG7TZx2wIZNl4YlLc5w3vB1B4GGhDUnlTotQceA6aaln4g2bDxeuIkJtsSEfbtQZE9a6kBcP61KKhBTSGGUy29s+KDe7Rpu8Qq+NICbmBqIOxxj07L2m8fPyeK+K0+ZkTHV+EmqZWbKzY3RhMmf4MyRsrYAueWrfC4CSPFE82Wz1eDIKEW4qPOtgWwKvrl0Ohb4WT2IIqxwcK4cRTVC99VpUmpdqCkxgcXv9y7OpfukfCslJbBXTpprKlUBco+FS7T9+3825Cj+9EhHCA4X/9ZspsctC6TBi3DGreNTCtUzVJKErpMoM6sRjff/TANNrjnca4qflECCYErja/K7BF4uswbz45fV1zJR7QMlnArEQd6CoRCTpqiJhk8IN0iAsTlzMamSGeX8KKw5/+UfS/bVvpueLuwdIv+iLpnNb+2RzEyxyEH4u9SKNjtYMvPO5KIYNythYOQNUQKtZynXBZO8vYMMnsc5s5bGItxp05OL/QC/pklZLCk2VcomBPivr9Xg2CtTsdR4Aq0f0CFE1GYH6c8A/NzMcY7SOV8bfkNCYm6py35pllp8tAHgyzX8xAK9X/ehoWnUkFzqOIXbD5xfIVVdOlcibO303GrQOFygVfilrs9YWuyLFzCj7tXbdcud780rPV8kJGxQAVFanc1jEWCLBEDSR6DapVV1sHSPU6V9dR701AmCLlwKGdBhnzoHNlkNgCJvtTzR2t3l+EbIa6nLZMgPAE5lY0v1vP6oyYz12PjS3tufNB7O8qVjtkRyng14BoWzCghrzSoh41FUs7tg85Ek30+hJiLUXoKnbxChP0JRQWn7KBGurGj7AZ951YTMOLMT2xZAX8CdUbD16gcNSdnL0wg95MZqslA/WsSeaG5zLYOro91RH5SMPqgsHlUd5d48qJgs0Laxh6cR4No1tgfg0X9InFmTbGsknAjUdFkOO8nYTJLVtyh7pPRbsPby8msQ== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 75856efe-8c84-461b-9356-08d9ead3c6ab X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB2869.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Feb 2022 07:22:34.3017 (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: +28U3HbAlpvgDSmA6X1+fvEs/ChCkvyeW89a0JSkQF0/Pw2P6vtpuE8Co6D7Wg3qQDpYBz4a/r+f2YWcT5hSCAAmGZVp38qegN6KVvtw+XI= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN4PR10MB5608 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10251 signatures=673430 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 bulkscore=0 suspectscore=0 mlxlogscore=999 mlxscore=0 adultscore=0 malwarescore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2201110000 definitions=main-2202080038 X-Proofpoint-ORIG-GUID: CA_jay0y9tTqQaOlwZm7SnAdCzArxmOr X-Proofpoint-GUID: CA_jay0y9tTqQaOlwZm7SnAdCzArxmOr Received-SPF: pass client-ip=205.220.165.32; envelope-from=elena.ufimtseva@oracle.com; helo=mx0a-00069f02.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=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: , Cc: eduardo@habkost.net, john.g.johnson@oracle.com, cohuck@redhat.com, jag.raman@oracle.com, john.levon@nutanix.com, eblake@redhat.com, david@redhat.com, armbru@redhat.com, peterx@redhat.com, mst@redhat.com, berrange@redhat.com, stefanha@redhat.com, pbonzini@redhat.com, philmd@redhat.com Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Elena Ufimtseva --- include/hw/remote/ioregionfd.h | 1 + include/hw/remote/remote.h | 1 + hw/remote/ioregionfd.c | 26 ++++++++++ hw/remote/remote-obj.c | 93 ++++++++++++++++++++++++++++++++++ 4 files changed, 121 insertions(+) diff --git a/include/hw/remote/ioregionfd.h b/include/hw/remote/ioregionfd.h index c8a8b32ee0..85a2ef2c4f 100644 --- a/include/hw/remote/ioregionfd.h +++ b/include/hw/remote/ioregionfd.h @@ -37,4 +37,5 @@ struct IORegionFDObject { typedef struct IORegionFDObject IORegionFDObject; +GSList *ioregionfd_get_obj_list(void); #endif /* IOREGIONFD_H */ diff --git a/include/hw/remote/remote.h b/include/hw/remote/remote.h index a2d23178b9..46390c7934 100644 --- a/include/hw/remote/remote.h +++ b/include/hw/remote/remote.h @@ -23,6 +23,7 @@ struct RemoteObject { DeviceState *dev; DeviceListener listener; + GHashTable *ioregionfd_hash; }; #endif diff --git a/hw/remote/ioregionfd.c b/hw/remote/ioregionfd.c index ae95f702a6..85ec0f7d38 100644 --- a/hw/remote/ioregionfd.c +++ b/hw/remote/ioregionfd.c @@ -37,6 +37,32 @@ struct IORegionFDObjectClass { unsigned int max_ioregfds; }; +static int ioregionfd_obj_list(Object *obj, void *opaque) +{ + GSList **list = opaque; + + if (object_dynamic_cast(obj, TYPE_IOREGIONFD_OBJECT)) { + *list = g_slist_append(*list, obj); + } + + object_child_foreach(obj, ioregionfd_obj_list, opaque); + return 0; +} + +/* + * inquire ioregionfd objects and link them into the list which is + * returned to the caller. + * + * Caller must free the list. + */ +GSList *ioregionfd_get_obj_list(void) +{ + GSList *list = NULL; + + object_child_foreach(object_get_root(), ioregionfd_obj_list, &list); + return list; +} + static void ioregionfd_object_init(Object *obj) { IORegionFDObjectClass *k = IOREGIONFD_OBJECT_GET_CLASS(obj); diff --git a/hw/remote/remote-obj.c b/hw/remote/remote-obj.c index f0da696662..9bb61c3a2d 100644 --- a/hw/remote/remote-obj.c +++ b/hw/remote/remote-obj.c @@ -24,6 +24,10 @@ #include "qemu/sockets.h" #include "monitor/monitor.h" #include "hw/remote/remote.h" +#include "hw/remote/ioregionfd.h" +#include "qemu/cutils.h" +#include "qapi/qapi-visit-qom.h" +#include "qapi/string-output-visitor.h" #define TYPE_REMOTE_OBJECT "x-remote-object" OBJECT_DECLARE_TYPE(RemoteObject, RemoteObjectClass, REMOTE_OBJECT) @@ -74,6 +78,80 @@ static void remote_object_unrealize_listener(DeviceListener *listener, } } +static GSList *ioregions_list; + +static unsigned int ioregionfd_bar_hash(const void *key) +{ + const IORegionFDObject *o = key; + + return g_int_hash(&o->ioregfd.bar); +} + +/* TODO: allow for multiple ioregionfds per BAR. */ +static gboolean ioregionfd_bar_equal(const void *a, const void *b) +{ + const IORegionFDObject *oa = a; + const IORegionFDObject *ob = b; + + error_report("BARS comparing %d %d", oa->ioregfd.bar, ob->ioregfd.bar); + if (oa->ioregfd.bar == ob->ioregfd.bar) { + return TRUE; + } + return FALSE; +} + +static void ioregionfd_prepare_for_dev(RemoteObject *o, PCIDevice *dev) +{ + IORegionFDObject *ioregfd_obj = NULL; + GSList *obj_list, *list; + + list = ioregionfd_get_obj_list(); + + o->ioregionfd_hash = g_hash_table_new(ioregionfd_bar_hash, + ioregionfd_bar_equal); + + for (obj_list = list; obj_list; obj_list = obj_list->next) { + ioregfd_obj = obj_list->data; + if (strcmp(ioregfd_obj->ioregfd.devid, o->devid) != 0) { + list = g_slist_remove(list, ioregfd_obj); + error_report("No my dev remove"); + continue; + } + if (!g_hash_table_add(o->ioregionfd_hash, ioregfd_obj)) { + error_report("Cannot use more than one ioregionfd per bar"); + list = g_slist_remove(list, ioregfd_obj); + object_unparent(OBJECT(ioregfd_obj)); + } else { + error_report("Added to hash"); + } + } + + if (!list) { + error_report("Remote device %s will not have ioregionfds.", + o->devid); + goto fatal; + } + + /* + * Take first element in the list of ioregions and use its fd + * for all regions for this device. + * TODO: make this more flexible and allow different fd for the + * device. + */ + ioregfd_obj = list->data; + + /* This is default and will be changed when proxy requests region info. */ + ioregfd_obj->ioregfd.memory = true; + + ioregions_list = list; + return; + + fatal: + g_slist_free(list); + g_hash_table_destroy(o->ioregionfd_hash); + return; +} + static void remote_object_machine_done(Notifier *notifier, void *data) { RemoteObject *o = container_of(notifier, RemoteObject, machine_done); @@ -98,6 +176,10 @@ static void remote_object_machine_done(Notifier *notifier, void *data) o->dev = dev; +#if CONFIG_IOREGIONFD + ioregionfd_prepare_for_dev(o, PCI_DEVICE(dev)); +#endif + o->listener.unrealize = remote_object_unrealize_listener; device_listener_register(&o->listener); @@ -132,6 +214,13 @@ static void remote_object_init(Object *obj) qemu_add_machine_init_done_notifier(&o->machine_done); } +static void ioregionfd_release(gpointer data, gpointer user_data) +{ + IORegionFDObject *o = data; + + object_unparent(OBJECT(o)); +} + static void remote_object_finalize(Object *obj) { RemoteObjectClass *k = REMOTE_OBJECT_GET_CLASS(obj); @@ -148,6 +237,10 @@ static void remote_object_finalize(Object *obj) k->nr_devs--; g_free(o->devid); + /* Free the list of the ioregions. */ + g_slist_foreach(ioregions_list, ioregionfd_release, NULL); + g_slist_free(ioregions_list); + g_hash_table_destroy(o->ioregionfd_hash); } static void remote_object_class_init(ObjectClass *klass, void *data) From patchwork Tue Feb 8 07:22:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elena Ufimtseva X-Patchwork-Id: 12738409 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 79923C433EF for ; Tue, 8 Feb 2022 09:42:38 +0000 (UTC) Received: from localhost ([::1]:40254 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nHN1B-0007FH-Cy for qemu-devel@archiver.kernel.org; Tue, 08 Feb 2022 04:42:37 -0500 Received: from eggs.gnu.org ([209.51.188.92]:53988) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nHKpr-0001x5-PP for qemu-devel@nongnu.org; Tue, 08 Feb 2022 02:22:49 -0500 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]:48312) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nHKpl-0001vg-VA for qemu-devel@nongnu.org; Tue, 08 Feb 2022 02:22:47 -0500 Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 2186pU43007539; Tue, 8 Feb 2022 07:22:39 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-transfer-encoding : content-type : mime-version; s=corp-2021-07-09; bh=8UauS2CS3oErEplA5shbyREpZMDyj2XT9cAdMg2XCj0=; b=Hau8SC08TD5XEEo5KEhkv7wzYd2XeTs1msckEty5ayOZzDEnDpnH9MdfDrWEDzkqZA2x D2u6ZaYRJ1p3fsW8KtYk6GllfxYZOFbeamDDPNappvEE9HUxsGouQiG+H+UEnbiSfccr jEjBk5xOGd2PJGn6sPfn6y9MN3UjHkC/Pki1XpZ82eED2pm9wqWIrwQZZcRKwjkhScUq PdWHfmoIfQYOY/wvCxafios2S0rXgf5uWNOAJuoG4tfZdsmrIEExoqUJZ136AblhRNgi L+M0jGS9n0MvCF4TWnGnxGhVBKjCLXbn/T4H3nKfx23aKpqCSbDqsCnBqjidbpL1V0qI WA== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by mx0b-00069f02.pphosted.com with ESMTP id 3e368tsxcx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 08 Feb 2022 07:22:39 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 2187BlYu093365; Tue, 8 Feb 2022 07:22:38 GMT Received: from nam10-mw2-obe.outbound.protection.outlook.com (mail-mw2nam10lp2104.outbound.protection.outlook.com [104.47.55.104]) by userp3030.oracle.com with ESMTP id 3e1ebykknc-7 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 08 Feb 2022 07:22:38 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hnUwoE1viz/1Sz7vc1dm1FC6Ypixay9iuncfnlmGxtZnG3Xp0ZsZAI0/mDGQuT7rymOmJYJXS8bpytTtGD/Iyvbck5/nBYTkSWagTPrrKDRfvYIZnOAQeqwiVeBBdsyQfa2lWsK/xRMEcW+UqDuEO8ABvNOcvP422WJZlAkI0j8RtCSAouTNF87xUPfW4i2YtYyDOE2gefPIWp1Q9fgFbic7m2SHkPAaWs+l24sV1sZoH02rVtzzhVAn1SixUxZWgSYciG05Y7i1f/gYqpa5/tyhg8LFpWGsLVcTVxT5KiCiUVsTOuRE3VGATE31S2eSwamNl1ovchtgTWvD6/Up/w== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=8UauS2CS3oErEplA5shbyREpZMDyj2XT9cAdMg2XCj0=; b=ReYMsAryeZVo4L3MJtjhW4dJodUsXZtALMd1MUhFz/L0Znjw+mj0XPVww7GXoKjiO5rxxZp3DEoVAy0RaXOtQJ/n1JfRRY0HnREa8F/XPqvSURLnQ/+X8WjLFINW3D3OB1a12tqH+s/fPIwxxdXYVhJfqS044QZ/zLIERROr/2mVlJ1XEi0M4Ig6eU1Zjl0QQpowXOUh6/UEAj7zJxkwROtLaWyktVSUVESel0UJ5RFJy2a2lmxiwTj6Ofdoa7ek6JmRObij2NeGWm9FnUpPZ1Z6Pw2a79syQtV863xqyFGctjHyRG7XK24HhZCW/mxRHk4xNUdQJHRXnsHgrxGBDg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; 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=8UauS2CS3oErEplA5shbyREpZMDyj2XT9cAdMg2XCj0=; b=sk7LG6KQNkcZl45WlejkCFcwgqCPAhowzYfK6+D6FVGU82Z++4gRG0w1Sjb0P5Wh/eIObgMgdWKwx9sY3XaPLx/HXIvFRNwXoQm8LBXeN9yB6x6YM9UtfSVCLbYwBSSzoc0AcnlH2qsha7xNTW8W4pwcDmbBh9L+btHxooAqYzU= Received: from BYAPR10MB2869.namprd10.prod.outlook.com (2603:10b6:a03:85::17) by SN4PR10MB5608.namprd10.prod.outlook.com (2603:10b6:806:20b::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.18; Tue, 8 Feb 2022 07:22:35 +0000 Received: from BYAPR10MB2869.namprd10.prod.outlook.com ([fe80::4bd:1cfa:5aee:6c81]) by BYAPR10MB2869.namprd10.prod.outlook.com ([fe80::4bd:1cfa:5aee:6c81%3]) with mapi id 15.20.4951.019; Tue, 8 Feb 2022 07:22:35 +0000 From: Elena Ufimtseva To: qemu-devel@nongnu.org Subject: [RFC 6/8] multiprocess: add MPQEMU_CMD_BAR_INFO Date: Mon, 7 Feb 2022 23:22:20 -0800 Message-Id: <234ed1f65ba8684d82f2e78ee6116d2209cbd499.1644302411.git.elena.ufimtseva@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: X-ClientProxiedBy: BY5PR16CA0006.namprd16.prod.outlook.com (2603:10b6:a03:1a0::19) To BYAPR10MB2869.namprd10.prod.outlook.com (2603:10b6:a03:85::17) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d255ef6c-5349-4b11-5023-08d9ead3c72c X-MS-TrafficTypeDiagnostic: SN4PR10MB5608:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:121; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: A21Yme1zVAxM4xe0RUvaOGWSfMq6C4mrKYf+g5HzfTqOz22TfgpnnVzXpT5r6MmP9cRtNT38l6w2hqUG2R3uB4SWG6s11oQIHadk/aiUjQgmQt81H2C8iYsbrCZDfyeOxbDOM60QsoWDs5AKLcE4g0yCFcCPFS4MFQMeJXq8ZikFn+06fMyqXdgo9cc6lVX1fW16Dq766Q84C07r2xl92rRXwUrQ45YzNNEZpjgovnAQD0gDGpR6bjTXqgQljRZIk/oppFaou6sS0Y/X6QMeQDrJfVSMhHHJ+oFhvygueDdNwYY59SeAkNiQY9JhXhvqxRdHujMv5knjSMhmElAAtm4KpyCULsruG/2Rdisfe8ejd4g+J4749xETJmF5KZntQl6emj5XZXujPxW+B25nxNYJJjm2Ir+FBM79sJtcf+H9D1VMVQIlLqUd0qk53IdFEZk82qb+hVU90VuGscONXInx8TSzXl4KpcJ2fsRAQ4OYupzzsGmvyICP44FmFLBjzq+M3qA74o0Oq/vOvjKjHmifoBEb6TAdA0M35lGSk+6uO5UnqWUeaYYO4cVwxIz8DMX94fP7OojEfHTuz6vTYS7uwiM7dX+45HcJjkoAxK5CZz5Lz21FOu2K1370k6GEbNFKk1aVQNJHIoZ9rrPYPw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR10MB2869.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(366004)(6512007)(36756003)(83380400001)(186003)(38100700002)(86362001)(5660300002)(7416002)(2616005)(6486002)(44832011)(508600001)(6666004)(8676002)(4326008)(52116002)(2906002)(66946007)(66476007)(6506007)(66556008)(6916009)(316002)(8936002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: TYrC+cRJelpkw8rEPsTbBqmzfkd8ZFUpdqamTMLc/DnQ62N+jt4sGJLdeujnveMbtU35UIVMnV/P8kh9f//UAp/I3ZwPEjC5n2BANU2ayjjF8Q47nBDxOT/qc3r6ifCTAq1PVbyIfuyQwTC9qPb+Y0POYsr147OytMNq38EE2L+Ioe2QChKqz4Rj88vPaE4RtjtYGmItvU2c/ZuVLtza/R/Is07NwiTLBUdXyADuT2z3vF1p6P8lWOHUy0cnAUB0I46L7MqwqanIOZhT2xLJ4LkFf6Mt04qi9JAowEJL3/5N0B+GU+++iKaKg9TbqkdM0vh0AxdiP4CxUguAh3+ilWI/i7r0FIiN5CuFWPcHYtDFV3psZs0cnDESzCPuobp2ymb6D2HWW6u1TfoAlpolvJQVngKtFxCTTrCYDGe4Jh5jaL3Pzg/vY7J08gFCcM2+pLQbjFJU9YlAEV4F7+c5kbAzRYSDMvjXx+37yHVjmINuiNlzqL7Cj0NFJF/mXRyRh+25H10/fZq+I1ZFw8jSSIrOLvPUHoFQxW0m/tnUDpuZMRrmRjcS81JFqBq1h2ZYDTozdmyamj/oiTp/hUs4IYjw1m2/WOPR9Zj++Exsy6Uo3DU92hUNhHGsCEhbTjm2DyrO7qlzqCDZT388kB1o7LcsbLIYCan6iH3ZmmDyNYaz2QQmOExGiH9F/oNnzl61y8R4k8ZutfXc57JaCViJErVTx9OwzD0Rk4sMrLRG7QjKHUgdCZQBF449i8T3dryoLbP1e9cHoJeQnmseySaivkRBxwuPoMjYagw+26/Bx9anz/vxNzKkE6tr7EE04z/m60FsuqFlgsH5VlNF43vLDsYu/npvbG0/keHe9XoOg1+Rfg5F+Z9ZHcxusEJ7jTRRvqMIdZkKif5DUdjtp9OmK14mprRfU69KkUUn0O55ms4Ev44OrPvMjW7qrFOVrt1kKeqtugcfzcYvs3it1/DtTxQFSRN0POB0D4trwqfFgFLvBcIGEisIxQPJmlfj3wVBtzguXj5fSfzrkaaG4V6h+tMcwFG8O5xPMyIaBMVxo9URib5Hb2ymx+U+2CSNGqkPE2q/Z3heLpibjuMeFdz82EPabmpTNjJM21iNMG5Ej3vnr5CmXT2j0c66hwFRTwr1ItmtG1it+c2MbsG8Iyqk73vUOdpJ15dwaRxE4cyS28SOOo5J0B1Uxezp6VLm2PUsojQuSlDbJ8RY6BLahpzNQ0HE0vfKw4+QXKSJKoa7jxBQkvV/eix/2xYSWy5q0YgnvpBanAs7DRljk9Kd0NckcvTB/xV8KWA5VlVkeiXCvfvste96u1wT5yT/IM2pgTwvEp7lfU0ote2A5YA8HNpwGixuXBQIHB7wf2b7bCZCfMQ2wPkSnoVr4EXvxiqxzUUHIPiDqVCvmZLExb6oUmcEySOrlfxRm1Fbqa2E9VIceqnxpYPU/5rxCggNCycZHLVgceDp6QJACEW9G0+kf0NRILUl+bpskiMqliAfYrs7BNLAoX6Hs7d9xhKa/CkCHIrImv4qfKlsOhmo26mYw9VhgI54x2P9Bz6PwH7o2hGGsDNTHjZyssaMJL/qEtz0A9V0g8Hve4iUUJG76oxoTIfsnzoSzZQeDw1Pa/V3D3x0bbajkQh2D4PAsY4Feaa0INUpXba46ck56gcP668odyrZbWn7uvvKmxqVeHvpfnItEPL43w4vlvABZuYB5gnrpOzb5JwoVAjuN2znvGhEHD04cA== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: d255ef6c-5349-4b11-5023-08d9ead3c72c X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB2869.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Feb 2022 07:22:35.1298 (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: IGBv5wBdLCJJ6s8N9M3KTM2nLI59NECAlD1GO7JY6f77OO2ZvfFbaBDn0mNHFJ8n4uZz3pQdJhJstj4SeuxHJe0TIvb6WYET6XVa/pFlkqk= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN4PR10MB5608 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10251 signatures=673430 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 bulkscore=0 suspectscore=0 mlxlogscore=999 mlxscore=0 adultscore=0 malwarescore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2201110000 definitions=main-2202080038 X-Proofpoint-ORIG-GUID: 2p0JwgJgMQdMZFs2-VZqSHV2bjOBCrWP X-Proofpoint-GUID: 2p0JwgJgMQdMZFs2-VZqSHV2bjOBCrWP Received-SPF: pass client-ip=205.220.165.32; envelope-from=elena.ufimtseva@oracle.com; helo=mx0a-00069f02.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=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: , Cc: eduardo@habkost.net, john.g.johnson@oracle.com, cohuck@redhat.com, jag.raman@oracle.com, john.levon@nutanix.com, eblake@redhat.com, david@redhat.com, armbru@redhat.com, peterx@redhat.com, mst@redhat.com, berrange@redhat.com, stefanha@redhat.com, pbonzini@redhat.com, philmd@redhat.com Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" This command is used to request the bar type info from remote device. Signed-off-by: Elena Ufimtseva --- include/hw/remote/ioregionfd.h | 2 ++ include/hw/remote/machine.h | 1 + include/hw/remote/mpqemu-link.h | 2 ++ hw/remote/ioregionfd.c | 28 ++++++++++++++++++++++++ hw/remote/message.c | 38 +++++++++++++++++++++++++++++++++ hw/remote/remote-obj.c | 1 + 6 files changed, 72 insertions(+) diff --git a/include/hw/remote/ioregionfd.h b/include/hw/remote/ioregionfd.h index 85a2ef2c4f..66bb459f76 100644 --- a/include/hw/remote/ioregionfd.h +++ b/include/hw/remote/ioregionfd.h @@ -38,4 +38,6 @@ struct IORegionFDObject { typedef struct IORegionFDObject IORegionFDObject; GSList *ioregionfd_get_obj_list(void); +IORegionFD *ioregionfd_get_by_bar(GSList *list, uint32_t bar); +void ioregionfd_set_bar_type(GSList *list, uint32_t bar, bool memory); #endif /* IOREGIONFD_H */ diff --git a/include/hw/remote/machine.h b/include/hw/remote/machine.h index 2a2a33c4b2..71c53ba0d7 100644 --- a/include/hw/remote/machine.h +++ b/include/hw/remote/machine.h @@ -28,6 +28,7 @@ struct RemoteMachineState { typedef struct RemoteCommDev { PCIDevice *dev; QIOChannel *ioc; + GSList *ioregions_list; } RemoteCommDev; #define TYPE_REMOTE_MACHINE "x-remote-machine" diff --git a/include/hw/remote/mpqemu-link.h b/include/hw/remote/mpqemu-link.h index 4ec0915885..be546e4586 100644 --- a/include/hw/remote/mpqemu-link.h +++ b/include/hw/remote/mpqemu-link.h @@ -17,6 +17,7 @@ #include "exec/hwaddr.h" #include "io/channel-socket.h" #include "hw/remote/proxy.h" +#include "hw/remote/ioregionfd.h" #define REMOTE_MAX_FDS 8 @@ -41,6 +42,7 @@ typedef enum { MPQEMU_CMD_BAR_READ, MPQEMU_CMD_SET_IRQFD, MPQEMU_CMD_DEVICE_RESET, + MPQEMU_CMD_BAR_INFO, MPQEMU_CMD_MAX, } MPQemuCmd; diff --git a/hw/remote/ioregionfd.c b/hw/remote/ioregionfd.c index 85ec0f7d38..1d371357c6 100644 --- a/hw/remote/ioregionfd.c +++ b/hw/remote/ioregionfd.c @@ -63,6 +63,34 @@ GSList *ioregionfd_get_obj_list(void) return list; } +IORegionFD *ioregionfd_get_by_bar(GSList *list, uint32_t bar) +{ + IORegionFDObject *ioregionfd; + GSList *elem; + + for (elem = list; elem; elem = elem->next) { + ioregionfd = elem->data; + + if (ioregionfd->ioregfd.bar == bar) { + return &ioregionfd->ioregfd; + } + } + return NULL; +} + +void ioregionfd_set_bar_type(GSList *list, uint32_t bar, bool memory) +{ + IORegionFDObject *ioregionfd; + GSList *elem; + + for (elem = list; elem; elem = elem->next) { + ioregionfd = elem->data; + if (ioregionfd->ioregfd.bar == bar) { + ioregionfd->ioregfd.memory = memory; + } + } +} + static void ioregionfd_object_init(Object *obj) { IORegionFDObjectClass *k = IOREGIONFD_OBJECT_GET_CLASS(obj); diff --git a/hw/remote/message.c b/hw/remote/message.c index 11d729845c..a8fb9764ba 100644 --- a/hw/remote/message.c +++ b/hw/remote/message.c @@ -29,6 +29,8 @@ static void process_bar_write(QIOChannel *ioc, MPQemuMsg *msg, Error **errp); static void process_bar_read(QIOChannel *ioc, MPQemuMsg *msg, Error **errp); static void process_device_reset_msg(QIOChannel *ioc, PCIDevice *dev, Error **errp); +static void process_device_get_reg_info(QIOChannel *ioc, RemoteCommDev *com, + MPQemuMsg *msg, Error **errp); void coroutine_fn mpqemu_remote_msg_loop_co(void *data) { @@ -75,6 +77,9 @@ void coroutine_fn mpqemu_remote_msg_loop_co(void *data) case MPQEMU_CMD_DEVICE_RESET: process_device_reset_msg(com->ioc, pci_dev, &local_err); break; + case MPQEMU_CMD_BAR_INFO: + process_device_get_reg_info(com->ioc, com, &msg, &local_err); + break; default: error_setg(&local_err, "Unknown command (%d) received for device %s" @@ -91,6 +96,39 @@ void coroutine_fn mpqemu_remote_msg_loop_co(void *data) } } +static void process_device_get_reg_info(QIOChannel *ioc, RemoteCommDev *com, + MPQemuMsg *msg, Error **errp) +{ + ERRP_GUARD(); + uint32_t bar = (uint32_t)(msg->data.u64 & MAKE_64BIT_MASK(0, 32)); + bool memory; + + memory = (msg->data.u64 && MAKE_64BIT_MASK(32, 32)) == 1 ? true : false; + + IORegionFD *ioregfd; + MPQemuMsg ret = { 0 }; + + error_report("Bar is %d, mem %s", bar, memory ? "true" : "false"); + + memset(&ret, 0, sizeof(MPQemuMsg)); + ret.cmd = MPQEMU_CMD_RET; + ret.size = sizeof(ret.data.u64); + + ioregfd = ioregionfd_get_by_bar(com->ioregions_list, bar); + if (ioregfd) { + ret.data.u64 = ioregfd->bar; + if (ioregfd->memory != memory) { + ioregionfd_set_bar_type(com->ioregions_list, bar, memory); + } + } else { + ret.data.u64 = UINT64_MAX; + } + if (!mpqemu_msg_send(&ret, ioc, NULL)) { + error_prepend(errp, "Error returning code to proxy, pid "FMT_pid": ", + getpid()); + } +} + static void process_config_write(QIOChannel *ioc, PCIDevice *dev, MPQemuMsg *msg, Error **errp) { diff --git a/hw/remote/remote-obj.c b/hw/remote/remote-obj.c index 9bb61c3a2d..46c2e2a5bd 100644 --- a/hw/remote/remote-obj.c +++ b/hw/remote/remote-obj.c @@ -188,6 +188,7 @@ static void remote_object_machine_done(Notifier *notifier, void *data) *comdev = (RemoteCommDev) { .ioc = ioc, .dev = PCI_DEVICE(dev), + .ioregions_list = ioregions_list, }; co = qemu_coroutine_create(mpqemu_remote_msg_loop_co, comdev); From patchwork Tue Feb 8 07:22:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elena Ufimtseva X-Patchwork-Id: 12738351 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 5B6B0C433F5 for ; Tue, 8 Feb 2022 08:43:52 +0000 (UTC) Received: from localhost ([::1]:52398 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nHM6I-0004ME-T9 for qemu-devel@archiver.kernel.org; Tue, 08 Feb 2022 03:43:51 -0500 Received: from eggs.gnu.org ([209.51.188.92]:53998) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nHKpt-0001xK-3Y for qemu-devel@nongnu.org; Tue, 08 Feb 2022 02:22:49 -0500 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]:49584) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nHKpm-0001vk-J7 for qemu-devel@nongnu.org; Tue, 08 Feb 2022 02:22:47 -0500 Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 2186aMlU012771; Tue, 8 Feb 2022 07:22:40 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-transfer-encoding : content-type : mime-version; s=corp-2021-07-09; bh=Ve+EpoYs8Mu771IpCXIT8lQbQO6AkVkSbWXJhE/KJNc=; b=QTQSqUFOo5OBADxve1VrIL+QXH+sYulmPgOZyH0iTVJkg1KPSqtCm4d6GNcvQyLX2woz 8ozjggdQK5wD/9hPBBMRthy7Jhxevm7ItAYdvXq2GsG2F72kyKGIJrHcFb/f2l1HzRX2 MIq55XOY7V/ahZIKwL4fmJIWh6mA6V2PXnlmjuptvwyVoxsj506jAmG9iEa44HYvuioL +Q7qaeVQxsmkb/TvE06Jhf/wCf2cjNpHSxr8ZvAHCvINq7z2e7TNLSaeFk0qvL5KeI7n gDfE1Mn4hm76ZmX12RCufvm3BmSgBGR2APzIq5AY0r9fMJ0WQulCB+aIE2zZRj4N6Szb 7w== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by mx0b-00069f02.pphosted.com with ESMTP id 3e3fpggk4c-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 08 Feb 2022 07:22:40 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 2187BlYv093365; Tue, 8 Feb 2022 07:22:39 GMT Received: from nam10-mw2-obe.outbound.protection.outlook.com (mail-mw2nam10lp2104.outbound.protection.outlook.com [104.47.55.104]) by userp3030.oracle.com with ESMTP id 3e1ebykknc-8 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 08 Feb 2022 07:22:38 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WQ72v0VTIqw1dwnlRb8m5nfntv2R9NrJT64Wy9SEUhkXwi4YQLPiAtV1jdoIh94Gga6mSKXsgNdpD+ipNFEblcD8tC0WBArkliSr0W2kv+cfQQ0QcTT0gP11fIBVzHcXqcdkhC+Xx1m0upus4cBFtJVGwGSefcbYRXDidJWifVkb0/tpy5hqngolwovORDJFduBUQRWkrnumf9fXT/ejX0ERW0YWoB8TbHacdJfYkrl1gkgcqtjr26S2o/kiIi63QjNhyL1m3UCAoTzpfR8Wd5/8c0QWSSljUaKcTJIorNCb7mslggTjrbA8IdY2pwnexCRHDsMhErtDW6ZZWxFksg== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Ve+EpoYs8Mu771IpCXIT8lQbQO6AkVkSbWXJhE/KJNc=; b=kA89L133VI5bI++wYpRw3Ufqc6UEojcF15KJVhAvMIuD8ThzacyJ1X1MkGGosc0e359iNBB34BiHcwbB2E+qffIwctByrxllCNd2YG6x1/Dqm6xinsJVn81UuiNUcmuWuIA5iWml69R7ZRFmxAIiP+wQ5xL1f4UzOSHO6B3IVEXg3Ja66jGzNyEgPdIGEKAJ0JI38rDhJ0R/Mv0eT1ygonjUp3nvbdT+O0bXxPZAIBhYXrldDyiVtCe616ktAm6sc3Xnq8iOnaALEeshA8iJBkvyVbQSLsCZ/lirsFUIfnT2g0ouvMlERLdYezGwQ7eL2A2bFhZ+0+fZKq7He5ROOw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; 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=Ve+EpoYs8Mu771IpCXIT8lQbQO6AkVkSbWXJhE/KJNc=; b=hg70T7qYzc1vjJJNLKiBCwFuFsEfa/T8a1DV/SEc4eDAT6MNh2kzB8NtT9qUS9aBbprCDbXubwRiSQIqn6UpUW0tM6XixLtWnfXRot/saVS0vaMRxyIzpYx60hF8aWqdtu5sxYE5xeekWPZ0E7kjh9GWoHv0rpRaOB/u/XaBOl4= Received: from BYAPR10MB2869.namprd10.prod.outlook.com (2603:10b6:a03:85::17) by SN4PR10MB5608.namprd10.prod.outlook.com (2603:10b6:806:20b::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.18; Tue, 8 Feb 2022 07:22:35 +0000 Received: from BYAPR10MB2869.namprd10.prod.outlook.com ([fe80::4bd:1cfa:5aee:6c81]) by BYAPR10MB2869.namprd10.prod.outlook.com ([fe80::4bd:1cfa:5aee:6c81%3]) with mapi id 15.20.4951.019; Tue, 8 Feb 2022 07:22:35 +0000 From: Elena Ufimtseva To: qemu-devel@nongnu.org Subject: [RFC 7/8] multiprocess: add ioregionfd memory region in proxy Date: Mon, 7 Feb 2022 23:22:21 -0800 Message-Id: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: X-ClientProxiedBy: BY5PR16CA0006.namprd16.prod.outlook.com (2603:10b6:a03:1a0::19) To BYAPR10MB2869.namprd10.prod.outlook.com (2603:10b6:a03:85::17) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 69b69c4f-ac8d-4379-0ee5-08d9ead3c78e X-MS-TrafficTypeDiagnostic: SN4PR10MB5608:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6790; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: AZ7wzf+s8YV/rYs/wIH//pgF9eYA6475VfCRt/f+ujMG1EVBGJsjqpv+Ajv3XQBcFT6+Mi1F2WZdfokaGL46q/YTe32mFzbc7jijNZLewpC6MfACrsyKmrgKywfsEVNhuEk/ebKzCCc5cdt5d8fdPrg4dCgyKIHcL3rxXWdTpo/8NNlGfyiW0sTma/xoEhT70GUUgJQADWo+nMEq7piHLMkNG+kkRAC5KsyfnW0OOwd1sDZ7q2z9UqujvGDJjFSNJg0QdS3ILfUDlcjM7E2Q/qhDDvhWjcufKO70Oj1FnkEsnZkttT75th4ZoWGKAaj/iQp07AQeS02En4cwMLpt9m8A7tQqkLhhubPVtypADqKUluQgEbd26OPQ9sRcHPDBMWkeN5HUKwUl2czg/5DLw1Sps3gPz9U3r87RCz2RNCEYi2un3oB/Qd4hec//SP1pEHJGLDROfHofbJqdWjDNpVjWNzblbf9NcczRnKFUkKK3GNNtjzCmcHkwhvHawEVTtBAiktXRlEAeXzjuz/FEFxChEylE9b2qI9MJLDA3V6+aqPkBI5fWV145v1IYZ/27+x2FMkOWjHXNbJQ78QnMjJqRstFqBIom/JEbLD0Ah6oHB33F1c6SgCE13PIeRKz+nETt2DHEq6yonzqzet1nCg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR10MB2869.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(366004)(6512007)(36756003)(83380400001)(186003)(38100700002)(86362001)(5660300002)(7416002)(2616005)(6486002)(44832011)(508600001)(6666004)(8676002)(4326008)(52116002)(2906002)(66946007)(66476007)(6506007)(66556008)(6916009)(316002)(8936002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: L+VVDIeiwzjdYxaIssKSWkujOXUf+sX0kvPr6dB596UShpFZFB8W5uFmYFeENZPRJrff+C2+T3Mq1TBsurMkKNRdpuIN22i81naN5xZ9ZUd2kjuGC/rRiwRDH8Oj0Unky6eDyONlfa+m2wGyBnF/bDiLRwT+dvwlTf+AGslqjfiPuokbrllZ0+Uc1h7HxPmW9P6GjJBbPFXMYkOSkzyHeLEGeYZCnweXxvi903N962zdx9zCzZQxS5HpE3Mw80yR88jpi9piHwubqcSpZdc9DnDnPuZIMc1UIgl+c+MetMfHgjdIcnCGWtUKe/aC3f+6gVYZSuswDGn7I19+7vhZAGD/p8bq5vPJf8DSXVKzO2UokAOIhE83SygxdCOIQyA470R68Zx5DYuNownyDGy189RbCNvwOhyLL5n80Aez9Xb23vGzJvhbuhkWOgU7uOmSjuQ2OGEmUJX0D1mn6z5cFA0diJFeP9eJzcka0fCkJhndgdtD6njs8Pw7oiIg1pxN50HLvPceg5CApSxaJIBHMOj5O5C+Nl/IfXEuv9dhV8/juKEBRxf8mt5wxcaSyEEteZAO5Fh61EQGAqlWMZyrnWcvD6zU992Xn/ftJoFkc8ycTagGB1d+qHcV1v37YhkoDd7GEMNA21PkMhl8om9lQu1144m+Md2Rt+CBGWAuO+d5iSwRwkQYzSMLYlm2J3JKBLAv2oHuxHG2rztPd04SUi83EfUCB9OCcZUApiPnR7XgGV+RxJc5y5qcOwFgofI+Aat8Wk0MOupKnKTeHXol4OlAVqKOz77RvkWnFTYQM20rPX+h3SClR8vVC2db+s6rBCX/XgZc7eoEJr4WeCqHy9glFemyDhUebtmOC+3i19VB/e3C0dHIIL9QHEfi1dAMGHLPv5TLlijPujo5SPLJ3BoFdQEauvJYUBI8JZN9Lz1pX/GaUBj8KQWLx8nxRWHI1BtT2Cz8EG9jwkwCWAW1EYS19jPCcHJWFGEkGlLD0sWJbGqa6OwyJWskLU0X+I5E3uOvMcZ1j/afhnEpu4qrFUMkoFU7SJmxMkzIhmbXXbuHtXir4D6QWYLVVZZD+GDSLKq9pJafPV137OMJVw79I8kw+McRmcaOFcivulnoKiMn0n+eyl3x5E9L5CJIAQVP/AZwN9Mr5pE5Y4p2LxmSJYp03sPygCfhXl7gK8m0YRm02IUlftcYbezBPvDGVx9AKwfqW7s8VRRc1MgMIAbKPD64dHwUeIytRR2c9DNFakYIdtrfB1TgVlp1lSA06rfy0NlgEy+CaKffmqS3qF/P5LAcvfu1B+rnHBmQ/5D6gt+bOylvULDbRnIbM3VfCZ5G/S65YFKfClgjMO5lp1rqOpGn0vCPsMlrvX15JONkVwxkTPh05iE60tMIHOIVNI9AF1HiHwsKFs3gvcHKLLcaG/gb2VI1vUm8hzl+DAcTt28+OJWxvvuGucfh4+w2cHvU2Zf0oNkMAawLmniBYel8bVSaHjAEoQ+dt2vS90+0QwxP+LTyG8qlQVIrsoIHVE9q3+2RfK8DptQW41IDsWsO7sg8yzvvA0MMDeDUkZ9HjwTgs3/1xL/cTszn1/pzL0Dj8S0Iz2gwtLRZhmQKtJn4ufJ9dsiUeczaPcIXPcUB6ca3ILnv0pc2BvDqJJ/MCBquSI9mnrBDx2IA9YwfoII1LTLh1w+cMSFj8SbcMqK8AxHmLlYiw1Byb8B/9oQ4DBLMKky8YKJbYFR3s1uQe+DvaA== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 69b69c4f-ac8d-4379-0ee5-08d9ead3c78e X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB2869.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Feb 2022 07:22:35.7860 (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: 7mI63f6tf9JjgcxYSeAvZO4TRq0hKYIdbecjLf8Sa0LI+Ytp4kAdzgZXJCoxo7bwVYMVEESmSG/z0Ew2JxLoGta42uLLbiJ3yD0Ueqm2lzc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN4PR10MB5608 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10251 signatures=673430 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 bulkscore=0 suspectscore=0 mlxlogscore=999 mlxscore=0 adultscore=0 malwarescore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2201110000 definitions=main-2202080038 X-Proofpoint-GUID: 5CBlmOnHdjcGbkkXvJs0juVm8QVkCcVU X-Proofpoint-ORIG-GUID: 5CBlmOnHdjcGbkkXvJs0juVm8QVkCcVU Received-SPF: pass client-ip=205.220.165.32; envelope-from=elena.ufimtseva@oracle.com; helo=mx0a-00069f02.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=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: , Cc: eduardo@habkost.net, john.g.johnson@oracle.com, cohuck@redhat.com, jag.raman@oracle.com, john.levon@nutanix.com, eblake@redhat.com, david@redhat.com, armbru@redhat.com, peterx@redhat.com, mst@redhat.com, berrange@redhat.com, stefanha@redhat.com, pbonzini@redhat.com, philmd@redhat.com Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Elena Ufimtseva --- include/hw/remote/proxy.h | 1 + hw/remote/proxy.c | 66 ++++++++++++++++++++++++++++++++++++--- 2 files changed, 63 insertions(+), 4 deletions(-) diff --git a/include/hw/remote/proxy.h b/include/hw/remote/proxy.h index 741def71f1..9efef0b935 100644 --- a/include/hw/remote/proxy.h +++ b/include/hw/remote/proxy.h @@ -29,6 +29,7 @@ struct PCIProxyDev { PCIDevice parent_dev; char *fd; + char *ioregfd; /* * Mutex used to protect the QIOChannel fd from * the concurrent access by the VCPUs since proxy diff --git a/hw/remote/proxy.c b/hw/remote/proxy.c index bad164299d..ba1aa20d78 100644 --- a/hw/remote/proxy.c +++ b/hw/remote/proxy.c @@ -146,6 +146,33 @@ static void pci_proxy_dev_exit(PCIDevice *pdev) event_notifier_cleanup(&dev->resample); } +static void config_get_ioregionfd_info(PCIProxyDev *pdev, uint32_t reg_num, + uint32_t *val, bool memory) +{ + MPQemuMsg msg = { 0 }; + Error *local_err = NULL; + uint64_t ret = -EINVAL; + + memset(&msg, 0, sizeof(MPQemuMsg)); + msg.cmd = MPQEMU_CMD_BAR_INFO; + msg.num_fds = 0; + msg.data.u64 = (uint64_t)reg_num & MAKE_64BIT_MASK(0, 32); + + msg.data.u64 |= memory ? (1ULL << 32) : 0; + msg.size = sizeof(msg.data.u64); + + ret = mpqemu_msg_send_and_await_reply(&msg, pdev, &local_err); + if (local_err) { + error_report_err(local_err); + error_report("Error while receiving reply from remote about fd"); + } + if (ret == UINT64_MAX) { + error_report("Failed to request bar info for %d", reg_num); + } + + *val = (uint32_t)ret; +} + static void config_op_send(PCIProxyDev *pdev, uint32_t addr, uint32_t *val, int len, unsigned int op) { @@ -198,6 +225,7 @@ static void pci_proxy_write_config(PCIDevice *d, uint32_t addr, uint32_t val, static Property proxy_properties[] = { DEFINE_PROP_STRING("fd", PCIProxyDev, fd), + DEFINE_PROP_STRING("ioregfd", PCIProxyDev, ioregfd), DEFINE_PROP_END_OF_LIST(), }; @@ -297,7 +325,7 @@ const MemoryRegionOps proxy_mr_ops = { static void probe_pci_info(PCIDevice *dev, Error **errp) { PCIDeviceClass *pc = PCI_DEVICE_GET_CLASS(dev); - uint32_t orig_val, new_val, base_class, val; + uint32_t orig_val, new_val, base_class, val, ioregionfd_bar; PCIProxyDev *pdev = PCI_PROXY_DEV(dev); DeviceClass *dc = DEVICE_CLASS(pc); uint8_t type; @@ -342,6 +370,9 @@ static void probe_pci_info(PCIDevice *dev, Error **errp) } for (i = 0; i < PCI_NUM_REGIONS; i++) { + bool init_ioregionfd = false; + int fd = -1; + config_op_send(pdev, PCI_BASE_ADDRESS_0 + (4 * i), &orig_val, 4, MPQEMU_CMD_PCI_CFGREAD); new_val = 0xffffffff; @@ -362,9 +393,36 @@ static void probe_pci_info(PCIDevice *dev, Error **errp) if (type == PCI_BASE_ADDRESS_SPACE_MEMORY) { pdev->region[i].memory = true; } - memory_region_init_io(&pdev->region[i].mr, OBJECT(pdev), - &proxy_mr_ops, &pdev->region[i], - name, size); +#ifdef CONFIG_IOREGIONFD + /* + * Currently, only one fd per device is supported. + * TODO: Drop this limit. + */ + if (pdev->ioregfd) { + fd = monitor_fd_param(monitor_cur(), pdev->ioregfd, errp); + if (fd == -1) { + error_prepend(errp, "Could not parse ioregionfd fd %s:", + pdev->ioregfd); + } + + config_get_ioregionfd_info(pdev, i, &ioregionfd_bar, + pdev->region[i].memory); + if (ioregionfd_bar == i) { + init_ioregionfd = true; + } + } +#endif + if (init_ioregionfd) { + memory_region_init_io(&pdev->region[i].mr, OBJECT(pdev), + NULL, &pdev->region[i], + name, size); + memory_region_add_ioregionfd(&pdev->region[i].mr, 0, size, i, + fd, false); + } else { + memory_region_init_io(&pdev->region[i].mr, OBJECT(pdev), + &proxy_mr_ops, &pdev->region[i], + name, size); + } pci_register_bar(dev, i, type, &pdev->region[i].mr); } } From patchwork Tue Feb 8 07:22:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elena Ufimtseva X-Patchwork-Id: 12738365 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 30EB7C433F5 for ; Tue, 8 Feb 2022 09:04:58 +0000 (UTC) Received: from localhost ([::1]:42580 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nHMQi-0001IZ-Ul for qemu-devel@archiver.kernel.org; Tue, 08 Feb 2022 04:04:56 -0500 Received: from eggs.gnu.org ([209.51.188.92]:54004) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nHKpt-0001xl-KE for qemu-devel@nongnu.org; Tue, 08 Feb 2022 02:22:49 -0500 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]:50470) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nHKpn-0001vq-CP for qemu-devel@nongnu.org; Tue, 08 Feb 2022 02:22:49 -0500 Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 2186dmko012748; Tue, 8 Feb 2022 07:22:41 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-transfer-encoding : content-type : mime-version; s=corp-2021-07-09; bh=PcgQUwvWl+PJG5TKIWJbzjrGqej2468YU/0cDbJ4ZYc=; b=nOVgXYXj5+bQu1rrcNMDxUIfu9aAYHygNbtdhYZ0ml2BkALuQoSTbqm3D0UbL6ic/RRV pB0UMrQA/eIJaTcHLbrmFmb27Ry978d5oLEMp6vA2hZ1q/3rjr7uylOXPV5QQlaxMng1 mTugzQbHxzcn1sZEH/oFb4zJHxQx4pALDjB3paH2AkQvI6y3j4UNckOXhPSvYtfP0g2l U+ijI7kMjvz6iXrElOd7xDqJjNii7sjMnhtFer5vTZyqEeQtQEJQ5y1/YS/J1522U6Zi J34QP8pDGYYucd4Wyn2AxSYT9pLZukNOCABO7mI8FW+kHFvtDWOHVTKmpos4uWklPi36 WA== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by mx0b-00069f02.pphosted.com with ESMTP id 3e3fpggk4e-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 08 Feb 2022 07:22:40 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 2187BlYw093365; Tue, 8 Feb 2022 07:22:39 GMT Received: from nam10-mw2-obe.outbound.protection.outlook.com (mail-mw2nam10lp2104.outbound.protection.outlook.com [104.47.55.104]) by userp3030.oracle.com with ESMTP id 3e1ebykknc-9 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 08 Feb 2022 07:22:39 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=m2Sjt4OyMdek5txKTLoAyevjHDN9L5hydD75YfiEnXTL906aWMwgU03LWppEQUgzufcj40xhKAlE3RwVtncaADZidaDBMF8Ll2P8r48EroXZqviVM3AQySpPZlpb+3ht6F8PCgi42pnDwwGYQsjGi/nNAUxO/j/+wnT+EhSwEqDtMuhixoeqnqkEwIwYqNIQbqRYkLx/JE4XigXWysLbGxlxyp7JWfKXIAs8QZXAmtKlS9PKEdT83NhCrN9Ziu40X6mYpfHwiREOW/3UUMnGAE50p6bKp5/bLhMg6YcTKxgoM+k+M2+hmlcDhHw8r8avq7qc3RFz1IAdOqBF4blC0A== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=PcgQUwvWl+PJG5TKIWJbzjrGqej2468YU/0cDbJ4ZYc=; b=ALKyt7TYAl0sz02gdH3h6RM7LtwCzIy4JKHtHxU7evvP8Nn15I2Xx9UfZ4UpJab1r0zUfOgWVYTKN2mtIZ1T/SjgfRvFZFiyBLPcabvx3iZNnf366it6mn/8WHaiC1MPpFqUJK4hbrnqfw9KElyB/L2YOG81Mxf7L8S6auI0IfQNULqjvB7N0y1lqagyG6wt3mQmUZIl39Ig7q7KbLDuWLmWO1Qw4dh8eRkurWG/6rjjSgH1CV4za+KLdokqUsilYAxk8vTUmSsNHVjcfb5SqehvaGM4WvBVu2UaiiqgO/4j9XHdkAvn/IHZAmEX1R0Z2ixK4ThXVs9cDt03X7s5Pg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; 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=PcgQUwvWl+PJG5TKIWJbzjrGqej2468YU/0cDbJ4ZYc=; b=V7/apou4o923evNsuSqH631nPmGEhQv5RUKpVLE6tJRVTX06+ikCR9oRih4MtV609M1KtOoThmPempwMtFHrYLxQWsJVT8zvB5ZZYQuV0jW8ONJyWQgfQ2PxDjgjm87ZhOCJmIMTMcJ0s9TDUzHrkWzxaZqYOXdULHYDqiFds8g= Received: from BYAPR10MB2869.namprd10.prod.outlook.com (2603:10b6:a03:85::17) by SN4PR10MB5608.namprd10.prod.outlook.com (2603:10b6:806:20b::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.18; Tue, 8 Feb 2022 07:22:36 +0000 Received: from BYAPR10MB2869.namprd10.prod.outlook.com ([fe80::4bd:1cfa:5aee:6c81]) by BYAPR10MB2869.namprd10.prod.outlook.com ([fe80::4bd:1cfa:5aee:6c81%3]) with mapi id 15.20.4951.019; Tue, 8 Feb 2022 07:22:36 +0000 From: Elena Ufimtseva To: qemu-devel@nongnu.org Subject: [RFC 8/8] multiprocess: handle ioregionfd commands Date: Mon, 7 Feb 2022 23:22:22 -0800 Message-Id: <2b891256b5c6ded52810ce3f25c923e9c593cea2.1644302411.git.elena.ufimtseva@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: X-ClientProxiedBy: BY5PR16CA0006.namprd16.prod.outlook.com (2603:10b6:a03:1a0::19) To BYAPR10MB2869.namprd10.prod.outlook.com (2603:10b6:a03:85::17) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 190f01f2-716b-4ede-56f2-08d9ead3c7f9 X-MS-TrafficTypeDiagnostic: SN4PR10MB5608:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:159; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 9cKlke09z0KCzAUVvZeVsWQXv+RFbZNwmsUDPsm5W40HODp8IVBXujHlUuPTfN1U3Z1rzNjqTOuRlhuBu4Rjt/ylSW4Iu4cl57GBXxoOdEK6t1evE4XAvIph6zIa/TxzXlGCDZYdLUKNZGzB2Pe2++bZqqqFkzDlNPlMO96qoM9EaAG4Khilc4PglKcyip5FOy+r9VqbX/IRLeHDJVfoA2iVyQ59ppRA0PyKeaN622Dmig20v0fClYnvuMK5gOumRYID3GJnlU7e+1szH68zRKmcj2Tm0xkOcRRrUfUZvuICruOUzIVylgoDibIHlmqOgH5KDvMYAiwanOK9X2evECA5a6fANhy/PpFDaRp9i84Y3/12niRzrcyRDp9E3/x/E6Fhae2FH6qBW7qQsY2ohxUJfqR6uK0M0WNm1+GMb3KEqo8LyqA3ZGzaAqPpQw6k7ENshJsXnSxoOrlnmLWI2T5PcG3Z60Tte+ci2hc4Mp9ncFiH2YbF93g3DmUjoAZpn5eYYaGsQGqYbMNghpjYNx68yBc7cagJp562Xjywyh1ldX6Z3oAuLrq4Ah2uYFlxkk4U7PSwyybQEdPpaqk3z8BX4tAFzqQBOIpi84FMTRjY2J4ThOdlaLLQXb2VuZS4b0iBxSI5ggT9c/k3S6goVA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR10MB2869.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(366004)(6512007)(36756003)(83380400001)(186003)(38100700002)(86362001)(5660300002)(7416002)(2616005)(6486002)(44832011)(508600001)(6666004)(8676002)(4326008)(52116002)(2906002)(66946007)(66476007)(6506007)(66556008)(6916009)(316002)(8936002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: z5TAPynmb7AYU3AQU+qAL0/gCvdERjL3WJW/KHPIBzBZ3TJaSRKAHqaSwd2r1wxLUXugIR3fkMaCJct0jCi89IhvxYk+Aufs+U52u1Uu7rV6JPz/a91BJWIsG2jhvVebBwdtvyrju7MquF1zWImtjlW4B/qAv1LvaeO1B+EleH+smQOW4gOp/pyMaVmG1gl0FYtaWaiaCXEWlesWP+pxMY2lpmia7zEV3oJ9+Dl3RPos2PlnJ7EQVvK3HageuO9MNYwnUEyPTNJV++sS3xcqM6OsQEWQMGeV8VXW2d8fMNRMwiMUp8G6saQePOhn2ZHmol5uWvyzRO3FNIz6QUKcvo0TP9BfIVOI6keqiZwm8RK2bDbHD2J+PRWL7Lgq1lmQEg0NeIRpTF2IjeAs7Zpi1SyfPdOiu1WvSYznl3xXF3V6FED3qtSusD2vbScUk7xjBdRrg8e4jl3I2dwt+tCL8SDzdVh5tNW7O2wPQV2JUI9q+MkIX76RJ2Er9O2ERvOnyFeqwJU8BsLlR1urpOJi7FFjI9kIWMEcWR4aQCluyy+V/fh5SEbJhOZ0fyZTtd/wyQ/NioZWc7fHC/Ey5r6+QOUjjfaxc2t3qKgxYs6lCQ/rs/uG3mQa0uwUe5i/xqUHMLl8RrsWmq8rohlsxlACONJreedGTpoauclibQs291CH8NXcYZH7fZZs8TDdYYCCvaypUV+rSvxN5GQ3pqTWPTFFn0BhA3ZZOv79xyx5Hl1KK4CeRPBrdEuswf58JWS5ouvDFqg77cum6DvA+HF/pGhhChKQKTwPejdmANPPo7WpgPKLNsqefL+ExFDZSOnfy1i/gl+I/BTepC6C9qBrY3Scwq5lh6Y4RgIemAIgAXmFb+6OrtknSuw65OEl4ve2+COfG3qN4XwUDEKgxzZEgzgitE5LxRw3N4PlfJwXatJbowtGru6nDTNQ3gXjykOtKrSR1UP8VeeqECOiq+cPrcu5NMuutP84CXw5kRY69egKOoqizKk1pPPgSlq4jUQjBcULRToAb4ZYYc3QHRQjI2Z6QptgSOWQw8MyoAv5e97594puOC6ntrR5uW+pp+aMIW8gXpB7CoICjgZvauTDjTuMJUEaebDZk78qcDmT2O0zf4akF52OrqLHxHQDDFCG4OJPtFWQEeN1pT/uRACYzpZ0hVxVs1EC935Ks2qGLAJgYxpTrLRbASRRG23htTkXNaaBcg9FySRt7W9H09X9ieyXtJ0Mk8Ufn7PLWD+nHyoX8DPNlZPZX9EXNg1fOOsvipbUSG4pGR9ipZxidvWhMzTIluwu/uW4A42kQmdHic0Hnlgmlkic9f63GRoyzj3o4RtQKhQvWa1aqcIrUNPipHPF4JoimR/LpwZKsOZxwcXo29do+NOtV5RfQug6pOXzP13WksDfCNapyYplYQHNavu/tzo0XmXjyo4m4or/vGWcg8BxR1fkSkkpQbrhRS+srvST/CBl3mX+iU+OjoWh/kXdX7KxIJTxTTI6kpYZiaqX0G+CwsT9tCY/kbwmlBNKK2L/hVO4tit6yeMydI19JPpEbIj58j2PMwnKMWOh9KCQx7wZ/xrUAUwoINOq8IRvY/zLsGL7M9+O4lLa3wmEWhT8x8Tut1gQHF6139QeOBrGBrL2PsR3OVOl/FPmd0bwwv3qsbAtGecVmVT+ipOUO3iOe9PpqanFM+L9fGWosY7IiDIlPGrqBqEayIj4QhL/knp3sJTLngxYTS0Fy87Z+Q== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 190f01f2-716b-4ede-56f2-08d9ead3c7f9 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB2869.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Feb 2022 07:22:36.4735 (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: ur1UnNmCkFmMaYJxRBkdvpgMGW7nGD6sjAXtTwHrS9dPp+xeDUhI8EzlLUz6zaImJT3ix6S5GV2KCSQiYfi9X36Ys0HOl6RiFBfR8gTEG4U= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN4PR10MB5608 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10251 signatures=673430 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 bulkscore=0 suspectscore=0 mlxlogscore=999 mlxscore=0 adultscore=0 malwarescore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2201110000 definitions=main-2202080038 X-Proofpoint-GUID: jm7MNHC1WTFtVX41658yvczAmbDVe0JS X-Proofpoint-ORIG-GUID: jm7MNHC1WTFtVX41658yvczAmbDVe0JS Received-SPF: pass client-ip=205.220.165.32; envelope-from=elena.ufimtseva@oracle.com; helo=mx0a-00069f02.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=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: , Cc: eduardo@habkost.net, john.g.johnson@oracle.com, cohuck@redhat.com, jag.raman@oracle.com, john.levon@nutanix.com, eblake@redhat.com, david@redhat.com, armbru@redhat.com, peterx@redhat.com, mst@redhat.com, berrange@redhat.com, stefanha@redhat.com, pbonzini@redhat.com, philmd@redhat.com Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Elena Ufimtseva --- include/hw/remote/ioregionfd.h | 2 + include/hw/remote/remote.h | 2 + linux-headers/ioregionfd.h | 30 +++++++++ hw/remote/ioregionfd.c | 111 +++++++++++++++++++++++++++++++++ hw/remote/remote-obj.c | 44 +++++++++++++ 5 files changed, 189 insertions(+) create mode 100644 linux-headers/ioregionfd.h diff --git a/include/hw/remote/ioregionfd.h b/include/hw/remote/ioregionfd.h index 66bb459f76..8021eed6f1 100644 --- a/include/hw/remote/ioregionfd.h +++ b/include/hw/remote/ioregionfd.h @@ -40,4 +40,6 @@ typedef struct IORegionFDObject IORegionFDObject; GSList *ioregionfd_get_obj_list(void); IORegionFD *ioregionfd_get_by_bar(GSList *list, uint32_t bar); void ioregionfd_set_bar_type(GSList *list, uint32_t bar, bool memory); +int qio_channel_ioregionfd_read(QIOChannel *ioc, gpointer opaque, + Error **errp); #endif /* IOREGIONFD_H */ diff --git a/include/hw/remote/remote.h b/include/hw/remote/remote.h index 46390c7934..53b570e1ac 100644 --- a/include/hw/remote/remote.h +++ b/include/hw/remote/remote.h @@ -23,6 +23,8 @@ struct RemoteObject { DeviceState *dev; DeviceListener listener; + QIOChannel *ioregfd_ioc; + AioContext *ioregfd_ctx; GHashTable *ioregionfd_hash; }; diff --git a/linux-headers/ioregionfd.h b/linux-headers/ioregionfd.h new file mode 100644 index 0000000000..58f9b5ba61 --- /dev/null +++ b/linux-headers/ioregionfd.h @@ -0,0 +1,30 @@ +/* SPDX-License-Identifier: ((GPL-2.0-only WITH Linux-syscall-note) OR BSD-3-Clause) */ +#ifndef _UAPI_LINUX_IOREGION_H +#define _UAPI_LINUX_IOREGION_H + +/* Wire protocol */ + +struct ioregionfd_cmd { + __u8 cmd; + __u8 size_exponent : 4; + __u8 resp : 1; + __u8 padding[6]; + __u64 user_data; + __u64 offset; + __u64 data; +}; + +struct ioregionfd_resp { + __u64 data; + __u8 pad[24]; +}; + +#define IOREGIONFD_CMD_READ 0 +#define IOREGIONFD_CMD_WRITE 1 + +#define IOREGIONFD_SIZE_8BIT 0 +#define IOREGIONFD_SIZE_16BIT 1 +#define IOREGIONFD_SIZE_32BIT 2 +#define IOREGIONFD_SIZE_64BIT 3 + +#endif diff --git a/hw/remote/ioregionfd.c b/hw/remote/ioregionfd.c index 1d371357c6..dd04c39e25 100644 --- a/hw/remote/ioregionfd.c +++ b/hw/remote/ioregionfd.c @@ -26,6 +26,7 @@ #include "hw/pci/pci.h" #include "qapi/qapi-visit-qom.h" #include "hw/remote/remote.h" +#include "ioregionfd.h" #define TYPE_IOREGIONFD_OBJECT "ioregionfd-object" OBJECT_DECLARE_TYPE(IORegionFDObject, IORegionFDObjectClass, IOREGIONFD_OBJECT) @@ -91,6 +92,116 @@ void ioregionfd_set_bar_type(GSList *list, uint32_t bar, bool memory) } } +int qio_channel_ioregionfd_read(QIOChannel *ioc, gpointer opaque, + Error **errp) +{ + struct RemoteObject *o = (struct RemoteObject *)opaque; + struct ioregionfd_cmd cmd = {}; + struct iovec iov = { + .iov_base = &cmd, + .iov_len = sizeof(struct ioregionfd_cmd), + }; + IORegionFDObject *ioregfd_obj; + PCIDevice *pci_dev; + hwaddr addr; + struct ioregionfd_resp resp = {}; + int bar = 0; + Error *local_err = NULL; + uint64_t val = UINT64_MAX; + AddressSpace *as; + int ret = -EINVAL; + + ERRP_GUARD(); + + if (!ioc) { + return -EINVAL; + } + ret = qio_channel_readv_full(ioc, &iov, 1, NULL, 0, &local_err); + + if (ret == QIO_CHANNEL_ERR_BLOCK) { + return -EINVAL; + } + + if (ret <= 0) { + /* read error or other side closed connection */ + if (local_err) { + error_report_err(local_err); + } + error_setg(errp, "ioregionfd receive error"); + return -EINVAL; + } + + bar = cmd.user_data; + pci_dev = PCI_DEVICE(o->dev); + addr = (hwaddr)(pci_get_bar_addr(pci_dev, bar) + cmd.offset); + IORegionFDObject key = {.ioregfd = {.bar = bar} }; + ioregfd_obj = g_hash_table_lookup(o->ioregionfd_hash, &key); + + if (!ioregfd_obj) { + error_setg(errp, "Could not find IORegionFDObject"); + return -EINVAL; + } + if (ioregfd_obj->ioregfd.memory) { + as = &address_space_memory; + } else { + as = &address_space_io; + } + + if (ret > 0 && pci_dev) { + switch (cmd.cmd) { + case IOREGIONFD_CMD_READ: + ret = address_space_rw(as, addr, MEMTXATTRS_UNSPECIFIED, + (void *)&val, 1 << cmd.size_exponent, + false); + if (ret != MEMTX_OK) { + ret = -EINVAL; + error_setg(errp, "Bad address %"PRIx64" in mem read", addr); + val = UINT64_MAX; + } + + memset(&resp, 0, sizeof(resp)); + resp.data = val; + if (qio_channel_write_all(ioc, (char *)&resp, sizeof(resp), + &local_err)) { + error_propagate(errp, local_err); + goto fatal; + } + break; + case IOREGIONFD_CMD_WRITE: + ret = address_space_rw(as, addr, MEMTXATTRS_UNSPECIFIED, + (void *)&cmd.data, 1 << cmd.size_exponent, + true); + if (ret != MEMTX_OK) { + error_setg(errp, "Bad address %"PRIx64" for mem write", addr); + val = UINT64_MAX; + } + + if (cmd.resp) { + memset(&resp, 0, sizeof(resp)); + if (ret != MEMTX_OK) { + resp.data = UINT64_MAX; + ret = -EINVAL; + } else { + resp.data = cmd.data; + } + if (qio_channel_write_all(ioc, (char *)&resp, sizeof(resp), + &local_err)) { + error_propagate(errp, local_err); + goto fatal; + } + } + break; + default: + error_setg(errp, "Unknown ioregionfd command from kvm"); + break; + } + } + return ret; + + fatal: + return -EINVAL; +} + static void ioregionfd_object_init(Object *obj) { IORegionFDObjectClass *k = IOREGIONFD_OBJECT_GET_CLASS(obj); diff --git a/hw/remote/remote-obj.c b/hw/remote/remote-obj.c index 46c2e2a5bd..2b005eab40 100644 --- a/hw/remote/remote-obj.c +++ b/hw/remote/remote-obj.c @@ -11,6 +11,7 @@ #include "qemu-common.h" #include "qemu/error-report.h" +#include "sysemu/iothread.h" #include "qemu/notify.h" #include "qom/object_interfaces.h" #include "hw/qdev-core.h" @@ -78,6 +79,16 @@ static void remote_object_unrealize_listener(DeviceListener *listener, } } +static IOThread *ioregionfd_iot; + +static void ioregion_read(void *opaque) +{ + struct RemoteObject *o = opaque; + Error *local_error = NULL; + + qio_channel_ioregionfd_read(o->ioregfd_ioc, opaque, &local_error); +} + static GSList *ioregions_list; static unsigned int ioregionfd_bar_hash(const void *key) @@ -104,6 +115,8 @@ static void ioregionfd_prepare_for_dev(RemoteObject *o, PCIDevice *dev) { IORegionFDObject *ioregfd_obj = NULL; GSList *obj_list, *list; + QIOChannel *ioc = NULL; + Error *local_err = NULL; list = ioregionfd_get_obj_list(); @@ -143,6 +156,30 @@ static void ioregionfd_prepare_for_dev(RemoteObject *o, PCIDevice *dev) /* This is default and will be changed when proxy requests region info. */ ioregfd_obj->ioregfd.memory = true; + ioc = qio_channel_new_fd(ioregfd_obj->ioregfd.fd, &local_err); + if (!ioc) { + error_prepend(&local_err, "Could not create IOC channel for" \ + "ioregionfd fd %d", ioregfd_obj->ioregfd.fd); + error_report_err(local_err); + goto fatal; + } + o->ioregfd_ioc = ioc; + + if (ioregionfd_iot == NULL) { + ioregionfd_iot = iothread_create("ioregionfd iothread", + &local_err); + if (local_err) { + qio_channel_shutdown(o->ioregfd_ioc, QIO_CHANNEL_SHUTDOWN_BOTH, + NULL); + qio_channel_close(o->ioregfd_ioc, NULL); + error_report_err(local_err); + goto fatal; + } + } + o->ioregfd_ctx = iothread_get_aio_context(ioregionfd_iot); + qio_channel_set_aio_fd_handler(o->ioregfd_ioc, o->ioregfd_ctx, + ioregion_read, NULL, o); + ioregions_list = list; return; @@ -238,8 +275,15 @@ static void remote_object_finalize(Object *obj) k->nr_devs--; g_free(o->devid); + + iothread_destroy(ioregionfd_iot); /* Free the list of the ioregions. */ g_slist_foreach(ioregions_list, ioregionfd_release, NULL); + if (o->ioregfd_ioc) { + qio_channel_shutdown(o->ioregfd_ioc, QIO_CHANNEL_SHUTDOWN_BOTH, NULL); + qio_channel_close(o->ioregfd_ioc, NULL); + } + g_slist_free(ioregions_list); g_hash_table_destroy(o->ioregionfd_hash); }