Skip to content

Commit

Permalink
selftests: kvm: Clear uc so UCALL_NONE is being properly reported
Browse files Browse the repository at this point in the history
Ensure the out value 'uc' in get_ucall() is properly reporting
UCALL_NONE if the call fails.  The return value will be correctly
reported, however, the out parameter 'uc' will not be.  Clear the struct
to ensure the correct value is being reported in the out parameter.

Signed-off-by: Aaron Lewis <[email protected]>
Reviewed-by: Andrew Jones <[email protected]>
Reviewed-by: Alexander Graf <[email protected]>
Message-Id: <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
  • Loading branch information
suomilewis authored and bonzini committed Nov 8, 2020
1 parent df11f7d commit 85f2a43
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions tools/testing/selftests/kvm/lib/aarch64/ucall.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ uint64_t get_ucall(struct kvm_vm *vm, uint32_t vcpu_id, struct ucall *uc)
struct kvm_run *run = vcpu_state(vm, vcpu_id);
struct ucall ucall = {};

if (uc)
memset(uc, 0, sizeof(*uc));

if (run->exit_reason == KVM_EXIT_MMIO &&
run->mmio.phys_addr == (uint64_t)ucall_exit_mmio_addr) {
vm_vaddr_t gva;
Expand Down
3 changes: 3 additions & 0 deletions tools/testing/selftests/kvm/lib/s390x/ucall.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ uint64_t get_ucall(struct kvm_vm *vm, uint32_t vcpu_id, struct ucall *uc)
struct kvm_run *run = vcpu_state(vm, vcpu_id);
struct ucall ucall = {};

if (uc)
memset(uc, 0, sizeof(*uc));

if (run->exit_reason == KVM_EXIT_S390_SIEIC &&
run->s390_sieic.icptcode == 4 &&
(run->s390_sieic.ipa >> 8) == 0x83 && /* 0x83 means DIAGNOSE */
Expand Down
3 changes: 3 additions & 0 deletions tools/testing/selftests/kvm/lib/x86_64/ucall.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ uint64_t get_ucall(struct kvm_vm *vm, uint32_t vcpu_id, struct ucall *uc)
struct kvm_run *run = vcpu_state(vm, vcpu_id);
struct ucall ucall = {};

if (uc)
memset(uc, 0, sizeof(*uc));

if (run->exit_reason == KVM_EXIT_IO && run->io.port == UCALL_PIO_PORT) {
struct kvm_regs regs;

Expand Down

0 comments on commit 85f2a43

Please sign in to comment.