KVM: VMX: Combine "check" and "get" APIs for passthrough MSR lookups
authorSean Christopherson <seanjc@google.com>
Fri, 23 Feb 2024 20:21:04 +0000 (12:21 -0800)
committerSean Christopherson <seanjc@google.com>
Tue, 27 Feb 2024 20:29:46 +0000 (12:29 -0800)
commit259720c37d51aae21f70060ef96e1f1b08df0652
treedae7ca6b748febbda000b3cd9dcbb4d6b70be0df
parentbab22040d7fdeb935e57215a183912ba46eee7f0
KVM: VMX: Combine "check" and "get" APIs for passthrough MSR lookups

Combine possible_passthrough_msr_slot() and is_valid_passthrough_msr()
into a single function, vmx_get_passthrough_msr_slot(), and have the
combined helper return the slot on success, using a negative value to
indicate "failure".

Combining the operations avoids iterating over the array of passthrough
MSRs twice for relevant MSRs.

Suggested-by: Dongli Zhang <dongli.zhang@oracle.com>
Reviewed-by: Dongli Zhang <dongli.zhang@oracle.com>
Link: https://lore.kernel.org/r/20240223202104.3330974-4-seanjc@google.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
arch/x86/kvm/vmx/vmx.c