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: stsp
Date: Mon Dec 07 2020 - 09:04:53 EST


07.12.2020 16:35, Paolo Bonzini пишет:


Il lun 7 dic 2020, 12:47 stsp <stsp2@xxxxxxxxx <mailto:stsp2@xxxxxxxxx>> ha scritto:

So am I right that KVM_SET_CPUID only "lowers"
the supported bits? In which case I don't need to
call it at all, but instead just call KVM_GET_SUPPORTED_CPUID
and see if the needed bits are supported, and
exit otherwise, right?


You always have to call KVM_SET_CPUID2, but you can just pass in whatever you got from KVM_GET_SUPPORTED_CPUID.
OK, done that, thanks.
(after checking that KVM_GET_SUPPORTED_CPUID
actually has the needed features itself, otherwise exit).

Perhaps it would be good if guest cpuid to
have a default values of KVM_GET_SUPPORTED_CPUID,
so that the user doesn't have to do the needless
calls to just copy host features to guest cpuid.