From patchwork Sun Mar 12 09:22:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Huang Rui X-Patchwork-Id: 1755832 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.a=rsa-sha256 header.s=selector1 header.b=AkTK3YLg; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4PZDqw1Wjbz2471 for ; Sun, 12 Mar 2023 20:23:56 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pbHvP-0006FW-QH; Sun, 12 Mar 2023 05:23:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pbHvO-0006FE-FR for qemu-devel@nongnu.org; Sun, 12 Mar 2023 05:23:30 -0400 Received: from mail-bn8nam12on2061c.outbound.protection.outlook.com ([2a01:111:f400:fe5b::61c] helo=NAM12-BN8-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pbHvL-0004NT-Ej for qemu-devel@nongnu.org; Sun, 12 Mar 2023 05:23:29 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iUxCE7eyuR8ZKzC6jQVUJJf8lEHwqBFeQ22rRNEsREPenq+303Q91LmB4YK5HNoJH1b4TmaQyC5nhjhgzRvsevZJSLfL66X5uzE5g1oOKZoUL96JglIajvdyO7pteZW0MGR0gBP3ij54F8UKzp9InNbN4khsppnr0nQd165mp4L0hQdmoHD6rXTM7QfXBndokfL5YllrKExcDVVgj0t5SO64S4LnKefA451FPbmh/sNZN/lgMTh2sdsXE9Qmzu1+i2WHjBeMTugI7OTA7S/dbVpcS8OIQ/vsGBhO8WYFd2olDHYBYpZUFd7OR/eNbGtAYapsAMKEPIJ7boF8LsmZMw== 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=MySP99NL4Cc5eNFlOLDdl3uxiv6CT1oGstfJsAE3Zaw=; b=EPJ6KKMRtHz443HHu2OKfl36iVa9458gL+ud6eLEKO13FeoyeHFpU1/TLGvsSrA4Utf3G7f1O2wjPLRoMbHdjmE97u6Z6nLtomTUS83RhsUPJq3k5Zpa/JJ6DFoTBtIfesBQC1uPkvPxsslNIBOd2lg9j1DhXeE5TArwPaOK6oRp6gRAfmBssYIMDpTECUnj+SmXmKyRJeW4YDISGtYVY3/p3bJe1pzJucnZL+DgfpqihQCkyD+ZNroKjzoS0SuW1vcfBgtNJMin6jufFIV3hDgTJfK/Iw7FBFU8rYtOTKLebQgsraoE7/99nV0Q0DjQ+YplFIMno1l705sUo5AV4A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=redhat.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=MySP99NL4Cc5eNFlOLDdl3uxiv6CT1oGstfJsAE3Zaw=; b=AkTK3YLgnHy6VYr7v27eE2gkD/2YkkZi32WvIzit2W8IFAqo0ZxrHGtm3JgtZZB7ARIKyEh4YsAwvfpQ3qsIRNJmiGyCr+fJq+3ICuBkbQTSOjaOFSgZQGVg8xumId9U1vlkiF2NzXnZJImZGl+awjYoJu6kZcbQ3qwkTD02O7Y= Received: from MW4PR03CA0315.namprd03.prod.outlook.com (2603:10b6:303:dd::20) by BL1PR12MB5351.namprd12.prod.outlook.com (2603:10b6:208:317::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.24; Sun, 12 Mar 2023 09:23:21 +0000 Received: from CO1NAM11FT082.eop-nam11.prod.protection.outlook.com (2603:10b6:303:dd:cafe::7c) by MW4PR03CA0315.outlook.office365.com (2603:10b6:303:dd::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.23 via Frontend Transport; Sun, 12 Mar 2023 09:23:21 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CO1NAM11FT082.mail.protection.outlook.com (10.13.175.224) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6178.25 via Frontend Transport; Sun, 12 Mar 2023 09:23:21 +0000 Received: from hr-amd.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Sun, 12 Mar 2023 04:23:16 -0500 From: Huang Rui To: Gerd Hoffmann , "Michael S . Tsirkin" , Stefano Stabellini , Anthony PERARD , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , Jan Beulich , Antonio Caggiano , "Dr . David Alan Gilbert" , Robert Beckett , , CC: Alex Deucher , =?utf-8?q?Christian_K=C3=B6nig?= , "Stewart Hildebrand" , Xenia Ragiadakou , Honglei Huang , Julia Zhang , Chen Jiqian Subject: [RFC QEMU PATCH 01/18] virtio: Add shared memory capability Date: Sun, 12 Mar 2023 17:22:27 +0800 Message-ID: <20230312092244.451465-2-ray.huang@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230312092244.451465-1-ray.huang@amd.com> References: <20230312092244.451465-1-ray.huang@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT082:EE_|BL1PR12MB5351:EE_ X-MS-Office365-Filtering-Correlation-Id: cc7f3646-c4a3-4231-417c-08db22db6c70 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: GUUVhREe5AEdwl7j0EIEkBb3I6AML33ZQLUI9+NFxJRD3WLhcyhTToors9wdBlYTKApwCd7XmTlD5D2NCxzv2yBjVsl8ozCO0wyfXrINiFXUfr2kq5kMcTJmYc95u0VmklK88GsLXF+O4EDvWydrEsmXoRhPNNOWesVHxGHoz5zrrKGQxaL0MG7NCi/XxkoLDHGmlgevLDvbjM2uaO6VLfzWsfgj/GLK1YcqxbWRsz8wpnf57Ks3XKZh8XaARviE33twlXN5+oFXi+WAuRI4FyvhziMkvD6czfEd7eJLiOl1MS92n1ZirsTLRJZlPvq+hMGMPYjmRRbBk4cwf/idsZJr51XyYNXAaBfR4UWeP2D1T7ZzAvVPk6qo4jJ0FuDjsvc0N5DHhG1sojMmDAJ4cj1ujuban8Q7Irha+YCCMO+jfJGOxLBe1F1DpguwF039ZGxngTrbIq7u8CzybeKTpxsCagAZPaYRQtDGs1Cu6aKZQ3h/Hk/UaGUwmutc54PbE8DJWLTuCspVGiPkGEX/tZ2RoYrTqqTnhhmjGmWg57SHMkn3gjzBUtNoGjaQjhrBroiYXFbOTunJlFB1z/FzhGHhKCwMn1jXvnibzdSM6YWpNh1JADZuvcwB7ik+edczhbGE6gRqy+nabYmqi+Hpn9U+udnT3ipF8tpub5a4akml6wLs3gqsBLdIRdehjqvy/DLEtao0LGPiajuM4Ag9/uglbdA9x6/5uJWYCenzKKIdUShD5ZRjYOf9yPOGyLPD X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230025)(4636009)(39860400002)(396003)(136003)(346002)(376002)(451199018)(36840700001)(46966006)(40470700004)(82310400005)(36756003)(86362001)(16526019)(186003)(41300700001)(1076003)(26005)(5660300002)(40460700003)(7416002)(336012)(4326008)(2616005)(8936002)(316002)(7696005)(110136005)(478600001)(54906003)(70586007)(8676002)(6666004)(70206006)(40480700001)(81166007)(82740400003)(921005)(356005)(2906002)(47076005)(426003)(36860700001)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Mar 2023 09:23:21.3973 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: cc7f3646-c4a3-4231-417c-08db22db6c70 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT082.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR12MB5351 Received-SPF: softfail client-ip=2a01:111:f400:fe5b::61c; envelope-from=Ray.Huang@amd.com; helo=NAM12-BN8-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: "Dr. David Alan Gilbert" Define a new capability type 'VIRTIO_PCI_CAP_SHARED_MEMORY_CFG' to allow defining shared memory regions with sizes and offsets of 2^32 and more. Multiple instances of the capability are allowed and distinguished by a device-specific 'id'. Signed-off-by: Dr. David Alan Gilbert Signed-off-by: Antonio Caggiano --- hw/virtio/virtio-pci.c | 18 ++++++++++++++++++ include/hw/virtio/virtio-pci.h | 4 ++++ 2 files changed, 22 insertions(+) diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c index a1c9dfa7bb..ae4c29cb96 100644 --- a/hw/virtio/virtio-pci.c +++ b/hw/virtio/virtio-pci.c @@ -1191,6 +1191,24 @@ static int virtio_pci_add_mem_cap(VirtIOPCIProxy *proxy, return offset; } +int virtio_pci_add_shm_cap(VirtIOPCIProxy *proxy, + uint8_t bar, uint64_t offset, uint64_t length, + uint8_t id) +{ + struct virtio_pci_cap64 cap = { + .cap.cap_len = sizeof cap, + .cap.cfg_type = VIRTIO_PCI_CAP_SHARED_MEMORY_CFG, + }; + + cap.cap.bar = bar; + cap.cap.length = cpu_to_le32(length); + cap.length_hi = cpu_to_le32(length >> 32); + cap.cap.offset = cpu_to_le32(offset); + cap.offset_hi = cpu_to_le32(offset >> 32); + cap.cap.id = id; + return virtio_pci_add_mem_cap(proxy, &cap.cap); +} + static uint64_t virtio_pci_common_read(void *opaque, hwaddr addr, unsigned size) { diff --git a/include/hw/virtio/virtio-pci.h b/include/hw/virtio/virtio-pci.h index 938799e8f6..e67fe422a1 100644 --- a/include/hw/virtio/virtio-pci.h +++ b/include/hw/virtio/virtio-pci.h @@ -257,4 +257,8 @@ void virtio_pci_types_register(const VirtioPCIDeviceTypeInfo *t); */ unsigned virtio_pci_optimal_num_queues(unsigned fixed_queues); +int virtio_pci_add_shm_cap(VirtIOPCIProxy *proxy, + uint8_t bar, uint64_t offset, uint64_t length, + uint8_t id); + #endif