From: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
To: kvm@vger.kernel.org, Sean Christopherson <seanjc@google.com>,
Paolo Bonzini <pbonzini@redhat.com>
Cc: 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>,
linux-kernel@vger.kernel.org,
Vincent Mailhol <mailhol.vincent@wanadoo.fr>
Subject: [PATCH] KVM: x86: do not shadow apic global definition
Date: Fri, 29 Jul 2022 17:45:33 +0900 [thread overview]
Message-ID: <20220729084533.54500-1-mailhol.vincent@wanadoo.fr> (raw)
arch/x86/include/asm/apic.h declares a global variable named `apic'.
Many function arguments from arch/x86/kvm/lapic.h also uses the same
name and thus shadow the global declaration. For each case of
shadowing, rename the function argument from `apic' to `lapic'.
This patch silences below -Wshadow warnings:
| In file included from arch/x86/kernel/../kvm/vmx/capabilities.h:7,
| from arch/x86/kernel/../kvm/vmx/vmx.h:10:
| arch/x86/kernel/../kvm/vmx/../lapic.h: In function 'kvm_lapic_set_irr':
| arch/x86/kernel/../kvm/vmx/../lapic.h:143:65: warning: declaration of 'apic' shadows a global declaration [-Wshadow]
| 143 | static inline void kvm_lapic_set_irr(int vec, struct kvm_lapic *apic)
| | ~~~~~~~~~~~~~~~~~~^~~~
| In file included from ./arch/x86/include/asm/kvm_host.h:29,
| from ./include/linux/kvm_host.h:45:
| ./arch/x86/include/asm/apic.h:357:21: note: shadowed declaration is here
| 357 | extern struct apic *apic;
| | ^~~~
| arch/x86/kernel/../kvm/vmx/../lapic.h: In function 'kvm_lapic_get_reg':
| arch/x86/kernel/../kvm/vmx/../lapic.h:158:55: warning: declaration of 'apic' shadows a global declaration [-Wshadow]
| 158 | static inline u32 kvm_lapic_get_reg(struct kvm_lapic *apic, int reg_off)
| | ~~~~~~~~~~~~~~~~~~^~~~
| ./arch/x86/include/asm/apic.h:357:21: note: shadowed declaration is here
| 357 | extern struct apic *apic;
| | ^~~~
| arch/x86/kernel/../kvm/vmx/../lapic.h: In function 'kvm_apic_hw_enabled':
| arch/x86/kernel/../kvm/vmx/../lapic.h:174:57: warning: declaration of 'apic' shadows a global declaration [-Wshadow]
| 174 | static inline int kvm_apic_hw_enabled(struct kvm_lapic *apic)
| | ~~~~~~~~~~~~~~~~~~^~~~
| ./arch/x86/include/asm/apic.h:357:21: note: shadowed declaration is here
| 357 | extern struct apic *apic;
| | ^~~~
| arch/x86/kernel/../kvm/vmx/../lapic.h: In function 'kvm_apic_sw_enabled':
| arch/x86/kernel/../kvm/vmx/../lapic.h:183:58: warning: declaration of 'apic' shadows a global declaration [-Wshadow]
| 183 | static inline bool kvm_apic_sw_enabled(struct kvm_lapic *apic)
| | ~~~~~~~~~~~~~~~~~~^~~~
| ./arch/x86/include/asm/apic.h:357:21: note: shadowed declaration is here
| 357 | extern struct apic *apic;
| | ^~~~
| arch/x86/kernel/../kvm/vmx/../lapic.h: In function 'apic_x2apic_mode':
| arch/x86/kernel/../kvm/vmx/../lapic.h:200:54: warning: declaration of 'apic' shadows a global declaration [-Wshadow]
| 200 | static inline int apic_x2apic_mode(struct kvm_lapic *apic)
| | ~~~~~~~~~~~~~~~~~~^~~~
| ./arch/x86/include/asm/apic.h:357:21: note: shadowed declaration is here
| 357 | extern struct apic *apic;
| | ^~~~
| arch/x86/kernel/../kvm/vmx/../lapic.h: In function 'kvm_xapic_id':
| arch/x86/kernel/../kvm/vmx/../lapic.h:249:49: warning: declaration of 'apic' shadows a global declaration [-Wshadow]
| 249 | static inline u8 kvm_xapic_id(struct kvm_lapic *apic)
| | ~~~~~~~~~~~~~~~~~~^~~~
| ./arch/x86/include/asm/apic.h:357:21: note: shadowed declaration is here
| 357 | extern struct apic *apic;
| | ^~~~
Signed-off-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
---
arch/x86/kvm/lapic.h | 26 +++++++++++++-------------
1 file changed, 13 insertions(+), 13 deletions(-)
diff --git a/arch/x86/kvm/lapic.h b/arch/x86/kvm/lapic.h
index 117a46df5cc1..55abd5e22462 100644
--- a/arch/x86/kvm/lapic.h
+++ b/arch/x86/kvm/lapic.h
@@ -156,14 +156,14 @@ static inline void kvm_lapic_set_vector(int vec, void *bitmap)
set_bit(VEC_POS(vec), (bitmap) + REG_POS(vec));
}
-static inline void kvm_lapic_set_irr(int vec, struct kvm_lapic *apic)
+static inline void kvm_lapic_set_irr(int vec, struct kvm_lapic *lapic)
{
- kvm_lapic_set_vector(vec, apic->regs + APIC_IRR);
+ kvm_lapic_set_vector(vec, lapic->regs + APIC_IRR);
/*
* irr_pending must be true if any interrupt is pending; set it after
* APIC_IRR to avoid race with apic_clear_irr
*/
- apic->irr_pending = true;
+ lapic->irr_pending = true;
}
static inline u32 __kvm_lapic_get_reg(char *regs, int reg_off)
@@ -171,9 +171,9 @@ static inline u32 __kvm_lapic_get_reg(char *regs, int reg_off)
return *((u32 *) (regs + reg_off));
}
-static inline u32 kvm_lapic_get_reg(struct kvm_lapic *apic, int reg_off)
+static inline u32 kvm_lapic_get_reg(struct kvm_lapic *lapic, int reg_off)
{
- return __kvm_lapic_get_reg(apic->regs, reg_off);
+ return __kvm_lapic_get_reg(lapic->regs, reg_off);
}
DECLARE_STATIC_KEY_FALSE(kvm_has_noapic_vcpu);
@@ -187,19 +187,19 @@ static inline bool lapic_in_kernel(struct kvm_vcpu *vcpu)
extern struct static_key_false_deferred apic_hw_disabled;
-static inline int kvm_apic_hw_enabled(struct kvm_lapic *apic)
+static inline int kvm_apic_hw_enabled(struct kvm_lapic *lapic)
{
if (static_branch_unlikely(&apic_hw_disabled.key))
- return apic->vcpu->arch.apic_base & MSR_IA32_APICBASE_ENABLE;
+ return lapic->vcpu->arch.apic_base & MSR_IA32_APICBASE_ENABLE;
return MSR_IA32_APICBASE_ENABLE;
}
extern struct static_key_false_deferred apic_sw_disabled;
-static inline bool kvm_apic_sw_enabled(struct kvm_lapic *apic)
+static inline bool kvm_apic_sw_enabled(struct kvm_lapic *lapic)
{
if (static_branch_unlikely(&apic_sw_disabled.key))
- return apic->sw_enabled;
+ return lapic->sw_enabled;
return true;
}
@@ -213,9 +213,9 @@ static inline int kvm_lapic_enabled(struct kvm_vcpu *vcpu)
return kvm_apic_present(vcpu) && kvm_apic_sw_enabled(vcpu->arch.apic);
}
-static inline int apic_x2apic_mode(struct kvm_lapic *apic)
+static inline int apic_x2apic_mode(struct kvm_lapic *lapic)
{
- return apic->vcpu->arch.apic_base & X2APIC_ENABLE;
+ return lapic->vcpu->arch.apic_base & X2APIC_ENABLE;
}
static inline bool kvm_vcpu_apicv_active(struct kvm_vcpu *vcpu)
@@ -262,9 +262,9 @@ static inline enum lapic_mode kvm_apic_mode(u64 apic_base)
return apic_base & (MSR_IA32_APICBASE_ENABLE | X2APIC_ENABLE);
}
-static inline u8 kvm_xapic_id(struct kvm_lapic *apic)
+static inline u8 kvm_xapic_id(struct kvm_lapic *lapic)
{
- return kvm_lapic_get_reg(apic, APIC_ID) >> 24;
+ return kvm_lapic_get_reg(lapic, APIC_ID) >> 24;
}
#endif
--
2.35.1
next reply other threads:[~2022-07-29 8:46 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-29 8:45 Vincent Mailhol [this message]
2022-07-29 17:48 ` Sean Christopherson
2022-07-30 4:15 ` Vincent MAILHOL
2022-08-02 20:12 ` Sean Christopherson
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=20220729084533.54500-1-mailhol.vincent@wanadoo.fr \
--to=mailhol.vincent@wanadoo.fr \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=hpa@zytor.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=pbonzini@redhat.com \
--cc=seanjc@google.com \
--cc=tglx@linutronix.de \
--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
all inboxes | Powered by JetHome®