# Re: \[PATCH 09/12\] powerpc: Mark writes registering ipi to host cpu through kvm

- From: Nicholas Piggin \<npiggin@gmail.com\>
- Date: 2023-05-09 02:31:10 
- List: linuxppc-dev
- Page: https://ratatoskr.run/linuxppc-dev/2023/05/9530856
- Thread: https://ratatoskr.run/linuxppc-dev/2023/05/9530811/t.md

```text
On Mon May 8, 2023 at 12:01 PM AEST, Rohan McLure wrote:
> 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.

How about READ_ONCE for the read side of host_ipi?

Thanks,
Nick

>
> Signed-off-by: Rohan McLure <redacted>
> ---
>  arch/powerpc/include/asm/kvm_ppc.h | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/arch/powerpc/include/asm/kvm_ppc.h b/arch/powerpc/include/asm/kvm_ppc.h
> index bc57d058ad5b..d701df006c08 100644
> --- a/arch/powerpc/include/asm/kvm_ppc.h
> +++ b/arch/powerpc/include/asm/kvm_ppc.h
> @@ -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
>  	 *
> -- 
> 2.37.2

```
