Skip to content

Commit 1261903

Browse files
committed
KVM: selftests: Extend VM creation's @shape to allow control of VM subtype
Carve out space in the @shape passed to the various VM creation helpers to allow using the shape to control the subtype of VM, e.g. to identify x86's SEV VMs (which are "regular" VMs as far as KVM is concerned). Cc: Paolo Bonzini <[email protected]> Cc: Sean Christopherson <[email protected]> Cc: Vishal Annapurve <[email protected]> Cc: Ackerley Tng <[email protected]> Cc: Andrew Jones <[email protected]> Cc: Tom Lendacky <[email protected]> Cc: Michael Roth <[email protected]> Tested-by: Carlos Bilbao <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Sean Christopherson <[email protected]>
1 parent 8d25185 commit 1261903

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

tools/testing/selftests/kvm/include/kvm_util_base.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ enum kvm_mem_region_type {
9090
struct kvm_vm {
9191
int mode;
9292
unsigned long type;
93+
uint8_t subtype;
9394
int kvm_fd;
9495
int fd;
9596
unsigned int pgtable_levels;
@@ -191,10 +192,14 @@ enum vm_guest_mode {
191192
};
192193

193194
struct vm_shape {
194-
enum vm_guest_mode mode;
195-
unsigned int type;
195+
uint32_t type;
196+
uint8_t mode;
197+
uint8_t subtype;
198+
uint16_t padding;
196199
};
197200

201+
kvm_static_assert(sizeof(struct vm_shape) == sizeof(uint64_t));
202+
198203
#define VM_TYPE_DEFAULT 0
199204

200205
#define VM_SHAPE(__mode) \

tools/testing/selftests/kvm/lib/kvm_util.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,7 @@ struct kvm_vm *____vm_create(struct vm_shape shape)
225225

226226
vm->mode = shape.mode;
227227
vm->type = shape.type;
228+
vm->subtype = shape.subtype;
228229

229230
vm->pa_bits = vm_guest_mode_params[vm->mode].pa_bits;
230231
vm->va_bits = vm_guest_mode_params[vm->mode].va_bits;

0 commit comments

Comments
 (0)