KVM: Reduce kvm stack usage in kvm_arch_vm_ioctl()
authorDave Hansen <dave@linux.vnet.ibm.com>
Thu, 6 Aug 2009 17:39:49 +0000 (14:39 -0300)
committerGreg Kroah-Hartman <gregkh@suse.de>
Wed, 9 Sep 2009 03:17:09 +0000 (20:17 -0700)
commit34707a6e4a012334cffadb2b2b2d216e3c970423
treef64032d7a302f4ccf421ef671c27fbd073fc1ccd
parent04051e5cf91f5ab9f13509cd0b16b61560556de0
KVM: Reduce kvm stack usage in kvm_arch_vm_ioctl()

(cherry picked from commit f0d662759a2465babdba1160749c446648c9d159)

On my machine with gcc 3.4, kvm uses ~2k of stack in a few
select functions.  This is mostly because gcc fails to
notice that the different case: statements could have their
stack usage combined.  It overflows very nicely if interrupts
happen during one of these large uses.

This patch uses two methods for reducing stack usage.
1. dynamically allocate large objects instead of putting
   on the stack.
2. Use a union{} member for all of the case variables. This
   tricks gcc into combining them all into a single stack
   allocation. (There's also a comment on this)

Signed-off-by: Dave Hansen <dave@linux.vnet.ibm.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
arch/x86/kvm/x86.c