All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sebastian Macke <sebastian@macke.de>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: openrisc@lists.openrisc.net, openrisc@lists.opencores.org,
	QEMU Developers <qemu-devel@nongnu.org>,
	Ethan Hunt <proljc@gmail.com>
Subject: Re: [Qemu-devel] [PATCH 05/13] target-openrisc: Remove TLB flush on exception
Date: Tue, 29 Oct 2013 15:41:30 -0700	[thread overview]
Message-ID: <5270399A.1080907@macke.de> (raw)
In-Reply-To: <CAFEAcA8Xzqz2b=GHc25W-GLkhcJ3SmTA_d2Hxu40855q094t4Q@mail.gmail.com>

On 29/10/2013 12:47 PM, Peter Maydell wrote:
> On 29 October 2013 19:04, Sebastian Macke <sebastian@macke.de> wrote:
>> The TLB flush is not necessary as the mmu_index field
>> already takes care of correct memory locations.
>> Instead the tb flag field must be expanded that
>> the exception takes the correct translation block.
>>
>> Signed-off-by: Sebastian Macke <sebastian@macke.de>
>> ---
>>   target-openrisc/cpu.h       | 4 ++--
>>   target-openrisc/interrupt.c | 4 ----
>>   2 files changed, 2 insertions(+), 6 deletions(-)
>>
>> diff --git a/target-openrisc/cpu.h b/target-openrisc/cpu.h
>> index 24afe6f..057821d 100644
>> --- a/target-openrisc/cpu.h
>> +++ b/target-openrisc/cpu.h
>> @@ -85,7 +85,7 @@ enum {
>>   #define SPR_VR 0xFFFF003F
>>
>>   /* Internal flags, delay slot flag */
>> -#define D_FLAG    1
>> +#define D_FLAG    2
> Since this set of #defines effectively is the documentation for
> what the tb_flags usage is, can you update it to include the
> new flag you've added, please?

I will. I think I have done it in one of the later patches.
But the D_FLAG was there before. What I did was just changing it to 2 
because 1 is used by the new SR_SM
(supervisor mode) Flag.


>>   /* Interrupt */
>>   #define NR_IRQS  32
>> @@ -412,7 +412,7 @@ static inline void cpu_get_tb_cpu_state(CPUOpenRISCState *env,
>>       *pc = env->pc;
>>       *cs_base = 0;
>>       /* D_FLAG -- branch instruction exception */
>> -    *flags = (env->flags & D_FLAG);
>> +    *flags = (env->flags & D_FLAG) | (env->sr & SR_SM);
>>   }
>>
>>   static inline int cpu_mmu_index(CPUOpenRISCState *env)
>> diff --git a/target-openrisc/interrupt.c b/target-openrisc/interrupt.c
>> index d1d6ae2..ee98ed3 100644
>> --- a/target-openrisc/interrupt.c
>> +++ b/target-openrisc/interrupt.c
>> @@ -41,10 +41,6 @@ void openrisc_cpu_do_interrupt(CPUState *cs)
>>           env->epcr += 4;
>>       }
>>
>> -    /* For machine-state changed between user-mode and supervisor mode,
>> -       we need flush TLB when we enter&exit EXCP.  */
>> -    tlb_flush(env, 1);
>> -
>>       env->esr = ENV_GET_SR(env);
>>       env->sr &= ~SR_DME;
>>       env->sr &= ~SR_IME;
> It looks suspicious that this patch doesn't include any change to
> translate.c which reads the tb flag you've just added. Either:
>   (a) the translated code doesn't actually build in any dependencies
>    on the SR_SM flag, in which case it doesn't need to be a tb_flag at all
>   (b) the translated code is still referring directly to env->sr somewhere,
>    in which case it needs to be changed to use the tb_flags version instead
>
> Also, are you sure that tlb_flush() is needed purely for the change to the
> SR_SM flags and not for any of the other CPU state changes that
> openrisc_cpu_do_interrupt() is making when it does the user->supervisor
> state change?
>
> thanks
> -- PMM

The exception is going into supervisor mode and disables the mmu. The 
mmu_index is changed and it should work.
But then the emulated Linux crashes.
This does not happen when I add the supervisor mode flag to the tb_flags.

I was also a little bit confused when I implemented it. But I don't know 
the internals of QEMU as good as you. And some other targets
doing it the same way I think.

What is included in the tb hash? The virtual pc + physical page + the 
tb_flags? Not the mmu_index?

  reply	other threads:[~2013-10-29 22:41 UTC|newest]

Thread overview: 48+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-29 19:04 [Qemu-devel] [PATCH 00/13] target-openrisc: More optimizations and corrections Sebastian Macke
2013-10-29 19:04 ` [Qemu-devel] [PATCH 01/13] target-openrisc: Implement translation block chaining Sebastian Macke
2013-10-29 19:04 ` [Qemu-devel] [PATCH 02/13] target-openrisc: Separate Delayed slot handling from main loop Sebastian Macke
2013-10-29 19:04 ` [Qemu-devel] [PATCH 03/13] target-openrisc: Separate of load/store instructions Sebastian Macke
2013-10-29 20:05   ` Max Filippov
2013-10-29 21:36     ` Sebastian Macke
2013-10-29 21:49       ` Richard Henderson
2013-10-29 22:55       ` Max Filippov
2013-10-29 23:37         ` Sebastian Macke
2013-10-29 19:04 ` [Qemu-devel] [PATCH 04/13] target-openrisc: sync flags only when necessary Sebastian Macke
2013-10-29 21:51   ` Richard Henderson
2013-10-29 19:04 ` [Qemu-devel] [PATCH 05/13] target-openrisc: Remove TLB flush on exception Sebastian Macke
2013-10-29 19:47   ` Peter Maydell
2013-10-29 22:41     ` Sebastian Macke [this message]
2013-11-01 18:58       ` Peter Maydell
2013-11-02  1:21         ` Richard Henderson
2013-11-06 22:59           ` [Qemu-devel] [Openrisc] " Edgar E. Iglesias
2013-11-02  1:29       ` [Qemu-devel] " Richard Henderson
2013-10-29 19:04 ` [Qemu-devel] [PATCH 06/13] target-openrisc: Remove TLB flush from l.rfe instruction Sebastian Macke
2013-10-29 21:01   ` Max Filippov
2013-10-29 21:53     ` Sebastian Macke
2013-10-29 22:20       ` Max Filippov
2013-10-29 23:14         ` Sebastian Macke
2013-10-29 19:04 ` [Qemu-devel] [PATCH 07/13] target-openrisc: Correct l.cmov conditional check Sebastian Macke
2013-10-29 21:15   ` Max Filippov
2013-10-29 21:23     ` Sebastian Macke
2013-10-29 19:04 ` [Qemu-devel] [PATCH 08/13] target-openrisc: Test for Overflow exception statically Sebastian Macke
2013-10-29 21:25   ` Max Filippov
2013-10-29 22:06     ` Sebastian Macke
2013-10-29 19:04 ` [Qemu-devel] [PATCH 09/13] target-openrisc: Add CPU which neglects Carry and Overflow Flag Sebastian Macke
2013-10-30 18:14   ` Richard Henderson
2013-10-30 19:22     ` Sebastian Macke
2013-10-30 19:31       ` Richard Henderson
2013-10-29 19:04 ` [Qemu-devel] [PATCH 10/13] target-openrisc: Correct target number for 64 bit llseek Sebastian Macke
2013-10-29 19:04 ` [Qemu-devel] [PATCH 11/13] target-openrisc: use jmp_pc as flag variable for branches Sebastian Macke
2013-10-30 18:33   ` Richard Henderson
2013-10-30 19:07     ` Sebastian Macke
2013-10-30 19:32       ` Richard Henderson
2013-10-30 19:47       ` Richard Henderson
2013-10-30 21:08         ` Sebastian Macke
2013-10-30 22:02           ` Richard Henderson
2013-10-31  0:29             ` Sebastian Macke
2013-10-29 19:04 ` [Qemu-devel] [PATCH 12/13] target-openrisc: Add correct gdb information for the pc value Sebastian Macke
2013-10-29 19:04 ` [Qemu-devel] [PATCH 13/13] target-openrisc: Add In-circuit emulator support Sebastian Macke
2013-10-29 19:53 ` [Qemu-devel] [PATCH 00/13] target-openrisc: More optimizations and corrections Peter Maydell
2013-10-29 21:15 ` Max Filippov
2013-10-29 21:22   ` Sebastian Macke
2013-10-31 11:47     ` Jia Liu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5270399A.1080907@macke.de \
    --to=sebastian@macke.de \
    --cc=openrisc@lists.opencores.org \
    --cc=openrisc@lists.openrisc.net \
    --cc=peter.maydell@linaro.org \
    --cc=proljc@gmail.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.