Received: from eggs.gnu.org ([2001:4830:134:3::10]:33170) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c6t7L-0005dF-L6 for qemu-devel@nongnu.org; Wed, 16 Nov 2016 00:50:44 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c6t7H-0004hE-KR for qemu-devel@nongnu.org; Wed, 16 Nov 2016 00:50:43 -0500 Received: from smtp2-g21.free.fr ([2a01:e0c:1:1599::11]:37784) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1c6t7H-0004dn-6d for qemu-devel@nongnu.org; Wed, 16 Nov 2016 00:50:39 -0500 References: <1476275861-27613-1-git-send-email-ppandit@redhat.com> <33183CC9F5247A488A2544077AF19020B0429759@SZXEMA503-MBS.china.huawei.com> <9d8d6a84-1220-2e61-dbdc-b86d5e348bef@redhat.com> From: =?UTF-8?Q?Herv=c3=a9_Poussineau?= Message-ID: <292d3a97-4dc9-6678-6a4f-acb5856e91f7@reactos.org> Date: Wed, 16 Nov 2016 06:50:17 +0100 MIME-Version: 1.0 In-Reply-To: <9d8d6a84-1220-2e61-dbdc-b86d5e348bef@redhat.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH] dma: rc4030: limit interval timer reload value List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini , "Gonglei (Arei)" , P J P , Qemu Developers Cc: Huawei PSIRT , Prasad J Pandit , "Michael S. Tsirkin" , Aurelien Jarno Hi, Le 10/11/2016 =E0 15:50, Paolo Bonzini a =E9crit : > > > On 10/11/2016 06:56, Gonglei (Arei) wrote: >> Any ideas about this fix? > > It seems sensible, but perhaps the field is even smaller. Let's CC > Herv=E9 and Aurelien as I don't have a datasheet for this device. Sorry for the delay... I don't have any datasheet for this device either, so I tested with real = programs. Those initialize itr field to either 0 or to 9, so your mask doesn't chan= ge anything. Tested-by: Herv=E9 Poussineau > > Also, s->itr is used here: > > tm_hz =3D 1000 / (s->itr + 1); > > timer_mod(s->periodic_timer, qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) = + > NANOSECONDS_PER_SECOND / tm_hz); > > and this is the same as > > timer_mod(s->periodic_timer, qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) = + > NANOSECONDS_PER_SECOND / 1000 * (s->itr + 1)); > > so perhaps it's better to do it like that. > > Paolo > >>> -----Original Message----- >>> From: Qemu-devel >>> [mailto:qemu-devel-bounces+arei.gonglei=3Dhuawei.com@nongnu.org] On >>> Behalf Of P J P >>> Sent: Wednesday, October 12, 2016 8:38 PM >>> To: Qemu Developers >>> Cc: Paolo Bonzini; Huawei PSIRT; Prasad J Pandit; Michael S. Tsirkin >>> Subject: [Qemu-devel] [PATCH] dma: rc4030: limit interval timer reloa= d value >>> >>> From: Prasad J Pandit >>> >>> The JAZZ RC4030 chipset emulator has a periodic timer and >>> associated interval reload register. The reload value is used >>> as divider when computing timer's next tick value. If reload >>> value is large, it could lead to divide by zero error. Limit >>> the interval reload value to avoid it. >>> >>> Reported-by: Huawei PSIRT >>> Signed-off-by: Prasad J Pandit >>> --- >>> hw/dma/rc4030.c | 2 +- >>> 1 file changed, 1 insertion(+), 1 deletion(-) >>> >>> diff --git a/hw/dma/rc4030.c b/hw/dma/rc4030.c >>> index 2f2576f..c1b4997 100644 >>> --- a/hw/dma/rc4030.c >>> +++ b/hw/dma/rc4030.c >>> @@ -460,7 +460,7 @@ static void rc4030_write(void *opaque, hwaddr add= r, >>> uint64_t data, >>> break; >>> /* Interval timer reload */ >>> case 0x0228: >>> - s->itr =3D val; >>> + s->itr =3D val & 0x01FF; >>> qemu_irq_lower(s->timer_irq); >>> set_next_tick(s); >>> break; >>> -- >>> 2.5.5 >>> >> >> >> >