On 18-06-11 11:19:00, nilal@xxxxxxxxxx wrote: > From: Nitesh Narayan Lal <nilal@xxxxxxxxxx> > > This patch creates a new vq (hinting_vq) to be used for page hinting > and adds support in the existing virtio balloon infrastructure so > that the hyper list carrying pages which are supposed to be freed > could be sent to the host (QEMU) for processing by using hinting_vq. > > Signed-off-by: Nitesh Narayan Lal <nilal@xxxxxxxxxx> > --- > drivers/virtio/virtio_balloon.c | 99 ++++++++++++++++++++++++++++++++++++- > include/linux/page_hinting.h | 16 ++++++ > include/uapi/linux/virtio_balloon.h | 1 + > virt/kvm/page_hinting.c | 36 ++++++-------- > 4 files changed, 129 insertions(+), 23 deletions(-) > create mode 100644 include/linux/page_hinting.h > > diff --git a/drivers/virtio/virtio_balloon.c b/drivers/virtio/virtio_balloon.c > index 6b237e3..217523f 100644 > --- a/drivers/virtio/virtio_balloon.c > +++ b/drivers/virtio/virtio_balloon.c > @@ -32,6 +32,7 @@ [...] > #ifdef CONFIG_BALLOON_COMPACTION > /* > * virtballoon_migratepage - perform the balloon page migration on behalf of > @@ -604,6 +693,13 @@ static int virtballoon_probe(struct virtio_device *vdev) > > virtio_device_ready(vdev); > > +#ifdef CONFIG_KVM_FREE_PAGE_HINTING > + if (virtio_has_feature(vb->vdev, VIRTIO_GUEST_PAGE_HINTING_VQ)) { > + request_hypercall = (void *)&virtballoon_page_hinting; > + balloon_ptr = vb; > + } > +#endif balloon_ptr is valid only when VIRTIO_GUEST_PAGE_HINTING_VQ is set. So .... > +void hyperlist_ready(int entries) > { > - /* > - * Dummy function: Tobe filled later. > - */ > - empty_hyperlist(); > trace_guest_str_dump("Hypercall to host...:"); > + request_hypercall(balloon_ptr, entries); Should check if balloon_ptr is valid here. Otherwise, there may be "kernel NULL pointer dereference" bug. > + empty_hyperlist(); > }