Skip to contentSkip to conversation

x86/dmop: Properly fail for PV guests

PATCH In review Andrew Cooper 3 participants 5 messages Feb 25, 2021 – Feb 26, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/dmop: Properly fail for PV guests

The current code has an early exit for PV guests, but it returns 0 having done nothing.

Fixes 524a98c2ac5 ("public / x86: introduce __HYPERCALL_dm_op...")

---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Wei Liu <[email protected]>
CC: Ian Jackson <[email protected]>
CC: Paul Durrant <[email protected]>

For 4.15. Found while testing XEN_DMOP_nr_vcpus. Needs backporting to all stable releases.

---
 xen/arch/x86/hvm/dm.c | 1 +
 1 file changed, 1 insertion(+)
xen/arch/x86/hvm/dm.c +1 -0
index 5bc172a5d4..612749442e 100644
@@ -365,6 +365,7 @@ int dm_op(const struct dmop_args *op_args)
     if ( rc )
         return rc;
 
+    rc = -EINVAL;
     if ( !is_hvm_domain(d) )
         goto out;
 
Signature · 1 line
2.11.0
Reviewed-by on v1 1/1
#1 lore raw

Andrew Cooper writes ("[PATCH for-4.15] x86/dmop: Properly fail for PV guests"):

Quoted 2 lines

The current code has an early exit for PV guests, but it returns 0 having done nothing.

xen/arch/x86/hvm/dm.c int dm_op(const struct dmop_args *op_args) · line 370

Quoted 11 lines
xen/arch/x86/hvm/dm.c +1 -0
index 5bc172a5d4..612749442e 100644
@@ -365,6 +365,7 @@ int dm_op(const struct dmop_args *op_args)
     if ( rc )
         return rc;
 
+    rc = -EINVAL;
     if ( !is_hvm_domain(d) )
         goto out;

Is this style, of setting rc outside the if, the standard hypervisor style ?

Ian.

#2 lore raw
Quoted 4 lines · Ian Jackson

Andrew Cooper writes ("[PATCH for-4.15] x86/dmop: Properly fail for PV guests"):

Quoted 2 lines

The current code has an early exit for PV guests, but it returns 0 having done nothing.

Thanks.

Quoted 9 lines
Quoted 9 lines
xen/arch/x86/hvm/dm.c +0 -0
index 5bc172a5d4..612749442e 100644
@@ -365,6 +365,7 @@ int dm_op(const struct dmop_args *op_args)
     if ( rc )
         return rc;
 
Quoted 5 lines

xen/arch/x86/hvm/dm.c int dm_op(const struct dmop_args *op_args) · line 370

Quoted 3 lines
xen/arch/x86/hvm/dm.c +1 -0
+    rc = -EINVAL;
     if ( !is_hvm_domain(d) )
         goto out;

Is this style, of setting rc outside the if, the standard hypervisor style ?

If you think the cyclomatic complexity is bad in libxl...

This is the prevailing style in this function.  Its common, but not universal style.

~Andrew

#3 lore raw

Andrew Cooper writes ("Re: [PATCH for-4.15] x86/dmop: Properly fail for PV guests"):

Quoted 7 lines · Ian Jackson
Quoted 4 lines

Andrew Cooper writes ("[PATCH for-4.15] x86/dmop: Properly fail for PV guests"):

Quoted 2 lines

The current code has an early exit for PV guests, but it returns 0 having done nothing.

Thanks.