From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759148AbcEFXnU (ORCPT ); Fri, 6 May 2016 19:43:20 -0400 Received: from mga01.intel.com ([192.55.52.88]:44064 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758844AbcEFXnT (ORCPT ); Fri, 6 May 2016 19:43:19 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.24,588,1455004800"; d="asc'?scan'208";a="974416895" From: "Rustad, Mark D" To: Denys Vlasenko CC: "Kirsher, Jeffrey T" , "intel-wired-lan@lists.osuosl.org" , LKML , "netdev@vger.kernel.org" Subject: Re: [Intel-wired-lan] [PATCH] e1000e: prevent division by zero if TIMINCA is zero Thread-Topic: [Intel-wired-lan] [PATCH] e1000e: prevent division by zero if TIMINCA is zero Thread-Index: AQHRp89jLx9wBADjd0+y3pIbNhe9QJ+tB9kA Date: Fri, 6 May 2016 23:43:17 +0000 Message-ID: <5E18E4A4-E10F-46B5-A2F5-FCA10FAA5030@intel.com> References: <1462563711-30350-1-git-send-email-dvlasenk@redhat.com> In-Reply-To: <1462563711-30350-1-git-send-email-dvlasenk@redhat.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: yes X-MS-TNEF-Correlator: x-originating-ip: [134.134.3.165] Content-Type: multipart/signed; boundary="Apple-Mail=_61D6A58B-1F97-4278-A1A2-C2126EAE927C"; protocol="application/pgp-signature"; micalg=pgp-sha256 MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --Apple-Mail=_61D6A58B-1F97-4278-A1A2-C2126EAE927C Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=us-ascii; delsp=yes; format=flowed Denys Vlasenko wrote: > Users report that under VMWare, er32(TIMINCA) returns zero. > This causes division by zero at init time as follows: > > ==> incvalue = er32(TIMINCA) & E1000_TIMINCA_INCVALUE_MASK; > for (i = 0; i < E1000_MAX_82574_SYSTIM_REREADS; i++) { > /* latch SYSTIMH on read of SYSTIML */ > systim_next = (cycle_t)er32(SYSTIML); > systim_next |= (cycle_t)er32(SYSTIMH) << 32; > > time_delta = systim_next - systim; > temp = time_delta; > ====> rem = do_div(temp, incvalue); > > This change makes kernel survive this, and users report that > NIC does work after this change. > > Since on real hardware incvalue is never zero, this should not affect > real hardware use case. > > Signed-off-by: Denys Vlasenko > CC: Jeff Kirsher > CC: "Ruinskiy, Dima" > CC: intel-wired-lan@lists.osuosl.org > CC: netdev@vger.kernel.org > CC: LKML > --- > drivers/net/ethernet/intel/e1000e/netdev.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/drivers/net/ethernet/intel/e1000e/netdev.c > b/drivers/net/ethernet/intel/e1000e/netdev.c > index 269087c..0626935 100644 > --- a/drivers/net/ethernet/intel/e1000e/netdev.c > +++ b/drivers/net/ethernet/intel/e1000e/netdev.c > @@ -4315,7 +4315,8 @@ static cycle_t e1000e_cyclecounter_read(const > struct cyclecounter *cc) > > time_delta = systim_next - systim; > temp = time_delta; > - rem = do_div(temp, incvalue); > + /* VMWare users have seen incvalue of zero, don't div / 0 */ > + rem = incvalue ? do_div(temp, incvalue) : (time_delta != 0); > > systim = systim_next; > I seem to recall that this was rejected before because it really is VMWare's bug and, if they fix it, any existing VMs that use this will just work. Changing the driver will only fix it for vms that install a new driver. I don't object to doing it, it just seems like not the most effective place to address the issue. -- Mark Rustad, Networking Division, Intel Corporation --Apple-Mail=_61D6A58B-1F97-4278-A1A2-C2126EAE927C Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="signature.asc" Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Message signed with OpenPGP using GPGMail -----BEGIN PGP SIGNATURE----- Comment: GPGTools - http://gpgtools.org iQIcBAEBCAAGBQJXLSwUAAoJEDwO/+eO4+5uGK4P+wZgqR2qumTDUtZAKYUXLTEP aVwfpCEa15AAdgsVMIiJTrPc3o766VFMzsSxVZ5MUTwrJFvjea8qjZomEUyxXGP6 tis+G92t7nDC36D20YZuR5GJtKb/w67NCs7ndD3VkBzyTrkFEL1FIjURhIkjTCGh 1S5JPVnUCKeBxKiPKlxIcz3UHtkQbp98yIdKXQTAQSBHxjfA84dkc29b9nTg5c3H +7TviaC0DaZyggiFoAPFSnGGrMGoRfKaxp3MI62NUPmznaDwzGfnuKUdcr0glcop 9raXRNgyNTDXVF44+z3M+yMTY1TpFdp7PRSwr/KQ7qj5/d9f0z8e1SplBD9YvPvL qan0GRhH298TSIskmK2eK81jibONBjIvx/K31XqqDHLtfh8XSrRwEWEfbiiLvjdy 0JjSY0nnP77rAunkL1P40ypmVQtTy/P/8kZ8KVPwOVdQZW9pgP954+R8YR5qhLjN YHt6dHTlizDAHvJ3T136LGahmnGfhftRr6DIc9y4PXFT+B04+l2zfi6hHlU81lpB fT8Me25TVZAxgOoS8DPe8fDHJB4g22QjjrJoHIUwbzSeQU5zaRAW04gDfCzShUAX 18R7oopOXWvNivrkMHIWoHdvjeQffOXrAjiHNHi6/lHMXAa955jn2rOofWksYwJ2 KiG7GGOa+Zq2Rr69XKSU =VjU6 -----END PGP SIGNATURE----- --Apple-Mail=_61D6A58B-1F97-4278-A1A2-C2126EAE927C--