From patchwork Fri Oct 6 01:08:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gurchetan Singh X-Patchwork-Id: 13410910 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 E2FA5E92FD1 for ; Fri, 6 Oct 2023 01:10:27 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qoZKi-00019R-J1; Thu, 05 Oct 2023 21:08:48 -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 1qoZKd-00017C-TV for qemu-devel@nongnu.org; Thu, 05 Oct 2023 21:08:44 -0400 Received: from mail-pf1-x42f.google.com ([2607:f8b0:4864:20::42f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qoZKc-0007zA-5d for qemu-devel@nongnu.org; Thu, 05 Oct 2023 21:08:43 -0400 Received: by mail-pf1-x42f.google.com with SMTP id d2e1a72fcca58-690d2441b95so1275558b3a.1 for ; Thu, 05 Oct 2023 18:08:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1696554519; x=1697159319; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=7QKzZjXmHyLbcOHjy/a1yw3mk7OwvaLG82VBMPcnnE8=; b=VAsnoWLy8pBP6HFM66AEKiIuUMlqnlWcTZqhYDS11W1L4QUkTDG/x0CBwznO+gwKGy qqbXSHseLuXYdTF3U5Ge1PO1u50vtekAvnhd8XU7rRkEfWusAztasS17E9aRRrHnuQkr HqseO0IMWVIjq9bywt+Pbg4xv+3VPvmVPvOIQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696554519; x=1697159319; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=7QKzZjXmHyLbcOHjy/a1yw3mk7OwvaLG82VBMPcnnE8=; b=a/Zey8AoJgkY37P1g2/QGVw0ofTdkQdg8PJ4sAbfcRxg83t1PT7uyPo8S16qZMfG7L axPxOFR8JlRzC1pBky9kpo5FvM3Smi/N5VpfEqa+iHP2R9Oc305feltu7mvmUZUfN2Es 3ew0aKKX9NRZ1e1BrWDavgrC9n5fQQB4+v5XEWPTtZNLo4Lt4rMl6J1I9/1OIjosrjxW 5wHuOai8qRXQUKVKS9rngTk/ocfThQD1mwEfN3JJnBOt2rhPI1hJ3y3YxdzNAabsNfdz DMKdme4y+st2bUwaurXZqglQ7J5Pi2PapXEpQDlpCzUCdBw57MI9/gowZX7geh+O3eHB J83w== X-Gm-Message-State: AOJu0YwlaqDJ1IL24juJzVz8zccB+ZttM287CLhN99x2cjCNYonrKowy LKWB2d+hr0fwajX5UhDiaBPA8mJgbTrb7W+1QcE= X-Google-Smtp-Source: AGHT+IFd/YmmFG5n3WZi2jIgvtmHPmTujz8vEWIS/XjOYnu4NyY1qPmgtEXKuKAw1CXGVboxz0DqbA== X-Received: by 2002:a05:6a00:1d09:b0:692:6417:728a with SMTP id a9-20020a056a001d0900b006926417728amr3574608pfx.14.1696554519275; Thu, 05 Oct 2023 18:08:39 -0700 (PDT) Received: from gurchetansingh0.mtv.corp.google.com ([2620:15c:a7:2:176a:c8b6:faa3:f083]) by smtp.gmail.com with ESMTPSA id u22-20020a62ed16000000b00690fe1c928csm215079pfh.147.2023.10.05.18.08.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Oct 2023 18:08:38 -0700 (PDT) From: Gurchetan Singh To: qemu-devel@nongnu.org Cc: marcandre.lureau@redhat.com, akihiko.odaki@gmail.com, ray.huang@amd.com, alex.bennee@linaro.org, shentey@gmail.com, hi@alyssa.is, ernunes@redhat.com, manos.pitsidianakis@linaro.org, mark.cave-ayland@ilande.co.uk, thuth@redhat.com Subject: [PATCH v17 1/9] virtio: Add shared memory capability Date: Thu, 5 Oct 2023 18:08:27 -0700 Message-Id: <20231006010835.444-2-gurchetansingh@chromium.org> X-Mailer: git-send-email 2.31.0 In-Reply-To: <20231006010835.444-1-gurchetansingh@chromium.org> References: <20231006010835.444-1-gurchetansingh@chromium.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::42f; envelope-from=gurchetansingh@chromium.org; helo=mail-pf1-x42f.google.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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.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 Signed-off-by: Gurchetan Singh Tested-by: Alyssa Ross Tested-by: Huang Rui Tested-by: Akihiko Odaki Acked-by: Huang Rui Reviewed-by: Gurchetan Singh Reviewed-by: Akihiko Odaki --- 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 edbc0daa18..da8c9ea12d 100644 --- a/hw/virtio/virtio-pci.c +++ b/hw/virtio/virtio-pci.c @@ -1435,6 +1435,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 ab2051b64b..5a3f182f99 100644 --- a/include/hw/virtio/virtio-pci.h +++ b/include/hw/virtio/virtio-pci.h @@ -264,4 +264,8 @@ unsigned virtio_pci_optimal_num_queues(unsigned fixed_queues); void virtio_pci_set_guest_notifier_fd_handler(VirtIODevice *vdev, VirtQueue *vq, int n, bool assign, bool with_irqfd); + +int virtio_pci_add_shm_cap(VirtIOPCIProxy *proxy, uint8_t bar, uint64_t offset, + uint64_t length, uint8_t id); + #endif