All of lore.kernel.org
 help / color / mirror / Atom feed
From: Gleb Natapov <gleb@redhat.com>
To: "李春奇 <Arthur Chunqi Li>" <yzt356@gmail.com>
Cc: kvm <kvm@vger.kernel.org>, Paolo Bonzini <pbonzini@redhat.com>
Subject: Re: [PATCH 1/2] kvm-unit-tests: Add a func to run instruction in emulator
Date: Sun, 9 Jun 2013 19:00:49 +0300	[thread overview]
Message-ID: <20130609160049.GB29022@redhat.com> (raw)
In-Reply-To: <CABpY8MJvgRixqaRLnP6i=jS9E6OGZwKS-PAMneSqFcU-USA0+w@mail.gmail.com>

On Sun, Jun 09, 2013 at 11:23:26PM +0800, 李春奇 <Arthur Chunqi Li> wrote:
> On Sun, Jun 9, 2013 at 10:09 PM, Gleb Natapov <gleb@redhat.com> wrote:
> > On Sun, Jun 09, 2013 at 09:22:27PM +0800, 李春奇 <Arthur Chunqi Li> wrote:
> >> On Sun, Jun 9, 2013 at 8:49 PM, Gleb Natapov <gleb@redhat.com> wrote:
> >> > On Sun, Jun 09, 2013 at 08:44:32PM +0800, 李春奇 <Arthur Chunqi Li> wrote:
> >> >> On Sun, Jun 9, 2013 at 7:07 PM, Gleb Natapov <gleb@redhat.com> wrote:
> >> >> > On Fri, Jun 07, 2013 at 10:31:38AM +0800, Arthur Chunqi Li wrote:
> >> >> >> Add a function trap_emulator to run an instruction in emulator.
> >> >> >> Set inregs first (%rax, %rsp, %rbp, %rflags have special usage and
> >> >> >> cannot set in inregs), put instruction codec in alt_insn and call
> >> >> >> func with alt_insn_length. Get results in outregs.
> >> >> >>
> >> >> > Why %rax, %rsp, %rbp, %rflags cannot be set in inregs?
> >> >> >
> >> >> > %rax because trapping instruction uses it? Use one that does not use
> >> >> > register at all: MOV r/m32, imm32
> >> >> I don't know why set %rax before call alt_insn_page can cause error. I
> >> >> use "xchg %%rax, 0+%[save]" before "call *%1" and the %rcx is not set
> >> >> correctly.
> >> > We better find this out :)
> >> I found that before calling alt_insn_page, address of "mem" is saved
> >> to %rax, why?
> > Because instruction that we use to trigger vmexit is mov %eax, (%rax) so
> > MMOI address mem is loaded into %rax before jumping into it.
> I think this is why changing %rax will cause error. If we use mov
> %eax, (%rax) to trigger vmexit, and %rax is changed before calling
> alt_insn_page, codes in alt_insn_page will not be executed and return
> directly.
> I changed the codes which trigger vmexit to "mov %eax, (%r8)" and set
> "mem" to %r8 before calling alt_insn_page, it runs OK.
> 
Just use an instruction that does not use registers at all. mov $1, addr
where addr is immediate and encoded from mem parameter.

> Besides, I also don't know if changed %rflags may cause some
> unpredictable actions, so now we just treat it with no error :)
If test sets rflags to a value that causes crashes this is a test bug,
no need to prevent this from happening.

--
			Gleb.

  reply	other threads:[~2013-06-09 16:00 UTC|newest]

Thread overview: 53+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-07  2:31 [PATCH 1/2] kvm-unit-tests: Add a func to run instruction in emulator Arthur Chunqi Li
2013-06-07  2:31 ` [PATCH 2/2] kvm-unit-tests: Change two cases to use trap_emulator Arthur Chunqi Li
2013-06-09 11:07 ` [PATCH 1/2] kvm-unit-tests: Add a func to run instruction in emulator Gleb Natapov
2013-06-09 12:44   ` 李春奇 <Arthur Chunqi Li>
2013-06-09 12:49     ` Gleb Natapov
2013-06-09 12:56       ` 李春奇 <Arthur Chunqi Li>
2013-06-09 12:58         ` Gleb Natapov
2013-06-09 13:22       ` 李春奇 <Arthur Chunqi Li>
2013-06-09 14:09         ` Gleb Natapov
2013-06-09 15:23           ` 李春奇 <Arthur Chunqi Li>
2013-06-09 16:00             ` Gleb Natapov [this message]
2013-06-09 17:09               ` 李春奇 <Arthur Chunqi Li>
2013-06-09 17:13                 ` Gleb Natapov
2013-06-09 17:28                   ` 李春奇 <Arthur Chunqi Li>
2013-06-09 17:39                     ` Gleb Natapov
  -- strict thread matches above, loose matches on Subject: below --
2013-06-20 10:45 Arthur Chunqi Li
2013-06-20 10:47 ` Jan Kiszka
2013-06-20 12:32 ` Gleb Natapov
2013-06-19 15:00 Arthur Chunqi Li
2013-06-19 15:07 ` 李春奇 <Arthur Chunqi Li>
2013-06-19 16:03   ` Gleb Natapov
2013-06-19 17:48     ` Gmail
2013-06-20  5:42       ` Gleb Natapov
2013-06-20  8:29     ` Paolo Bonzini
2013-06-20  8:31       ` Gleb Natapov
2013-06-20  8:48 ` Gleb Natapov
2013-06-20  8:58   ` Gmail
2013-06-13 15:16 Arthur Chunqi Li
2013-06-10 13:38 Arthur Chunqi Li
2013-06-10 17:36 ` Gleb Natapov
2013-06-06 15:24 Arthur Chunqi Li
2013-06-07  2:14 ` 李春奇 <Arthur Chunqi Li>
2013-06-12 20:50 ` Paolo Bonzini
2013-06-13  4:50   ` 李春奇 <Arthur Chunqi Li>
2013-06-13  9:30     ` 李春奇 <Arthur Chunqi Li>
2013-06-13 13:12       ` Paolo Bonzini
2013-06-18 12:45       ` Gleb Natapov
2013-06-18 13:40         ` 李春奇 <Arthur Chunqi Li>
2013-06-18 14:28         ` 李春奇 <Arthur Chunqi Li>
2013-06-18 15:47           ` Gleb Natapov
2013-06-18 15:56             ` 李春奇 <Arthur Chunqi Li>
2013-06-18 16:09               ` Gleb Natapov
2013-06-18 16:14                 ` 李春奇 <Arthur Chunqi Li>
2013-06-18 16:44                   ` Gleb Natapov
2013-06-19  1:26                     ` 李春奇 <Arthur Chunqi Li>
2013-06-19  9:31                       ` Gleb Natapov
2013-06-19 12:18                         ` 李春奇 <Arthur Chunqi Li>
2013-06-19 12:26                           ` Gleb Natapov
2013-06-19 12:30                             ` 李春奇 <Arthur Chunqi Li>
2013-06-19 12:32                               ` Gleb Natapov
2013-06-19 14:01                                 ` 李春奇 <Arthur Chunqi Li>
2013-06-19 14:13                                   ` Gleb Natapov
2013-06-19 14:20                                     ` 李春奇 <Arthur Chunqi Li>

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=20130609160049.GB29022@redhat.com \
    --to=gleb@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=yzt356@gmail.com \
    /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.