Skip to content

Commit

Permalink
KVM: arm64: Drop type input from kvm_put_guest
Browse files Browse the repository at this point in the history
We can use typeof() to avoid the need for the type input.

Suggested-by: Marc Zyngier <[email protected]>
Signed-off-by: Andrew Jones <[email protected]>
Signed-off-by: Marc Zyngier <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
  • Loading branch information
Andrew Jones authored and Marc Zyngier committed Aug 21, 2020
1 parent 2dbd780 commit 4d2d4ce
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion arch/arm64/kvm/pvtime.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ void kvm_update_stolen_time(struct kvm_vcpu *vcpu)
steal_le = cpu_to_le64(steal);
idx = srcu_read_lock(&kvm->srcu);
offset = offsetof(struct pvclock_vcpu_stolen_time, stolen_time);
kvm_put_guest(kvm, base + offset, steal_le, u64);
kvm_put_guest(kvm, base + offset, steal_le);
srcu_read_unlock(&kvm->srcu, idx);
}

Expand Down
11 changes: 6 additions & 5 deletions include/linux/kvm_host.h
Original file line number Diff line number Diff line change
Expand Up @@ -749,25 +749,26 @@ int kvm_write_guest_offset_cached(struct kvm *kvm, struct gfn_to_hva_cache *ghc,
int kvm_gfn_to_hva_cache_init(struct kvm *kvm, struct gfn_to_hva_cache *ghc,
gpa_t gpa, unsigned long len);

#define __kvm_put_guest(kvm, gfn, offset, value, type) \
#define __kvm_put_guest(kvm, gfn, offset, v) \
({ \
unsigned long __addr = gfn_to_hva(kvm, gfn); \
type __user *__uaddr = (type __user *)(__addr + offset); \
typeof(v) __user *__uaddr = (typeof(__uaddr))(__addr + offset); \
int __ret = -EFAULT; \
\
if (!kvm_is_error_hva(__addr)) \
__ret = put_user(value, __uaddr); \
__ret = put_user(v, __uaddr); \
if (!__ret) \
mark_page_dirty(kvm, gfn); \
__ret; \
})

#define kvm_put_guest(kvm, gpa, value, type) \
#define kvm_put_guest(kvm, gpa, v) \
({ \
gpa_t __gpa = gpa; \
struct kvm *__kvm = kvm; \
\
__kvm_put_guest(__kvm, __gpa >> PAGE_SHIFT, \
offset_in_page(__gpa), (value), type); \
offset_in_page(__gpa), v); \
})

int kvm_clear_guest_page(struct kvm *kvm, gfn_t gfn, int offset, int len);
Expand Down

0 comments on commit 4d2d4ce

Please sign in to comment.