powerpc/kvm: Prefer fault_in_pages_readable function
authorMathieu Malaterre <malat@debian.org>
Wed, 28 Mar 2018 19:58:11 +0000 (21:58 +0200)
committerMichael Ellerman <mpe@ellerman.id.au>
Thu, 17 May 2018 04:12:40 +0000 (14:12 +1000)
Directly use fault_in_pages_readable instead of manual __get_user code. Fix
warning treated as error with W=1:

  arch/powerpc/kernel/kvm.c:675:6: error: variable ‘tmp’ set but not used [-Werror=unused-but-set-variable]

Suggested-by: Christophe Leroy <christophe.leroy@c-s.fr>
Signed-off-by: Mathieu Malaterre <malat@debian.org>
Reviewed-by: Christophe Leroy <christophe.leroy@c-s.fr>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
arch/powerpc/kernel/kvm.c

index 9ad37f827a975f1f2a7f165447f951c9e2aa8fa7..683b5b3805bd17493d97c261afc19279ac76b69f 100644 (file)
@@ -25,6 +25,7 @@
 #include <linux/kvm_para.h>
 #include <linux/slab.h>
 #include <linux/of.h>
+#include <linux/pagemap.h>
 
 #include <asm/reg.h>
 #include <asm/sections.h>
@@ -672,14 +673,13 @@ static void kvm_use_magic_page(void)
 {
        u32 *p;
        u32 *start, *end;
-       u32 tmp;
        u32 features;
 
        /* Tell the host to map the magic page to -4096 on all CPUs */
        on_each_cpu(kvm_map_magic_page, &features, 1);
 
        /* Quick self-test to see if the mapping works */
-       if (__get_user(tmp, (u32*)KVM_MAGIC_PAGE)) {
+       if (!fault_in_pages_readable((const char *)KVM_MAGIC_PAGE, sizeof(u32))) {
                kvm_patching_worked = false;
                return;
        }