From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50296) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aWTmm-0006Fb-Se for qemu-devel@nongnu.org; Thu, 18 Feb 2016 13:58:46 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aWTmh-0007TF-UA for qemu-devel@nongnu.org; Thu, 18 Feb 2016 13:58:44 -0500 Received: from relay1.mentorg.com ([192.94.38.131]:34232) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aWTmh-0007SU-Nq for qemu-devel@nongnu.org; Thu, 18 Feb 2016 13:58:39 -0500 References: <174e5d40f6c59bf57ea997c0575f21b8b67ce5d6.1455739133.git.alistair.francis@xilinx.com> <56C60C10.1070204@mentor.com> From: Hollis Blanchard Message-ID: <56C6145C.7010305@mentor.com> Date: Thu, 18 Feb 2016 10:58:36 -0800 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v1 2/2] generic-loader: Add a generic loader List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Alistair Francis Cc: Peter Maydell , "qemu-devel@nongnu.org Developers" , Peter Crosthwaite , Christopher Covington , Paolo Bonzini , lig.fnst@cn.fujitsu.com On 02/18/2016 10:49 AM, Alistair Francis wrote: > On Thu, Feb 18, 2016 at 10:23 AM, Hollis Blanchard > wrote: >> On 02/17/2016 01:04 PM, Alistair Francis wrote: >>> +static void generic_loader_reset(DeviceState *dev) >>> +{ >>> + GenericLoaderState *s = GENERIC_LOADER(dev); >>> + >>> + if (s->cpu) { >>> + CPUClass *cc = CPU_GET_CLASS(s->cpu); >>> + cpu_reset(s->cpu); >>> + cc->set_pc(s->cpu, s->addr); >>> + } >>> + >>> + if (s->data_len) { >>> + dma_memory_write((s->cpu ? s->cpu : first_cpu)->as, s->addr, >>> &s->data, >>> + s->data_len); >>> + } >>> +} >> >> What happens if I accidentally make "data-len" bigger than sizeof(s->data)? >> I think some bounds checking is needed? > Good point! I'll add an assert as it isn't a recoverable error. Perhaps a more user-friendly error message would be, well, more user-friendly. :-) That could be done when reading the "data-len" property, in addition to an assert when using s->data_len. Hollis Blanchard Mentor Graphics Emulation Division