From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 452F845024; Fri, 12 Jul 2024 21:55:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720821320; cv=none; b=Q0aPdff0Pk3u/h8xDM0k4xHz7fFds6YdHPC+92G7Y5f4qCQ5up1SzXgt9BhKTUINZywLkoXdw4gh1WfgKX4a0ZeJoWyUGN55GQqOHSfyCXh4F9x3AgBvJ+VqPN8UVmxLurwWSlpOf0HCdFzgsrKXEHa1hxHlO+RXFmZNajkg5rU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720821320; c=relaxed/simple; bh=hHPoaV7UEU4AsfewMnxxIEnFJZjwwHobfKZXCH2J90Y=; h=Date:Message-ID:From:To:Cc:Subject:In-Reply-To:References: MIME-Version:Content-Type; b=spehhIeZbZ6FVcQQkxxpCGg+L4/MWV1ZvO2EXtqwHyY3F1VAG/7cdMRIuYODzQ1aYHiqLGSDUqKvkjEMt9Qe4U1A/e8DZsjnF/94zbncGeW4Juq3Lx9o3AbYE3Y7mDgBY6VOAVKatLyvBKqL4hyuohWICpCxWs3Bp9dYD74Am9I= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=jhQvDJIe; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="jhQvDJIe" 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) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 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.