Re: [PATCH] KVM: x86: fix deadlock for KVM_XEN_EVTCHN_RESET

From: Sean Christopherson
Date: Thu Jan 19 2023 - 12:58:08 EST


On Thu, Jan 19, 2023, Yu Zhang wrote:
> Hi Paolo,
>
> > diff --git a/tools/testing/selftests/kvm/x86_64/xen_shinfo_test.c b/tools/testing/selftests/kvm/x86_64/xen_shinfo_test.c
> > index 721f6a693799..dae510c263b4 100644
> > --- a/tools/testing/selftests/kvm/x86_64/xen_shinfo_test.c
> > +++ b/tools/testing/selftests/kvm/x86_64/xen_shinfo_test.c
> > @@ -962,6 +962,12 @@ int main(int argc, char *argv[])
> > }
> >
> > done:
> > + struct kvm_xen_hvm_attr evt_reset = {
> > + .type = KVM_XEN_ATTR_TYPE_EVTCHN,
> > + .u.evtchn.flags = KVM_XEN_EVTCHN_RESET,
> > + };
> > + vm_ioctl(vm, KVM_XEN_HVM_SET_ATTR, &evt_reset);
> > +
> > alarm(0);
> > clock_gettime(CLOCK_REALTIME, &max_ts);
> >
>
> This change generates a build failure with error message:
> "error: a label can only be part of a statement and a declaration is not a statement".

And other flavors too, e.g.

x86_64/xen_shinfo_test.c:965:2: error: expected expression
struct kvm_xen_hvm_attr evt_reset = {
^
x86_64/xen_shinfo_test.c:969:38: error: use of undeclared identifier 'evt_reset'
vm_ioctl(vm, KVM_XEN_HVM_SET_ATTR, &evt_reset);
^
x86_64/xen_shinfo_test.c:969:38: error: use of undeclared identifier 'evt_reset'
3 errors generated.
make: *** [../lib.mk:145: tools/testing/selftests/kvm/x86_64/xen_shinfo_test] Error 1
make: *** Waiting for unfinished jobs....

I'm surprised bots haven't complained about this, haven't seen any reports.

> Moving the definition of evt_reset to the beginning of main() can fix it:

I'll queue a patch, this is already in Linus' tree and I've collected a few other
tiny fixes for v6.2-rcwhatever that I'll send to Paolo.

Thanks!