From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36358) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YRmnt-0007us-B9 for qemu-devel@nongnu.org; Sat, 28 Feb 2015 14:11:58 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YRmnq-0001Tz-4k for qemu-devel@nongnu.org; Sat, 28 Feb 2015 14:11:57 -0500 Received: from out1134-218.mail.aliyun.com ([42.120.134.218]:21973) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YRmnp-0001Sb-Py for qemu-devel@nongnu.org; Sat, 28 Feb 2015 14:11:54 -0500 Message-ID: <54F214C8.20903@sunrus.com.cn> Date: Sun, 01 Mar 2015 03:19:36 +0800 From: Chen Gang S MIME-Version: 1.0 References: <54E9DA4D.1050702@sunrus.com.cn> <54E9DA93.8000507@sunrus.com.cn> <54F0AB3A.9060100@suse.de> In-Reply-To: <54F0AB3A.9060100@suse.de> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Subject: Re: [Qemu-devel] [PATCH 1/6 v4] target-tilegx: Firstly add to qemu with minimized features List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: =?UTF-8?B?QW5kcmVhcyBGw6RyYmVy?= Cc: Peter Maydell , Riku Voipio , qemu-devel , Chris Metcalf , "walt@tilera.com" , "rth@twiddle.net" On 2/28/15 01:36, Andreas Färber wrote: >> +static void tilegx_cpu_class_init(ObjectClass *oc, void *data) >> > +{ >> > + DeviceClass *dc = DEVICE_CLASS(oc); >> > + CPUClass *cc = CPU_CLASS(oc); >> > + TilegxCPUClass *mcc = TILEGX_CPU_CLASS(oc); >> > + >> > + mcc->parent_realize = dc->realize; >> > + dc->realize = tilegx_cpu_realizefn; >> > + >> > + mcc->parent_reset = cc->reset; >> > + cc->reset = tilegx_cpu_reset; >> > + >> > + cc->has_work = tilegx_cpu_has_work; >> > + cc->do_interrupt = tilegx_cpu_do_interrupt; >> > + cc->cpu_exec_interrupt = tilegx_cpu_exec_interrupt; >> > + cc->dump_state = NULL; >> > + cc->set_pc = tilegx_cpu_set_pc; >> > + cc->gdb_read_register = NULL; >> > + cc->gdb_write_register = NULL; > Is this really safe to do? If so, all fields are zero-initialized at > this point already, so no need to assign NULL or 0. > >> > + cc->handle_mmu_fault = tilegx_cpu_handle_mmu_fault; >> > + dc->vmsd = &vmstate_tilegx_cpu; >> > + dc->props = tilegx_properties; >> > + cc->gdb_num_core_regs = 0; >> > +} >> > + When we set gdb_num_core_regs be 0, gdb_read/write_register should not be called, and they assume the callers always pass valid parameters. - For alpha, s390 have considered about the invalid parameter. - arm, i386 and microblaze do not consider about the invalid parameter. For dump_state, the caller will check whether it is NULL, before use it. Thanks. -- Chen Gang Open, share, and attitude like air, water, and life which God blessed