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 99E0D39860; Mon, 12 Feb 2024 11:51:46 +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=1707738706; cv=none; b=Ny+JWZE2B5usAFeBeowN/9u7quLE4upACQU7CRyKNiFu9PtD1t3HfzmxZIzsh00uCuxTw7lI+0c0uJSte/pMCWArOMfpjS4vlZRVcdjzI0TXvhcVviMraGKad3k3DZWJCuwfuvw4lguvawNvvwF6Sr2mf7/12vuwyPY7pLEIpn4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707738706; c=relaxed/simple; bh=bTVJvlBr8xA7AJ8ry9czvvHc5Z9HCrBIlnOGVk+k5kc=; h=Date:Message-ID:From:To:Cc:Subject:In-Reply-To:References: MIME-Version:Content-Type; b=Lm58nMLKjhXFzJizaa8lswWYHELFv5y73ulS1hbqUC0CdMqhkb/gvcxb0lhW3ylO3jCB/I0cXHfL2YgErUyln1UaeDUJgJcUxywHCX7ONoK7f/e6RBBIEqNTOgnk7SKBRe+bToprrOr1aBnTpU4BNLaPHpxiL8BIA0Q7HyApTmg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=jNRa8rWT; 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="jNRa8rWT" Received: by smtp.kernel.org (Postfix) with ESMTPSA id EF1D3C433C7; Mon, 12 Feb 2024 11:51:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1707738706; bh=bTVJvlBr8xA7AJ8ry9czvvHc5Z9HCrBIlnOGVk+k5kc=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=jNRa8rWTI8Tc3Pr4lUPjevvzTe7pAKhaadCCx0fkI019EIQ18Zdr6dJy3WPzLYCbD uCOjznDFiOybYCIq/C8Z4opYCEcxkGGWHuSOcDqLSsM4SwNstzL/qc54RqeV45IdxE rDWg9wmVSYMIeP+WQgrYSZmzHIHFVANpFtVGOtve2Y57b4a2IRAsZRkIcUOFjzunE1 w5XReuwsR865lfiQmt6n9ninpXl24MCqdW1mjY4znTQbot3W2I9YzG83YR7p65dIQJ R8iKRkp6A4VaQNLEsot+ptjtRg45bfkP2VW1MJIcRaZB9sEYFnCFYX4YvF3DI4PX1w nZiyVOBKgHBVg== Received: from sofa.misterjones.org ([185.219.108.64] helo=goblin-girl.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 1rZUqd-002OGl-Ck; Mon, 12 Feb 2024 11:51:43 +0000 Date: Mon, 12 Feb 2024 11:51:42 +0000 Message-ID: <86frxx6gtt.wl-maz@kernel.org> From: Marc Zyngier To: Arnd Bergmann Cc: Paolo Bonzini , David Matlack , Arnd Bergmann , Sean Christopherson , Fuad Tabba , Shaoqin Huang , Chao Peng , kvm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] KVM: fix kvm_mmu_memory_cache allocation warning In-Reply-To: <20240212112419.1186065-1-arnd@kernel.org> References: <20240212112419.1186065-1-arnd@kernel.org> 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/29.1 (aarch64-unknown-linux-gnu) MULE/6.0 (HANACHIRUSATO) Precedence: bulk X-Mailing-List: kvm@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: 185.219.108.64 X-SA-Exim-Rcpt-To: arnd@kernel.org, pbonzini@redhat.com, dmatlack@google.com, arnd@arndb.de, seanjc@google.com, tabba@google.com, shahuang@redhat.com, chao.p.peng@linux.intel.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false On Mon, 12 Feb 2024 11:24:10 +0000, Arnd Bergmann wrote: > > From: Arnd Bergmann > > gcc-14 notices that the arguments to kvmalloc_array() are mixed up: > > arch/x86/kvm/../../../virt/kvm/kvm_main.c: In function '__kvm_mmu_topup_memory_cache': > arch/x86/kvm/../../../virt/kvm/kvm_main.c:424:53: error: 'kvmalloc_array' sizes specified with 'sizeof' in the earlier argument and not in the later argument [-Werror=calloc-transposed-args] > 424 | mc->objects = kvmalloc_array(sizeof(void *), capacity, gfp); > | ^~~~ > arch/x86/kvm/../../../virt/kvm/kvm_main.c:424:53: note: earlier argument should specify number of elements, later size of each element > > The code still works correctly, but the incorrect order prevents the compiler > from properly tracking the object sizes. > > Fixes: 837f66c71207 ("KVM: Allow for different capacities in kvm_mmu_memory_cache structs") > Signed-off-by: Arnd Bergmann > --- > virt/kvm/kvm_main.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c > index 8f03b56dafbd..4c48f61cae35 100644 > --- a/virt/kvm/kvm_main.c > +++ b/virt/kvm/kvm_main.c > @@ -421,7 +421,7 @@ int __kvm_mmu_topup_memory_cache(struct kvm_mmu_memory_cache *mc, int capacity, > if (WARN_ON_ONCE(!capacity)) > return -EIO; > > - mc->objects = kvmalloc_array(sizeof(void *), capacity, gfp); > + mc->objects = kvmalloc_array(capacity, sizeof(void *), gfp); > if (!mc->objects) > return -ENOMEM; > Huh, well spotted GCC. And thanks Arnd for the fix. Reviewed-by: Marc Zyngier M. -- Without deviation from the norm, progress is not possible.