qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Andriy Gapon <avg@FreeBSD.org>
To: Gleb Natapov <gleb@redhat.com>
Cc: "Andreas Färber" <afaerber@suse.de>, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] in_asm substitute for accel=kvm:tcg
Date: Thu, 19 Sep 2013 17:36:16 +0300	[thread overview]
Message-ID: <523B0BE0.90102@FreeBSD.org> (raw)
In-Reply-To: <20130917184954.GA5657@redhat.com>

on 17/09/2013 21:49 Gleb Natapov said the following:
> http://www.linux-kvm.org/page/Tracing

Gleb,

thank you very much!

Here's an interesting snippet from the trace:
 qemu-system-x86-4639  [003] 263925.182731: kvm_entry:            vcpu 0
 qemu-system-x86-4639  [003] 263925.182733: kvm_exit:             reason
IO_INSTRUCTION rip 0x89b1 info 3f60000 0
 qemu-system-x86-4639  [003] 263925.182733: kvm_pio:              pio_write at
0x3f6 size 1 count 1
 qemu-system-x86-4639  [003] 263925.182734: kvm_userspace_exit:   reason
KVM_EXIT_IO (2)
 qemu-system-x86-4639  [003] 263925.182736: kvm_entry:            vcpu 0
 qemu-system-x86-4639  [003] 263925.182738: kvm_exit:             reason
EXCEPTION_NMI rip 0x934e info 0 80000b0d
 qemu-system-x86-4639  [003] 263925.182739: kvm_emulate_insn:     0:934e:0f 01
1e d6 95 (real)
 qemu-system-x86-4639  [003] 263925.182741: kvm_entry:            vcpu 0
 qemu-system-x86-4639  [003] 263925.182742: kvm_exit:             reason
EXCEPTION_NMI rip 0x9353 info 0 80000b0d
 qemu-system-x86-4639  [003] 263925.182743: kvm_emulate_insn:     0:9353:0f 01
16 d0 95 (real)
 qemu-system-x86-4639  [003] 263925.182745: kvm_entry:            vcpu 0
 qemu-system-x86-4639  [003] 263925.182746: kvm_exit:             reason
EXCEPTION_NMI rip 0x9358 info 0 80000b0d
 qemu-system-x86-4639  [003] 263925.182747: kvm_emulate_insn:     0:9358:0f 20
c0 (real)
 qemu-system-x86-4639  [003] 263925.182748: kvm_entry:            vcpu 0
 qemu-system-x86-4639  [003] 263925.182749: kvm_exit:             reason
EXCEPTION_NMI rip 0x935c info 0 80000b0d
 qemu-system-x86-4639  [003] 263925.182750: kvm_emulate_insn:     0:935c:0f 22
c0 (real)
 qemu-system-x86-4639  [003] 263925.182752: kvm_entry:            vcpu 0
CPU:3 [2995 EVENTS DROPPED]
 qemu-system-x86-4639  [003] 263925.188830: kvm_emulate_insn:     0:9315: (real)
 qemu-system-x86-4639  [003] 263925.188831: kvm_emulate_insn:     0:9315: (real)
 qemu-system-x86-4639  [003] 263925.188831: kvm_emulate_insn:     0:9315: (real)
... ad infinitum

I believe that the following log from unaccelerated qemu corresponds to the last
few instructions:

0x0000000000009346:  cli
0x0000000000009347:  std
0x0000000000009348:  xor    %ax,%ax
0x000000000000934a:  mov    %ax,%ds
0x000000000000934c:  mov    %ax,%es
0x000000000000934e:  lidtw  -0x6a2a
0x0000000000009353:  lgdtw  -0x6a30
0x0000000000009358:  mov    %cr0,%eax
0x000000000000935b:  inc    %ax
0x000000000000935c:  mov    %eax,%cr0
----------------
IN:
0x000000000000935f:  ljmp   $0x8,$0x9364

That is, 0x935c seems to be the last meaningful ip and the instruction seems to
be enabling protected mode.  Not sure how the code ends up at 0x9315 after that.


And here is original assembly code:
rret_tramp:     movw $MEM_ESPR-0x08,%sp         # Reset stack pointer
                pushal                          # Save gp regs
                pushl %gs                       # Save
                pushl %fs                       #  seg
                pushl %ds                       #  regs
                pushl %es
                pushfl                          # Save %eflags
                cli                             # Disable interrupts
                std                             # String ops dec
                xorw %ax,%ax                    # Reset seg
                movw %ax,%ds                    #  regs
                movw %ax,%es                    #  (%ss is already 0)
                lidt idtdesc                    # Set IDT
                lgdt gdtdesc                    # Set GDT
                mov %cr0,%eax                   # Switch to protected
                inc %ax                         #  mode
                mov %eax,%cr0                   #
                ljmp $SEL_SCODE,$rret_tramp.1   # To 32-bit code
                .code32
rret_tramp.1:   xorl %ecx,%ecx                  # Zero
                movb $SEL_SDATA,%cl             # Setup
                movw %cx,%ss                    #  32-bit
                movw %cx,%ds                    #  seg
                movw %cx,%es                    #  regs
                movl MEM_ESPR-0x04,%esp         # Switch to kernel stack
                leal 0x44(%esp,1),%esi          # Base of frame
                andb $~0x2,tss_desc+0x5         # Clear TSS busy
                movb $SEL_TSS,%cl               # Set task
                ltr %cx                         #  register

I can provide full logs, etc.
Please let me know what else I could do.
Thanks!
-- 
Andriy Gapon

  reply	other threads:[~2013-09-19 14:37 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-17 11:37 [Qemu-devel] in_asm substitute for accel=kvm:tcg Andriy Gapon
2013-09-17 12:32 ` Andreas Färber
2013-09-17 14:33   ` Andriy Gapon
2013-09-17 18:49     ` Gleb Natapov
2013-09-19 14:36       ` Andriy Gapon [this message]
2013-09-19 16:53         ` Paolo Bonzini
2013-09-19 17:18           ` Andriy Gapon
2013-09-19 17:26             ` Paolo Bonzini
2013-09-19 18:05               ` Andriy Gapon
2013-09-19 17:49           ` Andriy Gapon
2013-09-22  6:31             ` Gleb Natapov
2013-09-22  8:05               ` Andriy Gapon
2013-09-22  8:17                 ` Gleb Natapov
2013-09-22  9:41                   ` Andriy Gapon

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=523B0BE0.90102@FreeBSD.org \
    --to=avg@freebsd.org \
    --cc=afaerber@suse.de \
    --cc=gleb@redhat.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).