qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Blue Swirl" <blauwirbel@gmail.com>
To: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] SH4: Privilege check for instructions
Date: Mon, 15 Sep 2008 18:19:31 +0300	[thread overview]
Message-ID: <f43fc5580809150819p407a8698t4f1deda042c0c180@mail.gmail.com> (raw)
In-Reply-To: <48CDBC9A.2070504@juno.dti.ne.jp>

On 9/15/08, Shin-ichiro KAWASAKI <kawasaki@juno.dti.ne.jp> wrote:
> Blue Swirl wrote:
>
> > On 9/14/08, Shin-ichiro KAWASAKI <kawasaki@juno.dti.ne.jp> wrote:
> >
> > > Thank you for the comment!
> > >
> > >  Blue Swirl wrote:
> > >
> > >
> > > > On 9/14/08, Shin-ichiro KAWASAKI <kawasaki@juno.dti.ne.jp> wrote:
> > > >
> > > >
> > > > > This patch adds check for all SH4 instructions which are
> > > > >  executed only in privileged mode.
> > > > >
> > > > >
> > > > The checks get the privileged mode status from translation context. In
> > > > theory, the same TB code block could be used in unprivileged and
> > > > privileged mode, so the status that was true at translation time may
> > > > no longer be correct at execution time. Of course normally kernel code
> > > > is not visible or executable to user processes.
> > > >
> > > >
> > >  As you say, this patch has the restriction that you pointed out : the
> > >  generated TB cannot used for both unprivileged and privileged.
> > >
> >
> > Qemu will happily use the same TB for both modes, if the TB flags
> > match (cpu-exec.c):
> >
> >    if (unlikely(!tb || tb->pc != pc || tb->cs_base != cs_base ||
> >                 tb->flags != flags)) {
> >        tb = tb_find_slow(pc, cs_base, flags);
> >    }
> >
>
>  Thanks!  I have not understood this point.  You mean,
>  the main problem is that the one TB can be reused for both modes, and to
> check if new translation for the TB is necessary or not,
>  flags should contain enough information taken from CPU status.

Right.

> > >  I guess the codes generated by tcg_gen_qemu_st/ld() have the same
> > >  restriction, because those tcg_gen functions take the argument QEMU
> memory
> > >  index flags, which is decided at translation time.  If it is true, the
> > >  restriction might be allowed for privilege check.
> > >
> >
> > The loads and stores have the same problem, the generated code assumes
> > that the privilege mode stays the same as what it was during
> > translation.
> >
>
>  And the other problem is that loads/stores instructions (and privilege
>  instructions), cannot follow some CPU status changes within one TB.
>  This problem will be left considering the trade off with performance.

The loads/stores will use the ctx->memidx, but that's fine as long as
ctx->memidx is accurate. To ensure this, the supervisor/user bits of
the CPU status may not change during the TB, all instructions that
write to those bits must end the TB. Maybe the other instructions are
fine, but how about  'rte'?

  parent reply	other threads:[~2008-09-15 15:19 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-09-14  4:04 [Qemu-devel] [PATCH] SH4: Privilege check for instructions Shin-ichiro KAWASAKI
2008-09-14  6:34 ` Blue Swirl
2008-09-14 10:27   ` Shin-ichiro KAWASAKI
2008-09-14 11:26     ` Blue Swirl
2008-09-15  1:38       ` Shin-ichiro KAWASAKI
2008-09-15  8:49         ` Aurelien Jarno
2008-09-15 15:19         ` Blue Swirl [this message]
2008-09-16 16:44           ` Shin-ichiro KAWASAKI
2008-09-16 18:19             ` Blue Swirl
2008-09-17  1:20               ` Shin-ichiro KAWASAKI
2008-09-17 14:42             ` Paul Mundt

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=f43fc5580809150819p407a8698t4f1deda042c0c180@mail.gmail.com \
    --to=blauwirbel@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).