qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Montesel <1809144@bugs.launchpad.net>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [Bug 1809144] [NEW] SVM instructions fail with SVME bit enabled
Date: Wed, 19 Dec 2018 17:31:26 -0000	[thread overview]
Message-ID: <154524068665.20249.14759163527388138129.malonedeb@wampee.canonical.com> (raw)

Public bug reported:

I was trying to use QEMU/TCG to emulate some stuff that uses SVM.
I know SVM is only partially implemented but I gave it a try anyway.

I found that if SVM is enabled in the same basic block in which there's a call to VMSAVE/etc,
the call fails as illegal op because the flags don't get updated correctly.

The pseudocode for the asm I'm running is:

```
EFER |= SVME; set the appropriate bit with wrmsr
vmsave
```

This is an example of the relevant translate.c code:

```
            if (!(s->flags & HF_SVME_MASK) || !s->pe) {
                goto illegal_op;
            }
            if (s->cpl != 0) {
                gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
                break;
            }
```

s->flags doesn't get updated after the wrmsr instruction and so QEMU
raises an illegal opcode interrupt.

A quick fix is to make the tb end after `wrmsr` instructions, but it's an hack afaik.
I'm not too comfortable with QEMU's code, so I don't know what a proper fix would be.

Cheers,

thebabush

** Affects: qemu
     Importance: Undecided
         Status: New

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1809144

Title:
  SVM instructions fail with SVME bit enabled

Status in QEMU:
  New

Bug description:
  I was trying to use QEMU/TCG to emulate some stuff that uses SVM.
  I know SVM is only partially implemented but I gave it a try anyway.

  I found that if SVM is enabled in the same basic block in which there's a call to VMSAVE/etc,
  the call fails as illegal op because the flags don't get updated correctly.

  The pseudocode for the asm I'm running is:

  ```
  EFER |= SVME; set the appropriate bit with wrmsr
  vmsave
  ```

  This is an example of the relevant translate.c code:

  ```
              if (!(s->flags & HF_SVME_MASK) || !s->pe) {
                  goto illegal_op;
              }
              if (s->cpl != 0) {
                  gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base);
                  break;
              }
  ```

  s->flags doesn't get updated after the wrmsr instruction and so QEMU
  raises an illegal opcode interrupt.

  A quick fix is to make the tb end after `wrmsr` instructions, but it's an hack afaik.
  I'm not too comfortable with QEMU's code, so I don't know what a proper fix would be.

  Cheers,

  thebabush

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1809144/+subscriptions

             reply	other threads:[~2018-12-19 17:41 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-19 17:31 Paolo Montesel [this message]
2018-12-19 18:14 ` [Qemu-devel] [Bug 1809144] [NEW] SVM instructions fail with SVME bit enabled Richard Henderson
2021-04-20  7:57 ` [Bug 1809144] " Thomas Huth
2021-06-20  4:17 ` Launchpad Bug Tracker

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=154524068665.20249.14759163527388138129.malonedeb@wampee.canonical.com \
    --to=1809144@bugs.launchpad.net \
    --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).