Re: KVM_SET_CPUID doesn't check supported bits (was Re: [PATCH 0/6] KVM: x86: KVM_SET_SREGS.CR4 bug fixes and cleanup)

From: Paolo Bonzini
Date: Mon Dec 07 2020 - 06:31:23 EST


On 07/12/20 12:24, stsp wrote:
It tries to enable VME among other things.
qemu appears to disable VME by default,
unless you do "-cpu host". So we have a situation where
the host (which is qemu) doesn't have VME,
and guest (dosemu) is trying to enable it.
Now obviously KVM_SET_CPUID doesn't check anyting
at all and returns success. That later turns
into an invalid guest state.


Question: should KVM_SET_CPUID check for
supported bits, end return error if not everything
is supported?

No, it is intentional. Most bits of CPUID are not ever checked by KVM, so userspace is supposed to set values that makes sense or just copy the value of KVM_GET_SUPPORTED_CPUID more or less blindly.

Paolo