Discussion of the VIRTIO specification
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
Cc: virtio-comment@lists.linux.dev
Subject: Re: [PATCH v4 3/3] balloon: add VIRTIO_BALLOON_F_DEVICE_INIT_ON_INFLATE
Date: Fri, 15 May 2026 05:35:15 -0400	[thread overview]
Message-ID: <20260515052929-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <CAAjaMXYMOjxEL6uwVgzmfiH0PDkkdOrsCw2AzwOgj6Oie3D7Xw@mail.gmail.com>

On Fri, May 15, 2026 at 12:28:14PM +0300, Manos Pitsidianakis wrote:
> On Fri, May 15, 2026 at 12:23 PM Michael S. Tsirkin <mst@redhat.com> wrote:
> >
> > On Fri, May 15, 2026 at 12:09:24PM +0300, Manos Pitsidianakis wrote:
> > > On Thu, May 7, 2026 at 10:52 AM Michael S. Tsirkin <mst@redhat.com> wrote:
> > > >
> > > > Add VIRTIO_BALLOON_F_DEVICE_INIT_ON_INFLATE (bit 7): the device
> > > > initializes inflated pages and returns a per-page bitmap indicating
> > > > which pages were successfully initialized.
> > > >
> > > > Update Security Considerations Data Integrity subsection to cover
> > > > both DEVICE_INIT_REPORTED and DEVICE_INIT_ON_INFLATE.
> > > >
> > > > Fixes: https://github.com/oasis-tcs/virtio-spec/issues/242
> > > > Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> > > > ---
> > > >  device-types/balloon/description.tex | 73 +++++++++++++++++++++++++++-
> > > >  1 file changed, 71 insertions(+), 2 deletions(-)
> > > >
> > > > diff --git a/device-types/balloon/description.tex b/device-types/balloon/description.tex
> > > > index fa33105..7afdb24 100644
> > > > --- a/device-types/balloon/description.tex
> > > > +++ b/device-types/balloon/description.tex
> > > > @@ -52,6 +52,9 @@ \subsection{Feature bits}\label{sec:Device Types / Memory Balloon Device / Featu
> > > >  \item[ VIRTIO_BALLOON_F_DEVICE_INIT_REPORTED(6) ] The device initializes
> > > >      reported pages.
> > > >
> > > > +\item[ VIRTIO_BALLOON_F_DEVICE_INIT_ON_INFLATE(7) ] The device initializes
> > > > +    inflated pages.
> > > > +
> > > >  \end{description}
> > > >
> > > >  \subsubsection{Feature bit requirements}\label{sec:Device Types / Memory Balloon Device / Feature bits / Feature bit requirements}
> > > > @@ -249,6 +252,10 @@ \subsection{Device Operation}\label{sec:Device Types / Memory Balloon Device / D
> > > >  and before detecting its physical number in a deflate request
> > > >  and acknowledging the deflate request.
> > > >
> > > > +If VIRTIO_BALLOON_F_DEVICE_INIT_ON_INFLATE is negotiated, the
> > > > +device MUST NOT modify a page after reporting it as initialized
> > > > +in the bitmap.
> > > > +
> > > >  \paragraph{Legacy Interface: Device Operation}\label{sec:Device
> > > >  Types / Memory Balloon Device / Device Operation / Legacy
> > > >  Interface: Device Operation}
> > > > @@ -672,6 +679,67 @@ \subsubsection{Device Initialized Reported Pages}\label{sec:Device Types / Memor
> > > >  If VIRTIO_BALLOON_F_PAGE_POISON is not negotiated, the device
> > > >  MUST fill each initialized page with zeros.
> > > >
> > > > +\subsubsection{Device Initialized Pages on Inflate}\label{sec:Device Types / Memory Balloon Device / Device Operation / Device Initialized Pages on Inflate}
> > > > +
> > > > +When VIRTIO_BALLOON_F_DEVICE_INIT_ON_INFLATE is negotiated, the
> > > > +device initializes inflated pages and reports which pages were
> > > > +successfully initialized via a per-page bitmap.
> > > > +
> > > > +The driver appends a device-writable bitmap buffer to each inflate
> > > > +descriptor chain, after the PFN outbuf.
> > >
> > > Maybe we could say "page physical number" instead of PFN to stay
> > > consistent with the rest of the balloon spec.
> > >
> > > > The bitmap contains one
> > > > +bit per balloon page (4KB), where bit N corresponds to the Nth PFN
> > > > +in the inflate request (0-indexed). Bit N is stored as bit (N mod 8)
> > > > +of byte (N / 8), with bit 0 being the least significant bit.
> > > > +The device sets a bit to 1 if it successfully initialized the
> > > > +corresponding page, or 0 if it did not.
> > >
> > > Does this mean page size cannot be larger than 4kb?
> >
> > With legacy balloon, pretty much.
> > This hack of sticking right-shifted PFNs in an outbuf
> > is a broken interface that can't even support large guests.
> > If someone worked on a better one, would be great.
> > But for now, this just supports zero reporting with that.
> 
> Makes sense. Should we mention it in the traditional balloon device
> description? Or even put device and driver MUST statements that page
> size is always 4kb.
> 
> For this patch:
> 
> Reviewed-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
> 
> >
> > --
> > MST
> >

Well it says:

  \item The driver constructs an array of addresses of unused memory
    pages. These addresses are divided by 4096\footnote{This is historical, and independent of the guest page size.
} and the descriptor
    describing the resulting 32-bit array is added to the inflateq.
  \end{enumerate}


having said that:

- it should be "a device read-only buffer is made available in the
  inflateq".

- the text mixes "pages as in arbitrary chunks of memory" for page
  hinting/reporting
and
- pages as in 4k chunks for inflate/deflate


if there's work to modernize balloon, fixing these might be a
prerequisite


  reply	other threads:[~2026-05-15  9:35 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-07  7:51 [PATCH v4 0/3] balloon: DEVICE_INIT_REPORTED and DEVICE_INIT_ON_INFLATE Michael S. Tsirkin
2026-05-07  7:51 ` [PATCH v4 1/3] balloon: add Security Considerations section Michael S. Tsirkin
2026-05-15  8:53   ` Manos Pitsidianakis
2026-05-07  7:51 ` [PATCH v4 2/3] balloon: add VIRTIO_BALLOON_F_DEVICE_INIT_REPORTED Michael S. Tsirkin
2026-05-15  9:02   ` Manos Pitsidianakis
2026-05-07  7:51 ` [PATCH v4 3/3] balloon: add VIRTIO_BALLOON_F_DEVICE_INIT_ON_INFLATE Michael S. Tsirkin
2026-05-15  9:09   ` Manos Pitsidianakis
2026-05-15  9:23     ` Michael S. Tsirkin
2026-05-15  9:28       ` Manos Pitsidianakis
2026-05-15  9:35         ` Michael S. Tsirkin [this message]
2026-05-15 10:46           ` Manos Pitsidianakis

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260515052929-mutt-send-email-mst@kernel.org \
    --to=mst@redhat.com \
    --cc=manos.pitsidianakis@linaro.org \
    --cc=virtio-comment@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox