All of lore.kernel.org
 help / color / mirror / Atom feed
From: Cai Huoqing <caihuoqing@baidu.com>
To: <alex.williamson@redhat.com>, <cohuck@redhat.com>, <jgg@ziepe.ca>,
	<eric.auger@redhat.com>, <kevin.tian@intel.com>,
	<giovanni.cabiddu@intel.com>, <mgurtovoy@nvidia.com>,
	<jannh@google.com>
Cc: <kvm@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	Cai Huoqing <caihuoqing@baidu.com>
Subject: [PATCH] vfio: Add "#ifdef CONFIG_MMU" for vma operations
Date: Tue, 27 Jul 2021 11:40:00 +0800	[thread overview]
Message-ID: <20210727034000.547-1-caihuoqing@baidu.com> (raw)

Add "#ifdef CONFIG_MMU",
because vma mmap and vm_operations_struct depend on MMU

Signed-off-by: Cai Huoqing <caihuoqing@baidu.com>
---
 drivers/vfio/pci/vfio_pci.c | 4 ++++
 drivers/vfio/vfio.c         | 8 ++++++++
 2 files changed, 12 insertions(+)

diff --git a/drivers/vfio/pci/vfio_pci.c b/drivers/vfio/pci/vfio_pci.c
index 318864d52837..d49b27f15a3f 100644
--- a/drivers/vfio/pci/vfio_pci.c
+++ b/drivers/vfio/pci/vfio_pci.c
@@ -1559,6 +1559,7 @@ static int __vfio_pci_add_vma(struct vfio_pci_device *vdev,
  * Zap mmaps on open so that we can fault them in on access and therefore
  * our vma_list only tracks mappings accessed since last zap.
  */
+#ifdef CONFIG_MMU
 static void vfio_pci_mmap_open(struct vm_area_struct *vma)
 {
 	zap_vma_ptes(vma, vma->vm_start, vma->vm_end - vma->vm_start);
@@ -1701,6 +1702,7 @@ static int vfio_pci_mmap(struct vfio_device *core_vdev, struct vm_area_struct *v
 
 	return 0;
 }
+#endif /* CONFIG_MMU */
 
 static void vfio_pci_request(struct vfio_device *core_vdev, unsigned int count)
 {
@@ -1875,7 +1877,9 @@ static const struct vfio_device_ops vfio_pci_ops = {
 	.ioctl		= vfio_pci_ioctl,
 	.read		= vfio_pci_read,
 	.write		= vfio_pci_write,
+#ifdef CONFIG_MMU
 	.mmap		= vfio_pci_mmap,
+#endif /* CONFIG_MMU */
 	.request	= vfio_pci_request,
 	.match		= vfio_pci_match,
 };
diff --git a/drivers/vfio/vfio.c b/drivers/vfio/vfio.c
index 02cc51ce6891..2fb2de8d4d13 100644
--- a/drivers/vfio/vfio.c
+++ b/drivers/vfio/vfio.c
@@ -1182,6 +1182,7 @@ static ssize_t vfio_fops_write(struct file *filep, const char __user *buf,
 	return ret;
 }
 
+#ifdef CONFIG_MMU
 static int vfio_fops_mmap(struct file *filep, struct vm_area_struct *vma)
 {
 	struct vfio_container *container = filep->private_data;
@@ -1194,6 +1195,7 @@ static int vfio_fops_mmap(struct file *filep, struct vm_area_struct *vma)
 
 	return ret;
 }
+#endif /* CONFIG_MMU */
 
 static const struct file_operations vfio_fops = {
 	.owner		= THIS_MODULE,
@@ -1203,7 +1205,9 @@ static const struct file_operations vfio_fops = {
 	.write		= vfio_fops_write,
 	.unlocked_ioctl	= vfio_fops_unl_ioctl,
 	.compat_ioctl	= compat_ptr_ioctl,
+#ifdef CONFIG_MMU
 	.mmap		= vfio_fops_mmap,
+#endif /* CONFIG_MMU */
 };
 
 /**
@@ -1601,6 +1605,7 @@ static ssize_t vfio_device_fops_write(struct file *filep,
 	return device->ops->write(device, buf, count, ppos);
 }
 
+#ifdef CONFIG_MMU
 static int vfio_device_fops_mmap(struct file *filep, struct vm_area_struct *vma)
 {
 	struct vfio_device *device = filep->private_data;
@@ -1610,6 +1615,7 @@ static int vfio_device_fops_mmap(struct file *filep, struct vm_area_struct *vma)
 
 	return device->ops->mmap(device, vma);
 }
+#endif /* CONFIG_MMU */
 
 static const struct file_operations vfio_device_fops = {
 	.owner		= THIS_MODULE,
@@ -1618,7 +1624,9 @@ static const struct file_operations vfio_device_fops = {
 	.write		= vfio_device_fops_write,
 	.unlocked_ioctl	= vfio_device_fops_unl_ioctl,
 	.compat_ioctl	= compat_ptr_ioctl,
+#ifdef CONFIG_MMU
 	.mmap		= vfio_device_fops_mmap,
+#endif /* CONFIG_MMU */
 };
 
 /**
-- 
2.25.1


             reply	other threads:[~2021-07-27  3:40 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-27  3:40 Cai Huoqing [this message]
2021-07-27 16:35 ` [PATCH] vfio: Add "#ifdef CONFIG_MMU" for vma operations Cornelia Huck
2021-07-27 18:01   ` Alex Williamson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210727034000.547-1-caihuoqing@baidu.com \
    --to=caihuoqing@baidu.com \
    --cc=alex.williamson@redhat.com \
    --cc=cohuck@redhat.com \
    --cc=eric.auger@redhat.com \
    --cc=giovanni.cabiddu@intel.com \
    --cc=jannh@google.com \
    --cc=jgg@ziepe.ca \
    --cc=kevin.tian@intel.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mgurtovoy@nvidia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.