lkml.org 
[lkml]   [2012]   [Apr]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: [PATCH 2/3] virtio_balloon: Fix endian bug
    On Thu, Apr 12, 2012 at 03:36:34PM +1000, David Gibson wrote:
    > Although virtio config space fields are usually in guest-native endian,
    > the spec for the virtio balloon device explicitly states that both fields
    > in its config space are little-endian.
    >
    > However, the current virtio_balloon driver does not have a suitable endian
    > swap for the 'num_pages' field, although it does have one for the 'actual'
    > field. This patch corrects the bug, adding sparse annotation while we're
    > at it.
    >
    > Signed-off-by: David Gibson <david@gibson.dropbear.id.au>

    Indeed. And qemu byte-swaps according to the spec, too.
    Applied for 3.4, thanks.

    > ---
    > drivers/virtio/virtio_balloon.c | 7 +++++--
    > 1 file changed, 5 insertions(+), 2 deletions(-)
    >
    > diff --git a/drivers/virtio/virtio_balloon.c b/drivers/virtio/virtio_balloon.c
    > index 6c07793..553cc1f 100644
    > --- a/drivers/virtio/virtio_balloon.c
    > +++ b/drivers/virtio/virtio_balloon.c
    > @@ -238,11 +238,14 @@ static void virtballoon_changed(struct virtio_device *vdev)
    >
    > static inline s64 towards_target(struct virtio_balloon *vb)
    > {
    > - u32 v;
    > + __le32 v;
    > + s64 target;
    > +
    > vb->vdev->config->get(vb->vdev,
    > offsetof(struct virtio_balloon_config, num_pages),
    > &v, sizeof(v));
    > - return (s64)v - vb->num_pages;
    > + target = le32_to_cpu(v);
    > + return target - vb->num_pages;
    > }
    >
    > static void update_balloon_size(struct virtio_balloon *vb)
    > --
    > 1.7.9.5


    \
     
     \ /
      Last update: 2012-04-12 10:33    [W:0.022 / U:1.284 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site