All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/4] Prevent inlining for asm blocks with labels
@ 2021-08-25 22:26 Bill Wendling
  2021-08-25 22:26 ` [PATCH 1/4] x86: realmode: mark exec_in_big_real_mode as noinline Bill Wendling
                   ` (5 more replies)
  0 siblings, 6 replies; 18+ messages in thread
From: Bill Wendling @ 2021-08-25 22:26 UTC (permalink / raw)
  To: kvm, Paolo Bonzini, Roman Bolshakov, David Matlack; +Cc: Bill Wendling

Clang may decide to inline some functions that have inline asm with labels.
Doing this duplicates the labels, causing the assembler to be complain. These
patches add the "noinline" attribute to the functions to prevent this.

Bill Wendling (4):
  x86: realmode: mark exec_in_big_real_mode as noinline
  x86: svm: mark test_run as noinline
  x86: umip: mark do_ring3 as noinline
  x86: vmx: mark some test_* functions as noinline

 x86/realmode.c | 2 +-
 x86/svm.c      | 2 +-
 x86/umip.c     | 2 +-
 x86/vmx.c      | 6 +++---
 4 files changed, 6 insertions(+), 6 deletions(-)

-- 
2.33.0.rc2.250.ged5fa647cd-goog


^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH 1/4] x86: realmode: mark exec_in_big_real_mode as noinline
  2021-08-25 22:26 [PATCH 0/4] Prevent inlining for asm blocks with labels Bill Wendling
@ 2021-08-25 22:26 ` Bill Wendling
  2021-08-25 22:26 ` [PATCH 2/4] x86: svm: mark test_run " Bill Wendling
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 18+ messages in thread
From: Bill Wendling @ 2021-08-25 22:26 UTC (permalink / raw)
  To: kvm, Paolo Bonzini, Roman Bolshakov, David Matlack; +Cc: Bill Wendling

exec_in_big_real_mode() uses inline asm that has labels. Clang decides
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..56bd238 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 void __attribute__((noinline)) exec_in_big_real_mode(struct insn_desc *insn)
 {
 	unsigned long tmp;
 	static struct regs save;
-- 
2.33.0.rc2.250.ged5fa647cd-goog


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH 2/4] x86: svm: mark test_run as noinline
  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 ` Bill Wendling
  2021-08-25 22:26 ` [PATCH 3/4] x86: umip: mark do_ring3 " Bill Wendling
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 18+ messages in thread
From: Bill Wendling @ 2021-08-25 22:26 UTC (permalink / raw)
  To: kvm, Paolo Bonzini, Roman Bolshakov, David Matlack; +Cc: Bill Wendling

test_run() uses inline asm that has labels. Clang decides 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/svm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/x86/svm.c b/x86/svm.c
index beb40b7..68fd29b 100644
--- a/x86/svm.c
+++ b/x86/svm.c
@@ -256,7 +256,7 @@ int svm_vmrun(void)
 
 extern u8 vmrun_rip;
 
-static void test_run(struct svm_test *test)
+static void __attribute__((noinline)) test_run(struct svm_test *test)
 {
 	u64 vmcb_phys = virt_to_phys(vmcb);
 
-- 
2.33.0.rc2.250.ged5fa647cd-goog


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH 3/4] x86: umip: mark do_ring3 as noinline
  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 ` Bill Wendling
  2021-08-25 22:26 ` [PATCH 4/4] x86: vmx: mark some test_* functions " Bill Wendling
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 18+ messages in thread
From: Bill Wendling @ 2021-08-25 22:26 UTC (permalink / raw)
  To: kvm, Paolo Bonzini, Roman Bolshakov, David Matlack; +Cc: Bill Wendling

do_ring3() uses inline asm that has labels. Clang decides 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/umip.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/x86/umip.c b/x86/umip.c
index c5700b3..5ae6f44 100644
--- a/x86/umip.c
+++ b/x86/umip.c
@@ -114,7 +114,7 @@ static void test_umip_gp(const char *msg)
 
 /* The ugly mode switching code */
 
-static int do_ring3(void (*fn)(const char *), const char *arg)
+static int __attribute__((noinline)) do_ring3(void (*fn)(const char *), const char *arg)
 {
     static unsigned char user_stack[4096];
     int ret;
-- 
2.33.0.rc2.250.ged5fa647cd-goog


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH 4/4] x86: vmx: mark some test_* functions as noinline
  2021-08-25 22:26 [PATCH 0/4] Prevent inlining for asm blocks with labels Bill Wendling
                   ` (2 preceding siblings ...)
  2021-08-25 22:26 ` [PATCH 3/4] x86: umip: mark do_ring3 " Bill Wendling
@ 2021-08-25 22:26 ` Bill Wendling
  2021-08-26 18:21 ` [PATCH 0/4] Prevent inlining for asm blocks with labels Sean Christopherson
  2021-09-08 20:45 ` [kvm-unit-tests PATCH v2 0/5] " Bill Wendling
  5 siblings, 0 replies; 18+ messages in thread
From: Bill Wendling @ 2021-08-25 22:26 UTC (permalink / raw)
  To: kvm, Paolo Bonzini, Roman Bolshakov, David Matlack; +Cc: Bill Wendling

Some test_* functions use inline asm that has labels. Clang decides that
it can inline these functions, which causes the assembler to complain
about duplicate symbols. Mark the functions as "noinline" to prevent
this.

Signed-off-by: Bill Wendling <morbo@google.com>
---
 x86/vmx.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/x86/vmx.c b/x86/vmx.c
index f0b853a..a264136 100644
--- a/x86/vmx.c
+++ b/x86/vmx.c
@@ -426,7 +426,7 @@ static void prep_flags_test_env(void **vpage, struct vmcs **vmcs, handler *old)
 	*old = handle_exception(PF_VECTOR, &pf_handler);
 }
 
-static void test_read_sentinel(void)
+static void __attribute__((noinline)) test_read_sentinel(void)
 {
 	void *vpage;
 	struct vmcs *vmcs;
@@ -474,7 +474,7 @@ static void test_vmread_flags_touch(void)
 	test_read_sentinel();
 }
 
-static void test_write_sentinel(void)
+static void __attribute__((noinline)) test_write_sentinel(void)
 {
 	void *vpage;
 	struct vmcs *vmcs;
@@ -1786,7 +1786,7 @@ static int exit_handler(union exit_reason exit_reason)
  * Tries to enter the guest, populates @result with VM-Fail, VM-Exit, entered,
  * etc...
  */
-static void vmx_enter_guest(struct vmentry_result *result)
+static void __attribute__((noinline)) vmx_enter_guest(struct vmentry_result *result)
 {
 	memset(result, 0, sizeof(*result));
 
-- 
2.33.0.rc2.250.ged5fa647cd-goog


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* Re: [PATCH 0/4] Prevent inlining for asm blocks with labels
  2021-08-25 22:26 [PATCH 0/4] Prevent inlining for asm blocks with labels Bill Wendling
                   ` (3 preceding siblings ...)
  2021-08-25 22:26 ` [PATCH 4/4] x86: vmx: mark some test_* functions " Bill Wendling
@ 2021-08-26 18:21 ` Sean Christopherson
  2021-08-26 21:05   ` Bill Wendling
  2021-09-08 20:45 ` [kvm-unit-tests PATCH v2 0/5] " Bill Wendling
  5 siblings, 1 reply; 18+ messages in thread
From: Sean Christopherson @ 2021-08-26 18:21 UTC (permalink / raw)
  To: Bill Wendling; +Cc: kvm, Paolo Bonzini, Roman Bolshakov, David Matlack

On Wed, Aug 25, 2021, Bill Wendling wrote:
> Clang may decide to inline some functions that have inline asm with labels.

For all changlogs, it's probably worth clarifying that they have _global_ labels,
e.g. local labels within an asm block are perfectly ok for inlining, as are local
labels in the function (but outside of the block) used by asm goto.

And maybe add a "#define noinline ..." to match the kernel and convert the two
existing uses in pmu_lbr.c as a prep patch?

> Doing this duplicates the labels, causing the assembler to be complain. These
> patches add the "noinline" attribute to the functions to prevent this.
> 
> Bill Wendling (4):
>   x86: realmode: mark exec_in_big_real_mode as noinline
>   x86: svm: mark test_run as noinline
>   x86: umip: mark do_ring3 as noinline
>   x86: vmx: mark some test_* functions as noinline
> 
>  x86/realmode.c | 2 +-
>  x86/svm.c      | 2 +-
>  x86/umip.c     | 2 +-
>  x86/vmx.c      | 6 +++---
>  4 files changed, 6 insertions(+), 6 deletions(-)
> 
> -- 
> 2.33.0.rc2.250.ged5fa647cd-goog
> 

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 0/4] Prevent inlining for asm blocks with labels
  2021-08-26 18:21 ` [PATCH 0/4] Prevent inlining for asm blocks with labels Sean Christopherson
@ 2021-08-26 21:05   ` Bill Wendling
  0 siblings, 0 replies; 18+ messages in thread
From: Bill Wendling @ 2021-08-26 21:05 UTC (permalink / raw)
  To: Sean Christopherson
  Cc: kvm list, Paolo Bonzini, Roman Bolshakov, David Matlack

On Thu, Aug 26, 2021 at 11:21 AM Sean Christopherson <seanjc@google.com> wrote:
>
> On Wed, Aug 25, 2021, Bill Wendling wrote:
> > Clang may decide to inline some functions that have inline asm with labels.
>
> For all changlogs, it's probably worth clarifying that they have _global_ labels,
> e.g. local labels within an asm block are perfectly ok for inlining, as are local
> labels in the function (but outside of the block) used by asm goto.
>
> And maybe add a "#define noinline ..." to match the kernel and convert the two
> existing uses in pmu_lbr.c as a prep patch?
>
I sent out a patch for this. Thanks!

As for the changelogs, I'll send an updated patch series once the
noinline patch is resolved.

-bw

> > Doing this duplicates the labels, causing the assembler to be complain. These
> > patches add the "noinline" attribute to the functions to prevent this.
> >
> > Bill Wendling (4):
> >   x86: realmode: mark exec_in_big_real_mode as noinline
> >   x86: svm: mark test_run as noinline
> >   x86: umip: mark do_ring3 as noinline
> >   x86: vmx: mark some test_* functions as noinline
> >
> >  x86/realmode.c | 2 +-
> >  x86/svm.c      | 2 +-
> >  x86/umip.c     | 2 +-
> >  x86/vmx.c      | 6 +++---
> >  4 files changed, 6 insertions(+), 6 deletions(-)
> >
> > --
> > 2.33.0.rc2.250.ged5fa647cd-goog
> >

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [kvm-unit-tests PATCH v2 0/5] Prevent inlining for asm blocks with labels
  2021-08-25 22:26 [PATCH 0/4] Prevent inlining for asm blocks with labels Bill Wendling
                   ` (4 preceding siblings ...)
  2021-08-26 18:21 ` [PATCH 0/4] Prevent inlining for asm blocks with labels Sean Christopherson
@ 2021-09-08 20:45 ` Bill Wendling
  2021-09-08 20:45   ` [kvm-unit-tests PATCH v2 1/5] libcflag: define the "noinline" macro Bill Wendling
                     ` (4 more replies)
  5 siblings, 5 replies; 18+ messages in thread
From: Bill Wendling @ 2021-09-08 20:45 UTC (permalink / raw)
  To: kvm, Paolo Bonzini, Roman Bolshakov, David Matlack,
	Sean Christopherson, Jim Mattson
  Cc: Bill Wendling

Clang may decide to inline some functions that have inline asm with labels.
Doing this duplicates the labels, causing the assembler to be complain. These
patches add the "noinline" attribute to the functions to prevent this.

v2: Combine "libcflat.h" change and use the new "noinline" macro.

Bill Wendling (5):
  libcflag: define the "noinline" macro
  x86: realmode: mark exec_in_big_real_mode as noinline
  x86: svm: mark test_run as noinline
  x86: umip: mark do_ring3 as noinline
  x86: vmx: mark some test_* functions as noinline

 lib/libcflat.h | 1 +
 x86/pmu_lbr.c  | 4 ++--
 x86/realmode.c | 2 +-
 x86/svm.c      | 2 +-
 x86/umip.c     | 2 +-
 x86/vmx.c      | 6 +++---
 6 files changed, 9 insertions(+), 8 deletions(-)

-- 
2.33.0.309.g3052b89438-goog


^ permalink raw reply	[flat|nested] 18+ messages in thread

* [kvm-unit-tests PATCH v2 1/5] libcflag: define the "noinline" macro
  2021-09-08 20:45 ` [kvm-unit-tests PATCH v2 0/5] " Bill Wendling
@ 2021-09-08 20:45   ` 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
                     ` (3 subsequent siblings)
  4 siblings, 1 reply; 18+ messages in thread
From: Bill Wendling @ 2021-09-08 20:45 UTC (permalink / raw)
  To: kvm, Paolo Bonzini, Roman Bolshakov, David Matlack,
	Sean Christopherson, Jim Mattson
  Cc: Bill Wendling

Define "noline" macro to reduce the amount of typing for functions using
the "noinline" attribute.

Signed-off-by: Bill Wendling <morbo@google.com>
---
v2: Combine separate change with this series.
---
 lib/libcflat.h | 1 +
 x86/pmu_lbr.c  | 4 ++--
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/lib/libcflat.h b/lib/libcflat.h
index 97db9e3..a652c76 100644
--- a/lib/libcflat.h
+++ b/lib/libcflat.h
@@ -29,6 +29,7 @@
 #include <stdbool.h>
 
 #define __unused __attribute__((__unused__))
+#define noinline __attribute__((noinline))
 
 #define xstr(s...) xxstr(s)
 #define xxstr(s...) #s
diff --git a/x86/pmu_lbr.c b/x86/pmu_lbr.c
index 3bd9e9f..5ff805a 100644
--- a/x86/pmu_lbr.c
+++ b/x86/pmu_lbr.c
@@ -16,14 +16,14 @@
 
 volatile int count;
 
-static __attribute__((noinline)) int compute_flag(int i)
+static noinline int compute_flag(int i)
 {
 	if (i % 10 < 4)
 		return i + 1;
 	return 0;
 }
 
-static __attribute__((noinline)) int lbr_test(void)
+static noinline int lbr_test(void)
 {
 	int i;
 	int flag;
-- 
2.33.0.309.g3052b89438-goog


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [kvm-unit-tests PATCH v2 2/5] x86: realmode: mark exec_in_big_real_mode as noinline
  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 20:45   ` Bill Wendling
  2021-09-08 21:49     ` Sean Christopherson
  2021-09-08 20:45   ` [kvm-unit-tests PATCH v2 3/5] x86: svm: mark test_run " Bill Wendling
                     ` (2 subsequent siblings)
  4 siblings, 1 reply; 18+ messages in thread
From: Bill Wendling @ 2021-09-08 20:45 UTC (permalink / raw)
  To: kvm, Paolo Bonzini, Roman Bolshakov, David Matlack,
	Sean Christopherson, Jim Mattson
  Cc: Bill Wendling

exec_in_big_real_mode() uses inline asm that has labels. Clang decides
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)
 {
 	unsigned long tmp;
 	static struct regs save;
-- 
2.33.0.309.g3052b89438-goog


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [kvm-unit-tests PATCH v2 3/5] x86: svm: mark test_run as noinline
  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 20:45   ` [kvm-unit-tests PATCH v2 2/5] x86: realmode: mark exec_in_big_real_mode as noinline Bill Wendling
@ 2021-09-08 20:45   ` 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
  4 siblings, 0 replies; 18+ messages in thread
From: Bill Wendling @ 2021-09-08 20:45 UTC (permalink / raw)
  To: kvm, Paolo Bonzini, Roman Bolshakov, David Matlack,
	Sean Christopherson, Jim Mattson
  Cc: Bill Wendling

test_run uses inline asm that has labels. Clang decides 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>
---
v2: Use "noinline" instead of "__attribute__((noinline)).
---
 x86/svm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/x86/svm.c b/x86/svm.c
index beb40b7..3f94b2a 100644
--- a/x86/svm.c
+++ b/x86/svm.c
@@ -256,7 +256,7 @@ int svm_vmrun(void)
 
 extern u8 vmrun_rip;
 
-static void test_run(struct svm_test *test)
+static noinline void test_run(struct svm_test *test)
 {
 	u64 vmcb_phys = virt_to_phys(vmcb);
 
-- 
2.33.0.309.g3052b89438-goog


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [kvm-unit-tests PATCH v2 4/5] x86: umip: mark do_ring3 as noinline
  2021-09-08 20:45 ` [kvm-unit-tests PATCH v2 0/5] " Bill Wendling
                     ` (2 preceding siblings ...)
  2021-09-08 20:45   ` [kvm-unit-tests PATCH v2 3/5] x86: svm: mark test_run " Bill Wendling
@ 2021-09-08 20:45   ` Bill Wendling
  2021-09-08 20:45   ` [kvm-unit-tests PATCH v2 5/5] x86: vmx: mark some test_* functions " Bill Wendling
  4 siblings, 0 replies; 18+ messages in thread
From: Bill Wendling @ 2021-09-08 20:45 UTC (permalink / raw)
  To: kvm, Paolo Bonzini, Roman Bolshakov, David Matlack,
	Sean Christopherson, Jim Mattson
  Cc: Bill Wendling

do_ring3 uses inline asm that has labels. Clang decides 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>
---
v2: Use "noinline" instead of "__attribute__((noinline)).
---
 x86/umip.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/x86/umip.c b/x86/umip.c
index c5700b3..0fc1f65 100644
--- a/x86/umip.c
+++ b/x86/umip.c
@@ -114,7 +114,7 @@ static void test_umip_gp(const char *msg)
 
 /* The ugly mode switching code */
 
-static int do_ring3(void (*fn)(const char *), const char *arg)
+static noinline int do_ring3(void (*fn)(const char *), const char *arg)
 {
     static unsigned char user_stack[4096];
     int ret;
-- 
2.33.0.309.g3052b89438-goog


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [kvm-unit-tests PATCH v2 5/5] x86: vmx: mark some test_* functions as noinline
  2021-09-08 20:45 ` [kvm-unit-tests PATCH v2 0/5] " Bill Wendling
                     ` (3 preceding siblings ...)
  2021-09-08 20:45   ` [kvm-unit-tests PATCH v2 4/5] x86: umip: mark do_ring3 " Bill Wendling
@ 2021-09-08 20:45   ` Bill Wendling
  4 siblings, 0 replies; 18+ messages in thread
From: Bill Wendling @ 2021-09-08 20:45 UTC (permalink / raw)
  To: kvm, Paolo Bonzini, Roman Bolshakov, David Matlack,
	Sean Christopherson, Jim Mattson
  Cc: Bill Wendling

Some test_* functions use inline asm that has labels. Clang decides that
it can inline these functions, which causes the assembler to complain
about duplicate symbols. Mark the functions as "noinline" to prevent
this.

Signed-off-by: Bill Wendling <morbo@google.com>
---
v2: Use "noinline" instead of "__attribute__((noinline)).
---
 x86/vmx.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/x86/vmx.c b/x86/vmx.c
index f0b853a..2a32aa2 100644
--- a/x86/vmx.c
+++ b/x86/vmx.c
@@ -426,7 +426,7 @@ static void prep_flags_test_env(void **vpage, struct vmcs **vmcs, handler *old)
 	*old = handle_exception(PF_VECTOR, &pf_handler);
 }
 
-static void test_read_sentinel(void)
+static noinline void test_read_sentinel(void)
 {
 	void *vpage;
 	struct vmcs *vmcs;
@@ -474,7 +474,7 @@ static void test_vmread_flags_touch(void)
 	test_read_sentinel();
 }
 
-static void test_write_sentinel(void)
+static noinline void test_write_sentinel(void)
 {
 	void *vpage;
 	struct vmcs *vmcs;
@@ -1786,7 +1786,7 @@ static int exit_handler(union exit_reason exit_reason)
  * Tries to enter the guest, populates @result with VM-Fail, VM-Exit, entered,
  * etc...
  */
-static void vmx_enter_guest(struct vmentry_result *result)
+static noinline void vmx_enter_guest(struct vmentry_result *result)
 {
 	memset(result, 0, sizeof(*result));
 
-- 
2.33.0.309.g3052b89438-goog


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* Re: [kvm-unit-tests PATCH v2 1/5] libcflag: define the "noinline" macro
  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
  0 siblings, 0 replies; 18+ messages in thread
From: Sean Christopherson @ 2021-09-08 21:44 UTC (permalink / raw)
  To: Bill Wendling
  Cc: kvm, Paolo Bonzini, Roman Bolshakov, David Matlack, Jim Mattson

On Wed, Sep 08, 2021, Bill Wendling wrote:
> Define "noline" macro to reduce the amount of typing for functions using
> the "noinline" attribute.
> 
> Signed-off-by: Bill Wendling <morbo@google.com>
> ---

Reviewed-by: Sean Christopherson <seanjc@google.com>

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [kvm-unit-tests PATCH v2 2/5] x86: realmode: mark exec_in_big_real_mode as noinline
  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
  0 siblings, 1 reply; 18+ messages in thread
From: Sean Christopherson @ 2021-09-08 21:49 UTC (permalink / raw)
  To: Bill Wendling
  Cc: kvm, Paolo Bonzini, Roman Bolshakov, David Matlack, Jim Mattson

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 :-)

>  {
>  	unsigned long tmp;
>  	static struct regs save;
> -- 
> 2.33.0.309.g3052b89438-goog
> 

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [kvm-unit-tests PATCH v2 2/5] x86: realmode: mark exec_in_big_real_mode as noinline
  2021-09-08 21:49     ` Sean Christopherson
@ 2021-09-08 22:07       ` Bill Wendling
  2021-09-08 22:51         ` Sean Christopherson
  0 siblings, 1 reply; 18+ messages in thread
From: Bill Wendling @ 2021-09-08 22:07 UTC (permalink / raw)
  To: Sean Christopherson
  Cc: kvm list, Paolo Bonzini, Roman Bolshakov, David Matlack, Jim Mattson

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.

-bw

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [kvm-unit-tests PATCH v2 2/5] x86: realmode: mark exec_in_big_real_mode as noinline
  2021-09-08 22:07       ` Bill Wendling
@ 2021-09-08 22:51         ` Sean Christopherson
  2021-09-09 17:19           ` Bill Wendling
  0 siblings, 1 reply; 18+ messages in thread
From: Sean Christopherson @ 2021-09-08 22:51 UTC (permalink / raw)
  To: Bill Wendling
  Cc: kvm list, Paolo Bonzini, Roman Bolshakov, David Matlack, Jim Mattson

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))


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* Re: [kvm-unit-tests PATCH v2 2/5] x86: realmode: mark exec_in_big_real_mode as noinline
  2021-09-08 22:51         ` Sean Christopherson
@ 2021-09-09 17:19           ` Bill Wendling
  0 siblings, 0 replies; 18+ messages in thread
From: Bill Wendling @ 2021-09-09 17:19 UTC (permalink / raw)
  To: Sean Christopherson
  Cc: kvm list, Paolo Bonzini, Roman Bolshakov, David Matlack, Jim Mattson

On Wed, Sep 8, 2021 at 3:51 PM Sean Christopherson <seanjc@google.com> wrote:
>
> 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.
>
Sounds good to me. Please go ahead and submit this for inclusion and I
can revamp my stuff.

-bw

> 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))
>

^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2021-09-09 17:19 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
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

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.