[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] public/xen.h: Update comment on mmu_update sub-command size and PTE alignment


  • To: Teddy Astie <teddy.astie@xxxxxxxxxx>
  • From: Frediano Ziglio <freddy77@xxxxxxxxx>
  • Date: Sun, 9 Aug 2026 02:03:53 +0100
  • Arc-authentication-results: i=1; mx.google.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:dkim-signature; bh=/ooYtvOl/yrpSWjC6UMdC3vC8WtM8ahkSkG9Lt94FP0=; fh=A7KicbXY4441il0jhjM7233yohb6a4hGn+JPZkGjASc=; b=HCK0nIn5dJIsqxCNBoaCl+Tbypf+sjRDvFCSDbPxPu5ykw+h/ZcoqtVbBFsgXejD4c CPCpYMPnthSOt1hnNs6eZJgW3FA+qkkgs0pLefGNa82nvKSBaD+C1v+gOjS1yk45ZUzR 5PaTI5PRx+B6pjX9rOnJXYfgxmuLyHXqVmg5CZG9wt2Ty+3Mr+KA3CGOEVy8Fl4T9WE2 oA+OxqobnJf5R2P+dFKRGTFzKZAn7x2dwb1cc0GIxFvyXqNOFeYQHe1ax7jp3cXse2sX sigGL1V6hr4VOybs9X8oVIgOkfGUohHqDaMwXTsOWPo1FCvrsMR2PXQbNWn/LbpwDIZ3 Nz2A==; darn=lists.xenproject.org
  • Arc-seal: i=1; a=rsa-sha256; t=1786237448; cv=none; d=google.com; s=arc-20260327; b=U9DIo9+dqt2Bo0uacPSOf4OmnTbwhmIzG+r3MXzkhj1U/jv8fq9S59LbA2tSz/Nr7x yc00w1C6N7mpjUXJke0V6VcCpLa0Dl33FwbyxvGp2mbfCU6G5i9pWQnX2pC5eWLpcwVB wc+5h6OVFZWr3QS7oxgIXbtdF+b1BytR35MCxY8ez9NYQksGO7dntuHmNhtrLxZCHXgA XP46mldXpjn6dCetfk2wkcYZXS0egeKx3uM5oY4KYbJObNKmR/q+gKFVN9MEzCTYgRb4 u6oQWxhpoo8blkkvz7Etg/oPJVGgTFUTO0cHaDXrT8gQLI4CMiC1k6Phrd2dg/EhyAr6 40rA==
  • Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=20251104 header.d=gmail.com header.i="@gmail.com" header.h="Content-Type:Cc:To:Subject:Message-ID:Date:From:In-Reply-To:References:MIME-Version"
  • Cc: xen-devel@xxxxxxxxxxxxxxxxxxxx, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Anthony PERARD <anthony.perard@xxxxxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, Julien Grall <julien@xxxxxxx>, Roger Pau Monné <roger@xxxxxxxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Kevin Lampis <kevin.lampis@xxxxxxxxxx>
  • Delivery-date: Sun, 09 Aug 2026 01:04:33 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On Fri, 7 Aug 2026 at 22:29, Teddy Astie <teddy.astie@xxxxxxxxxx> wrote:
>
> HYPERVISOR_mmu_update passes a set of request, where each request has a 
> pointer
> to the PTE along with a sub-command.
>
> The PTE alignment padding is used to transport the sub-command while the rest
> is used as a address to a PTE entry. The current documentation state that the

"an address"

> 2 first bits are used for sub-command, hence the other ones for PTE which
> imply here a 4-bytes alignment on PTEs.
>
> On PV64 and PV32-PAE guests, all pagetable PTEs are 8-bytes aligned, hence
> off-by-4 PTEs addresses are always incorrect. Non-PAE PV32 guests used
> "legacy pagetables" which had 4-byte aligned PTEs. However, support had
> been completely removed since Xen 4.0, and were only available when Xen was

"was only available"

> built in 32-bits non-PAE mode [1].
>
> Current Xen logic behave as if 3 bits are used as sub-command, thus all

"behaves"

> off-by-4 PTEs are actually rejected as being unknown sub-commands.
>
> Adjust the documentation to match the current logic implemented in Xen,
> also expanding the documented sub-command parameter to 3 bits.
>
> [1] 84d54d5d8b31 ("i386: Remove non-PAE hypervisor build target.")
>
> Signed-off-by: Teddy Astie <teddy.astie@xxxxxxxxxx>
> ---
> This happens to be a complete rewording of [2]. I'm not sure what to do 
> exactly
> regarding the signed-off.
>

You should use them both.

> CC: Kevin Lampis <kevin.lampis@xxxxxxxxxx>
> This now expanded sub-command field can be used for your "unmap_page_range 
> optimisation"
> series to avoid having to introduce a new dedicated hypercall.
>
> [2] 
> https://lore.kernel.org/xen-devel/20260528075539.10209-3-frediano.ziglio@xxxxxxxxx/
>
>  xen/include/public/xen.h | 14 +++++++-------
>  1 file changed, 7 insertions(+), 7 deletions(-)
>
> diff --git a/xen/include/public/xen.h b/xen/include/public/xen.h
> index 2149b8dd38..b4fef2c5ba 100644
> --- a/xen/include/public/xen.h
> +++ b/xen/include/public/xen.h
> @@ -218,16 +218,16 @@ DEFINE_XEN_GUEST_HANDLE(xen_ulong_t);
>   *                     x == 0 => PFD == DOMID_SELF
>   *                     x != 0 => PFD == x - 1
>   *
> - * Sub-commands: ptr[1:0] specifies the appropriate MMU_* command.
> + * Sub-commands: ptr[2:0] specifies the appropriate MMU_* command.
>   * -------------
> - * ptr[1:0] == MMU_NORMAL_PT_UPDATE:
> + * ptr[2:0] == MMU_NORMAL_PT_UPDATE:
>   * Updates an entry in a page table belonging to PFD. If updating an L1 
> table,
>   * and the new table entry is valid/present, the mapped frame must belong to
>   * FD. If attempting to map an I/O page then the caller assumes the privilege
>   * of the FD.
>   * FD == DOMID_IO: Permit /only/ I/O mappings, at the priv level of the 
> caller.
>   * FD == DOMID_XEN: Map restricted areas of Xen's heap space.
> - * ptr[:2]  -- Machine address of the page-table entry to modify.
> + * ptr[:3]  -- Machine address of the page-table entry to modify.
>   * val      -- Value to write.
>   *
>   * There also certain implicit requirements when using this hypercall. The
> @@ -264,17 +264,17 @@ DEFINE_XEN_GUEST_HANDLE(xen_ulong_t);
>   * mentioned above. The argument is MMUEXT_UNPIN_TABLE for all levels and the
>   * pagetable MUST not be in use (meaning that the cr3 is not set to it).
>   *
> - * ptr[1:0] == MMU_MACHPHYS_UPDATE:
> + * ptr[2:0] == MMU_MACHPHYS_UPDATE:
>   * Updates an entry in the machine->pseudo-physical mapping table.
> - * ptr[:2]  -- Machine address within the frame whose mapping to modify.
> + * ptr[:3]  -- Machine address within the frame whose mapping to modify.
>   *             The frame must belong to the FD, if one is specified.
>   * val      -- Value to write into the mapping entry.
>   *
> - * ptr[1:0] == MMU_PT_UPDATE_PRESERVE_AD:
> + * ptr[2:0] == MMU_PT_UPDATE_PRESERVE_AD:
>   * As MMU_NORMAL_PT_UPDATE above, but A/D bits currently in the PTE are ORed
>   * with those in @val.
>   *
> - * ptr[1:0] == MMU_PT_UPDATE_NO_TRANSLATE:
> + * ptr[2:0] == MMU_PT_UPDATE_NO_TRANSLATE:
>   * As MMU_NORMAL_PT_UPDATE above, but @val is not translated though FD
>   * page tables.
>   *

Frediano



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.