From patchwork Fri Jan 27 11:39:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suzuki K Poulose X-Patchwork-Id: 49298 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp788037wrn; Fri, 27 Jan 2023 03:45:53 -0800 (PST) X-Google-Smtp-Source: AMrXdXsnygQhjKcOM958ulrOH1OUIBR5AI9WZy77clcBJ+r9vtngu3q0uI9jOX7GeMx2LubL4IvM X-Received: by 2002:a05:6a20:1e64:b0:b8:63bd:7c3e with SMTP id cy36-20020a056a201e6400b000b863bd7c3emr36268218pzb.2.1674819953318; Fri, 27 Jan 2023 03:45:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674819953; cv=none; d=google.com; s=arc-20160816; b=NRvlE80u1ltekyrVJvvt1MwG4P7S/9djylkhWFRfF+z2INhF+AJAHkb+uDso+2SccL 1+R/Vu5+JzP/GD/jinLvYowz+7vHkjEhpLhaAqQmJthFeHvoWorPJldz/dLkS7scIf+9 70JWp5hoKYeiydpaZprv1nqWUsABigTnNInZuoEN/DcF+k0hS47aCgcqeUOPiMUoDwVs 6h+RvNPJKego45JnrIuPcnahLejd3laV7VysFtHvkGNays7Zn+RhyU/YYeLJ+pSiU54n 3mKEdSfoy+IxdQ924GM8X+UHs2V+hICP2P1sZo4OAVXEEAnv0tKpvs18RaV1Y7aypRDN pchQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=1m/+FvQpO8U9prPz1n17ph3x+s7qWHS7eGLm4H1yzmo=; b=stCz25rL63fWZ+MtQf6rPvH0kX/9xfeU0roFQ6tQJJOEQLG16XnjAy12OFK6UHbxne BB/7No7fc/emEefYsJ2KiydAVhD1ne9VmGGi2akORylyQxmnImPuS9zCyuhGorSJu/GB vanMefmpvUSUPMOw/oRhMzjE/Bvx9SK8GJpFwJdkKzo+zSMiWFQh3ZuX2DIcbiY3Y2c4 CQKa0zhjR7zvHEx37XwvHpwc6OAnvjp3bVc9VKCj559f+0gQN7cS6L48JkVT6ta82O7b nQ5tXl8snISV5GtMgABhuACd19B+/0954xPFuFei+MsXItQnn8NBxKzx4WIMM+sQLAdU eLpA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x17-20020a656ab1000000b004769983b39asi4165183pgu.667.2023.01.27.03.45.40; Fri, 27 Jan 2023 03:45:53 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230092AbjA0Lmp (ORCPT + 99 others); Fri, 27 Jan 2023 06:42:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60376 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233879AbjA0LmA (ORCPT ); Fri, 27 Jan 2023 06:42:00 -0500 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 3586270D7E; Fri, 27 Jan 2023 03:41:28 -0800 (PST) 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-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756176007447567035?= X-GMAIL-MSGID: =?utf-8?q?1756176007447567035?= 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;