Skip to content

Commit f588557

Browse files
anlshsean-jc
authored andcommitted
KVM: Simplify error handling in __gfn_to_pfn_memslot()
KVM_HVA_ERR_RO_BAD satisfies kvm_is_error_hva(), so there's no need to duplicate the "if (writable)" block. Fix this by bringing all kvm_is_error_hva() cases under one conditional. Signed-off-by: Anish Moorthy <[email protected]> Link: https://lore.kernel.org/r/[email protected] [sean: use ternary operator] Signed-off-by: Sean Christopherson <[email protected]>
1 parent a3bd2f7 commit f588557

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

virt/kvm/kvm_main.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3035,16 +3035,12 @@ kvm_pfn_t __gfn_to_pfn_memslot(const struct kvm_memory_slot *slot, gfn_t gfn,
30353035
if (hva)
30363036
*hva = addr;
30373037

3038-
if (addr == KVM_HVA_ERR_RO_BAD) {
3039-
if (writable)
3040-
*writable = false;
3041-
return KVM_PFN_ERR_RO_FAULT;
3042-
}
3043-
30443038
if (kvm_is_error_hva(addr)) {
30453039
if (writable)
30463040
*writable = false;
3047-
return KVM_PFN_NOSLOT;
3041+
3042+
return addr == KVM_HVA_ERR_RO_BAD ? KVM_PFN_ERR_RO_FAULT :
3043+
KVM_PFN_NOSLOT;
30483044
}
30493045

30503046
/* Do not map writable pfn in the readonly memslot. */

0 commit comments

Comments
 (0)