lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Mon, 27 Feb 2023 17:18:56 +0800
From:   "Longpeng(Mike)" <longpeng2@...wei.com>
To:     <mst@...hat.com>, <jasowang@...hat.com>
CC:     <stefanha@...hat.com>, <sgarzare@...hat.com>,
        <arei.gonglei@...wei.com>, <yechuan@...wei.com>,
        <huangzhichao@...wei.com>,
        <virtualization@...ts.linux-foundation.org>,
        <linux-kernel@...r.kernel.org>, <eperezma@...hat.com>,
        Longpeng <longpeng2@...wei.com>
Subject: [PATCH v4 1/2] vdpa: support specify the pgprot of vq notification area

From: Longpeng <longpeng2@...wei.com>

Adds get_vq_notification_pgprot operation to vdpa_config_ops to support
specify the pgprot of vq norification area. It's an optional operation,
the vdpa framework will treat the pgprot of vq notification area as
noncached as default as usual.

Acked-by: Jason Wang <jasowang@...hat.com>
Signed-off-by: Longpeng <longpeng2@...wei.com>
---
 drivers/vhost/vdpa.c | 4 +++-
 include/linux/vdpa.h | 9 +++++++++
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/drivers/vhost/vdpa.c b/drivers/vhost/vdpa.c
index ec32f785dfde..8b595521c958 100644
--- a/drivers/vhost/vdpa.c
+++ b/drivers/vhost/vdpa.c
@@ -1273,7 +1273,9 @@ static vm_fault_t vhost_vdpa_fault(struct vm_fault *vmf)
 
 	notify = ops->get_vq_notification(vdpa, index);
 
-	vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
+	vma->vm_page_prot = ops->get_vq_notification_pgprot ?
+		ops->get_vq_notification_pgprot(vdpa, index, vma->vm_page_prot) :
+		pgprot_noncached(vma->vm_page_prot);
 	if (remap_pfn_range(vma, vmf->address & PAGE_MASK,
 			    PFN_DOWN(notify.addr), PAGE_SIZE,
 			    vma->vm_page_prot))
diff --git a/include/linux/vdpa.h b/include/linux/vdpa.h
index 6d0f5e4e82c2..07fcf5e6abc8 100644
--- a/include/linux/vdpa.h
+++ b/include/linux/vdpa.h
@@ -169,6 +169,12 @@ struct vdpa_map_file {
  *				@vdev: vdpa device
  *				@idx: virtqueue index
  *				Returns the notifcation area
+ * @get_vq_notification_pgprot:	Get the pgprot of the vq's notification area (optional)
+ *				@vdev: vdpa device
+ *				@idx: virtqueue index
+ *				@prot: original page protection value of the
+ *				       notification area
+ *				Returns pgprot_t: the pgprot of the notification area
  * @get_vq_irq:			Get the irq number of a virtqueue (optional,
  *				but must implemented if require vq irq offloading)
  *				@vdev: vdpa device
@@ -305,6 +311,9 @@ struct vdpa_config_ops {
 				   struct netlink_ext_ack *extack);
 	struct vdpa_notification_area
 	(*get_vq_notification)(struct vdpa_device *vdev, u16 idx);
+	pgprot_t (*get_vq_notification_pgprot)(struct vdpa_device *vdev,
+					       u16 idx,
+					       pgprot_t prot);
 	/* vq irq is not expected to be changed once DRIVER_OK is set */
 	int (*get_vq_irq)(struct vdpa_device *vdev, u16 idx);
 
-- 
2.23.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ