Linux KVM/arm64 development list
 help / color / mirror / Atom feed
From: Nadav Amit <nadav.amit@gmail.com>
To: Andrew Jones <andrew.jones@linux.dev>
Cc: kvmarm@lists.linux.dev, kvmarm@lists.cs.columbia.edu,
	kvm@vger.kernel.org, Nadav Amit <namit@vmware.com>
Subject: [kvm-unit-tests PATCH 2/2] arm64: ensure tlbi is safe
Date: Sat, 17 Jun 2023 01:31:38 +0000	[thread overview]
Message-ID: <20230617013138.1823-3-namit@vmware.com> (raw)
In-Reply-To: <20230617013138.1823-1-namit@vmware.com>

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");
+	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


  parent reply	other threads:[~2023-06-17  1:32 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 ` Nadav Amit [this message]
2023-07-14 10:55   ` [kvm-unit-tests PATCH 2/2] arm64: ensure tlbi is safe Alexandru Elisei
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=20230617013138.1823-3-namit@vmware.com \
    --to=nadav.amit@gmail.com \
    --cc=andrew.jones@linux.dev \
    --cc=kvm@vger.kernel.org \
    --cc=kvmarm@lists.cs.columbia.edu \
    --cc=kvmarm@lists.linux.dev \
    --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