Received: by 2002:ac0:e350:0:0:0:0:0 with SMTP id g16csp132798imn; Fri, 29 Jul 2022 02:05:16 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sCTt9UFS4xmAvq7k92UlgjZK+FdwSOb/X/Zv4b7N/9yv/fZHvKGAtZPwfWHNsBa0wPgp1q X-Received: by 2002:a17:906:d54b:b0:72e:ece1:2956 with SMTP id cr11-20020a170906d54b00b0072eece12956mr2171713ejc.156.1659085505802; Fri, 29 Jul 2022 02:05:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659085505; cv=none; d=google.com; s=arc-20160816; b=EyPjQMhDYwQmtiS8a+iUXY6HmiL5z0coms1n4DwD0bj3OFULSCR+cUr8alErdLO/ZU fXlw/mGZAZX1QKtR1FXj5dC/4pPn24KLbRb6MgIV1l3G2CaSbkcB8vYy9NRGX9JhgB0C gE9I8HcprnxJdsWyU84GStSGgc1vj+rGBRBuIOdV1y7anyBNZBhAeM8xhEQJD+tIjwxf vv1qI5NIJTUHjAxYfC0r8ke5d/yd0uhE8buJviKeTqQGHuDcYbQYamotHhrnn5+ovO/2 n2aprAUf8L2jAfnBf/ityi5EbgJcSl0Yt1nTl7xzBNb0znd39PDqUwRpiGjdtTgs7L8G qqqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:sender:dkim-signature; bh=3W7hNFmAJEfXBo7DpbR7xQUy/ygc6BlRe7J3ZXgX4QI=; b=iyW56CIHRfVzL/1jiD+JcvuFDGZIi16wzN4niJOpFWNsQGVE8Lzc0LSQbqo6qLMSTq NlIYexweFupiXMl9E9AYufUafqoZL5/zEyrcOWvZHNoQ5r19b47ccP0oLB3i4Wrfq9Lw pAg54LKfa2KaPtJl4oiOfhaMxe3K5LvvLtGHY6qsDNYFZcw2FffEUY/D/RNFayo5e1KR gw8iKogINqw+rMcRkJdJqAvobnMa+Uk4JZvAre8hatdXNyiiV3dg6ssdvBG+e0CWPn91 8vrFdLabfYGOmiY0Go4mG0m437IEDZfJkG6R0V0E/dILi3hVdZd7xKlXz3yNJ29BxFSu lOIg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=dQ+W+ksU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k4-20020a170906128400b007269a9c3019si2449309ejb.818.2022.07.29.02.04.39; Fri, 29 Jul 2022 02:05:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=dQ+W+ksU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234699AbiG2Ip4 (ORCPT + 99 others); Fri, 29 Jul 2022 04:45:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53886 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230317AbiG2Ipw (ORCPT ); Fri, 29 Jul 2022 04:45:52 -0400 Received: from mail-pf1-x431.google.com (mail-pf1-x431.google.com [IPv6:2607:f8b0:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8DB94491D8; Fri, 29 Jul 2022 01:45:51 -0700 (PDT) Received: by mail-pf1-x431.google.com with SMTP id b133so4068278pfb.6; Fri, 29 Jul 2022 01:45:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=3W7hNFmAJEfXBo7DpbR7xQUy/ygc6BlRe7J3ZXgX4QI=; b=dQ+W+ksU7zadADK/7nZApQgG6i/N0vxl6+ss4UhEd0mmiBety/RiYD4ooYxZki6WTH 2yXAO/lJ53RY3/DCRlGkPo9rIl+rjt52iGpRf/VywKr5jHzW1PXQst1+5WPYsz4Fmi/m Hl22mON2zMOPH3h9sqw4MNpMesyMFvkrRrfOSmg4juYYqCTXlMhn+zgJXu6T1dQfyP/v Y15CTJZnuonWA2r+dYCJV7MF/dUtcvl04HNEK10ensrHTUgzPHuNhF6pKTohsn7kt9Qf 7Cw43E4+01H6SyCeh9GNMnoA6PRsliOEzwwhKpgZ+Lo70LwN4zh7a+Ws9dbHA2XCf1rC NBig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :mime-version:content-transfer-encoding; bh=3W7hNFmAJEfXBo7DpbR7xQUy/ygc6BlRe7J3ZXgX4QI=; b=wXiDvhnzx8nikFyd/jlZvWi49UzTq/9nEmUEYfMmRFCN0+HbmOuBDf9ceSA7xXLa9h htz5FhPWOzuC0FKmVcMWsM9fcDAHk7i6uK792Dvl68SHn+1gLNd2DnROFBHudUzkqRUz XZpcZDIVISz4TfkRERJPbRhq3Z+usNPwDXT3aYjx49ko+pgh1Zp48/NNwp6fVcLh8K0L mz6VQhVEVbUJH7rLUjcz6CliJ9JFaUJOMYenFySQlLW65H8F8i5JK2sf0LKX34DRMLkk BUXGEgWfpWz08ea6w/A7T2pyglZxzNA940OPiyjnI//z+TqYU0PSRrN2D/X8ADT3Wz5W ViGg== X-Gm-Message-State: AJIora/ZLk6uEp2yLhkYNNENCM+k+HvRXGX7jFYneJYZrLCVXdG5UxqV dLLZhbr9W60diGMgzQTuTEahpnEvfH0bZA== X-Received: by 2002:a65:6bd6:0:b0:39d:4f85:9ecf with SMTP id e22-20020a656bd6000000b0039d4f859ecfmr2180776pgw.336.1659084350338; Fri, 29 Jul 2022 01:45:50 -0700 (PDT) Received: from localhost.localdomain (124x33x176x97.ap124.ftth.ucom.ne.jp. [124.33.176.97]) by smtp.gmail.com with ESMTPSA id y11-20020aa793cb000000b0052c89540659sm2208145pff.189.2022.07.29.01.45.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Jul 2022 01:45:49 -0700 (PDT) Sender: Vincent Mailhol From: Vincent Mailhol To: kvm@vger.kernel.org, Sean Christopherson , Paolo Bonzini Cc: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H . Peter Anvin" , linux-kernel@vger.kernel.org, Vincent Mailhol Subject: [PATCH] KVM: x86: do not shadow apic global definition Date: Fri, 29 Jul 2022 17:45:33 +0900 Message-Id: <20220729084533.54500-1-mailhol.vincent@wanadoo.fr> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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