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]
Message-Id: <20231202091541.13568-1-yan.y.zhao@intel.com>
Date:   Sat,  2 Dec 2023 17:15:41 +0800
From:   Yan Zhao <yan.y.zhao@...el.com>
To:     iommu@...ts.linux.dev, kvm@...r.kernel.org,
        linux-kernel@...r.kernel.org
Cc:     alex.williamson@...hat.com, jgg@...dia.com, pbonzini@...hat.com,
        seanjc@...gle.com, joro@...tes.org, will@...nel.org,
        robin.murphy@....com, kevin.tian@...el.com,
        baolu.lu@...ux.intel.com, dwmw2@...radead.org, yi.l.liu@...el.com,
        Yan Zhao <yan.y.zhao@...el.com>
Subject: [RFC PATCH 03/42] KVM: Introduce VM ioctl KVM_CREATE_TDP_FD

Introduce VM ioctl KVM_CREATE_TDP_FD to create KVM TDP FD object, which
will act as an interface of KVM to export TDP page tables and communicate
with external components of KVM.

Signed-off-by: Yan Zhao <yan.y.zhao@...el.com>
---
 include/uapi/linux/kvm.h | 19 +++++++++++++++++++
 virt/kvm/kvm_main.c      | 19 +++++++++++++++++++
 virt/kvm/tdp_fd.h        | 10 ++++++++++
 3 files changed, 48 insertions(+)
 create mode 100644 virt/kvm/tdp_fd.h

diff --git a/include/uapi/linux/kvm.h b/include/uapi/linux/kvm.h
index 211b86de35ac5..f181883c60fed 100644
--- a/include/uapi/linux/kvm.h
+++ b/include/uapi/linux/kvm.h
@@ -1582,6 +1582,9 @@ struct kvm_s390_ucas_mapping {
 #define KVM_GET_DEVICE_ATTR	  _IOW(KVMIO,  0xe2, struct kvm_device_attr)
 #define KVM_HAS_DEVICE_ATTR	  _IOW(KVMIO,  0xe3, struct kvm_device_attr)
 
+/* ioctl for vm fd to create tdp fd */
+#define KVM_CREATE_TDP_FD	  _IOWR(KVMIO,  0xe4, struct kvm_create_tdp_fd)
+
 /*
  * ioctls for vcpu fds
  */
@@ -2267,4 +2270,20 @@ struct kvm_s390_zpci_op {
 /* flags for kvm_s390_zpci_op->u.reg_aen.flags */
 #define KVM_S390_ZPCIOP_REGAEN_HOST    (1 << 0)
 
+/**
+ * struct kvm_create_tdp_fd - VM ioctl(KVM_CREATE_TDP_FD)
+ * Create a TDP fd object for a TDP exported by KVM.
+ *
+ * @as_id: in: Address space ID for this TDP.
+ * @mode:  in: Mode of this tdp.
+ *             Reserved for future usage. Currently, this field must be 0.
+ * @fd:    out: fd of TDP fd object for a TDP exported by KVM.
+ * @pad:   in: Reserved as 0.
+ */
+struct kvm_create_tdp_fd {
+	__u32 as_id;
+	__u32 mode;
+	__u32 fd;
+	__u32 pad;
+};
 #endif /* __LINUX_KVM_H */
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 486800a7024b3..494b6301a6065 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -61,6 +61,7 @@
 #include "async_pf.h"
 #include "kvm_mm.h"
 #include "vfio.h"
+#include "tdp_fd.h"
 
 #include <trace/events/ipi.h>
 
@@ -4973,6 +4974,24 @@ static long kvm_vm_ioctl(struct file *filp,
 	case KVM_GET_STATS_FD:
 		r = kvm_vm_ioctl_get_stats_fd(kvm);
 		break;
+	case KVM_CREATE_TDP_FD: {
+		struct kvm_create_tdp_fd ct;
+
+		r = -EFAULT;
+		if (copy_from_user(&ct, argp, sizeof(ct)))
+			goto out;
+
+		r = kvm_create_tdp_fd(kvm, &ct);
+		if (r)
+			goto out;
+
+		r = -EFAULT;
+		if (copy_to_user(argp, &ct, sizeof(ct)))
+			goto out;
+
+		r = 0;
+		break;
+	}
 	default:
 		r = kvm_arch_vm_ioctl(filp, ioctl, arg);
 	}
diff --git a/virt/kvm/tdp_fd.h b/virt/kvm/tdp_fd.h
new file mode 100644
index 0000000000000..05c8a6d767469
--- /dev/null
+++ b/virt/kvm/tdp_fd.h
@@ -0,0 +1,10 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef __TDP_FD_H
+#define __TDP_FD_H
+
+static inline int kvm_create_tdp_fd(struct kvm *kvm, struct kvm_create_tdp_fd *ct)
+{
+	return -EOPNOTSUPP;
+}
+
+#endif /* __TDP_FD_H */
-- 
2.17.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ