public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Dave Hansen <dave@linux.vnet.ibm.com>
To: Avi Kivity <avi@argo.co.il>
Cc: kvm-devel <kvm@vger.kernel.org>,
	Anthony Liguori <aliguori@us.ibm.com>,
	linux-kernel@vger.kernel.org,
	Dave Hansen <dave@linux.vnet.ibm.com>
Subject: [PATCH 3/4] reduce stack usage in kvm_arch_vcpu_ioctl()
Date: Mon,  4 Aug 2008 11:31:36 -0700	[thread overview]
Message-ID: <1217874696-28459-1-git-send-email-dave@linux.vnet.ibm.com> (raw)
In-Reply-To: <1217874693-28398-1-git-send-email-dave@linux.vnet.ibm.com>

This time it is kvm_arch_vcpu_ioctl().  Use dynamic
allocations to reduce its stack usage.

Signed-off-by: Dave Hansen <dave@linux.vnet.ibm.com>
---
 arch/x86/kvm/x86.c |   20 +++++++++++++-------
 1 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 9d77da1..3bbd123 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -1303,13 +1303,16 @@ long kvm_arch_vcpu_ioctl(struct file *filp,
 	struct kvm_vcpu *vcpu = filp->private_data;
 	void __user *argp = (void __user *)arg;
 	int r;
+	struct kvm_lapic_state *lapic = NULL;
 
 	switch (ioctl) {
 	case KVM_GET_LAPIC: {
-		struct kvm_lapic_state lapic;
+		lapic = kzalloc(sizeof(struct kvm_lapic_state), GFP_KERNEL);
 
-		memset(&lapic, 0, sizeof lapic);
-		r = kvm_vcpu_ioctl_get_lapic(vcpu, &lapic);
+		r = -ENOMEM;
+		if (!lapic)
+			goto out;
+		r = kvm_vcpu_ioctl_get_lapic(vcpu, lapic);
 		if (r)
 			goto out;
 		r = -EFAULT;
@@ -1319,12 +1322,14 @@ long kvm_arch_vcpu_ioctl(struct file *filp,
 		break;
 	}
 	case KVM_SET_LAPIC: {
-		struct kvm_lapic_state lapic;
-
+		lapic = kmalloc(sizeof(struct kvm_lapic_state), GFP_KERNEL);
+		r = -ENOMEM;
+		if (!lapic)
+			goto out;
 		r = -EFAULT;
-		if (copy_from_user(&lapic, argp, sizeof lapic))
+		if (copy_from_user(lapic, argp, sizeof(struct kvm_lapic_state)))
 			goto out;
-		r = kvm_vcpu_ioctl_set_lapic(vcpu, &lapic);;
+		r = kvm_vcpu_ioctl_set_lapic(vcpu, lapic);
 		if (r)
 			goto out;
 		r = 0;
@@ -1422,6 +1427,7 @@ long kvm_arch_vcpu_ioctl(struct file *filp,
 		r = -EINVAL;
 	}
 out:
+	kfree(lapic);
 	return r;
 }
 
-- 
1.5.4.3


  parent reply	other threads:[~2008-08-04 18:31 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-04 18:31 [PATCH 1/4] reduce kvm stack usage in kvm_arch_vm_ioctl() Dave Hansen
2008-08-04 18:31 ` [PATCH 2/4] reduce stack usage in kvm_vcpu_ioctl() Dave Hansen
2008-08-11  9:41   ` Avi Kivity
2008-08-04 18:31 ` Dave Hansen [this message]
2008-08-04 18:31 ` [PATCH 4/4] kvm: reduce stack usage in kvm_pv_mmu_op() Dave Hansen
2008-08-11  9:29 ` [PATCH 1/4] reduce kvm stack usage in kvm_arch_vm_ioctl() Avi Kivity
  -- strict thread matches above, loose matches on Subject: below --
2008-08-11 17:01 Dave Hansen
2008-08-11 17:01 ` [PATCH 3/4] reduce stack usage in kvm_arch_vcpu_ioctl() Dave Hansen
2008-07-28 18:15 Dave Hansen

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=1217874696-28459-1-git-send-email-dave@linux.vnet.ibm.com \
    --to=dave@linux.vnet.ibm.com \
    --cc=aliguori@us.ibm.com \
    --cc=avi@argo.co.il \
    --cc=kvm@vger.kernel.org \
    --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