From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 070BEC2BD09 for ; Fri, 12 Jul 2024 21:55:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:MIME-Version: References:In-Reply-To:Subject:Cc:To:From:Message-ID:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=60NsSon823j4GT4Tp5Z2gfVqWiGKepPOngX23NQ+8hk=; b=oZNL46RGmxDLAFM4BmoQ9cWBc3 OJReG3zgqg5T9ZRNdbiZFh2X6ACEm9Jo0I5Pi+UUyYNZ3HKVvIpHXxBGs8Q7tpFz+C9pSS96pE5nv i3xGBSam0cq3zZh3GNFEMuRtUOBndQNWwcvuQXgxzkEPY4IuRBmdd8a8NOGxROi3QPtu2V6gPdP0k FafUPKa4Aj9d1o6p4UituyZ5VGx34fPORrX8bkKHVwQHs+4OgVl/+VzVfyFwtMZ834gwcK/o7xEei +mdGgJXFyvXNy80rYrwgzDMh6WejBVLoOIJSL2sfBI+YSyfkGj+8+1YUj1ZsuVCzfzZL8POMRiE2r fTWTdalA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sSOEv-00000001Kgb-2fok; Fri, 12 Jul 2024 21:55:41 +0000 Received: from sin.source.kernel.org ([2604:1380:40e1:4800::1]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sSOEc-00000001Kd9-3pWq for linux-arm-kernel@lists.infradead.org; Fri, 12 Jul 2024 21:55:24 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 9A0D0CE0FFC; Fri, 12 Jul 2024 21:55:20 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DA5F3C32782; Fri, 12 Jul 2024 21:55:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1720821319; bh=hHPoaV7UEU4AsfewMnxxIEnFJZjwwHobfKZXCH2J90Y=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=jhQvDJIeW17sOq8mFwHrZgi+NRfn6Qrp/j75Sy5u5OT51wzAz1XZCKd/Y1KnhUCZ4 mlIYlGw/DT3tBwd32oBBkLvk4D2ZlLagxnP9jbR1VRObmt+I3cdnZ631F+65Qp6XOX 9GeSIuzJfNsKktf3f2PNHuWY1jzMro78JYKM9xaSgLCSLgrSSrDH+16xOraQu3p/nA yLJTwymEjTHOAMsrdWJamaK+Z2LPeh5JnSFMAv01xo+6crjCRB4zfu2N7fgQFTBkam RFnZkWigE6E7NGDF15y0Gtpa86RNp66oZK0Q6TGhMxC6uZ8hDj7AXvifSiA1Fy47cV 62a6eczgs+CdA== Received: from [213.208.208.122] (helo=wait-a-minute.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1sSOEX-00Byls-FJ; Fri, 12 Jul 2024 22:55:17 +0100 Date: Fri, 12 Jul 2024 22:55:16 +0100 Message-ID: <8734oep96j.wl-maz@kernel.org> From: Marc Zyngier To: Sebastian Ott Cc: linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, linux-kernel@vger.kernel.org, Oliver Upton , James Morse , Suzuki K Poulose , Catalin Marinas , Will Deacon , Zenghui Yu Subject: Re: [PATCH 1/3] KVM: arm64: fix override-init warnings in W=1 builds In-Reply-To: <20240712110332.10970-2-sebott@redhat.com> References: <20240712110332.10970-1-sebott@redhat.com> <20240712110332.10970-2-sebott@redhat.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/28.2 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-SA-Exim-Connect-IP: 213.208.208.122 X-SA-Exim-Rcpt-To: sebott@redhat.com, linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, linux-kernel@vger.kernel.org, oliver.upton@linux.dev, james.morse@arm.com, suzuki.poulose@arm.com, catalin.marinas@arm.com, will@kernel.org, yuzenghui@huawei.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240712_145523_323358_B77EA038 X-CRM114-Status: GOOD ( 23.37 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Fri, 12 Jul 2024 12:03:30 +0100, Sebastian Ott wrote: > > Remove double initializations in cases where that's easily possible > - like extra NULL initialization in static global structures. In the > other cases just silence -Woverride-init. > > To fix warnings like the following: > arch/arm64/kvm/hyp/vhe/switch.c:271:43: warning: initialized field overwritten [-Woverride-init] > 271 | [ESR_ELx_EC_CP15_32] = kvm_hyp_handle_cp15_32, > | ^~~~~~~~~~~~~~~~~~~~~~ > > Signed-off-by: Sebastian Ott > --- > arch/arm64/kvm/handle_exit.c | 5 +++++ > arch/arm64/kvm/hyp/nvhe/switch.c | 6 ++---- > arch/arm64/kvm/hyp/vhe/switch.c | 3 +-- > arch/arm64/kvm/sys_regs.c | 5 +++++ > 4 files changed, 13 insertions(+), 6 deletions(-) > > diff --git a/arch/arm64/kvm/handle_exit.c b/arch/arm64/kvm/handle_exit.c > index d7c2990e7c9e..2c049746657c 100644 > --- a/arch/arm64/kvm/handle_exit.c > +++ b/arch/arm64/kvm/handle_exit.c > @@ -291,6 +291,9 @@ static int handle_svc(struct kvm_vcpu *vcpu) > return 1; > } > > +__diag_push(); > +__diag_ignore_all("-Woverride-init", "Allow field overrides in exit_handlers"); The wording you are looking for is "Silence stupid warning". I really mean it. There is really nothing wrong with this code, and if the compiler doesn't understand the purpose of a default initialiser, then *maybe* it should be fixed rather than polluting the kernel with this stuff. > + > static exit_handle_fn arm_exit_handlers[] = { > [0 ... ESR_ELx_EC_MAX] = kvm_handle_unknown_ec, > [ESR_ELx_EC_WFx] = kvm_handle_wfx, > @@ -319,6 +322,8 @@ static exit_handle_fn arm_exit_handlers[] = { > [ESR_ELx_EC_PAC] = kvm_handle_ptrauth, > }; > > +__diag_pop(); > + > static exit_handle_fn kvm_get_exit_handler(struct kvm_vcpu *vcpu) > { > u64 esr = kvm_vcpu_get_esr(vcpu); > diff --git a/arch/arm64/kvm/hyp/nvhe/switch.c b/arch/arm64/kvm/hyp/nvhe/switch.c > index 6af179c6356d..bf49afc01542 100644 > --- a/arch/arm64/kvm/hyp/nvhe/switch.c > +++ b/arch/arm64/kvm/hyp/nvhe/switch.c > @@ -200,8 +200,7 @@ static void kvm_hyp_save_fpsimd_host(struct kvm_vcpu *vcpu) > } > } > > -static const exit_handler_fn hyp_exit_handlers[] = { > - [0 ... ESR_ELx_EC_MAX] = NULL, > +static const exit_handler_fn hyp_exit_handlers[ESR_ELx_EC_MAX + 1] = { Is this really any better? I don't think so. It makes the intent disappear instead of making it explicit. Intent matters *a lot*. M. -- Without deviation from the norm, progress is not possible.