Skip to contentSkip to conversation

docs:Clarify that only 5 hypercall parameters are supported

PATCH In review Andrew Cooper 3 participants 6 messages Oct 6, 2023 – Oct 7, 2023

lore
Share & tools
lore
#0 lore raw

v2 cover docs:Clarify that only 5 hypercall parameters are supported

An extention to the original patch Michal did, providing the historical context.

Arguably for backport to 4.17.

Andrew Cooper (1):
docs/spnix: Switch hypercall-abi.rst to named footnotes

Michal Orzel (1):
x86: Clarify that only 5 hypercall parameters are supported

 docs/guest-guide/x86/hypercall-abi.rst   | 39 ++++++++++++++----------
 xen/include/public/arch-x86/xen-x86_32.h |  2 +-
 xen/include/public/arch-x86/xen-x86_64.h |  2 +-
 3 files changed, 25 insertions(+), 18 deletions(-)

base-commit: 01343f99de858c7e24bcfcb4ad4fc584559bcc08

Signature · 1 line
2.30.2
#1 lore raw

PATCH v2 1/2 docs/spnix: Switch hypercall-abi.rst to named footnotes

This will simplify inserting a new one in the middle.

---
CC: George Dunlap <[email protected]>
CC: Jan Beulich <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Wei Liu <[email protected]>
CC: Julien Grall <[email protected]>
CC: Michal Orzel <[email protected]>
CC: Henry Wang <[email protected]>

---
 docs/guest-guide/x86/hypercall-abi.rst | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)
docs/guest-guide/x86/hypercall-abi.rst +12 -12
index 14c48929d748..42a820386b68 100644
@@ -6,7 +6,7 @@ Hypercall ABI
 Hypercalls are system calls to Xen.  Two modes of guest operation are
 supported, and up to 6 individual parameters are supported.
 
-Hypercalls may only be issued by kernel-level software [1]_.
+Hypercalls may only be issued by kernel-level software [#kern]_.
 
 Registers
 ---------
@@ -33,7 +33,7 @@ The registers used for hypercalls depends on the operating mode of the guest.
 
 32 and 64bit PV guests have an ABI fixed by their guest type.  The ABI for an
 HVM guest depends on whether the vCPU is operating in a 64bit segment or not
-[2]_.
+[#mode]_.
 
 
 Parameters
@@ -87,7 +87,7 @@ written by Xen, is mapped with executable permissions so it may be used.
 Multiple hypercall pages may be created by the guest, if it wishes.
 
 The stubs are arranged by hypercall index, and start on 32-byte boundaries.
-To invoke a specific hypercall, ``call`` the relevant stub [3]_:
+To invoke a specific hypercall, ``call`` the relevant stub [#iret]_:
 
 .. code-block:: none
 
@@ -116,14 +116,14 @@ means.
 
 .. rubric:: Footnotes
 
-.. [1] For HVM guests, ``HVMOP_guest_request_vm_event`` may be configured to
-       be usable from userspace, but this behaviour is not default.
+.. [#kern] For HVM guests, ``HVMOP_guest_request_vm_event`` may be configured
+   to be usable from userspace, but this behaviour is not default.
 
-.. [2] While it is possible to use compatibility mode segments in a 64bit
-       kernel, hypercalls issues from such a mode will be interpreted with the
-       32bit ABI.  Such a setup is not expected in production scenarios.
+.. [#mode] While it is possible to use compatibility mode segments in a 64bit
+   kernel, hypercalls issues from such a mode will be interpreted with the
+   32bit ABI.  Such a setup is not expected in production scenarios.
 
-.. [3] ``HYPERCALL_iret`` is special.  It is only implemented for PV guests
-       and takes all its parameters on the stack.  This stub should be
-       ``jmp``'d to, rather than ``call``'d.  HVM guests have this stub
-       implemented as ``ud2a`` to prevent accidental use.
+.. [#iret] ``HYPERCALL_iret`` is special.  It is only implemented for PV
+   guests and takes all its parameters on the stack.  This stub should be
+   ``jmp``'d to, rather than ``call``'d.  HVM guests have this stub
+   implemented as ``ud2a`` to prevent accidental use.
Signature · 1 line
2.30.2
#2 lore raw

Re: [PATCH for-4.18 v2 1/2] docs/spnix: Switch hypercall-abi.rst to named footnotes

Hi Andrew,

Title typo: s/spnix/sphinx/. Can be fixed on commit.

Quoted 5 lines · Andrew Cooper

This will simplify inserting a new one in the middle.

Kind regards,
Henry

Quoted 70 lines

---
CC: George Dunlap <[email protected]>
CC: Jan Beulich <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Wei Liu <[email protected]>
CC: Julien Grall <[email protected]>
CC: Michal Orzel <[email protected]>
CC: Henry Wang <[email protected]>
---
docs/guest-guide/x86/hypercall-abi.rst | 24 ++++++++++++------------

1 file changed, 12 insertions(+), 12 deletions(-)
docs/guest-guide/x86/hypercall-abi.rst +0 -0
index 14c48929d748..42a820386b68 100644
@@ -6,7 +6,7 @@ Hypercall ABI

Hypercalls are system calls to Xen. Two modes of guest operation are supported, and up to 6 individual parameters are supported.

docs/guest-guide/x86/hypercall-abi.rst +1 -1
-Hypercalls may only be issued by kernel-level software [1]_.
+Hypercalls may only be issued by kernel-level software [#kern]_.

Registers
---------

docs/guest-guide/x86/hypercall-abi.rst +0 -0
@@ -33,7 +33,7 @@ The registers used for hypercalls depends on the operating mode of the guest.
 

32 and 64bit PV guests have an ABI fixed by their guest type. The ABI for an HVM guest depends on whether the vCPU is operating in a 64bit segment or not -[2]_.
+[#mode]_.

Parameters

docs/guest-guide/x86/hypercall-abi.rst +0 -0
@@ -87,7 +87,7 @@ written by Xen, is mapped with executable permissions so it may be used.

Multiple hypercall pages may be created by the guest, if it wishes.

The stubs are arranged by hypercall index, and start on 32-byte boundaries.

docs/guest-guide/x86/hypercall-abi.rst +1 -1
-To invoke a specific hypercall, ``call`` the relevant stub [3]_:
+To invoke a specific hypercall, ``call`` the relevant stub [#iret]_:

.. code-block:: none

docs/guest-guide/x86/hypercall-abi.rst +0 -0
@@ -116,14 +116,14 @@ means.
 

.. rubric:: Footnotes

-.. [1] For HVM guests, ``HVMOP_guest_request_vm_event`` may be configured to

docs/guest-guide/x86/hypercall-abi.rst +9 -8
-       be usable from userspace, but this behaviour is not default.
+.. [#kern] For HVM guests, ``HVMOP_guest_request_vm_event`` may be configured
+   to be usable from userspace, but this behaviour is not default.
 
-.. [2] While it is possible to use compatibility mode segments in a 64bit
-       kernel, hypercalls issues from such a mode will be interpreted with the
-       32bit ABI.  Such a setup is not expected in production scenarios.
+.. [#mode] While it is possible to use compatibility mode segments in a 64bit
+   kernel, hypercalls issues from such a mode will be interpreted with the
+   32bit ABI.  Such a setup is not expected in production scenarios.
 
-.. [3] ``HYPERCALL_iret`` is special.  It is only implemented for PV guests
-       and takes all its parameters on the stack.  This stub should be
-       ``jmp``'d to, rather than ``call``'d.  HVM guests have this stub
-       implemented as ``ud2a`` to prevent accidental use.
+.. [#iret] ``HYPERCALL_iret`` is special.  It is only implemented for PV
+   guests and takes all its parameters on the stack.  This stub should be
+   ``jmp``'d to, rather than ``call``'d.  HVM guests have this stub
+   implemented as ``ud2a`` to prevent accidental use.
Signature · 1 line
2.30.2
#3 lore raw

PATCH v2 2/2 x86: Clarify that only 5 hypercall parameters are supported

In reply to Andrew Cooper

From: Michal Orzel <[email protected]>

The x86 hypercall ABI really used to have 6-argument hypercalls. V4V, the downstream predecessor to Argo did take 6th args.

However, the 6th arg being %ebp in the 32bit ABI makes it unusable in practice, because that's the frame pointer in builds with frame pointers enabled. Therefore Argo was altered to being a 5-arg hypercall when it was upstreamed.

c/s 2f531c122e95 ("x86: limit number of hypercall parameters to 5") removed the ability for hypercalls to take 6 arguments.

Update the documentation to match reality.

---
CC: George Dunlap <[email protected]>
CC: Jan Beulich <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Wei Liu <[email protected]>
CC: Julien Grall <[email protected]>
CC: Michal Orzel <[email protected]>
CC: Henry Wang <[email protected]>

v2:
* Extend with the historical context of how 6-arg hypercalls have come and gone.

---
 docs/guest-guide/x86/hypercall-abi.rst   | 15 +++++++++++----
 xen/include/public/arch-x86/xen-x86_32.h |  2 +-
 xen/include/public/arch-x86/xen-x86_64.h |  2 +-
 3 files changed, 13 insertions(+), 6 deletions(-)
docs/guest-guide/x86/hypercall-abi.rst +11 -4
index 42a820386b68..c7a11a76712f 100644
@@ -4,7 +4,7 @@ Hypercall ABI
 =============
 
 Hypercalls are system calls to Xen.  Two modes of guest operation are
-supported, and up to 6 individual parameters are supported.
+supported, and up to 5 individual parameters are supported.
 
 Hypercalls may only be issued by kernel-level software [#kern]_.
 
@@ -18,17 +18,17 @@ The registers used for hypercalls depends on the operating mode of the guest.
 
    * - ABI
      - Hypercall Index
-     - Parameters (1 - 6)
+     - Parameters (1 - 5) [#params]_
      - Result
 
    * - 64bit
      - RAX
-     - RDI RSI RDX R10 R8 R9
+     - RDI RSI RDX R10 R8
      - RAX
 
    * - 32bit
      - EAX
-     - EBX ECX EDX ESI EDI EBP
+     - EBX ECX EDX ESI EDI
      - EAX
 
 32 and 64bit PV guests have an ABI fixed by their guest type.  The ABI for an
@@ -119,6 +119,13 @@ means.
 .. [#kern] For HVM guests, ``HVMOP_guest_request_vm_event`` may be configured
    to be usable from userspace, but this behaviour is not default.
 
+.. [#params] Xen's ABI used to declare support for 6 hypercall arguments,
+   using ``r9`` and ``ebp``.  However, such an ABI clobbers the frame pointer
+   in the 32bit code and does interact nicely with guest-side debugging.  The
+   predecessor to ``HYPERCALL_argo_op`` was a 6-argument hypercall, but the
+   ABI was intentionally altered when Argo was upstreamed (Xen 4.13) to be the
+   5-argument hypercall it now is.
+
 .. [#mode] While it is possible to use compatibility mode segments in a 64bit
    kernel, hypercalls issues from such a mode will be interpreted with the
    32bit ABI.  Such a setup is not expected in production scenarios.
xen/include/public/arch-x86/xen-x86_32.h +1 -1
index 139438e83534..9e3bf06b121e 100644
@@ -12,7 +12,7 @@
 
 /*
  * Hypercall interface:
- *  Input:  %ebx, %ecx, %edx, %esi, %edi, %ebp (arguments 1-6)
+ *  Input:  %ebx, %ecx, %edx, %esi, %edi (arguments 1-5)
  *  Output: %eax
  * Access is via hypercall page (set up by guest loader or via a Xen MSR):
  *  call hypercall_page + hypercall-number * 32
xen/include/public/arch-x86/xen-x86_64.h +1 -1
index 5d9035ed2230..43f6e3d22001 100644
@@ -12,7 +12,7 @@
 
 /*
  * Hypercall interface:
- *  Input:  %rdi, %rsi, %rdx, %r10, %r8, %r9 (arguments 1-6)
+ *  Input:  %rdi, %rsi, %rdx, %r10, %r8 (arguments 1-5)
  *  Output: %rax
  * Access is via hypercall page (set up by guest loader or via a Xen MSR):
  *  call hypercall_page + hypercall-number * 32
Signature · 1 line
2.30.2
#4 lore raw

Re: [PATCH for-4.18 v2 2/2] x86: Clarify that only 5 hypercall parameters are supported

Hi,

Quoted 12 lines · Andrew Cooper

From: Michal Orzel <[email protected]>

The x86 hypercall ABI really used to have 6-argument hypercalls. V4V, the downstream predecessor to Argo did take 6th args.

However, the 6th arg being %ebp in the 32bit ABI makes it unusable in practice, because that's the frame pointer in builds with frame pointers enabled. Therefore Argo was altered to being a 5-arg hypercall when it was upstreamed.

Quoted 7 lines

c/s 2f531c122e95 ("x86: limit number of hypercall parameters to 5") removed the ability for hypercalls to take 6 arguments.

Update the documentation to match reality.

Kind regards,
Henry

Quoted 94 lines

---
CC: George Dunlap <[email protected]>
CC: Jan Beulich <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Wei Liu <[email protected]>
CC: Julien Grall <[email protected]>
CC: Michal Orzel <[email protected]>
CC: Henry Wang <[email protected]>

v2:
* Extend with the historical context of how 6-arg hypercalls have come and gone.
---

docs/guest-guide/x86/hypercall-abi.rst   | 15 +++++++++++----
xen/include/public/arch-x86/xen-x86_32.h |  2 +-
xen/include/public/arch-x86/xen-x86_64.h |  2 +-
3 files changed, 13 insertions(+), 6 deletions(-)
docs/guest-guide/x86/hypercall-abi.rst +0 -0
index 42a820386b68..c7a11a76712f 100644
@@ -4,7 +4,7 @@ Hypercall ABI

=============

Hypercalls are system calls to Xen. Two modes of guest operation are

docs/guest-guide/x86/hypercall-abi.rst +1 -1
-supported, and up to 6 individual parameters are supported.
+supported, and up to 5 individual parameters are supported.

Hypercalls may only be issued by kernel-level software [#kern]_.

docs/guest-guide/x86/hypercall-abi.rst +3 -3
@@ -18,17 +18,17 @@ The registers used for hypercalls depends on the operating mode of the guest.
 
   * - ABI
     - Hypercall Index
-     - Parameters (1 - 6)
+     - Parameters (1 - 5) [#params]_
     - Result
 
   * - 64bit
     - RAX
-     - RDI RSI RDX R10 R8 R9
+     - RDI RSI RDX R10 R8
     - RAX
 
   * - 32bit
     - EAX
-     - EBX ECX EDX ESI EDI EBP
+     - EBX ECX EDX ESI EDI
     - EAX
 

32 and 64bit PV guests have an ABI fixed by their guest type. The ABI for an

docs/guest-guide/x86/hypercall-abi.rst +0 -0
@@ -119,6 +119,13 @@ means.

.. [#kern] For HVM guests, ``HVMOP_guest_request_vm_event`` may be configured
to be usable from userspace, but this behaviour is not default.

+.. [#params] Xen's ABI used to declare support for 6 hypercall arguments,

docs/guest-guide/x86/hypercall-abi.rst +6 -0
+   using ``r9`` and ``ebp``.  However, such an ABI clobbers the frame pointer
+   in the 32bit code and does interact nicely with guest-side debugging.  The
+   predecessor to ``HYPERCALL_argo_op`` was a 6-argument hypercall, but the
+   ABI was intentionally altered when Argo was upstreamed (Xen 4.13) to be the
+   5-argument hypercall it now is.
+

.. [#mode] While it is possible to use compatibility mode segments in a 64bit
kernel, hypercalls issues from such a mode will be interpreted with the 32bit ABI. Such a setup is not expected in production scenarios.

xen/include/public/arch-x86/xen-x86_32.h +1 -1
index 139438e83534..9e3bf06b121e 100644
@@ -12,7 +12,7 @@
 
 /*
 * Hypercall interface:
- *  Input:  %ebx, %ecx, %edx, %esi, %edi, %ebp (arguments 1-6)
+ *  Input:  %ebx, %ecx, %edx, %esi, %edi (arguments 1-5)
 *  Output: %eax
 * Access is via hypercall page (set up by guest loader or via a Xen MSR):
 *  call hypercall_page + hypercall-number * 32
xen/include/public/arch-x86/xen-x86_64.h +1 -1
index 5d9035ed2230..43f6e3d22001 100644
@@ -12,7 +12,7 @@
 
 /*
 * Hypercall interface:
- *  Input:  %rdi, %rsi, %rdx, %r10, %r8, %r9 (arguments 1-6)
+ *  Input:  %rdi, %rsi, %rdx, %r10, %r8 (arguments 1-5)
 *  Output: %rax
 * Access is via hypercall page (set up by guest loader or via a Xen MSR):
 *  call hypercall_page + hypercall-number * 32
Signature · 1 line
2.30.2
Reviewed-by on v2 2/2
#5 lore raw

Re: [PATCH for-4.18 v2 2/2] x86: Clarify that only 5 hypercall parameters are supported

In reply to Andrew Cooper
Quoted 41 lines · Andrew Cooper

From: Michal Orzel <[email protected]>

The x86 hypercall ABI really used to have 6-argument hypercalls. V4V, the downstream predecessor to Argo did take 6th args.

However, the 6th arg being %ebp in the 32bit ABI makes it unusable in practice, because that's the frame pointer in builds with frame pointers enabled. Therefore Argo was altered to being a 5-arg hypercall when it was upstreamed.

c/s 2f531c122e95 ("x86: limit number of hypercall parameters to 5") removed the ability for hypercalls to take 6 arguments.

Update the documentation to match reality.

---
CC: George Dunlap <[email protected]>
CC: Jan Beulich <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Wei Liu <[email protected]>
CC: Julien Grall <[email protected]>
CC: Michal Orzel <[email protected]>
CC: Henry Wang <[email protected]>

v2:
* Extend with the historical context of how 6-arg hypercalls have come and gone.

---
 docs/guest-guide/x86/hypercall-abi.rst   | 15 +++++++++++----
 xen/include/public/arch-x86/xen-x86_32.h |  2 +-
 xen/include/public/arch-x86/xen-x86_64.h |  2 +-
 3 files changed, 13 insertions(+), 6 deletions(-)
docs/guest-guide/x86/hypercall-abi.rst +0 -0
index 42a820386b68..c7a11a76712f 100644

docs/guest-guide/x86/hypercall-abi.rst means. · line 124

Quoted 6 lines
docs/guest-guide/x86/hypercall-abi.rst +3 -0
@@ -119,6 +119,13 @@ means.
 .. [#kern] For HVM guests, ``HVMOP_guest_request_vm_event`` may be configured
    to be usable from userspace, but this behaviour is not default.
 
+.. [#params] Xen's ABI used to declare support for 6 hypercall arguments,
+   using ``r9`` and ``ebp``.  However, such an ABI clobbers the frame pointer
+   in the 32bit code and does interact nicely with guest-side debugging.  The

I think you want s/does/does not/.

With that,

docs/guest-guide/x86/hypercall-abi.rst means. · line 125

Quoted 1 line
docs/guest-guide/x86/hypercall-abi.rst +1 -0
+   predecessor to ``HYPERCALL_argo_op`` was a 6-argument hypercall, but the

Also, I think it would be worth just naming v4v with "...predecessor to ``HYPERCALL_argo_op``, v4v, was...", so a future reader doesn't have to investigate to find out what the predecessor was.

Regards,
Jason

Quoted 6 lines
docs/guest-guide/x86/hypercall-abi.rst +3 -0
+   ABI was intentionally altered when Argo was upstreamed (Xen 4.13) to be the
+   5-argument hypercall it now is.
+
 .. [#mode] While it is possible to use compatibility mode segments in a 64bit
    kernel, hypercalls issues from such a mode will be interpreted with the
    32bit ABI.  Such a setup is not expected in production scenarios.