From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46296) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ye8Ph-0005a9-7k for qemu-devel@nongnu.org; Fri, 03 Apr 2015 16:42:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ye8Pe-0002Di-1O for qemu-devel@nongnu.org; Fri, 03 Apr 2015 16:42:01 -0400 Received: from mail-qc0-x233.google.com ([2607:f8b0:400d:c01::233]:33706) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ye8Pd-0002Dc-SV for qemu-devel@nongnu.org; Fri, 03 Apr 2015 16:41:57 -0400 Received: by qcrf4 with SMTP id f4so83469102qcr.0 for ; Fri, 03 Apr 2015 13:41:57 -0700 (PDT) Sender: Richard Henderson Message-ID: <551EFB10.3000504@twiddle.net> Date: Fri, 03 Apr 2015 13:41:52 -0700 From: Richard Henderson MIME-Version: 1.0 References: <1427993406-21323-1-git-send-email-heshamelmatary@gmail.com> In-Reply-To: <1427993406-21323-1-git-send-email-heshamelmatary@gmail.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] openrisc: terminate qemu process upon receiving a halt signal. List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Hesham ALMatary , qemu-devel@nongnu.org On 04/02/2015 09:50 AM, Hesham ALMatary wrote: > or1ksim simulator currently handles "l.nop 0xC" instruction as > a halt signal. Do the same for QEMU. > > Signed-off-by: Hesham ALMatary > --- > target-openrisc/translate.c | 5 +++++ > 1 file changed, 5 insertions(+) > > diff --git a/target-openrisc/translate.c b/target-openrisc/translate.c > index dc76789..5fa8ede 100644 > --- a/target-openrisc/translate.c > +++ b/target-openrisc/translate.c > @@ -750,6 +750,11 @@ static void dec_misc(DisasContext *dc, uint32_t insn) > switch (op1) { > case 0x01: /* l.nop */ > LOG_DIS("l.nop %d\n", I16); > + > + if(I16 == 0xC) { > + exit(0); > + } > + Ug. IMO l.nop was a poor choice; l.trap would have been better. But whatever... Further: (1) This is translation time, not execution time. You can't do the exit here, only when the instruction is executed. (2) This, and the other 10 things hidden under l_nop are similar to the "-semihosting" switch available for arm, lm32, m68k, and xtensa. Although semihosting is typically even more complex, generally implementing the exit/read/write/open/close/lseek/stat families of syscalls. r~