qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Richard Henderson <richard.henderson@linaro.org>
To: Peter Maydell <peter.maydell@linaro.org>, zou xu <iwatchnima@gmail.com>
Cc: QEMU Developers <qemu-devel@nongnu.org>
Subject: Re: [PATCH 1/1] accel/tcg/user-exec: support computing is_write for mips32
Date: Fri, 11 Sep 2020 09:55:59 -0700	[thread overview]
Message-ID: <b384912c-0e62-604d-df0b-b5181c2e7f3d@linaro.org> (raw)
In-Reply-To: <CAFEAcA9ap=c=1XZ6wpphiE=FYtCU+vdNCX8THW-m-hUp_XyGmg@mail.gmail.com>

On 9/11/20 3:41 AM, Peter Maydell wrote:
>> +    /* Detect store by reading the instruction at the program counter. */
>> +    uint32_t insn = *(uint32_t *)pc;
>> +    switch(insn>>29) {
>> +    case 0x5:
>> +        switch((insn>>26) & 0x7) {
> 
> Here we mask to get a 3-bit field...
> 
>> +        case 0x0: /* SB */
>> +        case 0x1: /* SH */
>> +        case 0x2: /* SWL */
>> +        case 0x3: /* SW */
>> +        case 0x4: /* SDL */
>> +        case 0x5: /* SDR */
>> +        case 0x6: /* SWR */
>> +        case 0x7: /* CACHE */
>> +            is_write = 1;
> 
> ...but here all 8 cases are handled identically.
> Is there a typo/logic error here, or should this
> really just be
> 
>     case 0x5:
>         /* SB, SH, SWL, SW, SDL, SDR, SWR, CACHE */
>         is_write = 1;
> 
> ?
> 
> Is CACHE really a write insn ?

Indeed not.  However, it's also illegal for user-mode, so we cannot arrive here
with SIGSEGV by executing it.  So we could ignore that case and not decode this
field.

>> +    case 0x7:
>> +        switch((insn>>26) & 0x7) {
>> +        case 0x0: /* SC */
>> +        case 0x1: /* SWC1 */
>> +        case 0x2: /* SWC2 */
>> +        case 0x4: /* SCD */
>> +        case 0x5: /* SDC1 */
>> +        case 0x6: /* SDC2 */
>> +        case 0x7: /* SD */
>> +            is_write = 1;

Well, the unconditional check of SWC2/SDC2 is not quite right. MIPS64R6 removes
them and replaces them with some compact branches.  That's easy enough to
include here, using

#if !defined(__mips_isa_rev) || __mips_isa_rev < 6
    case 2: /* SWC2 */
    case 6: /* SDC2 */
#endif

We should also add

#if defined(__mips16) || defined(__mips_micromips)
# error "Unsupported encoding"
#endif

I see no upstream compiler support for nanomips at all, so there's no point in
checking for that encoding.  (Indeed, I wonder at the code in target/mips...
how could it be tested?)


r~


  reply	other threads:[~2020-09-11 16:57 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-11  1:12 [PATCH 1/1] accel/tcg/user-exec: support computing is_write for mips32 zou xu
2020-09-11 10:41 ` Peter Maydell
2020-09-11 16:55   ` Richard Henderson [this message]
2020-09-11 17:23     ` Philippe Mathieu-Daudé
2020-11-02 10:00       ` target/mips: Deprecate nanoMIPS ISA? Philippe Mathieu-Daudé
2020-11-02 11:27         ` Philippe Mathieu-Daudé
2020-11-02 16:05         ` Richard Henderson

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=b384912c-0e62-604d-df0b-b5181c2e7f3d@linaro.org \
    --to=richard.henderson@linaro.org \
    --cc=iwatchnima@gmail.com \
    --cc=peter.maydell@linaro.org \
    --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).