mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/herbert/cryptodev-2.6.git
synced 2026-04-18 03:23:53 -04:00
KVM: selftests: Return a value from vcpu_get_reg() instead of using an out-param
Return a uint64_t from vcpu_get_reg() instead of having the caller provide a pointer to storage, as none of the vcpu_get_reg() usage in KVM selftests accesses a register larger than 64 bits, and vcpu_set_reg() only accepts a 64-bit value. If a use case comes along that needs to get a register that is larger than 64 bits, then a utility can be added to assert success and take a void pointer, but until then, forcing an out param yields ugly code and prevents feeding the output of vcpu_get_reg() into vcpu_set_reg(). Reviewed-by: Andrew Jones <ajones@ventanamicro.com> Acked-by: Claudio Imbrenda <imbrenda@linux.ibm.com> Link: https://lore.kernel.org/r/20241128005547.4077116-3-seanjc@google.com Signed-off-by: Sean Christopherson <seanjc@google.com>
This commit is contained in:
@@ -702,11 +702,13 @@ static inline int __vcpu_set_reg(struct kvm_vcpu *vcpu, uint64_t id, uint64_t va
|
||||
|
||||
return __vcpu_ioctl(vcpu, KVM_SET_ONE_REG, ®);
|
||||
}
|
||||
static inline void vcpu_get_reg(struct kvm_vcpu *vcpu, uint64_t id, void *addr)
|
||||
static inline uint64_t vcpu_get_reg(struct kvm_vcpu *vcpu, uint64_t id)
|
||||
{
|
||||
struct kvm_one_reg reg = { .id = id, .addr = (uint64_t)addr };
|
||||
uint64_t val;
|
||||
struct kvm_one_reg reg = { .id = id, .addr = (uint64_t)&val };
|
||||
|
||||
vcpu_ioctl(vcpu, KVM_GET_ONE_REG, ®);
|
||||
return val;
|
||||
}
|
||||
static inline void vcpu_set_reg(struct kvm_vcpu *vcpu, uint64_t id, uint64_t val)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user