login
Header Space

 
 

Re: KVM overflows the stack

Score:
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Avi Kivity <avi@...>
Cc: Dave Hansen <dave@...>, linux-kernel@vger.kernel.org <linux-kernel@...>, kvm-devel <kvm@...>, Anthony N. Liguori [imap] <aliguori@...>
Date: Thursday, July 17, 2008 - 2:08 am

> Yes, things like kvm_lapic_state are way too big to be on the stack.

I had a quick look at the code, and my worry about dynamic allocation
would be that handling allocation failure seems like it might get
tricky.  Eg for handling struct kvm_pv_mmu_op_buffer (which is 528 bytes
on the stack in kvm_pv_mmu_op()) can you deal with an mmu op failing?
(maybe in that case you can easily by just setting *ret to 0?)

 > There's an additional problem here, that apparently your gcc (which
 > version?) doesn't fold objects in a switch statement into the same
 > stack slot:
 > 
 > switch (...) {
 >    case x: {
 >         struct medium a;
 >         ...
 >    }
 >    case y:
 >          struct medium b;
 >          ...
 >    }
 > };

A trick for this is to do:

	union {
		struct medium1 a;
		struct medium2 b;
	} u;

	switch (...) {
	case x:
		use u.a;
		...

	case y:
		use u.b;
		...
	}
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
kvm causing memory corruption? ~2.6.25-rc6, Dave Hansen, (Tue Mar 25, 5:12 pm)
Re: kvm causing memory corruption? now 2.6.26-rc4, Dave Hansen, (Mon Jun 2, 6:30 pm)
Re: kvm causing memory corruption? now 2.6.26-rc4, Avi Kivity, (Wed Jun 4, 9:42 am)
Re: kvm causing memory corruption? now 2.6.26-rc4, Dave Hansen, (Fri Jun 6, 3:41 am)
Re: kvm causing memory corruption? now 2.6.26-rc4, Avi Kivity, (Thu Jun 12, 9:10 am)
Re: kvm causing memory corruption? now 2.6.26-rc8, Dave Hansen, (Tue Jul 15, 2:57 pm)
Re: kvm causing memory corruption? now 2.6.26, Dave Hansen, (Wed Jul 16, 5:44 pm)
Re: kvm causing memory corruption? now 2.6.26, Avi Kivity, (Thu Jul 17, 1:38 am)
KVM overflows the stack, Dave Hansen, (Wed Jul 16, 6:48 pm)
Re: KVM overflows the stack, Dave Hansen, (Thu Jul 17, 2:27 am)
Re: KVM overflows the stack, Avi Kivity, (Thu Jul 17, 1:52 am)
[PATCH] update kvm's anon_inodes.c for r/o bind mounts, Dave Hansen, (Thu Jul 17, 2:45 am)
Re: KVM overflows the stack, Dave Hansen, (Thu Jul 17, 2:14 am)
Re: KVM overflows the stack, Avi Kivity, (Thu Jul 17, 2:42 am)
Re: KVM overflows the stack, Roland Dreier, (Thu Jul 17, 2:08 am)
Re: KVM overflows the stack, Dave Hansen, (Thu Jul 17, 10:06 am)
Re: KVM overflows the stack, Avi Kivity, (Thu Jul 17, 10:15 am)
Re: kvm causing memory corruption? now 2.6.26-rc4, Dave Hansen, (Mon Jun 16, 2:07 pm)
Re: kvm causing memory corruption? now 2.6.26-rc4, Dave Hansen, (Mon Jun 2, 8:59 pm)
speck-geostationary