KVM: x86: KVM_CAP_SYNC_REGS
This commit implements an enhanced x86 version of S390 KVM_CAP_SYNC_REGS functionality. KVM_CAP_SYNC_REGS "allow[s] userspace to access certain guest registers without having to call SET/GET_*REGS”. This reduces ioctl overhead which is particularly important when userspace is making synchronous guest state modifications (e.g. when emulating and/or intercepting instructions). Originally implemented upstream for the S390, the x86 differences follow: - userspace can select the register sets to be synchronized with kvm_run using bit-flags in the kvm_valid_registers and kvm_dirty_registers fields. - vcpu_events is available in addition to the regs and sregs register sets. Signed-off-by: Ken Hofsass <hofsass@google.com> Reviewed-by: David Hildenbrand <david@redhat.com> [Removed wrapper around check for reserved kvm_valid_regs. - Radim] Signed-off-by: Radim Krčmář <rkrcmar@redhat.com>
This commit is contained in:

committed by
Radim Krčmář

parent
7b7e39522a
commit
01643c51bf
@@ -354,8 +354,25 @@ struct kvm_xcrs {
|
||||
__u64 padding[16];
|
||||
};
|
||||
|
||||
/* definition of registers in kvm_run */
|
||||
#define KVM_SYNC_X86_REGS (1UL << 0)
|
||||
#define KVM_SYNC_X86_SREGS (1UL << 1)
|
||||
#define KVM_SYNC_X86_EVENTS (1UL << 2)
|
||||
|
||||
#define KVM_SYNC_X86_VALID_FIELDS \
|
||||
(KVM_SYNC_X86_REGS| \
|
||||
KVM_SYNC_X86_SREGS| \
|
||||
KVM_SYNC_X86_EVENTS)
|
||||
|
||||
/* kvm_sync_regs struct included by kvm_run struct */
|
||||
struct kvm_sync_regs {
|
||||
/* Members of this structure are potentially malicious.
|
||||
* Care must be taken by code reading, esp. interpreting,
|
||||
* data fields from them inside KVM to prevent TOCTOU and
|
||||
* double-fetch types of vulnerabilities.
|
||||
*/
|
||||
struct kvm_regs regs;
|
||||
struct kvm_sregs sregs;
|
||||
struct kvm_vcpu_events events;
|
||||
};
|
||||
|
||||
#define KVM_X86_QUIRK_LINT0_REENABLED (1 << 0)
|
||||
|
Reference in New Issue
Block a user