Skip to contentSkip to conversation

x86/HVM: correct cleanup after failed viridian_vcpu_init()

PATCH In review Jan Beulich 4 participants 7 messages Oct 18, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/HVM: correct cleanup after failed viridian_vcpu_init()

This happens after nestedhvm_vcpu_initialise(), so its effects also need to be undone.

Fixes 40a4a9d72d16 ("viridian: add init hooks")
xen/arch/x86/hvm/hvm.c +1 -1
@@ -1583,7 +1583,7 @@ int hvm_vcpu_initialise(struct vcpu *v)
 
     rc = viridian_vcpu_init(v);
     if ( rc )
-        goto fail5;
+        goto fail6;
 
     rc = ioreq_server_add_vcpu_all(d, v);
     if ( rc != 0 )
#2 lore raw
In reply to Jan Beulich

Jan Beulich writes ("[PATCH] x86/HVM: correct cleanup after failed viridian_vcpu_init()"):

Quoted 9 lines

This happens after nestedhvm_vcpu_initialise(), so its effects also need to be undone.

Fixes 40a4a9d72d16 ("viridian: add init hooks")

xen/arch/x86/hvm/hvm.c int hvm_vcpu_initialise(struct vcpu *v) · line 1586

Quoted 5 lines
xen/arch/x86/hvm/hvm.c +1 -1
@@ -1583,7 +1583,7 @@ int hvm_vcpu_initialise(struct vcpu *v)
 
     rc = viridian_vcpu_init(v);
     if ( rc )
-        goto fail5;
+        goto fail6;

Not acomment about the patch; rather about the code in general.

I have not looked at the context.

But OMG, this is horrific. How can anyone write code in such an idiom without writing endless bugs ?

Ian.

#3 lore raw
Quoted 18 lines · Ian Jackson

Jan Beulich writes ("[PATCH] x86/HVM: correct cleanup after failed viridian_vcpu_init()"):

Quoted 9 lines

This happens after nestedhvm_vcpu_initialise(), so its effects also need to be undone.

Fixes 40a4a9d72d16 ("viridian: add init hooks")

xen/arch/x86/hvm/hvm.c int hvm_vcpu_initialise(struct vcpu *v) · line 1586

Quoted 5 lines
xen/arch/x86/hvm/hvm.c +1 -1
@@ -1583,7 +1583,7 @@ int hvm_vcpu_initialise(struct vcpu *v)
 
     rc = viridian_vcpu_init(v);
     if ( rc )
-        goto fail5;
+        goto fail6;

Not acomment about the patch; rather about the code in general.

Quoted 4 lines

I have not looked at the context.

But OMG, this is horrific. How can anyone write code in such an idiom without writing endless bugs ?

Well, one of the reasons I dislike "goto".

Since you've been looking here - any chance of getting a release ack? Perhaps also on "x86/shadow: make a local variable in sh_page_fault() HVM-only" and "x86/PV: address odd UB in I/O emulation"? Aiui that's going to be needed from today on ...

Jan

#4 lore raw

Jan Beulich writes ("Re: [PATCH] x86/HVM: correct cleanup after failed viridian_vcpu_init()"):

Quoted 1 line

Since you've been looking here - any chance of getting a release ack?

I don't think one is needed[1], but FTR

Quoted 3 lines

Perhaps also on "x86/shadow: make a local variable in sh_page_fault() HVM-only" and "x86/PV: address odd UB in I/O emulation"? Aiui that's going to be needed from today on ...

I assume these are bugfixes too ?

[1] I think I will send out a mail clearly stating the current state of the tree.

Ian.

#5 lore raw
Quoted 4 lines · Ian Jackson

Jan Beulich writes ("Re: [PATCH] x86/HVM: correct cleanup after failed viridian_vcpu_init()"):

Quoted 1 line

Since you've been looking here - any chance of getting a release ack?

I don't think one is needed[1],

Oh, okay - I keep mixing the different forms of "freeze".

Quoted 3 lines

but FTR

Thanks.

Quoted 5 lines
Quoted 3 lines

Perhaps also on "x86/shadow: make a local variable in sh_page_fault() HVM-only" and "x86/PV: address odd UB in I/O emulation"? Aiui that's going to be needed from today on ...

I assume these are bugfixes too ?

Yes.

Jan

#6 lore raw
In reply to Ian Jackson
Quoted 18 lines · Ian Jackson

Jan Beulich writes ("[PATCH] x86/HVM: correct cleanup after failed viridian_vcpu_init()"):

Quoted 9 lines

This happens after nestedhvm_vcpu_initialise(), so its effects also need to be undone.

Fixes 40a4a9d72d16 ("viridian: add init hooks")

xen/arch/x86/hvm/hvm.c int hvm_vcpu_initialise(struct vcpu *v) · line 1586

Quoted 5 lines
xen/arch/x86/hvm/hvm.c +1 -1
@@ -1583,7 +1583,7 @@ int hvm_vcpu_initialise(struct vcpu *v)
 
      rc = viridian_vcpu_init(v);
      if ( rc )
-        goto fail5;
+        goto fail6;

Not acomment about the patch; rather about the code in general.

Quoted 5 lines

I have not looked at the context.

But OMG, this is horrific. How can anyone write code in such an idiom without writing endless bugs ?

Fairly easily. I think this is the first one due to an incorrect exit label.
Using such an idiom in the Windows PV drivers had meant many issues could be easily debugged without further code modification because you get an fairly instant audit trail of the route out of any failure condition.

Paul