All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] Question of emulation on MSR's in KVM-mode
@ 2014-08-04  8:37 Morty Andersen
  2014-08-04 12:22 ` Paolo Bonzini
  0 siblings, 1 reply; 3+ messages in thread
From: Morty Andersen @ 2014-08-04  8:37 UTC (permalink / raw)
  To: qemu-devel

[-- Attachment #1: Type: text/plain, Size: 1105 bytes --]

Hi

I'm working on an extension to QEMU (target i386). This involves adding new
MSR's. I've got it working in non-KVM mode by adding these MSR's to the
state and adding extra cases to helper_wrmsr(), helper_rdmsr(). The guest
can now read/write these MSR's as expected. However, it fails when running
in KVM-mode. Specifically, writing the MSR's causes GPF. Note that these
MSR's are not natively supported by the host CPU. I don't know enough about
Intel's VMX to tell if it is even reasonable to expect that this could work
for a non-natively supported MSR. As far as I can read in the VMX
documentation, the hypervisor can setup a bitmap of which MSR's should
cause trap's to the hypervisor and which shouldn't. I guess it would be the
KVM kernel module that does this based on input it receives from QEMU. But
I haven't been able to find the part of QEMU that negotiates this. I guess
the solution for me is to set the necessary bits to that access to the new
MSR's causes traps. Next, I need to add/modify the trap handler so that it
can handle the MSR's.

I would much appreciate any help.

Thanks!

[-- Attachment #2: Type: text/html, Size: 1277 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] Question of emulation on MSR's in KVM-mode
  2014-08-04  8:37 [Qemu-devel] Question of emulation on MSR's in KVM-mode Morty Andersen
@ 2014-08-04 12:22 ` Paolo Bonzini
  2014-08-04 15:52   ` Morty Andersen
  0 siblings, 1 reply; 3+ messages in thread
From: Paolo Bonzini @ 2014-08-04 12:22 UTC (permalink / raw)
  To: Morty Andersen, qemu-devel

Il 04/08/2014 10:37, Morty Andersen ha scritto:
> Hi
> 
> I'm working on an extension to QEMU (target i386). This involves adding
> new MSR's. I've got it working in non-KVM mode by adding these MSR's to
> the state and adding extra cases to helper_wrmsr(), helper_rdmsr(). The
> guest can now read/write these MSR's as expected. However, it fails when
> running in KVM-mode. Specifically, writing the MSR's causes GPF. Note
> that these MSR's are not natively supported by the host CPU. I don't
> know enough about Intel's VMX to tell if it is even reasonable to expect
> that this could work for a non-natively supported MSR. As far as I can
> read in the VMX documentation, the hypervisor can setup a bitmap of
> which MSR's should cause trap's to the hypervisor and which shouldn't. I
> guess it would be the KVM kernel module that does this based on input it
> receives from QEMU. But I haven't been able to find the part of QEMU
> that negotiates this. I guess the solution for me is to set the
> necessary bits to that access to the new MSR's causes traps. Next, I
> need to add/modify the trap handler so that it can handle the MSR's.

Hi,

handling of the MSRs in KVM is done entirely in the hypervisor.  QEMU
only gets/sets them in order to support migration.  You need to modify
the KVM kernel module for the VM to recognize your special MSRs.

Paolo

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] Question of emulation on MSR's in KVM-mode
  2014-08-04 12:22 ` Paolo Bonzini
@ 2014-08-04 15:52   ` Morty Andersen
  0 siblings, 0 replies; 3+ messages in thread
From: Morty Andersen @ 2014-08-04 15:52 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: qemu-devel

[-- Attachment #1: Type: text/plain, Size: 1902 bytes --]

OK, thanks for the reply. In that case I think I will just forego KVM
support and base it 100% around QEMU itself. I also fear I could run into
other problems along the same lines, including possibly unsolvable problems
since it is not given that the underlying virtualization technology (i.e.
VMX) would support all the extensions I'm making, given its purpose is to
provide a faithful emulation of the host architecture.


2014-08-04 14:22 GMT+02:00 Paolo Bonzini <pbonzini@redhat.com>:

> Il 04/08/2014 10:37, Morty Andersen ha scritto:
> > Hi
> >
> > I'm working on an extension to QEMU (target i386). This involves adding
> > new MSR's. I've got it working in non-KVM mode by adding these MSR's to
> > the state and adding extra cases to helper_wrmsr(), helper_rdmsr(). The
> > guest can now read/write these MSR's as expected. However, it fails when
> > running in KVM-mode. Specifically, writing the MSR's causes GPF. Note
> > that these MSR's are not natively supported by the host CPU. I don't
> > know enough about Intel's VMX to tell if it is even reasonable to expect
> > that this could work for a non-natively supported MSR. As far as I can
> > read in the VMX documentation, the hypervisor can setup a bitmap of
> > which MSR's should cause trap's to the hypervisor and which shouldn't. I
> > guess it would be the KVM kernel module that does this based on input it
> > receives from QEMU. But I haven't been able to find the part of QEMU
> > that negotiates this. I guess the solution for me is to set the
> > necessary bits to that access to the new MSR's causes traps. Next, I
> > need to add/modify the trap handler so that it can handle the MSR's.
>
> Hi,
>
> handling of the MSRs in KVM is done entirely in the hypervisor.  QEMU
> only gets/sets them in order to support migration.  You need to modify
> the KVM kernel module for the VM to recognize your special MSRs.
>
> Paolo
>

[-- Attachment #2: Type: text/html, Size: 2489 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-08-04 15:52 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-08-04  8:37 [Qemu-devel] Question of emulation on MSR's in KVM-mode Morty Andersen
2014-08-04 12:22 ` Paolo Bonzini
2014-08-04 15:52   ` Morty Andersen

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.