[PATCH] x86/hypercall: fix gnttab hypercall args conditional build on pvshim

Roger Pau Monne posted 1 patch 3 years, 3 months ago
Test gitlab-ci failed
Patches applied successfully (tree, apply log)
git fetch https://gitlab.com/xen-project/patchew/xen tags/patchew/20210108154251.59952-1-roger.pau@citrix.com
xen/arch/x86/hypercall.c | 8 --------
1 file changed, 8 deletions(-)
[PATCH] x86/hypercall: fix gnttab hypercall args conditional build on pvshim
Posted by Roger Pau Monne 3 years, 3 months ago
A pvshim build doesn't require the grant table functionality built in,
but it does require knowing the number of arguments the hypercall has
so the hypercall parameter clobbering works properly.

Instead of also setting the argument count for the gnttab case if PV
shim functionality is enabled, just drop all of the conditionals from
hypercall_args_table, as a hypercall having a NULL handler won't get
to use that information anyway.

Note this hasn't been detected by osstest because the tools pvshim
build is done without debug enabled, so the hypercall parameter
clobbering doesn't happen.

Fixes: d2151152dd2 ('xen: make grant table support configurable')
Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
---
Changesa since v1:
 - Drop all preprocessor conditionals
---
 xen/arch/x86/hypercall.c | 8 --------
 1 file changed, 8 deletions(-)

diff --git a/xen/arch/x86/hypercall.c b/xen/arch/x86/hypercall.c
index dd00983005..14da9bc4ad 100644
--- a/xen/arch/x86/hypercall.c
+++ b/xen/arch/x86/hypercall.c
@@ -47,9 +47,7 @@ const hypercall_args_t hypercall_args_table[NR_hypercalls] =
     ARGS(xen_version, 2),
     ARGS(console_io, 3),
     ARGS(physdev_op_compat, 1),
-#ifdef CONFIG_GRANT_TABLE
     ARGS(grant_table_op, 3),
-#endif
     ARGS(vm_assist, 2),
     COMP(update_va_mapping_otherdomain, 4, 5),
     ARGS(vcpu_op, 3),
@@ -65,17 +63,11 @@ const hypercall_args_t hypercall_args_table[NR_hypercalls] =
     ARGS(sysctl, 1),
     ARGS(domctl, 1),
     ARGS(kexec_op, 2),
-#ifdef CONFIG_ARGO
     ARGS(argo_op, 5),
-#endif
     ARGS(xenpmu_op, 2),
-#ifdef CONFIG_HVM
     ARGS(hvm_op, 2),
     ARGS(dm_op, 3),
-#endif
-#ifdef CONFIG_HYPFS
     ARGS(hypfs_op, 5),
-#endif
     ARGS(mca, 1),
     ARGS(arch_1, 1),
 };
-- 
2.29.2


Re: [PATCH] x86/hypercall: fix gnttab hypercall args conditional build on pvshim
Posted by Jan Beulich 3 years, 3 months ago
On 08.01.2021 16:42, Roger Pau Monne wrote:
> A pvshim build doesn't require the grant table functionality built in,
> but it does require knowing the number of arguments the hypercall has
> so the hypercall parameter clobbering works properly.
> 
> Instead of also setting the argument count for the gnttab case if PV
> shim functionality is enabled, just drop all of the conditionals from
> hypercall_args_table, as a hypercall having a NULL handler won't get
> to use that information anyway.
> 
> Note this hasn't been detected by osstest because the tools pvshim
> build is done without debug enabled, so the hypercall parameter
> clobbering doesn't happen.
> 
> Fixes: d2151152dd2 ('xen: make grant table support configurable')
> Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>

Reviewed-by: Jan Beulich <jbeulich@suse.com>