From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A152F28EF; Fri, 27 Jan 2023 11:41:03 +0000 (UTC) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 06657176A; Fri, 27 Jan 2023 03:41:45 -0800 (PST) Received: from ewhatever.cambridge.arm.com (ewhatever.cambridge.arm.com [10.1.197.1]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 7CD023F64C; Fri, 27 Jan 2023 03:41:00 -0800 (PST) From: Suzuki K Poulose To: kvm@vger.kernel.org, kvmarm@lists.linux.dev Cc: suzuki.poulose@arm.com, Alexandru Elisei , Andrew Jones , Christoffer Dall , Fuad Tabba , Jean-Philippe Brucker , Joey Gouly , Marc Zyngier , Mark Rutland , Oliver Upton , Paolo Bonzini , Quentin Perret , Steven Price , Thomas Huth , Will Deacon , Zenghui Yu , linux-coco@lists.linux.dev, kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [RFC kvmtool 26/31] virtio: Add a wrapper for get_host_features Date: Fri, 27 Jan 2023 11:39:27 +0000 Message-Id: <20230127113932.166089-27-suzuki.poulose@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230127113932.166089-1-suzuki.poulose@arm.com> References: <20230127112248.136810-1-suzuki.poulose@arm.com> <20230127113932.166089-1-suzuki.poulose@arm.com> Precedence: bulk X-Mailing-List: linux-coco@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Add a wrapper to the vdev->ops->get_host_features() to allow setting platform specific flags outside the device Signed-off-by: Suzuki K Poulose --- include/kvm/virtio.h | 2 ++ virtio/core.c | 5 +++++ virtio/mmio-legacy.c | 2 +- virtio/mmio-modern.c | 2 +- virtio/pci-legacy.c | 2 +- virtio/pci-modern.c | 2 +- 6 files changed, 11 insertions(+), 4 deletions(-) diff --git a/include/kvm/virtio.h b/include/kvm/virtio.h index 94bddefe..e95cfad5 100644 --- a/include/kvm/virtio.h +++ b/include/kvm/virtio.h @@ -248,4 +248,6 @@ void virtio_set_guest_features(struct kvm *kvm, struct virtio_device *vdev, void virtio_notify_status(struct kvm *kvm, struct virtio_device *vdev, void *dev, u8 status); +u64 virtio_dev_get_host_features(struct virtio_device *vdev, struct kvm *kvm, void *dev); + #endif /* KVM__VIRTIO_H */ diff --git a/virtio/core.c b/virtio/core.c index ea0e5b65..50e7f86d 100644 --- a/virtio/core.c +++ b/virtio/core.c @@ -283,6 +283,11 @@ void virtio_notify_status(struct kvm *kvm, struct virtio_device *vdev, vdev->ops->notify_status(kvm, dev, ext_status); } +u64 virtio_dev_get_host_features(struct virtio_device *vdev, struct kvm *kvm, void *dev) +{ + return vdev->ops->get_host_features(kvm, dev); +} + bool virtio_access_config(struct kvm *kvm, struct virtio_device *vdev, void *dev, unsigned long offset, void *data, size_t size, bool is_write) diff --git a/virtio/mmio-legacy.c b/virtio/mmio-legacy.c index 7ca7e69f..42673236 100644 --- a/virtio/mmio-legacy.c +++ b/virtio/mmio-legacy.c @@ -26,7 +26,7 @@ static void virtio_mmio_config_in(struct kvm_cpu *vcpu, break; case VIRTIO_MMIO_DEVICE_FEATURES: if (vmmio->hdr.host_features_sel == 0) - val = vdev->ops->get_host_features(vmmio->kvm, + val = virtio_dev_get_host_features(vdev, vmmio->kvm, vmmio->dev); ioport__write32(data, val); break; diff --git a/virtio/mmio-modern.c b/virtio/mmio-modern.c index 6c0bb382..a09fa8e9 100644 --- a/virtio/mmio-modern.c +++ b/virtio/mmio-modern.c @@ -26,7 +26,7 @@ static void virtio_mmio_config_in(struct kvm_cpu *vcpu, case VIRTIO_MMIO_DEVICE_FEATURES: if (vmmio->hdr.host_features_sel > 1) break; - features |= vdev->ops->get_host_features(vmmio->kvm, vmmio->dev); + features |= virtio_dev_get_host_features(vdev, vmmio->kvm, vmmio->dev); val = features >> (32 * vmmio->hdr.host_features_sel); break; case VIRTIO_MMIO_QUEUE_NUM_MAX: diff --git a/virtio/pci-legacy.c b/virtio/pci-legacy.c index 58047967..d5f5dee7 100644 --- a/virtio/pci-legacy.c +++ b/virtio/pci-legacy.c @@ -44,7 +44,7 @@ static bool virtio_pci__data_in(struct kvm_cpu *vcpu, struct virtio_device *vdev switch (offset) { case VIRTIO_PCI_HOST_FEATURES: - val = vdev->ops->get_host_features(kvm, vpci->dev); + val = virtio_dev_get_host_features(vdev, kvm, vpci->dev); ioport__write32(data, val); break; case VIRTIO_PCI_QUEUE_PFN: diff --git a/virtio/pci-modern.c b/virtio/pci-modern.c index c5b4bc50..2c5bf3f8 100644 --- a/virtio/pci-modern.c +++ b/virtio/pci-modern.c @@ -158,7 +158,7 @@ static bool virtio_pci__common_read(struct virtio_device *vdev, case VIRTIO_PCI_COMMON_DF: if (vpci->device_features_sel > 1) break; - features |= vdev->ops->get_host_features(vpci->kvm, vpci->dev); + features |= virtio_dev_get_host_features(vdev, vpci->kvm, vpci->dev); val = features >> (32 * vpci->device_features_sel); ioport__write32(data, val); break; -- 2.34.1 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 2D281C54EAA for ; Fri, 27 Jan 2023 12:15:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=jiHtH1V7WCdS/Ks/lVTYxm6glRuns42hW7E3FzhTj/o=; b=LrXzjqknLbmK4c vR0A8skC11xKUy1OA7FkJ0M2mfB3e69LNotGKzcKFvPVROtaJ8UfFYinjDAGo07XWgxMVqqtc8uVa qZhZDt26J6F8p66OcNoyf+QuDkB2CK7D+3+I82CRCYjrhohZilBtbMZRuL1hqpNSQ6MXvEYAwRh4d I8e+s8w5UNZoLKxwLhi3SN1ZBmcMua5wgCPSBVj6BHD1n/upE7nTLX/Q9BFeeXJaZGwpP4ujogzDB n7k+5ybUBYnkvElew2OUIYKyIf5/EaLznSindBtTzkFeNRRyPXIeXFvkFHoATTBv3jmm+puz9p9Z+ OeIJhMPX2r72wIo/PjTg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pLNcw-00ESqh-Pe; Fri, 27 Jan 2023 12:14:43 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pLN6O-00EDGq-53 for linux-arm-kernel@lists.infradead.org; Fri, 27 Jan 2023 11:41:07 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 06657176A; Fri, 27 Jan 2023 03:41:45 -0800 (PST) Received: from ewhatever.cambridge.arm.com (ewhatever.cambridge.arm.com [10.1.197.1]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 7CD023F64C; Fri, 27 Jan 2023 03:41:00 -0800 (PST) From: Suzuki K Poulose To: kvm@vger.kernel.org, kvmarm@lists.linux.dev Cc: suzuki.poulose@arm.com, Alexandru Elisei , Andrew Jones , Christoffer Dall , Fuad Tabba , Jean-Philippe Brucker , Joey Gouly , Marc Zyngier , Mark Rutland , Oliver Upton , Paolo Bonzini , Quentin Perret , Steven Price , Thomas Huth , Will Deacon , Zenghui Yu , linux-coco@lists.linux.dev, kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [RFC kvmtool 26/31] virtio: Add a wrapper for get_host_features Date: Fri, 27 Jan 2023 11:39:27 +0000 Message-Id: <20230127113932.166089-27-suzuki.poulose@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230127113932.166089-1-suzuki.poulose@arm.com> References: <20230127112248.136810-1-suzuki.poulose@arm.com> <20230127113932.166089-1-suzuki.poulose@arm.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230127_034104_342965_E747CF57 X-CRM114-Status: GOOD ( 12.23 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Add a wrapper to the vdev->ops->get_host_features() to allow setting platform specific flags outside the device Signed-off-by: Suzuki K Poulose --- include/kvm/virtio.h | 2 ++ virtio/core.c | 5 +++++ virtio/mmio-legacy.c | 2 +- virtio/mmio-modern.c | 2 +- virtio/pci-legacy.c | 2 +- virtio/pci-modern.c | 2 +- 6 files changed, 11 insertions(+), 4 deletions(-) diff --git a/include/kvm/virtio.h b/include/kvm/virtio.h index 94bddefe..e95cfad5 100644 --- a/include/kvm/virtio.h +++ b/include/kvm/virtio.h @@ -248,4 +248,6 @@ void virtio_set_guest_features(struct kvm *kvm, struct virtio_device *vdev, void virtio_notify_status(struct kvm *kvm, struct virtio_device *vdev, void *dev, u8 status); +u64 virtio_dev_get_host_features(struct virtio_device *vdev, struct kvm *kvm, void *dev); + #endif /* KVM__VIRTIO_H */ diff --git a/virtio/core.c b/virtio/core.c index ea0e5b65..50e7f86d 100644 --- a/virtio/core.c +++ b/virtio/core.c @@ -283,6 +283,11 @@ void virtio_notify_status(struct kvm *kvm, struct virtio_device *vdev, vdev->ops->notify_status(kvm, dev, ext_status); } +u64 virtio_dev_get_host_features(struct virtio_device *vdev, struct kvm *kvm, void *dev) +{ + return vdev->ops->get_host_features(kvm, dev); +} + bool virtio_access_config(struct kvm *kvm, struct virtio_device *vdev, void *dev, unsigned long offset, void *data, size_t size, bool is_write) diff --git a/virtio/mmio-legacy.c b/virtio/mmio-legacy.c index 7ca7e69f..42673236 100644 --- a/virtio/mmio-legacy.c +++ b/virtio/mmio-legacy.c @@ -26,7 +26,7 @@ static void virtio_mmio_config_in(struct kvm_cpu *vcpu, break; case VIRTIO_MMIO_DEVICE_FEATURES: if (vmmio->hdr.host_features_sel == 0) - val = vdev->ops->get_host_features(vmmio->kvm, + val = virtio_dev_get_host_features(vdev, vmmio->kvm, vmmio->dev); ioport__write32(data, val); break; diff --git a/virtio/mmio-modern.c b/virtio/mmio-modern.c index 6c0bb382..a09fa8e9 100644 --- a/virtio/mmio-modern.c +++ b/virtio/mmio-modern.c @@ -26,7 +26,7 @@ static void virtio_mmio_config_in(struct kvm_cpu *vcpu, case VIRTIO_MMIO_DEVICE_FEATURES: if (vmmio->hdr.host_features_sel > 1) break; - features |= vdev->ops->get_host_features(vmmio->kvm, vmmio->dev); + features |= virtio_dev_get_host_features(vdev, vmmio->kvm, vmmio->dev); val = features >> (32 * vmmio->hdr.host_features_sel); break; case VIRTIO_MMIO_QUEUE_NUM_MAX: diff --git a/virtio/pci-legacy.c b/virtio/pci-legacy.c index 58047967..d5f5dee7 100644 --- a/virtio/pci-legacy.c +++ b/virtio/pci-legacy.c @@ -44,7 +44,7 @@ static bool virtio_pci__data_in(struct kvm_cpu *vcpu, struct virtio_device *vdev switch (offset) { case VIRTIO_PCI_HOST_FEATURES: - val = vdev->ops->get_host_features(kvm, vpci->dev); + val = virtio_dev_get_host_features(vdev, kvm, vpci->dev); ioport__write32(data, val); break; case VIRTIO_PCI_QUEUE_PFN: diff --git a/virtio/pci-modern.c b/virtio/pci-modern.c index c5b4bc50..2c5bf3f8 100644 --- a/virtio/pci-modern.c +++ b/virtio/pci-modern.c @@ -158,7 +158,7 @@ static bool virtio_pci__common_read(struct virtio_device *vdev, case VIRTIO_PCI_COMMON_DF: if (vpci->device_features_sel > 1) break; - features |= vdev->ops->get_host_features(vpci->kvm, vpci->dev); + features |= virtio_dev_get_host_features(vdev, vpci->kvm, vpci->dev); val = features >> (32 * vpci->device_features_sel); ioport__write32(data, val); break; -- 2.34.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel