From: Sean Christopherson <seanjc@google.com>
To: Bill Wendling <morbo@google.com>
Cc: kvm list <kvm@vger.kernel.org>,
Paolo Bonzini <pbonzini@redhat.com>,
Roman Bolshakov <r.bolshakov@yadro.com>,
David Matlack <dmatlack@google.com>,
Jim Mattson <jmattson@google.com>
Subject: Re: [kvm-unit-tests PATCH v2 2/5] x86: realmode: mark exec_in_big_real_mode as noinline
Date: Wed, 8 Sep 2021 22:51:22 +0000 [thread overview]
Message-ID: <YTk+amslyQCsM3+M@google.com> (raw)
In-Reply-To: <CAGG=3QX1L1dsFHhQhiEHPRycm8ot2Abw1j=wR60ezVoKgU0KmQ@mail.gmail.com>
On Wed, Sep 08, 2021, Bill Wendling wrote:
> On Wed, Sep 8, 2021 at 2:49 PM Sean Christopherson <seanjc@google.com> wrote:
> >
> > On Wed, Sep 08, 2021, Bill Wendling wrote:
> > > exec_in_big_real_mode() uses inline asm that has labels. Clang decides
> >
> > _global_ labels. Inlining functions with local labels, including asm goto labels,
> > is not problematic, the issue is specific to labels that must be unique for a
> > given compilation unit.
> >
> > > that it can inline this function, which causes the assembler to complain
> > > about duplicate symbols. Mark the function as "noinline" to prevent
> > > this.
> > >
> > > Signed-off-by: Bill Wendling <morbo@google.com>
> > > ---
> > > x86/realmode.c | 2 +-
> > > 1 file changed, 1 insertion(+), 1 deletion(-)
> > >
> > > diff --git a/x86/realmode.c b/x86/realmode.c
> > > index b4fa603..07a477f 100644
> > > --- a/x86/realmode.c
> > > +++ b/x86/realmode.c
> > > @@ -178,7 +178,7 @@ static inline void init_inregs(struct regs *regs)
> > > inregs.esp = (unsigned long)&tmp_stack.top;
> > > }
> > >
> > > -static void exec_in_big_real_mode(struct insn_desc *insn)
> > > +static __attribute__((noinline)) void exec_in_big_real_mode(struct insn_desc *insn)
> >
> > Forgot to use the new define in this patch :-)
> >
> This was intentional. realmode.c doesn't #include any header files,
> and adding '#include "libflat.h" causes a lot of warnings and errors.
> We could do that, but I feel it's beyond the scope of this series of
> patches.
Ah, right, realmode is compiled for real mode and can't use any of the libcflat
stuff.
A better option would be to put the #define in linux/compiler.h and include that
in libcflat.h and directly in realmode.h. It only requires a small prep patch to
avoid a duplicate barrier() definition.
From 6e6971ef22c335732a9597409a45fee8a3be6fb7 Mon Sep 17 00:00:00 2001
From: Sean Christopherson <seanjc@google.com>
Date: Wed, 8 Sep 2021 15:41:12 -0700
Subject: [PATCH] lib: Drop x86/processor.h's barrier() in favor of compiler.h
version
Drop x86's duplicate version of barrier() in favor of the generic #define
provided by linux/compiler.h. Include compiler.h in the all-encompassing
libcflat.h to pick up barrier() and other future goodies, e.g. new
attributes defines.
Signed-off-by: Sean Christopherson <seanjc@google.com>
---
lib/libcflat.h | 1 +
lib/x86/processor.h | 5 -----
2 files changed, 1 insertion(+), 5 deletions(-)
diff --git a/lib/libcflat.h b/lib/libcflat.h
index 97db9e3..e619de1 100644
--- a/lib/libcflat.h
+++ b/lib/libcflat.h
@@ -22,6 +22,7 @@
#ifndef __ASSEMBLY__
+#include <linux/compiler.h>
#include <stdarg.h>
#include <stddef.h>
#include <stdint.h>
diff --git a/lib/x86/processor.h b/lib/x86/processor.h
index f380321..eaf24d4 100644
--- a/lib/x86/processor.h
+++ b/lib/x86/processor.h
@@ -216,11 +216,6 @@ struct descriptor_table_ptr {
ulong base;
} __attribute__((packed));
-static inline void barrier(void)
-{
- asm volatile ("" : : : "memory");
-}
-
static inline void clac(void)
{
asm volatile (".byte 0x0f, 0x01, 0xca" : : : "memory");
--
and then your patch 1 can become:
diff --git a/lib/linux/compiler.h b/lib/linux/compiler.h
index 5d9552a..5937b7b 100644
--- a/lib/linux/compiler.h
+++ b/lib/linux/compiler.h
@@ -46,6 +46,7 @@
#define barrier() asm volatile("" : : : "memory")
#define __always_inline inline __attribute__((always_inline))
+#define noinline __attribute__((noinline))
next prev parent reply other threads:[~2021-09-08 22:51 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-25 22:26 [PATCH 0/4] Prevent inlining for asm blocks with labels Bill Wendling
2021-08-25 22:26 ` [PATCH 1/4] x86: realmode: mark exec_in_big_real_mode as noinline Bill Wendling
2021-08-25 22:26 ` [PATCH 2/4] x86: svm: mark test_run " Bill Wendling
2021-08-25 22:26 ` [PATCH 3/4] x86: umip: mark do_ring3 " Bill Wendling
2021-08-25 22:26 ` [PATCH 4/4] x86: vmx: mark some test_* functions " Bill Wendling
2021-08-26 18:21 ` [PATCH 0/4] Prevent inlining for asm blocks with labels Sean Christopherson
2021-08-26 21:05 ` Bill Wendling
2021-09-08 20:45 ` [kvm-unit-tests PATCH v2 0/5] " Bill Wendling
2021-09-08 20:45 ` [kvm-unit-tests PATCH v2 1/5] libcflag: define the "noinline" macro Bill Wendling
2021-09-08 21:44 ` Sean Christopherson
2021-09-08 20:45 ` [kvm-unit-tests PATCH v2 2/5] x86: realmode: mark exec_in_big_real_mode as noinline Bill Wendling
2021-09-08 21:49 ` Sean Christopherson
2021-09-08 22:07 ` Bill Wendling
2021-09-08 22:51 ` Sean Christopherson [this message]
2021-09-09 17:19 ` Bill Wendling
2021-09-08 20:45 ` [kvm-unit-tests PATCH v2 3/5] x86: svm: mark test_run " Bill Wendling
2021-09-08 20:45 ` [kvm-unit-tests PATCH v2 4/5] x86: umip: mark do_ring3 " Bill Wendling
2021-09-08 20:45 ` [kvm-unit-tests PATCH v2 5/5] x86: vmx: mark some test_* functions " Bill Wendling
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=YTk+amslyQCsM3+M@google.com \
--to=seanjc@google.com \
--cc=dmatlack@google.com \
--cc=jmattson@google.com \
--cc=kvm@vger.kernel.org \
--cc=morbo@google.com \
--cc=pbonzini@redhat.com \
--cc=r.bolshakov@yadro.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.