powerpc: Mark writes registering ipi to host cpu through kvm and polling
authorRohan McLure <rmclure@linux.ibm.com>
Wed, 10 May 2023 03:31:14 +0000 (13:31 +1000)
committerMichael Ellerman <mpe@ellerman.id.au>
Wed, 21 Jun 2023 05:13:57 +0000 (15:13 +1000)
Mark writes to hypervisor ipi state so that KCSAN recognises these
asynchronous issue of kvmppc_{set,clear}_host_ipi to be intended, with
atomic writes. Mark asynchronous polls to this variable in
kvm_ppc_read_one_intr().

Signed-off-by: Rohan McLure <rmclure@linux.ibm.com>
Reviewed-by: Nicholas Piggin <npiggin@gmail.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://msgid.link/20230510033117.1395895-9-rmclure@linux.ibm.com
arch/powerpc/include/asm/kvm_ppc.h
arch/powerpc/kvm/book3s_hv_builtin.c

index 79a9c0bb8bba9ca51ad5ec2e7f7c71c151a93056..d16d80ad2ae42f37749a62a64eb2c6aeab693f44 100644 (file)
@@ -548,12 +548,12 @@ static inline void kvmppc_set_host_ipi(int cpu)
         * pairs with the barrier in kvmppc_clear_host_ipi()
         */
        smp_mb();
-       paca_ptrs[cpu]->kvm_hstate.host_ipi = 1;
+       WRITE_ONCE(paca_ptrs[cpu]->kvm_hstate.host_ipi, 1);
 }
 
 static inline void kvmppc_clear_host_ipi(int cpu)
 {
-       paca_ptrs[cpu]->kvm_hstate.host_ipi = 0;
+       WRITE_ONCE(paca_ptrs[cpu]->kvm_hstate.host_ipi, 0);
        /*
         * order clearing of host_ipi flag vs. processing of IPI messages
         *
index da85f046377a4bbb1534ec884cf42cc13b99d466..0f5b021fa5590b59ac13227dcb952bd8e830d6ab 100644 (file)
@@ -406,7 +406,7 @@ static long kvmppc_read_one_intr(bool *again)
                return 1;
 
        /* see if a host IPI is pending */
-       host_ipi = local_paca->kvm_hstate.host_ipi;
+       host_ipi = READ_ONCE(local_paca->kvm_hstate.host_ipi);
        if (host_ipi)
                return 1;
 
@@ -466,7 +466,7 @@ static long kvmppc_read_one_intr(bool *again)
                 * meantime. If it's clear, we bounce the interrupt to the
                 * guest
                 */
-               host_ipi = local_paca->kvm_hstate.host_ipi;
+               host_ipi = READ_ONCE(local_paca->kvm_hstate.host_ipi);
                if (unlikely(host_ipi != 0)) {
                        /* We raced with the host,
                         * we need to resend that IPI, bummer