Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp4076034pxv; Mon, 26 Jul 2021 20:42:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz1eyaxm944sdl0hMF/KEJmSitt0DvTjOzY6s9pNSLIMW3fTCkBOr0eIvu5MDLdc8Yy9Dyy X-Received: by 2002:a05:6e02:20eb:: with SMTP id q11mr15649401ilv.272.1627357356395; Mon, 26 Jul 2021 20:42:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627357356; cv=none; d=google.com; s=arc-20160816; b=xdnVzKvuR9T03ZIJUv8IM086wQhmXbNXtGbaRrawQKGTqKL9W3IpDyaJ+7lua/201w Mtes9ssDHO4snBCaMNllgX82Tc2UT/sK9Ggstlvzj/sO4esQr7xzJnINWfeE29Wr2HUP fIakphxaOACMWsWt3izQBx0t0CnY0S9QzeV3QhNVuNTrqLj56ZO6x8jVrCzvmSXLTWpH z2BFBS6EhpRUDN/LZjYcKrTUZ1bMySrNbzbzTcI9K+j3D/JLguLhRRi4dxYrJq5jT5bm 4tGiZczEwYwQg7GQTv+nmm8Rx5cM/yD5X461GluHHSRQz3l0s5VnSN80O/qKB+ujWm9f Jyjg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from; bh=HcSuK6aMd8RoIrEqjfpo0Bh8YZHUp6JuO+OXQh4okqc=; b=l6jWrUh3X+WqHWnd/p9GPGK5Xj+uK68F4V33mX/U/jVM4Sjyd5nwoCr2YCQZJB/GvO qcdg/Ge25iussErqTBF9s1tJIMKq+F4foj5qJuZn3CbctWHT+smnekLy3HHDqO6c2X5p ubXKnpvolUA+HBlheIvES34sJJv3duMkrauKNGILb9khCLfgVRCp6iM6fWFS6D50/fV1 RNTQ+5fjH6e71fN0TByGKr9l/efj/X6zWARGzJTXsiA+puCJlvyjlG42UdlpM4vu27LP 10KC5fYeXRSfA+vAf+AX3tVVONX+JFNfXpqzUiQRZBmmXIXgiqCgpN6m4yw3hbZFrXPe WFaw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o18si2047528jah.71.2021.07.26.20.42.24; Mon, 26 Jul 2021 20:42:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234783AbhG0C7s (ORCPT + 99 others); Mon, 26 Jul 2021 22:59:48 -0400 Received: from mx21.baidu.com ([220.181.3.85]:42904 "EHLO baidu.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S234608AbhG0C7o (ORCPT ); Mon, 26 Jul 2021 22:59:44 -0400 Received: from BC-Mail-EX08.internal.baidu.com (unknown [172.31.51.48]) by Forcepoint Email with ESMTPS id 62CBB2F1BE2BD92E2D04; Tue, 27 Jul 2021 11:40:08 +0800 (CST) Received: from BJHW-MAIL-EX27.internal.baidu.com (10.127.64.42) by BC-Mail-EX08.internal.baidu.com (172.31.51.48) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2242.12; Tue, 27 Jul 2021 11:40:08 +0800 Received: from LAPTOP-UKSR4ENP.internal.baidu.com (172.31.63.8) by BJHW-MAIL-EX27.internal.baidu.com (10.127.64.42) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2308.14; Tue, 27 Jul 2021 11:40:07 +0800 From: Cai Huoqing To: , , , , , , , CC: , , Cai Huoqing Subject: [PATCH] vfio: Add "#ifdef CONFIG_MMU" for vma operations Date: Tue, 27 Jul 2021 11:40:00 +0800 Message-ID: <20210727034000.547-1-caihuoqing@baidu.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [172.31.63.8] X-ClientProxiedBy: BC-Mail-Ex12.internal.baidu.com (172.31.51.52) To BJHW-MAIL-EX27.internal.baidu.com (10.127.64.42) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add "#ifdef CONFIG_MMU", because vma mmap and vm_operations_struct depend on MMU Signed-off-by: Cai Huoqing --- 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