From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35208) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VbIqa-0002Jk-I4 for qemu-devel@nongnu.org; Tue, 29 Oct 2013 19:37:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VbIqU-0007ma-D4 for qemu-devel@nongnu.org; Tue, 29 Oct 2013 19:37:16 -0400 Received: from www11.your-server.de ([213.133.104.11]:53321) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VbIqU-0007mR-6s for qemu-devel@nongnu.org; Tue, 29 Oct 2013 19:37:10 -0400 Message-ID: <527046A1.5020204@macke.de> Date: Tue, 29 Oct 2013 16:37:05 -0700 From: Sebastian Macke MIME-Version: 1.0 References: <1383073495-5332-1-git-send-email-sebastian@macke.de> <1383073495-5332-4-git-send-email-sebastian@macke.de> <52702A72.8040705@macke.de> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 03/13] target-openrisc: Separate of load/store instructions List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Max Filippov Cc: openrisc@lists.openrisc.net, openrisc@lists.opencores.org, qemu-devel , Ethan Hunt On 29/10/2013 3:55 PM, Max Filippov wrote: > On Wed, Oct 30, 2013 at 1:36 AM, Sebastian Macke wrote: >> On 29/10/2013 1:05 PM, Max Filippov wrote: >>> On Tue, Oct 29, 2013 at 11:04 PM, Sebastian Macke >>> wrote: >>>> Additional this patch solves a severe bug for the softmmu emulation. >>>> The pc has to be saved as these instructions can fail and lead >>>> to a tlb miss exception. >>> In case of an exception we re-translate the TB to find the PC where >>> the exception happened, see cpu_restore_state call from the tlb_fill >>> function. Also this applies to both user and system emulation, but >>> you only handle the system emulation case. >> The problem is the epcr register in the interrupt routine in which the >> current pc must be saved. >> Of course in the user emulation case the interrupt handler is never >> executed. >> >> When is the pc of the fault determined? Before or after the interrupt >> handler? > Before, in the tlb_fill: cpu_restore_state is called to restore context, > and after that cpu_loop_exit is called to handle the exception. Ok, but then my line should be useless and the pc value should be immediately overwritten when the we get an OpenRISC TLB miss. This is definitely not the case. If I remove it I get random kernel crashes. So there is anything else wrong. Maybe the curent MMU code directly executes the exception handler. So QEMU has no chance in interfering and can't give me the correct pc. Maybe I will have to restore the context myself. >> Finding this problem gave me a long headache. But it would be nice if there >> is a better solution.