mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Peter Xu <peterx@redhat.com>,
	kvm@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Vitaly Kuznetsov <vkuznets@redhat.com>
Subject: Re: [PATCH] KVM: selftests: Fix build for evmcs.h
Date: Tue, 5 May 2020 14:36:02 +0200	[thread overview]
Message-ID: <aebe1f8a-8c58-7508-80ed-848d3143fcad@redhat.com> (raw)
In-Reply-To: <20200504220607.99627-1-peterx@redhat.com>

On 05/05/20 00:06, Peter Xu wrote:
> I got this error when building kvm selftests:
> 
> /usr/bin/ld: /home/xz/git/linux/tools/testing/selftests/kvm/libkvm.a(vmx.o):/home/xz/git/linux/tools/testing/selftests/kvm/include/evmcs.h:222: multiple definition of `current_evmcs'; /tmp/cco1G48P.o:/home/xz/git/linux/tools/testing/selftests/kvm/include/evmcs.h:222: first defined here
> /usr/bin/ld: /home/xz/git/linux/tools/testing/selftests/kvm/libkvm.a(vmx.o):/home/xz/git/linux/tools/testing/selftests/kvm/include/evmcs.h:223: multiple definition of `current_vp_assist'; /tmp/cco1G48P.o:/home/xz/git/linux/tools/testing/selftests/kvm/include/evmcs.h:223: first defined here
> 
> I think it's because evmcs.h is included both in a test file and a lib file so
> the structs have multiple declarations when linking.  After all it's not a good
> habit to declare structs in the header files.
> 
> Cc: Vitaly Kuznetsov <vkuznets@redhat.com>
> Signed-off-by: Peter Xu <peterx@redhat.com>
> ---
> 
> I initially thought it was something about my GCC 10 upgrade that I recently
> did to my laptop - gcc10 even fails the build of the latest kernel after
> all (though it turns out to be a kernel bug on build system rather than a gcc
> bug). but I'm not sure about this one...
> ---
>  tools/testing/selftests/kvm/include/evmcs.h  | 4 ++--
>  tools/testing/selftests/kvm/lib/x86_64/vmx.c | 3 +++
>  2 files changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/tools/testing/selftests/kvm/include/evmcs.h b/tools/testing/selftests/kvm/include/evmcs.h
> index d8f4d6bfe05d..a034438b6266 100644
> --- a/tools/testing/selftests/kvm/include/evmcs.h
> +++ b/tools/testing/selftests/kvm/include/evmcs.h
> @@ -219,8 +219,8 @@ struct hv_enlightened_vmcs {
>  #define HV_X64_MSR_VP_ASSIST_PAGE_ADDRESS_MASK	\
>  		(~((1ull << HV_X64_MSR_VP_ASSIST_PAGE_ADDRESS_SHIFT) - 1))
>  
> -struct hv_enlightened_vmcs *current_evmcs;
> -struct hv_vp_assist_page *current_vp_assist;
> +extern struct hv_enlightened_vmcs *current_evmcs;
> +extern struct hv_vp_assist_page *current_vp_assist;
>  
>  int vcpu_enable_evmcs(struct kvm_vm *vm, int vcpu_id);
>  
> diff --git a/tools/testing/selftests/kvm/lib/x86_64/vmx.c b/tools/testing/selftests/kvm/lib/x86_64/vmx.c
> index 6f17f69394be..4ae104f6ce69 100644
> --- a/tools/testing/selftests/kvm/lib/x86_64/vmx.c
> +++ b/tools/testing/selftests/kvm/lib/x86_64/vmx.c
> @@ -17,6 +17,9 @@
>  
>  bool enable_evmcs;
>  
> +struct hv_enlightened_vmcs *current_evmcs;
> +struct hv_vp_assist_page *current_vp_assist;
> +
>  struct eptPageTableEntry {
>  	uint64_t readable:1;
>  	uint64_t writable:1;
> 

Queued, thanks.

Paolo


      reply	other threads:[~2020-05-05 12:36 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-04 22:06 Peter Xu
2020-05-05 12:36 ` Paolo Bonzini [this message]

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=aebe1f8a-8c58-7508-80ed-848d3143fcad@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peterx@redhat.com \
    --cc=vkuznets@redhat.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

all inboxes | Powered by JetHome®