RE: [patch] fix kvm_arch_vcpu_ioctl_[gs]et_regs()

"Zhang, Xiantao" <[email protected]>
Newsgroups org.kernel.vger.kvm-ia64
Message-ID <706158FABBBA044BAD4FE898A02E4BC219CAB794@pdsmsx503.ccr.corp.intel.com>
Jes
   Good work!  I ever talked about the issue with Avi and wanted to enable the logic with the following patch, and Avi thought it may lead to security issues, so deferred to now :) 

One comment:  We still need the logic to save and restore the vcpu's stack for vcpu resuming to the guest in the same environment.  Maybe you can allocate one buf to save it in kvm_reg structure.
Xiantao


diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index cf0ab8e..9761a7e 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -1390,6 +1390,9 @@ static long kvm_vcpu_ioctl(struct file *filp,
                kvm_regs = kzalloc(sizeof(struct kvm_regs), GFP_KERNEL);
                if (!kvm_regs)
                        goto out;
+               r = -EFAULT;
+               if (copy_from_user(kvm_regs, argp, sizeof(struct kvm_regs)))
+                       goto out_free1;
                r = kvm_arch_vcpu_ioctl_get_regs(vcpu, kvm_regs);
                if (r)
                        goto out_free1;

Xiantao


-----Original Message-----
From: Jes Sorensen [mailto:[email protected]] 
Sent: Tuesday, December 09, 2008 11:36 PM
To: Avi Kivity; [email protected]; Zhang, Xiantao
Subject: [patch] fix kvm_arch_vcpu_ioctl_[gs]et_regs()

Hi,

This patch makes these two macros do something sensible on ia64 and
work the way qemu expects to use them. The old versions clearly couldn't
have worked since the get_regs() call expected pointers in the kvm_regs
struct which were never copied in.

Cheers,
Jes
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.