diff mbox series

[kvm-unit-tests,7/7] x86: VMX: the "noclone" attribute is gcc-specific

Message ID 20200226094433.210968-15-morbo@google.com (mailing list archive)
State New, archived
Headers show
Series None | expand

Commit Message

Bill Wendling Feb. 26, 2020, 9:44 a.m. UTC
Don't use the "noclone" attribute for clang as it's not supported.

Signed-off-by: Bill Wendling <morbo@google.com>
---
 x86/vmx_tests.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Paolo Bonzini Feb. 28, 2020, 11:16 a.m. UTC | #1
On 26/02/20 10:44, Bill Wendling wrote:
> Don't use the "noclone" attribute for clang as it's not supported.
> 
> Signed-off-by: Bill Wendling <morbo@google.com>
> ---
>  x86/vmx_tests.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/x86/vmx_tests.c b/x86/vmx_tests.c
> index ad8c002..ec88016 100644
> --- a/x86/vmx_tests.c
> +++ b/x86/vmx_tests.c
> @@ -4976,7 +4976,10 @@ extern unsigned char test_mtf1;
>  extern unsigned char test_mtf2;
>  extern unsigned char test_mtf3;
>  
> -__attribute__((noclone)) static void test_mtf_guest(void)
> +#ifndef __clang__
> +__attribute__((noclone))
> +#endif
> +static void test_mtf_guest(void)
>  {
>  	asm ("vmcall;\n\t"
>  	     "out %al, $0x80;\n\t"
> 

It's not needed at all, let's drop it.

Paolo
Oliver Upton Feb. 28, 2020, 6:19 p.m. UTC | #2
On Fri, Feb 28, 2020 at 3:16 AM Paolo Bonzini <pbonzini@redhat.com> wrote:
>
> On 26/02/20 10:44, Bill Wendling wrote:
> > Don't use the "noclone" attribute for clang as it's not supported.
> >
> > Signed-off-by: Bill Wendling <morbo@google.com>
> > ---
> >  x86/vmx_tests.c | 5 ++++-
> >  1 file changed, 4 insertions(+), 1 deletion(-)
> >
> > diff --git a/x86/vmx_tests.c b/x86/vmx_tests.c
> > index ad8c002..ec88016 100644
> > --- a/x86/vmx_tests.c
> > +++ b/x86/vmx_tests.c
> > @@ -4976,7 +4976,10 @@ extern unsigned char test_mtf1;
> >  extern unsigned char test_mtf2;
> >  extern unsigned char test_mtf3;
> >
> > -__attribute__((noclone)) static void test_mtf_guest(void)
> > +#ifndef __clang__
> > +__attribute__((noclone))
> > +#endif
> > +static void test_mtf_guest(void)
> >  {
> >       asm ("vmcall;\n\t"
> >            "out %al, $0x80;\n\t"
> >
>
> It's not needed at all, let's drop it.
>
> Paolo
>

If we wanted to be absolutely certain that the extern labels used for
assertions about the guest RIP are correct, we may still want it.
Alternatively, I could rewrite the test such that the guest will
report the instruction boundary where it anticipates MTF whenever it
makes the vmcall to request the host turns on MTF.

--
Thanks,
Oliver
Paolo Bonzini Feb. 28, 2020, 6:24 p.m. UTC | #3
On 28/02/20 19:19, Oliver Upton wrote:
> If we wanted to be absolutely certain that the extern labels used for
> assertions about the guest RIP are correct, we may still want it.
> Alternatively, I could rewrite the test such that the guest will
> report the instruction boundary where it anticipates MTF whenever it
> makes the vmcall to request the host turns on MTF.

Right, but it's used only once, and as a function pointer at that, so
there's only so much that the compiler can do to "optimize".  Let's
think about how to fix it if it breaks.

Paolo
Oliver Upton Feb. 28, 2020, 6:40 p.m. UTC | #4
On Fri, Feb 28, 2020 at 10:24 AM Paolo Bonzini <pbonzini@redhat.com> wrote:
>
> On 28/02/20 19:19, Oliver Upton wrote:
> > If we wanted to be absolutely certain that the extern labels used for
> > assertions about the guest RIP are correct, we may still want it.
> > Alternatively, I could rewrite the test such that the guest will
> > report the instruction boundary where it anticipates MTF whenever it
> > makes the vmcall to request the host turns on MTF.
>
> Right, but it's used only once, and as a function pointer at that, so
> there's only so much that the compiler can do to "optimize".  Let's
> think about how to fix it if it breaks.
>
> Paolo
>

Very true. Unchecked paranoia of the compiler isn't warranted here.

Thanks :)

--
Best,
Oliver
diff mbox series

Patch

diff --git a/x86/vmx_tests.c b/x86/vmx_tests.c
index ad8c002..ec88016 100644
--- a/x86/vmx_tests.c
+++ b/x86/vmx_tests.c
@@ -4976,7 +4976,10 @@  extern unsigned char test_mtf1;
 extern unsigned char test_mtf2;
 extern unsigned char test_mtf3;
 
-__attribute__((noclone)) static void test_mtf_guest(void)
+#ifndef __clang__
+__attribute__((noclone))
+#endif
+static void test_mtf_guest(void)
 {
 	asm ("vmcall;\n\t"
 	     "out %al, $0x80;\n\t"