On Mon, May 27, 2019 at 03:53:11AM -0700, Renato Aguiar wrote: > Hi, > > The following patch makes Linux guests use kvm-clock by setting KVM's CPUID > signature on VMM: >
By saying the hypervisor is KVM to all guests, does this cause the guests to make other assumptions we don't want? > Index: sys/arch/amd64/amd64/vmm.c > =================================================================== > RCS file: /cvs/src/sys/arch/amd64/amd64/vmm.c,v > retrieving revision 1.245 > diff -u -p -r1.245 vmm.c > --- sys/arch/amd64/amd64/vmm.c 17 May 2019 19:07:15 -0000 1.245 > +++ sys/arch/amd64/amd64/vmm.c 27 May 2019 09:44:07 -0000 > @@ -238,6 +238,7 @@ extern uint64_t tsc_frequency; > extern int tsc_is_invariant; > > const char *vmm_hv_signature = VMM_HV_SIGNATURE; > +const char *kvm_hv_signature = KVM_HV_SIGNATURE; > > const struct kmem_pa_mode vmm_kp_contig = { > .kp_constraint = &no_constraint, > @@ -6433,7 +6434,14 @@ vmm_handle_cpuid(struct vcpu *vcpu) > *rcx = *((uint32_t *)&vmm_hv_signature[4]); > *rdx = *((uint32_t *)&vmm_hv_signature[8]); > break; > + case 0x40000100: /* KVM CPUID signature */ > + *rax = 0; > + *rbx = *((uint32_t *)&kvm_hv_signature[0]); > + *rcx = *((uint32_t *)&kvm_hv_signature[4]); > + *rdx = *((uint32_t *)&kvm_hv_signature[8]); > + break; > case 0x40000001: /* KVM hypervisor features */ > + case 0x40000101: > *rax = (1 << KVM_FEATURE_CLOCKSOURCE2) | > (1 << KVM_FEATURE_CLOCKSOURCE_STABLE_BIT); > *rbx = 0; > Index: sys/arch/amd64/include/vmmvar.h > =================================================================== > RCS file: /cvs/src/sys/arch/amd64/include/vmmvar.h,v > retrieving revision 1.66 > diff -u -p -r1.66 vmmvar.h > --- sys/arch/amd64/include/vmmvar.h 17 May 2019 19:07:16 -0000 1.66 > +++ sys/arch/amd64/include/vmmvar.h 27 May 2019 09:44:07 -0000 > @@ -22,6 +22,7 @@ > #define _MACHINE_VMMVAR_H_ > > #define VMM_HV_SIGNATURE "OpenBSDVMM58" > +#define KVM_HV_SIGNATURE "KVMKVMKVM\0\0\0" > > #define VMM_MAX_MEM_RANGES 16 > #define VMM_MAX_DISKS_PER_VM 4 > Index: sys/arch/i386/include/vmmvar.h > =================================================================== > RCS file: /cvs/src/sys/arch/i386/include/vmmvar.h,v > retrieving revision 1.19 > diff -u -p -r1.19 vmmvar.h > --- sys/arch/i386/include/vmmvar.h 18 Jan 2019 01:34:50 -0000 1.19 > +++ sys/arch/i386/include/vmmvar.h 27 May 2019 09:44:07 -0000 > @@ -15,3 +15,4 @@ > */ > > #define VMM_HV_SIGNATURE "OpenBSDVMM58" > +#define KVM_HV_SIGNATURE "KVMKVMKVM\0\0\0" > Index: sys/dev/pv/pvbus.c > =================================================================== > RCS file: /cvs/src/sys/dev/pv/pvbus.c,v > retrieving revision 1.19 > diff -u -p -r1.19 pvbus.c > --- sys/dev/pv/pvbus.c 13 May 2019 15:40:34 -0000 1.19 > +++ sys/dev/pv/pvbus.c 27 May 2019 09:44:08 -0000 > @@ -85,7 +85,7 @@ struct pvbus_type { > void (*init)(struct pvbus_hv *); > void (*print)(struct pvbus_hv *); > } pvbus_types[PVBUS_MAX] = { > - { "KVMKVMKVM\0\0\0", "KVM", pvbus_kvm }, > + { KVM_HV_SIGNATURE, "KVM", pvbus_kvm }, > { "Microsoft Hv", "Hyper-V", pvbus_hyperv, pvbus_hyperv_print }, > { "VMwareVMware", "VMware" }, > { "XenVMMXenVMM", "Xen", pvbus_xen, pvbus_xen_print }, > > > -- > Renato Aguiar >