All of lore.kernel.org
 help / color / mirror / Atom feed
* [KVM]:could anyone give me some instruction for KVM pci driver? Thanks
@ 2011-08-12  8:33 liu pf
  2011-08-17  8:48 ` :could " liu pf
  0 siblings, 1 reply; 4+ messages in thread
From: liu pf @ 2011-08-12  8:33 UTC (permalink / raw)
  To: kvm; +Cc: Avi Kivity, linux-kernel

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

Hi guys,

When I develop a PCI device driver for qemu-kvm, I am suffering from
some problem, Could anyone give me some instruction? Thanks :)

My solution consists of two parts:  emulated PCI device in Qemu and
corresponding PCI device driver in guest OS.
The emulated  device has a PCI -memmap registers. So as expected, when
the guest device driver wrote this area, we will capture such event in
Qemu.
But it failed to do so. After tracing the host kernel, I found that
 1. my guest PCI device driver had claimed the gpa from
pci_dev->resource[0].start=0xf0050000 to resource[0].end=0xf00500ff
and succeed to ioremap
 2. In host kernel,  I added "printk" after
handle_ept_violation(struct kvm_vcpu *vcpu) {gpa
=vmcs_read64(GUEST_PHYSICAL_ADDRESS); printk(..);}
    BUT, when guest wrote this "ioremap" area, the host did NOT hit
the region [0xf0050000,0xf00500ff]


I had thought that when accessing the emulated device, the gva ->gpa
has been set up by guest, so EPT violation will be the only reason
which caused guest exit .  And the event will be finally passed to the
user mode--qemu.  Am I right?

And the most important is what I can do for the next step?

BTW, I am sure that "kvm_enable_tdp". and kernel is 2.6.39, for config
file, pls see attachment.


Thanks,
Pierce

[-- Attachment #2: config.gz --]
[-- Type: application/x-gzip, Size: 24799 bytes --]

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

* Re: :could anyone give me some instruction for KVM pci driver? Thanks
  2011-08-12  8:33 [KVM]:could anyone give me some instruction for KVM pci driver? Thanks liu pf
@ 2011-08-17  8:48 ` liu pf
  2011-08-19  0:52   ` Neo Jia
  0 siblings, 1 reply; 4+ messages in thread
From: liu pf @ 2011-08-17  8:48 UTC (permalink / raw)
  To: kvm

Hi guys,

After objdump the driver, I found that the access to the pci-memmap
register was optimized by GCC, and no code was generated.
And the EPT in 2.6.39 is fine.

Thanks,
Pierce


On Fri, Aug 12, 2011 at 4:33 PM, liu pf <kernelfans@gmail.com> wrote:
> Hi guys,
>
> When I develop a PCI device driver for qemu-kvm, I am suffering from
> some problem, Could anyone give me some instruction? Thanks :)
>
> My solution consists of two parts:  emulated PCI device in Qemu and
> corresponding PCI device driver in guest OS.
> The emulated  device has a PCI -memmap registers. So as expected, when
> the guest device driver wrote this area, we will capture such event in
> Qemu.
> But it failed to do so. After tracing the host kernel, I found that
>  1. my guest PCI device driver had claimed the gpa from
> pci_dev->resource[0].start=0xf0050000 to resource[0].end=0xf00500ff
> and succeed to ioremap
>  2. In host kernel,  I added "printk" after
> handle_ept_violation(struct kvm_vcpu *vcpu) {gpa
> =vmcs_read64(GUEST_PHYSICAL_ADDRESS); printk(..);}
>    BUT, when guest wrote this "ioremap" area, the host did NOT hit
> the region [0xf0050000,0xf00500ff]
>
>
> I had thought that when accessing the emulated device, the gva ->gpa
> has been set up by guest, so EPT violation will be the only reason
> which caused guest exit .  And the event will be finally passed to the
> user mode--qemu.  Am I right?
>
> And the most important is what I can do for the next step?
>
> BTW, I am sure that "kvm_enable_tdp". and kernel is 2.6.39, for config
> file, pls see attachment.
>
>
> Thanks,
> Pierce
>

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

* Re: :could anyone give me some instruction for KVM pci driver? Thanks
  2011-08-17  8:48 ` :could " liu pf
@ 2011-08-19  0:52   ` Neo Jia
  2011-08-19  9:11     ` pingfan liu
  0 siblings, 1 reply; 4+ messages in thread
From: Neo Jia @ 2011-08-19  0:52 UTC (permalink / raw)
  To: liu pf; +Cc: kvm

On Wed, Aug 17, 2011 at 04:48:52PM +0800, liu pf wrote:
> Hi guys,
> 
> After objdump the driver, I found that the access to the pci-memmap
> register was optimized by GCC, and no code was generated.
> And the EPT in 2.6.39 is fine.

Are you registering a callback function for the register range you are going to
monitor on QEMU? You will see a VM_EXIT, which then trigger a mmio access from
KVM.

Thanks,
CJ

> 
> Thanks,
> Pierce
> 
> 
> On Fri, Aug 12, 2011 at 4:33 PM, liu pf <kernelfans@gmail.com> wrote:
> > Hi guys,
> >
> > When I develop a PCI device driver for qemu-kvm, I am suffering from
> > some problem, Could anyone give me some instruction? Thanks :)
> >
> > My solution consists of two parts:  emulated PCI device in Qemu and
> > corresponding PCI device driver in guest OS.
> > The emulated  device has a PCI -memmap registers. So as expected, when
> > the guest device driver wrote this area, we will capture such event in
> > Qemu.
> > But it failed to do so. After tracing the host kernel, I found that
> >  1. my guest PCI device driver had claimed the gpa from
> > pci_dev->resource[0].start=0xf0050000 to resource[0].end=0xf00500ff
> > and succeed to ioremap
> >  2. In host kernel,  I added "printk" after
> > handle_ept_violation(struct kvm_vcpu *vcpu) {gpa
> > =vmcs_read64(GUEST_PHYSICAL_ADDRESS); printk(..);}
> >    BUT, when guest wrote this "ioremap" area, the host did NOT hit
> > the region [0xf0050000,0xf00500ff]
> >
> >
> > I had thought that when accessing the emulated device, the gva ->gpa
> > has been set up by guest, so EPT violation will be the only reason
> > which caused guest exit .  And the event will be finally passed to the
> > user mode--qemu.  Am I right?
> >
> > And the most important is what I can do for the next step?
> >
> > BTW, I am sure that "kvm_enable_tdp". and kernel is 2.6.39, for config
> > file, pls see attachment.
> >
> >
> > Thanks,
> > Pierce
> >
> --
> To unsubscribe from this list: send the line "unsubscribe kvm" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: :could anyone give me some instruction for KVM pci driver? Thanks
  2011-08-19  0:52   ` Neo Jia
@ 2011-08-19  9:11     ` pingfan liu
  0 siblings, 0 replies; 4+ messages in thread
From: pingfan liu @ 2011-08-19  9:11 UTC (permalink / raw)
  To: Neo Jia; +Cc: kvm

Hi Neo,

Thanks for you reply. You are right.
But I had found the problem and update this thread :)

Thanks,
Pierce

On Fri, Aug 19, 2011 at 8:52 AM, Neo Jia <cyclonusj@gmail.com> wrote:
> On Wed, Aug 17, 2011 at 04:48:52PM +0800, liu pf wrote:
>> Hi guys,
>>
>> After objdump the driver, I found that the access to the pci-memmap
>> register was optimized by GCC, and no code was generated.
>> And the EPT in 2.6.39 is fine.
>
> Are you registering a callback function for the register range you are going to
> monitor on QEMU? You will see a VM_EXIT, which then trigger a mmio access from
> KVM.
>
> Thanks,
> CJ
>
>>
>> Thanks,
>> Pierce
>>
>>
>> On Fri, Aug 12, 2011 at 4:33 PM, liu pf <kernelfans@gmail.com> wrote:
>> > Hi guys,
>> >
>> > When I develop a PCI device driver for qemu-kvm, I am suffering from
>> > some problem, Could anyone give me some instruction? Thanks :)
>> >
>> > My solution consists of two parts:  emulated PCI device in Qemu and
>> > corresponding PCI device driver in guest OS.
>> > The emulated  device has a PCI -memmap registers. So as expected, when
>> > the guest device driver wrote this area, we will capture such event in
>> > Qemu.
>> > But it failed to do so. After tracing the host kernel, I found that
>> >  1. my guest PCI device driver had claimed the gpa from
>> > pci_dev->resource[0].start=0xf0050000 to resource[0].end=0xf00500ff
>> > and succeed to ioremap
>> >  2. In host kernel,  I added "printk" after
>> > handle_ept_violation(struct kvm_vcpu *vcpu) {gpa
>> > =vmcs_read64(GUEST_PHYSICAL_ADDRESS); printk(..);}
>> >    BUT, when guest wrote this "ioremap" area, the host did NOT hit
>> > the region [0xf0050000,0xf00500ff]
>> >
>> >
>> > I had thought that when accessing the emulated device, the gva ->gpa
>> > has been set up by guest, so EPT violation will be the only reason
>> > which caused guest exit .  And the event will be finally passed to the
>> > user mode--qemu.  Am I right?
>> >
>> > And the most important is what I can do for the next step?
>> >
>> > BTW, I am sure that "kvm_enable_tdp". and kernel is 2.6.39, for config
>> > file, pls see attachment.
>> >
>> >
>> > Thanks,
>> > Pierce
>> >
>> --
>> To unsubscribe from this list: send the line "unsubscribe kvm" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>

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

end of thread, other threads:[~2011-08-19  9:11 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-08-12  8:33 [KVM]:could anyone give me some instruction for KVM pci driver? Thanks liu pf
2011-08-17  8:48 ` :could " liu pf
2011-08-19  0:52   ` Neo Jia
2011-08-19  9:11     ` pingfan liu

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.