public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Avi Kivity <avi@qumranet.com>
To: Laurent Vivier <Laurent.Vivier@bull.net>
Cc: kvm@vger.kernel.org
Subject: Re: [PATCH 1/7] libkvm: delayed MMIO support (common part)
Date: Mon, 26 May 2008 16:55:45 +0300	[thread overview]
Message-ID: <483AC161.2010804@qumranet.com> (raw)
In-Reply-To: <12115326463363-git-send-email-Laurent.Vivier@bull.net>

Laurent Vivier wrote:
> This patch introduces in libkvm the common part of MMIO batching interface.
>
> It checks the MMIO batching availability with ioctl(KVM_CHECK_EXTENSION).
> If KVM_CAP_DELAYED_MMIO is available, it processes the MMIO ring buffer
> at the return of ioctl(KVM_RUN).
> It defines kvm_register_delayed_mmio() to register a delayed MMIO zone, and 
> kvm_unregister_delayed_mmio() to unregister it.
>
>  
>  void init_slots(void);
> diff --git a/libkvm/libkvm.c b/libkvm/libkvm.c
> index d1e95a4..718f4c6 100644
> --- a/libkvm/libkvm.c
> +++ b/libkvm/libkvm.c
> @@ -879,6 +879,20 @@ again:
>  
>  	post_kvm_run(kvm, vcpu);
>  
> +#if defined(KVM_CAP_DELAYED_MMIO)
> +	if (kvm->delayed_mmio) {
> +	        struct kvm_batch *batch = (void *)run +
> +					  kvm->delayed_mmio * PAGE_SIZE;
> +		while (batch->first != batch->last) {
> +			kvm->callbacks->mmio_write(kvm->opaque,
> +					    batch->mmio[batch->first].phys_addr,
> +					   &batch->mmio[batch->first].data[0],
> +					    batch->mmio[batch->first].len);
> +			batch->first = (batch->first + 1) % KVM_MAX_BATCH;
>   

There needs to be a write barrier after this (smp_wmb()), to avoid 
compiler and cpu reordering.  Especially important for non-x86.  Also 
need a read barrier before reading batch->first.

Or maybe not, likely the pthread_mutex_lock() acts as the correct 
barrier.  But we do need the equivalent barriers in the kernel code 
(missed it on that review).

> +		}
> +	}
> +#endif
> +
>  	if (r == -1) {
>  		r = handle_io_window(kvm);
>  		goto more;
>   

> +
> +int kvm_register_delayed_mmio(kvm_context_t kvm, uint64_t addr, uint32_t size)
> +{
> +#ifdef KVM_CAP_DELAYED_MMIO
> +	struct kvm_delayed_mmio_zone zone;
> +	int r;
> +
> +	if (kvm->delayed_mmio) {
> +
> +		zone.addr = addr;
> +		zone.size = size;
> +
> +		r = ioctl(kvm->vm_fd, KVM_REGISTER_DELAYED_MMIO, &zone);
> +		if (r == -1) {
> +			perror("kvm_register_delayed_mmio_zone");
> +			return -errno;
> +		}
> +		return 0;
> +	}
> +#endif
> +	return -1;
>   

-ENOSYS, or something.  -1 is -ENOPERM.

> +}
> +
> +int kvm_unregister_delayed_mmio(kvm_context_t kvm, uint64_t addr, uint32_t size)
> +{
> +#ifdef KVM_CAP_DELAYED_MMIO
> +	struct kvm_delayed_mmio_zone zone;
> +	int r;
> +
> +	if (kvm->delayed_mmio) {
> +
> +		zone.addr = addr;
> +		zone.size = size;
> +
> +		r = ioctl(kvm->vm_fd, KVM_UNREGISTER_DELAYED_MMIO, &zone);
> +		if (r == -1) {
> +			perror("kvm_unregister_delayed_mmio_zone");
> +			return -errno;
> +		}
> +		return 0;
> +	}
> +#endif
> +	return -1;
>   

ditto.

-- 
error compiling committee.c: too many arguments to function


  parent reply	other threads:[~2008-05-26 13:55 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-05-23  8:50 [PATCH 0/7] kvm-userspace: Batch writes to MMIO Laurent Vivier
2008-05-23  8:50 ` [PATCH 1/7] libkvm: delayed MMIO support (common part) Laurent Vivier
2008-05-23  8:50   ` [PATCH 2/7] libkvm: delayed MMIO support (x86 part) Laurent Vivier
2008-05-23  8:50     ` [PATCH 3/7] libkvm: delayed MMIO support (powerpc part) Laurent Vivier
2008-05-23  8:50       ` [PATCH 4/7] libkvm: delayed MMIO support (ia64 part) Laurent Vivier
2008-05-23  8:50         ` [PATCH 5/7] qemu: delayed MMIO support (core) Laurent Vivier
2008-05-23  8:50           ` [PATCH 6/7] qemu: delayed MMIO support (VGA) Laurent Vivier
2008-05-23  8:50             ` [PATCH 7/7] qemu: delayed MMIO support (e1000) Laurent Vivier
2008-05-26 14:05               ` Avi Kivity
2008-05-26 14:27                 ` Laurent Vivier
2008-05-26 13:58             ` [PATCH 6/7] qemu: delayed MMIO support (VGA) Avi Kivity
2008-05-26 13:55   ` Avi Kivity [this message]
2008-05-26 14:15     ` [PATCH 1/7] libkvm: delayed MMIO support (common part) Laurent Vivier

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=483AC161.2010804@qumranet.com \
    --to=avi@qumranet.com \
    --cc=Laurent.Vivier@bull.net \
    --cc=kvm@vger.kernel.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