From: Sheng Yang <sheng@linux.intel.com>
To: "Michael S. Tsirkin" <mst@redhat.com>
Cc: Avi Kivity <avi@redhat.com>,
Marcelo Tosatti <mtosatti@redhat.com>,
Alex Williamson <alex.williamson@redhat.com>,
kvm@vger.kernel.org
Subject: Re: [PATCH 2/4] KVM: Add kvm_io_ext_data to IO handler
Date: Fri, 25 Feb 2011 11:23:30 +0800 [thread overview]
Message-ID: <201102251123.30662.sheng@linux.intel.com> (raw)
In-Reply-To: <20110224102219.GD6895@redhat.com>
On Thursday 24 February 2011 18:22:19 Michael S. Tsirkin wrote:
> On Thu, Feb 24, 2011 at 05:51:03PM +0800, Sheng Yang wrote:
> > Add a new parameter to IO writing handler, so that we can transfer
> > information from IO handler to caller.
> >
> > Signed-off-by: Sheng Yang <sheng@linux.intel.com>
> > ---
> >
> > arch/x86/kvm/i8254.c | 6 ++++--
> > arch/x86/kvm/i8259.c | 3 ++-
> > arch/x86/kvm/lapic.c | 3 ++-
> > arch/x86/kvm/x86.c | 13 ++++++++-----
> > include/linux/kvm_host.h | 12 ++++++++++--
> > virt/kvm/coalesced_mmio.c | 3 ++-
> > virt/kvm/eventfd.c | 2 +-
> > virt/kvm/ioapic.c | 2 +-
> > virt/kvm/iodev.h | 6 ++++--
> > virt/kvm/kvm_main.c | 4 ++--
> > 10 files changed, 36 insertions(+), 18 deletions(-)
> >
> > diff --git a/arch/x86/kvm/i8254.c b/arch/x86/kvm/i8254.c
> > index efad723..bd8f0c5 100644
> > --- a/arch/x86/kvm/i8254.c
> > +++ b/arch/x86/kvm/i8254.c
> > @@ -439,7 +439,8 @@ static inline int pit_in_range(gpa_t addr)
> >
> > }
> >
> > static int pit_ioport_write(struct kvm_io_device *this,
> >
> > - gpa_t addr, int len, const void *data)
> > + gpa_t addr, int len, const void *data,
> > + struct kvm_io_ext_data *ext_data)
> >
> > {
> >
> > struct kvm_pit *pit = dev_to_pit(this);
> > struct kvm_kpit_state *pit_state = &pit->pit_state;
> >
> > @@ -585,7 +586,8 @@ static int pit_ioport_read(struct kvm_io_device
> > *this,
> >
> > }
> >
> > static int speaker_ioport_write(struct kvm_io_device *this,
> >
> > - gpa_t addr, int len, const void *data)
> > + gpa_t addr, int len, const void *data,
> > + struct kvm_io_ext_data *ext_data)
> >
> > {
> >
> > struct kvm_pit *pit = speaker_to_pit(this);
> > struct kvm_kpit_state *pit_state = &pit->pit_state;
> >
> > diff --git a/arch/x86/kvm/i8259.c b/arch/x86/kvm/i8259.c
> > index 3cece05..96b1070 100644
> > --- a/arch/x86/kvm/i8259.c
> > +++ b/arch/x86/kvm/i8259.c
> > @@ -480,7 +480,8 @@ static inline struct kvm_pic *to_pic(struct
> > kvm_io_device *dev)
> >
> > }
> >
> > static int picdev_write(struct kvm_io_device *this,
> >
> > - gpa_t addr, int len, const void *val)
> > + gpa_t addr, int len, const void *val,
> > + struct kvm_io_ext_data *ext_data)
> >
> > {
> >
> > struct kvm_pic *s = to_pic(this);
> > unsigned char data = *(unsigned char *)val;
> >
> > diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
> > index 93cf9d0..f413e9c 100644
> > --- a/arch/x86/kvm/lapic.c
> > +++ b/arch/x86/kvm/lapic.c
> > @@ -836,7 +836,8 @@ static int apic_reg_write(struct kvm_lapic *apic, u32
> > reg, u32 val)
> >
> > }
> >
> > static int apic_mmio_write(struct kvm_io_device *this,
> >
> > - gpa_t address, int len, const void *data)
> > + gpa_t address, int len, const void *data,
> > + struct kvm_io_ext_data *ext_data)
> >
> > {
> >
> > struct kvm_lapic *apic = to_lapic(this);
> > unsigned int offset = address - apic->base_address;
> >
> > diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> > index fa708c9..21b84e2 100644
> > --- a/arch/x86/kvm/x86.c
> > +++ b/arch/x86/kvm/x86.c
> > @@ -3571,13 +3571,14 @@ static void kvm_init_msr_list(void)
> >
> > }
> >
> > static int vcpu_mmio_write(struct kvm_vcpu *vcpu, gpa_t addr, int len,
> >
> > - const void *v)
> > + const void *v, struct kvm_io_ext_data *ext_data)
> >
> > {
> >
> > if (vcpu->arch.apic &&
> >
> > - !kvm_iodevice_write(&vcpu->arch.apic->dev, addr, len, v))
> > + !kvm_iodevice_write(&vcpu->arch.apic->dev, addr, len, v, ext_data))
> >
> > return 0;
> >
> > - return kvm_io_bus_write(vcpu->kvm, KVM_MMIO_BUS, addr, len, v);
> > + return kvm_io_bus_write(vcpu->kvm, KVM_MMIO_BUS,
> > + addr, len, v, ext_data);
> >
> > }
> >
> > static int vcpu_mmio_read(struct kvm_vcpu *vcpu, gpa_t addr, int len,
> > void *v)
> >
> > @@ -3807,6 +3808,7 @@ static int emulator_write_emulated_onepage(unsigned
> > long addr,
> >
> > struct kvm_vcpu *vcpu)
> >
> > {
> >
> > gpa_t gpa;
> >
> > + struct kvm_io_ext_data ext_data;
> >
> > gpa = kvm_mmu_gva_to_gpa_write(vcpu, addr, exception);
> >
> > @@ -3825,7 +3827,7 @@ mmio:
> > /*
> >
> > * Is this MMIO handled locally?
> > */
> >
> > - if (!vcpu_mmio_write(vcpu, gpa, bytes, val))
> > + if (!vcpu_mmio_write(vcpu, gpa, bytes, val, &ext_data))
> >
> > return X86EMUL_CONTINUE;
> >
> > vcpu->mmio_needed = 1;
> >
> > @@ -3940,6 +3942,7 @@ static int kernel_pio(struct kvm_vcpu *vcpu, void
> > *pd)
> >
> > {
> >
> > /* TODO: String I/O for in kernel device */
> > int r;
> >
> > + struct kvm_io_ext_data ext_data;
> >
> > if (vcpu->arch.pio.in)
> >
> > r = kvm_io_bus_read(vcpu->kvm, KVM_PIO_BUS, vcpu->arch.pio.port,
> >
> > @@ -3947,7 +3950,7 @@ static int kernel_pio(struct kvm_vcpu *vcpu, void
> > *pd)
> >
> > else
> >
> > r = kvm_io_bus_write(vcpu->kvm, KVM_PIO_BUS,
> >
> > vcpu->arch.pio.port, vcpu->arch.pio.size,
> >
> > - pd);
> > + pd, &ext_data);
> >
> > return r;
> >
> > }
> >
> > diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
> > index 7d313e0..6bb211d 100644
> > --- a/include/linux/kvm_host.h
> > +++ b/include/linux/kvm_host.h
> > @@ -68,8 +68,15 @@ enum kvm_bus {
> >
> > KVM_NR_BUSES
> >
> > };
> >
> > +struct kvm_io_ext_data {
> > + int type;
>
> What values does this get? Please add documentation in comments.
See the next patch.
>
> > + union {
> > + char padding[256];
> > + };
>
> So the structure size is 260 bytes?
> What's the point of the padding?
Reserved spaces. Also used in the next patch.
--
regards
Yang, Sheng
>
> > +};
> > +
> >
> > int kvm_io_bus_write(struct kvm *kvm, enum kvm_bus bus_idx, gpa_t addr,
> >
> > - int len, const void *val);
> > + int len, const void *val, struct kvm_io_ext_data *data);
> >
> > int kvm_io_bus_read(struct kvm *kvm, enum kvm_bus bus_idx, gpa_t addr,
> > int len,
> >
> > void *val);
> >
> > int kvm_io_bus_register_dev(struct kvm *kvm, enum kvm_bus bus_idx,
> >
> > @@ -113,7 +120,8 @@ struct kvm_io_device_ops {
> >
> > int (*write)(struct kvm_io_device *this,
> >
> > gpa_t addr,
> > int len,
> >
> > - const void *val);
> > + const void *val,
> > + struct kvm_io_ext_data *data);
> >
> > void (*destructor)(struct kvm_io_device *this);
> >
> > };
> >
> > diff --git a/virt/kvm/coalesced_mmio.c b/virt/kvm/coalesced_mmio.c
> > index fc84875..37b254c 100644
> > --- a/virt/kvm/coalesced_mmio.c
> > +++ b/virt/kvm/coalesced_mmio.c
> > @@ -59,7 +59,8 @@ static int coalesced_mmio_in_range(struct
> > kvm_coalesced_mmio_dev *dev,
> >
> > }
> >
> > static int coalesced_mmio_write(struct kvm_io_device *this,
> >
> > - gpa_t addr, int len, const void *val)
> > + gpa_t addr, int len, const void *val,
> > + struct kvm_io_ext_data *ext_data)
> >
> > {
> >
> > struct kvm_coalesced_mmio_dev *dev = to_mmio(this);
> > struct kvm_coalesced_mmio_ring *ring = dev->kvm->coalesced_mmio_ring;
> >
> > diff --git a/virt/kvm/eventfd.c b/virt/kvm/eventfd.c
> > index 2ca4535..8edd757 100644
> > --- a/virt/kvm/eventfd.c
> > +++ b/virt/kvm/eventfd.c
> > @@ -483,7 +483,7 @@ ioeventfd_in_range(struct _ioeventfd *p, gpa_t addr,
> > int len, const void *val)
> >
> > /* MMIO/PIO writes trigger an event if the addr/val match */
> > static int
> > ioeventfd_write(struct kvm_io_device *this, gpa_t addr, int len,
> >
> > - const void *val)
> > + const void *val, struct kvm_io_ext_data *ext_data)
> >
> > {
> >
> > struct _ioeventfd *p = to_ioeventfd(this);
> >
> > diff --git a/virt/kvm/ioapic.c b/virt/kvm/ioapic.c
> > index 0b9df83..6a027ef 100644
> > --- a/virt/kvm/ioapic.c
> > +++ b/virt/kvm/ioapic.c
> > @@ -321,7 +321,7 @@ static int ioapic_mmio_read(struct kvm_io_device
> > *this, gpa_t addr, int len,
> >
> > }
> >
> > static int ioapic_mmio_write(struct kvm_io_device *this, gpa_t addr, int
> > len,
> >
> > - const void *val)
> > + const void *val, struct kvm_io_ext_data *ext_data)
> >
> > {
> >
> > struct kvm_ioapic *ioapic = to_ioapic(this);
> > u32 data;
> >
> > diff --git a/virt/kvm/iodev.h b/virt/kvm/iodev.h
> > index d1f5651..340ab79 100644
> > --- a/virt/kvm/iodev.h
> > +++ b/virt/kvm/iodev.h
> > @@ -33,9 +33,11 @@ static inline int kvm_iodevice_read(struct
> > kvm_io_device *dev,
> >
> > }
> >
> > static inline int kvm_iodevice_write(struct kvm_io_device *dev,
> >
> > - gpa_t addr, int l, const void *v)
> > + gpa_t addr, int l, const void *v,
> > + struct kvm_io_ext_data *data)
> >
> > {
> >
> > - return dev->ops->write ? dev->ops->write(dev, addr, l, v) :
> > -EOPNOTSUPP; + return dev->ops->write ?
> > + dev->ops->write(dev, addr, l, v, data) : -EOPNOTSUPP;
> >
> > }
> >
> > static inline void kvm_iodevice_destructor(struct kvm_io_device *dev)
> >
> > diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
> > index b1b6cbb..a61f90e 100644
> > --- a/virt/kvm/kvm_main.c
> > +++ b/virt/kvm/kvm_main.c
> > @@ -2221,14 +2221,14 @@ static void kvm_io_bus_destroy(struct kvm_io_bus
> > *bus)
> >
> > /* kvm_io_bus_write - called under kvm->slots_lock */
> > int kvm_io_bus_write(struct kvm *kvm, enum kvm_bus bus_idx, gpa_t addr,
> >
> > - int len, const void *val)
> > + int len, const void *val, struct kvm_io_ext_data *ext_data)
> >
> > {
> >
> > int i;
> > struct kvm_io_bus *bus;
> >
> > bus = srcu_dereference(kvm->buses[bus_idx], &kvm->srcu);
> > for (i = 0; i < bus->dev_count; i++)
> >
> > - if (!kvm_iodevice_write(bus->devs[i], addr, len, val))
> > + if (!kvm_iodevice_write(bus->devs[i], addr, len, val, ext_data))
> >
> > return 0;
> >
> > return -EOPNOTSUPP;
> >
> > }
next prev parent reply other threads:[~2011-02-25 3:21 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-02-24 9:51 [PATCH 0/4 v10] MSI-X MMIO support for KVM Sheng Yang
2011-02-24 9:51 ` [PATCH 1/4] KVM: Move struct kvm_io_device to kvm_host.h Sheng Yang
2011-02-24 9:51 ` [PATCH 2/4] KVM: Add kvm_io_ext_data to IO handler Sheng Yang
2011-02-24 10:22 ` Michael S. Tsirkin
2011-02-25 3:23 ` Sheng Yang [this message]
2011-02-25 8:12 ` Michael S. Tsirkin
2011-02-28 5:13 ` Sheng Yang
2011-02-24 9:51 ` [PATCH 3/4] KVM: Emulate MSI-X table in kernel Sheng Yang
2011-02-24 10:45 ` Michael S. Tsirkin
2011-02-25 6:28 ` Sheng Yang
2011-02-25 8:29 ` Michael S. Tsirkin
2011-02-28 5:18 ` Sheng Yang
2011-03-01 20:18 ` Marcelo Tosatti
2011-03-01 20:59 ` Michael S. Tsirkin
2011-03-02 1:23 ` Sheng Yang
2011-02-25 6:50 ` Sheng Yang
2011-02-25 6:50 ` [PATCH 3/4 v10 UPDATED] " Sheng Yang
2011-02-24 9:51 ` [PATCH 4/4] KVM: Add documents for MSI-X MMIO API Sheng Yang
-- strict thread matches above, loose matches on Subject: below --
2011-03-02 7:26 [PATCH 0/4 v12] MSI-X MMIO support for KVM Sheng Yang
2011-03-02 7:26 ` [PATCH 2/4] KVM: Add kvm_io_ext_data to IO handler Sheng Yang
2011-02-28 7:20 [PATCH 0/4 v11] MSI-X MMIO support for KVM Sheng Yang
2011-02-28 7:20 ` [PATCH 2/4] KVM: Add kvm_io_ext_data to IO handler Sheng Yang
2011-02-18 8:53 [PATCH 0/4 v9] MSI-X MMIO support for KVM Sheng Yang
2011-02-18 8:53 ` [PATCH 2/4] KVM: Add kvm_io_ext_data to IO handler Sheng Yang
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=201102251123.30662.sheng@linux.intel.com \
--to=sheng@linux.intel.com \
--cc=alex.williamson@redhat.com \
--cc=avi@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=mst@redhat.com \
--cc=mtosatti@redhat.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.