From: Heiko Carstens <heiko.carstens@de.ibm.com>
To: Avi Kivity <avi@argo.co.il>
Cc: Anthony Liguori <aliguori@us.ibm.com>,
Avi Kivity <avi@qumranet.com>,
kvm-devel@lists.sourceforge.net, Andrew Morton <akpm@osdl.org>,
linux-kernel@vger.kernel.org
Subject: Re: [kvm-devel] [PATCH 0/15] KVM userspace interface updates
Date: Mon, 19 Mar 2007 16:43:11 +0100 [thread overview]
Message-ID: <20070319154311.GB8331@osiris.boeblingen.de.ibm.com> (raw)
In-Reply-To: <45FD1778.6030602@argo.co.il>
On Sun, Mar 18, 2007 at 12:42:00PM +0200, Avi Kivity wrote:
> Heiko Carstens wrote:
> >In addition, if we would port kvm to s390, then we would need to
> >make sure that each virtual cpu only gets executed from the thread
> >that created it. That is simply because the upper half of our page
> >tables contain information about the guest page states. This is yet
> >another thing that would be strange to do via an ioctl based interface.
>
> Right. I agree it's more natural to associate a vcpu with a task
> instead of a vcpu being an independent entry. We'd still need a
> handle for it, and in Linux that's an fd (pid doesn't cut it as it's
> racy, and probably slower too as it has to go through a global structure).
If you go for: only one VM per thread group and only one vcpu per thread
you don't need any identifier.
All relevant information or a pointer to it would be saved in the
thread_info structure.
That would give you two system calls to add/remove cpus which implicitely
create a VM if none is present. This add_vcpu syscall would also map
a memory range to user space which would be used to communicate between
user/kernel space to avoid frequent copy_to/from_user just like your
latest patches for KVM_RUN do.
We implemented a prototype on s390 based on a system call interface
and which does have full smp support.
This is a simplified version of how a add_cpu system call would look like.
Please note that I left out all error checkings etc. E.g. checking if the
vcpu already exists in the VM.
asmlinkage long sys_kvm_add_cpu(int vcpu, unsigned long addr)
{
struct kvm *kvm;
if (current_thread_info()->vcpu != -1)
return -EINVAL;
mutex_lock(&kvm_mutex);
write_lock_bh(&tasklist_lock);
/*
* Check all thread_infos in thread group if a VM context
* was already created.
*/
kvm = search_threads_for_kvm();
write_unlock_bh(&tasklist_lock);
if (!kvm) {
kvm = create_kvm_context();
current_thread_info()->kvm = kvm;
}
arch_add_cpu(vcpu);
current_thread_info()->vcpu = vcpu;
/*
* Map vcpu data to userspace at addr.
*/
arch_create_kvm_area(addr);
mutex_unlock(&kvm_mutex);
return 0;
}
asmlinkage long sys_kvm_remove_cpu(void)
{
int vcpu;
vcpu = current_thread_info()->vcpu;
if (cpu == -1)
return -EINVAL;
mutex_lock(&kvm_mutex);
arch_remove_cpu(vcpu);
current_thread_info()->vcpu = -1;
mutex_unlock(&kvm_mutex);
return 0;
}
The interesting part with this is that you don't need any locking
for a kvm_run system call, simply because only the thread itself can
create/remove the vcpu:
asmlinkage long sys_kvm_run(void)
{
int vcpu;
vcpu = current_thread_info()->vcpu;
if (vcpu == -1)
return -EINVAL;
return arch_kvm_run();
}
Of course all this is rather simplified, but should give a good idea
why I think that a syscall based interface should be the way to go.
next prev parent reply other threads:[~2007-03-19 15:45 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-03-11 13:53 Avi Kivity
2007-03-11 13:53 ` [PATCH 01/15] KVM: Use a shared page for kernel/user communication when runing a vcpu Avi Kivity
2007-03-15 2:38 ` [kvm-devel] " Hollis Blanchard
2007-03-15 3:09 ` Hollis Blanchard
2007-03-11 13:53 ` [PATCH 02/15] KVM: Do not communicate to userspace through cpu registers during PIO Avi Kivity
2007-03-11 13:53 ` [PATCH 03/15] KVM: Initialize PIO I/O count Avi Kivity
2007-03-11 13:53 ` [PATCH 04/15] KVM: Handle cpuid in the kernel instead of punting to userspace Avi Kivity
2007-03-11 13:53 ` [PATCH 05/15] KVM: Remove the 'emulated' field from the userspace interface Avi Kivity
2007-03-11 13:53 ` [PATCH 06/15] KVM: Remove minor wart from KVM_CREATE_VCPU ioctl Avi Kivity
2007-03-11 13:53 ` [PATCH 07/15] KVM: Renumber ioctls Avi Kivity
2007-03-11 13:53 ` [PATCH 08/15] KVM: Add method to check for backwards-compatible API extensions Avi Kivity
2007-03-16 15:06 ` [kvm-devel] " Heiko Carstens
2007-03-18 8:20 ` Avi Kivity
2007-03-11 13:53 ` [PATCH 09/15] KVM: Allow userspace to process hypercalls which have no kernel handler Avi Kivity
2007-03-11 13:53 ` [PATCH 10/15] KVM: Fold kvm_run::exit_type into kvm_run::exit_reason Avi Kivity
2007-03-11 13:53 ` [PATCH 11/15] KVM: Add a special exit reason when exiting due to an interrupt Avi Kivity
2007-03-11 13:53 ` [PATCH 12/15] KVM: Initialize the apic_base msr on svm too Avi Kivity
2007-03-11 13:53 ` [PATCH 13/15] KVM: Add guest mode signal mask Avi Kivity
2007-03-11 13:53 ` [PATCH 14/15] KVM: Allow kernel to select size of mmap() buffer Avi Kivity
2007-03-11 13:53 ` [PATCH 15/15] KVM: Future-proof argument-less ioctls Avi Kivity
2007-03-16 8:36 ` [kvm-devel] [PATCH 0/15] KVM userspace interface updates Heiko Carstens
2007-03-16 14:03 ` Anthony Liguori
2007-03-16 15:01 ` Heiko Carstens
2007-03-18 10:42 ` Avi Kivity
2007-03-19 15:43 ` Heiko Carstens [this message]
2007-03-19 16:02 ` Avi Kivity
2007-03-19 16:37 ` Heiko Carstens
2007-03-19 17:49 ` Avi Kivity
2007-03-18 5:20 ` Avi Kivity
2007-03-18 10:22 ` Heiko Carstens
2007-03-18 10:32 ` Avi Kivity
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=20070319154311.GB8331@osiris.boeblingen.de.ibm.com \
--to=heiko.carstens@de.ibm.com \
--cc=akpm@osdl.org \
--cc=aliguori@us.ibm.com \
--cc=avi@argo.co.il \
--cc=avi@qumranet.com \
--cc=kvm-devel@lists.sourceforge.net \
--cc=linux-kernel@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
all inboxes | Powered by JetHome®