public inbox for llvm@lists.linux.dev
 help / color / mirror / Atom feed
From: Adam Dunlap <acdunlap@google.com>
To: Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
	 Dave Hansen <dave.hansen@linux.intel.com>,
	x86@kernel.org,  "H. Peter Anvin" <hpa@zytor.com>,
	Nathan Chancellor <nathan@kernel.org>,
	 Nick Desaulniers <ndesaulniers@google.com>,
	Tom Rix <trix@redhat.com>,
	 "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>,
	Sean Christopherson <seanjc@google.com>,
	 Kuppuswamy Sathyanarayanan
	<sathyanarayanan.kuppuswamy@linux.intel.com>,
	 Andi Kleen <ak@linux.intel.com>,
	Adam Dunlap <acdunlap@google.com>,
	 Ben Dooks <ben-linux@fluff.org>,
	linux-kernel@vger.kernel.org, llvm@lists.linux.dev
Cc: Jacob Xu <jacobhxu@google.com>, Alper Gun <alpergun@google.com>,
	 Marc Orr <marcorr@google.com>
Subject: [PATCH v2] x86/asm: Force native_apic_mem_read to use mov
Date: Fri, 12 Aug 2022 11:35:01 -0700	[thread overview]
Message-ID: <20220812183501.3555820-1-acdunlap@google.com> (raw)
In-Reply-To: <CAMBK9=b1ALFYOB1iTUW7BHgq=sg=x9t8sTnC5YgQ5bePF+UvNg@mail.gmail.com>

Previously, when compiled with clang, native_apic_mem_read gets inlined
into __xapic_wait_icr_idle and optimized to a testl instruction. When
run in a VM with SEV-ES enabled, it attempts to emulate this
instruction, but the emulator does not support it. Instead, use inline
assembly to force native_apic_mem_read to use the mov instruction which
is supported by the emulator.

Signed-off-by: Adam Dunlap <acdunlap@google.com>
---
V1 -> V2: Replaced asm with readl function which does the same thing

 arch/x86/include/asm/apic.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/x86/include/asm/apic.h b/arch/x86/include/asm/apic.h
index 3415321c8240..b4c9034aa073 100644
--- a/arch/x86/include/asm/apic.h
+++ b/arch/x86/include/asm/apic.h
@@ -12,6 +12,7 @@
 #include <asm/mpspec.h>
 #include <asm/msr.h>
 #include <asm/hardirq.h>
+#include <asm/io.h>
 
 #define ARCH_APICTIMER_STOPS_ON_C3	1
 
@@ -109,7 +110,7 @@ static inline void native_apic_mem_write(u32 reg, u32 v)
 
 static inline u32 native_apic_mem_read(u32 reg)
 {
-	return *((volatile u32 *)(APIC_BASE + reg));
+	return readl((void __iomem *)(APIC_BASE + reg));
 }
 
 extern void native_apic_wait_icr_idle(void);
-- 
2.37.1.559.g78731f0fdb-goog


  reply	other threads:[~2022-08-12 18:35 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-11 18:00 [PATCH] x86/asm: Force native_apic_mem_read to use mov Adam Dunlap
2022-08-11 19:27 ` Sean Christopherson
2022-08-11 19:57   ` H. Peter Anvin
2022-08-11 20:03     ` Sean Christopherson
2022-08-12  4:40       ` H. Peter Anvin
2022-08-12 18:32         ` Adam Dunlap
2022-08-12 18:35           ` Adam Dunlap [this message]
2022-09-08 17:04             ` [PATCH v2 RESEND] " Adam Dunlap
2022-09-14 11:13               ` Peter Gonda
2022-09-14 11:59                 ` Marc Orr
2022-09-14 11:59                   ` Marc Orr
2022-09-15  7:51                     ` Tom Lendacky
2022-09-14 12:03                 ` Dave Hansen
2022-09-14 16:22                   ` Sean Christopherson
2022-09-15  8:09                     ` Peter Gonda
     [not found]                       ` <CAMBK9=YB=8EQymDUda300qPFAL1=7dzC61c0pshrWEC5ibrUfQ@mail.gmail.com>
2022-10-03 23:07                         ` Adam Dunlap
     [not found]                         ` <B7175642-351D-44A0-B7AD-E69C6B64FC18@zytor.com>
2022-10-05 13:28                           ` Tom Lendacky
2022-11-17 21:23                             ` Marc Orr
2023-11-17 18:14                               ` Sidharth Telang
2023-11-17 19:23                                 ` Dave Hansen
2022-08-11 19:53 ` [PATCH] " H. Peter Anvin

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=20220812183501.3555820-1-acdunlap@google.com \
    --to=acdunlap@google.com \
    --cc=ak@linux.intel.com \
    --cc=alpergun@google.com \
    --cc=ben-linux@fluff.org \
    --cc=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=hpa@zytor.com \
    --cc=jacobhxu@google.com \
    --cc=kirill.shutemov@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=llvm@lists.linux.dev \
    --cc=marcorr@google.com \
    --cc=mingo@redhat.com \
    --cc=nathan@kernel.org \
    --cc=ndesaulniers@google.com \
    --cc=sathyanarayanan.kuppuswamy@linux.intel.com \
    --cc=seanjc@google.com \
    --cc=tglx@linutronix.de \
    --cc=trix@redhat.com \
    --cc=x86@kernel.org \
    /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