]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
KVM: arm64: Drop type input from kvm_put_guest
authorAndrew Jones <drjones@redhat.com>
Tue, 4 Aug 2020 17:06:01 +0000 (19:06 +0200)
committerMarc Zyngier <maz@kernel.org>
Fri, 21 Aug 2020 13:04:14 +0000 (14:04 +0100)
We can use typeof() to avoid the need for the type input.

Suggested-by: Marc Zyngier <maz@kernel.org>
Signed-off-by: Andrew Jones <drjones@redhat.com>
Signed-off-by: Marc Zyngier <maz@kernel.org>
Link: https://lore.kernel.org/r/20200804170604.42662-4-drjones@redhat.com
arch/arm64/kvm/pvtime.c
include/linux/kvm_host.h

index 95f9580275b1b57d791deee54db67a46c0ec4d03..241ded7ee0ad75a2ec50bfd1abe9caa44732cbc9 100644 (file)
@@ -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);
 }
 
index a23076765b4cc26040bd6b3110f06c1d14724e7b..84371fb06209dbcb8a8941bb5d8724f14c222a88 100644 (file)
@@ -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);