diff mbox series

x86/pv-shim: fix grant table operations for 32-bit guests

Message ID 0f6a5b8d5b3164dc58db193fa5c1ae7cd0969872.camel@infradead.org (mailing list archive)
State New, archived
Headers show
Series x86/pv-shim: fix grant table operations for 32-bit guests | expand

Commit Message

David Woodhouse Oct. 23, 2023, 11:34 a.m. UTC
From: David Woodhouse <dwmw@amazon.co.uk>

When switching to call the shim functions from the normal handlers, the
compat_grant_table_op() function was omitted, leaving it calling the
real grant table operations. This leaves a 32-bit shim guest failing to
set up its real grant table with the parent hypervisor.

Fixes: e7db635f4428 ("x86/pv-shim: Don't modify the hypercall table")
Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
---
 xen/common/compat/grant_table.c | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Jan Beulich Oct. 23, 2023, 11:50 a.m. UTC | #1
On 23.10.2023 13:34, David Woodhouse wrote:
> From: David Woodhouse <dwmw@amazon.co.uk>
> 
> When switching to call the shim functions from the normal handlers, the
> compat_grant_table_op() function was omitted, leaving it calling the
> real grant table operations. This leaves a 32-bit shim guest failing to
> set up its real grant table with the parent hypervisor.
> 
> Fixes: e7db635f4428 ("x86/pv-shim: Don't modify the hypercall table")
> Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>

A patch with this same effect has been pending for a long time:
https://lists.xen.org/archives/html/xen-devel/2023-03/msg00041.html (v2;
I have a re-based v3 pending locally, awaiting whatever kind of feedback
on v2). The question of whether it was necessary to split out the actual
bug fix was raised yet earlier, in the context of v1 (albeit I'm not
sure whether that was in email or on irc).

Jan
Andrew Cooper Oct. 23, 2023, 12:01 p.m. UTC | #2
On 23/10/2023 12:34 pm, David Woodhouse wrote:
> From: David Woodhouse <dwmw@amazon.co.uk>
>
> When switching to call the shim functions from the normal handlers, the
> compat_grant_table_op() function was omitted, leaving it calling the
> real grant table operations. This leaves a 32-bit shim guest failing to
> set up its real grant table with the parent hypervisor.
>
> Fixes: e7db635f4428 ("x86/pv-shim: Don't modify the hypercall table")
> Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>

It's a bit more nuanced than that.  It's only for shim built in
non-exclusive mode, which is probably why XenServer's testing never
found this.

Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
diff mbox series

Patch

diff --git a/xen/common/compat/grant_table.c b/xen/common/compat/grant_table.c
index e00bc24a34..af98eade17 100644
--- a/xen/common/compat/grant_table.c
+++ b/xen/common/compat/grant_table.c
@@ -63,6 +63,11 @@  int compat_grant_table_op(
     unsigned int i, cmd_op;
     XEN_GUEST_HANDLE_PARAM(void) cnt_uop;
 
+#ifdef CONFIG_PV_SHIM
+    if ( unlikely(pv_shim) )
+        return pv_shim_grant_table_op(cmd, uop, count);
+#endif
+
     set_xen_guest_handle(cnt_uop, NULL);
     cmd_op = cmd & GNTTABOP_CMD_MASK;
     if ( cmd_op != GNTTABOP_cache_flush )