From mboxrd@z Thu Jan 1 00:00:00 1970 From: Rusty Russell Subject: Re: [PATCH] virtio-balloon: do not attempt to release more than available pages Date: Tue, 11 Mar 2008 22:54:32 +1100 Message-ID: <200803112254.33112.rusty@rustcorp.com.au> References: <20080305162832.GA11563@dmt> <200803111126.55421.rusty@rustcorp.com.au> <47D5D7DE.5010906@codemonkey.ws> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Cc: Marcelo Tosatti , kvm-devel To: Anthony Liguori Return-path: In-Reply-To: <47D5D7DE.5010906@codemonkey.ws> Content-Disposition: inline List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: kvm-devel-bounces@lists.sourceforge.net Errors-To: kvm-devel-bounces@lists.sourceforge.net List-Id: kvm.vger.kernel.org On Tuesday 11 March 2008 11:52:46 Anthony Liguori wrote: > Rusty Russell wrote: > > 2) Handle the case where we get nonsense from the host, which causes us > > to wrap around. > > Here's my neither compiled nor tested version which should fix this > problem without breaking the ABI. Hmm, we could just refuse to grab >= 2G pages. It is not only reasonable, but also gives us an opportunity to make another Sophie Blanchard reference![1] Patch below. Cheers, Rusty. [1] Wow, I actually learned something from a Wikipedia Featured Article. virtio: handle > 2 billion page balloon targets If the host asks for a huge target towards_target() can overflow, and we up oops as we try to release more pages than we have. The simple fix is to use a 64-bit value. Signed-off-by: Rusty Russell diff -r fd0c80dbbd95 drivers/virtio/virtio_balloon.c --- a/drivers/virtio/virtio_balloon.c Tue Mar 11 09:21:00 2008 +1100 +++ b/drivers/virtio/virtio_balloon.c Tue Mar 11 11:25:52 2008 +1100 @@ -152,7 +152,7 @@ static void virtballoon_changed(struct v wake_up(&vb->config_change); } -static inline int towards_target(struct virtio_balloon *vb) +static inline s64 towards_target(struct virtio_balloon *vb) { u32 v; __virtio_config_val(vb->vdev, @@ -176,7 +183,7 @@ static int balloon(void *_vballoon) set_freezable(); while (!kthread_should_stop()) { - int diff; + s64 diff; try_to_freeze(); wait_event_interruptible(vb->config_change, ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/