Received: by 2002:ab2:620c:0:b0:1ef:ffd0:ce49 with SMTP id o12csp1698328lqt; Wed, 20 Mar 2024 11:13:55 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUQzY0zzXT0P2+shIwVrsIEezL8aC11ToAFgKKJJ8napR2abA9IwfMsmB9aQqdiNYNCT/0LYvwi0wS6yG5/0OIKZELtetOBX579uuwtaQ== X-Google-Smtp-Source: AGHT+IHloGQEPH1+qW0WnDulThEwm5NYIe/xkuBq42HVpM1EFoZp+Qy89nFFWsNNVdV97gZ+GTJQ X-Received: by 2002:a05:6a20:d043:b0:1a3:7de2:12c1 with SMTP id hv3-20020a056a20d04300b001a37de212c1mr4727571pzb.20.1710958435539; Wed, 20 Mar 2024 11:13:55 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710958435; cv=pass; d=google.com; s=arc-20160816; b=Sc40RNeLW2/CJ4LFh1cl2ApBQE2yoa08dZqQKsf4jcGDP2qOaVgQM08+oV73hydaRX HmbyNBxsZ0oaeO3LxGRqCNvQkiTVDCMxZdhCEfus2LXVTSoTzls1jOBAEaN6zmoEaVgh EKjwAvM94GXS1mUozrJrShL8y4WmIgPd17S9Md76VDRR7W8z0XQ76MaASS2lsTBCWxvw nOHJjiGK11p2Dm0nDIdsz7w/CmtAgNyrYbcd7S02Y+kVvbMxKYg9IfHSmSiIAuuJg4qe QeOMCDVYw9S6shH4av5XbSs+9/uChr85cDlvHvbhtUxIZ6fCWanIp+A7yQe9HpRxb4lU NtCA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :user-agent:content-transfer-encoding:references:in-reply-to:date:to :from:subject:message-id:dkim-signature; bh=LNtfmF1SjV+r3dkG+cOI2wd5UAsfVsB1ufaut4fNigo=; fh=qxpQPEUjUEhdRg3ZCVq1vy03OHdHk27f/HS42YcSoas=; b=ta2rT/yAFgleHmU+qj5KcgV6lphSxX53t7+zkGxjuYU/5C7NjSkAweSJqAliJIcWak Ypy0rVrGfVMSpSmOfP8KL8kzi8hWMkSOeSIF99tz/o8YXetGQ44E6rw/kifvB4+4l8j2 TkcDWMHVKA2QSOg7Z76RN98DAX03HnnO9B4wlFfc5+HpAd50DLrnkubyrg5fkg8EAN/c V7qvO4UoVOa9eJTsCqRmzub/v2R/eu0yNgu+JHpxLxB/fDqLMY9+m12qTjLdPonhDrhq h6hlRfMvd/3zUgVRth5TVDCae/qOxLRBV2LDp9MOE8vOrkON7XUGkMzvCcbU5nhMTnRD bWTQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="DoyI/INu"; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-crypto+bounces-2786-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-crypto+bounces-2786-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id y16-20020a056a00191000b006e6f89d0f3bsi11989333pfi.370.2024.03.20.11.13.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Mar 2024 11:13:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto+bounces-2786-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="DoyI/INu"; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-crypto+bounces-2786-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-crypto+bounces-2786-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 3A9952831BF for ; Wed, 20 Mar 2024 18:13:55 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 840616A323; Wed, 20 Mar 2024 18:13:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="DoyI/INu" X-Original-To: linux-crypto@vger.kernel.org Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.16]) (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 AA04E1DFC6 for ; Wed, 20 Mar 2024 18:13:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.16 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710958432; cv=none; b=CtCC4qCaEx1tNOW15TiLTl6/IqlGKocCiuqCBAmuc/S7A482cAfCPWgCDndcJIrnJXar3S21N8JUW6gh+4HPkhb5eHD7hZIFcMq+0jl2L551LvnzN9tYVPEqaiduXcjK1TI6ULANIB7vp87bcyKdgVLAZCzdxcGguVGwKbOang8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710958432; c=relaxed/simple; bh=1IQXI7XkZbPfT38EFmqDXCjPCYkAfzTQ/vAI62h4DZI=; h=Message-ID:Subject:From:To:Date:In-Reply-To:References: Content-Type:MIME-Version; b=bWSN6O2Q8gRnm/GXC22TPfOG8Hh/MTGz/gjDWNaItxCLnvWC9OTk1RMc2FgYsI04bMhTjbfuTKirRQxDzJYcAUUFtqAxAYav9TExHs5U89guXY5gYYkjZu7lcvTq7/hoJsoKEWlmvV2Gq7ZOVNyxE1ve4Rbc8yM/yPD9JO9BoWo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=DoyI/INu; arc=none smtp.client-ip=192.198.163.16 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1710958431; x=1742494431; h=message-id:subject:from:to:date:in-reply-to:references: content-transfer-encoding:mime-version; bh=1IQXI7XkZbPfT38EFmqDXCjPCYkAfzTQ/vAI62h4DZI=; b=DoyI/INu7w+ZbM3s2Ubo5kK39YfzuKzYiUvKirpABareAk4odp/W9wnf GwTwJUslH3Qly0pt4UTYvazmOiggS9DJEb/rU+Qsl61UDgKhqD5If773N ETGk9g9dM4TslGPrg+j5sqUMF2pkVtnK3O7hBngJtkszRks/qEeBXOGbm e+Esad/bs/sKU3NwELCfU+E16ewYqf7ADSuuI8NmKQ9yDkRJ4PLDwq7BB tI7lJ5y9pyKSFbRKXe5p1alhIwPm+aAplLiyIf4Q4JswHPKrzCIyvfyKW NodSCoB9vxpHyvRvka3uepK7r6gqZmwAoJ2I07q4gznDvuhTwpeh6E+99 w==; X-IronPort-AV: E=McAfee;i="6600,9927,11019"; a="6514283" X-IronPort-AV: E=Sophos;i="6.07,140,1708416000"; d="scan'208";a="6514283" Received: from fmviesa010.fm.intel.com ([10.60.135.150]) by fmvoesa110.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Mar 2024 11:13:50 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,140,1708416000"; d="scan'208";a="14123513" Received: from ahentabl-mobl1.amr.corp.intel.com ([10.213.169.123]) by fmviesa010-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Mar 2024 11:13:49 -0700 Message-ID: <4e917f9a299c46c82e1eb206c26e349fb7d810e7.camel@linux.intel.com> Subject: Re: Divide by zero in iaa_crypto during boot of a kdump kernel From: Tom Zanussi To: Jerry Snitselaar , Herbert Xu , "David S. Miller" , linux-crypto@vger.kernel.org Date: Wed, 20 Mar 2024 13:13:48 -0500 In-Reply-To: <39f73bd559aa96051b4d5c8e42d0ce942194b64f.camel@linux.intel.com> References: <39f73bd559aa96051b4d5c8e42d0ce942194b64f.camel@linux.intel.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.44.4-0ubuntu2 Precedence: bulk X-Mailing-List: linux-crypto@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Hi Jerry, On Tue, 2024-03-19 at 17:19 -0500, Tom Zanussi wrote: > Hi Jerry, >=20 > On Tue, 2024-03-19 at 13:51 -0700, Jerry Snitselaar wrote: > > Hi Tom, > >=20 > > While looking at a different issue on a GNR system I noticed that > > during the boot of the kdump kernel it crashes when probing > > iaa_crypto > > due to a divide by zero in rebalance_wq_table. The problem is that > > the > > kdump kernel comes up with a single cpu, and if there are multiple > > iaa > > devices cpus_per_iaa is going to be calculated to be 0, and then > > the > > 'if ((cpu % cpus_per_iaa) =3D=3D 0)' in rebalance_wq_table results in a > > divide by zero. I reproduced it with the 6.8 eln kernel, and so far > > have reproduced it on GNR, EMR, and SRF systems. I'm assuming the > > same > > will be the case on and SPR system with IAA devices enabled if I > > can > > find one. > >=20 >=20 > Good catch, I've never tested that before. Thanks for reporting it. >=20 > > Should save_iaa_wq return an error if the number of iaa devices is > > greater > > than the number of cpus? > >=20 >=20 > No, you should still be able to use the driver with just one cpu, > maybe > it just always maps to the same device. I'll take a look and come up > with a fix. >=20 > Tom The patch below fixes it for me. It gets rid of the crash and I was able to run some basic tests successfully. Tom=20 From 37dc97831c9e12c103115cb5fc9866b42cad7bc5 Mon Sep 17 00:00:00 2001 From: Tom Zanussi Date: Wed, 20 Mar 2024 05:37:11 -0700 Subject: [PATCH] crypto: iaa - Fix nr_cpus < nr_iaa case If nr_cpus < nr_iaa, the calculated cpus_per_iaa will be 0, which causes a divide-by-0 in rebalance_wq_table(). Make sure cpus_per_iaa is 1 in that case, and also in the nr_iaa =3D=3D 0 case, even though cpus_per_iaa is never used if nr_iaa =3D=3D 0, for paranoia. Reported-by: Jerry Snitselaar Signed-off-by: Tom Zanussi --- drivers/crypto/intel/iaa/iaa_crypto_main.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/crypto/intel/iaa/iaa_crypto_main.c b/drivers/crypto/in= tel/iaa/iaa_crypto_main.c index 1cd304de5388..b2191ade9011 100644 --- a/drivers/crypto/intel/iaa/iaa_crypto_main.c +++ b/drivers/crypto/intel/iaa/iaa_crypto_main.c @@ -806,6 +806,8 @@ static int save_iaa_wq(struct idxd_wq *wq) return -EINVAL; =20 cpus_per_iaa =3D (nr_nodes * nr_cpus_per_node) / nr_iaa; + if (!cpus_per_iaa) + cpus_per_iaa =3D 1; out: return 0; } @@ -821,10 +823,12 @@ static void remove_iaa_wq(struct idxd_wq *wq) } } =20 - if (nr_iaa) + if (nr_iaa) { cpus_per_iaa =3D (nr_nodes * nr_cpus_per_node) / nr_iaa; - else - cpus_per_iaa =3D 0; + if (!cpus_per_iaa) + cpus_per_iaa =3D 1; + } else + cpus_per_iaa =3D 1; } =20 static int wq_table_add_wqs(int iaa, int cpu) --=20 2.34.1