LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Erdem Aktas <erdemaktas@google.com>
To: linux-kselftest@vger.kernel.org
Cc: erdemaktas@google.com, Sean Christopherson <seanjc@google.com>,
Peter Gonda <pgonda@google.com>, Marc Orr <marcorr@google.com>,
Sagi Shahar <sagis@google.com>,
Paolo Bonzini <pbonzini@redhat.com>,
Shuah Khan <shuah@kernel.org>, Andrew Jones <drjones@redhat.com>,
Ben Gardon <bgardon@google.com>, Peter Xu <peterx@redhat.com>,
David Matlack <dmatlack@google.com>,
Emanuele Giuseppe Esposito <eesposit@redhat.com>,
Christian Borntraeger <borntraeger@de.ibm.com>,
Ricardo Koller <ricarkol@google.com>,
Eric Auger <eric.auger@redhat.com>,
Yanan Wang <wangyanan55@huawei.com>,
Aaron Lewis <aaronlewis@google.com>,
Jim Mattson <jmattson@google.com>,
Oliver Upton <oupton@google.com>,
Vitaly Kuznetsov <vkuznets@redhat.com>,
Peter Shier <pshier@google.com>,
Axel Rasmussen <axelrasmussen@google.com>,
Zhenzhong Duan <zhenzhong.duan@intel.com>,
"Maciej S. Szmigiero" <maciej.szmigiero@oracle.com>,
Like Xu <like.xu@linux.intel.com>,
open list <linux-kernel@vger.kernel.org>,
"open list:KERNEL VIRTUAL MACHINE (KVM)" <kvm@vger.kernel.org>
Subject: [RFC PATCH 1/4] KVM: selftests: Add support for creating non-default type VMs
Date: Mon, 26 Jul 2021 11:37:54 -0700 [thread overview]
Message-ID: <20210726183816.1343022-2-erdemaktas@google.com> (raw)
In-Reply-To: <20210726183816.1343022-1-erdemaktas@google.com>
Currently vm_create function only creates KVM_X86_LEGACY_VM type VMs.
Changing the vm_create function to accept type parameter to create
new VM types.
Signed-off-by: Erdem Aktas <erdemaktas@google.com>
Reviewed-by: Sean Christopherson <seanjc@google.com>
Reviewed-by: Peter Gonda <pgonda@google.com>
Reviewed-by: Marc Orr <marcorr@google.com>
Reviewed-by: Sagi Shahar <sagis@google.com>
---
.../testing/selftests/kvm/include/kvm_util.h | 1 +
tools/testing/selftests/kvm/lib/kvm_util.c | 29 +++++++++++++++++--
2 files changed, 27 insertions(+), 3 deletions(-)
diff --git a/tools/testing/selftests/kvm/include/kvm_util.h b/tools/testing/selftests/kvm/include/kvm_util.h
index d53bfadd2..c63df42d6 100644
--- a/tools/testing/selftests/kvm/include/kvm_util.h
+++ b/tools/testing/selftests/kvm/include/kvm_util.h
@@ -88,6 +88,7 @@ int vcpu_enable_cap(struct kvm_vm *vm, uint32_t vcpu_id,
void vm_enable_dirty_ring(struct kvm_vm *vm, uint32_t ring_size);
struct kvm_vm *vm_create(enum vm_guest_mode mode, uint64_t phy_pages, int perm);
+struct kvm_vm *__vm_create(enum vm_guest_mode mode, uint64_t phy_pages, int perm, int type);
void kvm_vm_free(struct kvm_vm *vmp);
void kvm_vm_restart(struct kvm_vm *vmp, int perm);
void kvm_vm_release(struct kvm_vm *vmp);
diff --git a/tools/testing/selftests/kvm/lib/kvm_util.c b/tools/testing/selftests/kvm/lib/kvm_util.c
index e5fbf16f7..70caa3882 100644
--- a/tools/testing/selftests/kvm/lib/kvm_util.c
+++ b/tools/testing/selftests/kvm/lib/kvm_util.c
@@ -180,13 +180,36 @@ _Static_assert(sizeof(vm_guest_mode_params)/sizeof(struct vm_guest_mode_params)
* Return:
* Pointer to opaque structure that describes the created VM.
*
- * Creates a VM with the mode specified by mode (e.g. VM_MODE_P52V48_4K).
+ * Wrapper VM Create function to create a VM with default type (0).
+ */
+struct kvm_vm *vm_create(enum vm_guest_mode mode, uint64_t phy_pages, int perm)
+{
+ return __vm_create(mode, phy_pages, perm, 0);
+}
+
+/*
+ * VM Create with a custom type
+ *
+ * Input Args:
+ * mode - VM Mode (e.g. VM_MODE_P52V48_4K)
+ * phy_pages - Physical memory pages
+ * perm - permission
+ * type - VM type
+ *
+ * Output Args: None
+ *
+ * Return:
+ * Pointer to opaque structure that describes the created VM.
+ *
+ * Creates a VM with the mode specified by mode (e.g. VM_MODE_P52V48_4K) and the
+ * type specified in type (e.g. KVM_X86_LEGACY_VM, KVM_X86_TDX_VM ...).
* When phy_pages is non-zero, a memory region of phy_pages physical pages
* is created and mapped starting at guest physical address 0. The file
* descriptor to control the created VM is created with the permissions
* given by perm (e.g. O_RDWR).
*/
-struct kvm_vm *vm_create(enum vm_guest_mode mode, uint64_t phy_pages, int perm)
+struct kvm_vm *__vm_create(enum vm_guest_mode mode, uint64_t phy_pages,
+ int perm, int type)
{
struct kvm_vm *vm;
@@ -200,7 +223,7 @@ struct kvm_vm *vm_create(enum vm_guest_mode mode, uint64_t phy_pages, int perm)
INIT_LIST_HEAD(&vm->userspace_mem_regions);
vm->mode = mode;
- vm->type = 0;
+ vm->type = type;
vm->pa_bits = vm_guest_mode_params[mode].pa_bits;
vm->va_bits = vm_guest_mode_params[mode].va_bits;
--
2.32.0.432.gabb21c7263-goog
next prev parent reply other threads:[~2021-07-26 18:41 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-26 18:37 [RFC PATCH 0/4] TDX KVM selftests Erdem Aktas
2021-07-26 18:37 ` Erdem Aktas [this message]
2021-07-26 22:26 ` [RFC PATCH 1/4] KVM: selftests: Add support for creating non-default type VMs David Matlack
2021-07-27 20:47 ` Sean Christopherson
2021-07-28 16:07 ` David Matlack
2021-07-28 20:11 ` Andrew Jones
2021-08-04 6:09 ` Xiaoyao Li
2021-08-04 14:24 ` Maxim Levitsky
2021-08-04 14:42 ` Xiaoyao Li
2021-08-04 14:45 ` Maxim Levitsky
2021-08-04 20:29 ` Erdem Aktas
2021-08-04 23:31 ` Sean Christopherson
2021-07-26 18:37 ` [RFC PATCH 2/4] KVM: selftest: Add helper functions to create TDX VMs Erdem Aktas
2021-07-26 18:37 ` [RFC PATCH 3/4] KVM: selftest: Adding TDX life cycle test Erdem Aktas
2021-07-26 22:42 ` David Matlack
2021-07-26 18:37 ` [RFC PATCH 4/4] KVM: selftest: Adding test case for TDX port IO Erdem Aktas
2021-07-28 4:02 ` [RFC PATCH 0/4] TDX KVM selftests Duan, Zhenzhong
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=20210726183816.1343022-2-erdemaktas@google.com \
--to=erdemaktas@google.com \
--cc=aaronlewis@google.com \
--cc=axelrasmussen@google.com \
--cc=bgardon@google.com \
--cc=borntraeger@de.ibm.com \
--cc=dmatlack@google.com \
--cc=drjones@redhat.com \
--cc=eesposit@redhat.com \
--cc=eric.auger@redhat.com \
--cc=jmattson@google.com \
--cc=kvm@vger.kernel.org \
--cc=like.xu@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=maciej.szmigiero@oracle.com \
--cc=marcorr@google.com \
--cc=oupton@google.com \
--cc=pbonzini@redhat.com \
--cc=peterx@redhat.com \
--cc=pgonda@google.com \
--cc=pshier@google.com \
--cc=ricarkol@google.com \
--cc=sagis@google.com \
--cc=seanjc@google.com \
--cc=shuah@kernel.org \
--cc=vkuznets@redhat.com \
--cc=wangyanan55@huawei.com \
--cc=zhenzhong.duan@intel.com \
--subject='Re: [RFC PATCH 1/4] KVM: selftests: Add support for creating non-default type VMs' \
/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
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).