Message ID | 20240212112419.1186065-1-arnd@kernel.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-61419-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp2375112dyd; Mon, 12 Feb 2024 03:49:32 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCV9XgGO9wBYzs/saC0VaRKVaFm0/n4JEr+/hqXusD58QgLscygBQiBMuFQiixoRXfyY3aI2b14qgVwLnq0Cn/avn//ReQ== X-Google-Smtp-Source: AGHT+IEa4fAymornU8KejsciodPsToav72JZlRAvXl+r9JpcxlAuItuyWgJF4tZ34ZQAVmFtFfMy X-Received: by 2002:a92:c6c2:0:b0:363:e41b:63f8 with SMTP id v2-20020a92c6c2000000b00363e41b63f8mr9130576ilm.19.1707738572523; Mon, 12 Feb 2024 03:49:32 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707738572; cv=pass; d=google.com; s=arc-20160816; b=qiiKj+HYR4kFcAGqUa6++EO1BW5M+UKTpcTKLjvDbg6ZjC4LU8CUXGTcQoYq7opsVK ypCR/f3iWKeLUx/BqS2kDFUgOQLnzChRgnhm1LTY4JWP3BXcSI/WNdbMHV+ovspxAb1Z OYgV2KSSw5FYQVCHuUHXLyFA3kfvc/fj11gdVQsgu9XqUmIET6rCGK5ni1vYYIAwPFaH 1ypCOprcGZ16C4WnFrCQzZ5kmlwY7bsDzY/SP/LFeXl8BS8B8bvp97mHWHAFeMeYJUTA JT10O86nZSqjvnk/kprgm3ct+ozK5NJ1JWBvLTtEVwVdjBYsdm4Twd65HKh/mAszDwbl Hq3w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=Qya8DvIJq5AQgAWdhBJR1XdCiL3bIuU6rZGtRpieBhM=; fh=YbKxn1JVaF/G/tfPADN9HLelR3JDE85GDSo32daE6ac=; b=KxQNkiOYJUs29A/eVlYweOXVjWs1Wr+Tcf7ht6jUrWc8D3syMtMeHjQU6a6CKEayJM te+xHJKT1bf0pFNnZcRgbHEK0F0608EAQavTA+ItNcGjfJh+BBWyRZNow9ARunzjGZlb 4bof5wBpJWh4Vd4ryUoEm1OaQtEUuf7fzRYul2MspXf/KmTUupuJ6Bv0keiYU8brEAbG Nwdz4RIGPiaxCn7kieT89DTKrhaSpTytk+02XB5d6XtKr8Bu/Ui4GcTF7cMp4498P8iO hO6mtftm6mapnIH4KYuOvMEWwASUAyPgsxcFlXDmqcWwKyHPmh94zbIHuT+SgqRf+yhs f5Jw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=B5noxPAz; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-61419-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-61419-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=2; AJvYcCXKPfAQKFBFq4O05tDKdGOWilzoaSgOGWxl794QvJDngppr22nHmD2ydt9Ij5tO8p+VjPMZ1Qx9aDJUO/hAbu3KIqmXKw== Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id l190-20020a6388c7000000b005ced6c45233si124860pgd.712.2024.02.12.03.49.32 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Feb 2024 03:49:32 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-61419-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=B5noxPAz; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-61419-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-61419-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id A7D67B2694A for <ouuuleilei@gmail.com>; Mon, 12 Feb 2024 11:24:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9A66539AC2; Mon, 12 Feb 2024 11:24:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="B5noxPAz" 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 DE0FE38DE4; Mon, 12 Feb 2024 11:24:24 +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=1707737065; cv=none; b=HNpLU9qyo2YAiDRbejg8oOwsXRXTXSeF+ktrzXRFVmly1JW66V8D5tsnW6OeyldPPnP24w/MYWG2tnWhvnPl1EseWHeFqsCP3T2Qk3v1LWccbRBQoVfY64QMNNcTJ62MaQsVqUt2tVv5ph54y7hlsy6DTCpZwYez1zzMiMF58EE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707737065; c=relaxed/simple; bh=ctB3UNnuko1So6jdWUHT6OoiQS0dR1uMODQ5VcPcPKc=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=ecGaLcdzWBadbq20algPSnvsPyRD3IzY744myK7tSxh4rjdZ5sbeIXhwqpfrfoUIdeaupybRe4UCkLOpWamxNSvQy6V6Mn1V87srACqtvSVHT5FNxv7U8m1ytAa9xzwnGNUxJj/lsyrfqmuIKX/WZ3I+jyOlr6194mVzZRUI9Bc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=B5noxPAz; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2BB6CC433F1; Mon, 12 Feb 2024 11:24:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1707737064; bh=ctB3UNnuko1So6jdWUHT6OoiQS0dR1uMODQ5VcPcPKc=; h=From:To:Cc:Subject:Date:From; b=B5noxPAzXIEuAGofnSaGSwq1xWlEazm6k239d4/xurIUbuH5MgkBZfs/R7TmGqlW5 T9lEmQcQLc010Rnb2Q8h/yB0kiY4BWU5AkdAXvVzwz0iaoBHRL8jy+nr3q62v4aRdc NIFNQ/KJZpWOQV2SBjEIHLMlvrgFh49TQOEnuMDuDpy5iOc7Cg6LZ9WKBdb2K0JZMM rsnWzKlx/pOIl/03GuxYcjmTILp7teizsQGVIfmV3yRrJiKqFE3ZDKZwZYF67tJbK0 KDHzzvHo/bwKCULiTcyXI+b5s3dD7nkaEAa/k533pVgeWBBGDG84tkj2nmuCmH8Wya wnHZDzTRf02eQ== From: Arnd Bergmann <arnd@kernel.org> To: Paolo Bonzini <pbonzini@redhat.com>, Marc Zyngier <maz@kernel.org>, David Matlack <dmatlack@google.com> Cc: Arnd Bergmann <arnd@arndb.de>, Sean Christopherson <seanjc@google.com>, Fuad Tabba <tabba@google.com>, Shaoqin Huang <shahuang@redhat.com>, Chao Peng <chao.p.peng@linux.intel.com>, kvm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] KVM: fix kvm_mmu_memory_cache allocation warning Date: Mon, 12 Feb 2024 12:24:10 +0100 Message-Id: <20240212112419.1186065-1-arnd@kernel.org> X-Mailer: git-send-email 2.39.2 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790693681704572115 X-GMAIL-MSGID: 1790693681704572115 |
Series |
KVM: fix kvm_mmu_memory_cache allocation warning
|
|
Commit Message
Arnd Bergmann
Feb. 12, 2024, 11:24 a.m. UTC
From: Arnd Bergmann <arnd@arndb.de> 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 <arnd@arndb.de> --- virt/kvm/kvm_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Comments
On Mon, 12 Feb 2024 11:24:10 +0000, Arnd Bergmann <arnd@kernel.org> wrote: > > From: Arnd Bergmann <arnd@arndb.de> > > 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 <arnd@arndb.de> > --- > 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 <maz@kernel.org> M.
On Mon, 12 Feb 2024 12:24:10 +0100, Arnd Bergmann wrote: > 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 > > [...] Applied to kvm-x86 generic, so that this doesn't languish with everyone looking at each other. [1/1] KVM: fix kvm_mmu_memory_cache allocation warning https://github.com/kvm-x86/linux/commit/ea3689d9df50 -- https://github.com/kvm-x86/linux/tree/next
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;