Linux KVM/arm64 development list
 help / color / mirror / Atom feed
From: Alexandru Elisei <alexandru.elisei@arm.com>
To: Nadav Amit <nadav.amit@gmail.com>
Cc: Andrew Jones <andrew.jones@linux.dev>,
	kvmarm@lists.linux.dev, kvmarm@lists.cs.columbia.edu,
	kvm@vger.kernel.org, Nadav Amit <namit@vmware.com>
Subject: Re: [kvm-unit-tests PATCH 2/2] arm64: ensure tlbi is safe
Date: Fri, 14 Jul 2023 11:55:10 +0100	[thread overview]
Message-ID: <ZLEoL8NbvmRNysJF@monolith.localdoman> (raw)
In-Reply-To: <20230617013138.1823-3-namit@vmware.com>

Hi,

On Sat, Jun 17, 2023 at 01:31:38AM +0000, Nadav Amit wrote:
> From: Nadav Amit <namit@vmware.com>
> 
> While no real problem was encountered, having an inline assembly without
> volatile keyword and output can allow the compiler to ignore it. And
> without a memory clobber, potentially reorder it.
> 
> Add volatile and memory clobber.
> 
> Signed-off-by: Nadav Amit <namit@vmware.com>
> ---
>  lib/arm64/asm/mmu.h | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/lib/arm64/asm/mmu.h b/lib/arm64/asm/mmu.h
> index 5c27edb..cf94403 100644
> --- a/lib/arm64/asm/mmu.h
> +++ b/lib/arm64/asm/mmu.h
> @@ -14,7 +14,7 @@
>  static inline void flush_tlb_all(void)
>  {
>  	dsb(ishst);
> -	asm("tlbi	vmalle1is");

From the gas manual [1]:

"asm statements that have no output operands and asm goto statements, are
implicitly volatile."

Looks to me like both TLBIs fall into this category.

And I think the "memory" clobber is not needed because the dsb macro before and
after the TLBI already have it.

[1] https://gcc.gnu.org/onlinedocs/gcc/Extended-Asm.html#Volatile

Thanks,
Alex

> +	asm volatile("tlbi	vmalle1is" ::: "memory");
>  	dsb(ish);
>  	isb();
>  }
> @@ -23,7 +23,7 @@ static inline void flush_tlb_page(unsigned long vaddr)
>  {
>  	unsigned long page = vaddr >> 12;
>  	dsb(ishst);
> -	asm("tlbi	vaae1is, %0" :: "r" (page));
> +	asm volatile("tlbi	vaae1is, %0" :: "r" (page) : "memory");
>  	dsb(ish);
>  	isb();
>  }
> -- 
> 2.34.1
> 
> 

  reply	other threads:[~2023-07-14 10:55 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-17  1:31 [kvm-unit-tests PATCH 0/2] arm64: fix paging issues Nadav Amit
2023-06-17  1:31 ` [kvm-unit-tests PATCH 1/2] arm64: set sctlr_el1.SPAN Nadav Amit
2023-06-25 19:44   ` Nadav Amit
2023-07-07 18:26   ` Nadav Amit
2023-07-14 10:31   ` Alexandru Elisei
2023-07-14 11:29     ` Shaoqin Huang
2023-07-14 18:42       ` Nadav Amit
2023-07-17  6:50         ` Andrew Jones
2023-07-17  6:52           ` Andrew Jones
2023-07-17  8:53             ` Nikos Nikoleris
2023-07-17 17:05               ` Nadav Amit
2023-07-18  8:44                 ` Alexandru Elisei
2023-07-19  5:42                   ` Nadav Amit
2023-06-17  1:31 ` [kvm-unit-tests PATCH 2/2] arm64: ensure tlbi is safe Nadav Amit
2023-07-14 10:55   ` Alexandru Elisei [this message]
2023-07-14 17:20     ` Nadav Amit

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZLEoL8NbvmRNysJF@monolith.localdoman \
    --to=alexandru.elisei@arm.com \
    --cc=andrew.jones@linux.dev \
    --cc=kvm@vger.kernel.org \
    --cc=kvmarm@lists.cs.columbia.edu \
    --cc=kvmarm@lists.linux.dev \
    --cc=nadav.amit@gmail.com \
    --cc=namit@vmware.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox