Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp3303620pxb; Sun, 7 Feb 2021 05:01:34 -0800 (PST) X-Google-Smtp-Source: ABdhPJwyLtTfm+N6A/VS+cNBfsK6xa8hfL2kmK9NbEE5XCDHB58hAYuAEEPmkuaPnU0f0n/+iPsO X-Received: by 2002:a17:907:9483:: with SMTP id dm3mr12464142ejc.120.1612702894191; Sun, 07 Feb 2021 05:01:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612702894; cv=none; d=google.com; s=arc-20160816; b=xxL7b0mkLzoDM1JH408mez23dRw9Yc+LNwm0aofZi5GU3NrA9Csq0X2PDb7vrEArJ1 IwiIxe9uE7HxZBUN1U54flo+g357Akhbn9umimQdFrJNcupKFOzrfQb4JqgNDu6LJyps 5n7vZ3IenVSOdqMZ63oAlxcp4481Whc6gko234YY+zBrgpn65HfFS9y/h5tKqy9mJ1zL 87Ctiwyev0D46npDSs8UVjhJ0znCaAeZLEuDR+iQcKQlAJfiC8LYRVGysjE/INkuy5Rf VSEzcD8i62zG90zjhJt7RU7CRkQ4BYhW5tAsVhePRlr616kvckbQDmSjDeQljl9quCp1 H+wg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:mime-version:user-agent:date :message-id:subject:from:references:cc:to:dkim-signature; bh=R4cfw25YjQoJcPP/iQMBZfe/aKgR1aMn6caYYNJq2oA=; b=OoR/pnMtVS13yxleqPTztEHPhWOWhQy6yYM6EPUJK2FhQwW1EqtJ8yK6JOR4plohEk Pel21jv8+uRvSAOBsVr1l7clFrzbAcQRrR/WU6zcakrrOBBFaTfN9Oynb69Py4cpXdIZ O5zGepL1QgHi0lC0cIJAoDVMnliq8sIHWjZRMJWLoToP8VJFfXAaBokUmXaJNVMc4Eur sogmUWuibFEHXSwROd8tofa9CYwm88Msv5/VTN4Uz2529ryz24TniZyQpCY7YNeS9kTr 20nOp44ZuTCzuZsnSxwRpwu1p6rJ9GbFKSgFMJ6gJqvVRscamjSJcJwek9MZJjA5571Y +ZdQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=NVUgb1rU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=suse.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id li7si3546011ejb.615.2021.02.07.05.01.07; Sun, 07 Feb 2021 05:01:34 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=NVUgb1rU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=suse.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229795AbhBGM7M (ORCPT + 99 others); Sun, 7 Feb 2021 07:59:12 -0500 Received: from mx2.suse.de ([195.135.220.15]:55280 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229562AbhBGM7K (ORCPT ); Sun, 7 Feb 2021 07:59:10 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1612702703; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=R4cfw25YjQoJcPP/iQMBZfe/aKgR1aMn6caYYNJq2oA=; b=NVUgb1rUvbGL7B8EVkCTRilE+7aJXjXcGnDQicYl5bl0Tjm57ZfU+dPxnJkVUB5wFTJze/ T737CA8q//lZm2NPNe8HQRz++grQzU4akhrhcv9Szk8TeLE/1eK6UdVIiN6goOOz/lYcrg VOH+VrW52LA+831qJjxNScRTPTjO5R4= Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id B65BFAD3E; Sun, 7 Feb 2021 12:58:22 +0000 (UTC) To: Julien Grall , xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, netdev@vger.kernel.org, linux-scsi@vger.kernel.org Cc: Boris Ostrovsky , Stefano Stabellini , stable@vger.kernel.org, Konrad Rzeszutek Wilk , =?UTF-8?Q?Roger_Pau_Monn=c3=a9?= , Jens Axboe , Wei Liu , Paul Durrant , "David S. Miller" , Jakub Kicinski References: <20210206104932.29064-1-jgross@suse.com> From: =?UTF-8?B?SsO8cmdlbiBHcm/Dnw==?= Subject: Re: [PATCH 0/7] xen/events: bug fixes and some diagnostic aids Message-ID: Date: Sun, 7 Feb 2021 13:58:20 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="jbyJhFnNSEXLNH4hAQuvMm4TNC9cM8aAU" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --jbyJhFnNSEXLNH4hAQuvMm4TNC9cM8aAU Content-Type: multipart/mixed; boundary="WsIzMPvAKA2367z5Rpwd77YJ5fV8xFlI0"; protected-headers="v1" From: =?UTF-8?B?SsO8cmdlbiBHcm/Dnw==?= To: Julien Grall , xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, netdev@vger.kernel.org, linux-scsi@vger.kernel.org Cc: Boris Ostrovsky , Stefano Stabellini , stable@vger.kernel.org, Konrad Rzeszutek Wilk , =?UTF-8?Q?Roger_Pau_Monn=c3=a9?= , Jens Axboe , Wei Liu , Paul Durrant , "David S. Miller" , Jakub Kicinski Message-ID: Subject: Re: [PATCH 0/7] xen/events: bug fixes and some diagnostic aids References: <20210206104932.29064-1-jgross@suse.com> In-Reply-To: --WsIzMPvAKA2367z5Rpwd77YJ5fV8xFlI0 Content-Type: multipart/mixed; boundary="------------2346595A18135BE727B08B51" Content-Language: en-US This is a multi-part message in MIME format. --------------2346595A18135BE727B08B51 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable On 06.02.21 19:46, Julien Grall wrote: > Hi Juergen, >=20 > On 06/02/2021 10:49, Juergen Gross wrote: >> The first three patches are fixes for XSA-332. The avoid WARN splats >> and a performance issue with interdomain events. >=20 > Thanks for helping to figure out the problem. Unfortunately, I still se= e=20 > reliably the WARN splat with the latest Linux master (1e0d27fce010) +=20 > your first 3 patches. >=20 > I am using Xen 4.11 (1c7d984645f9) and dom0 is forced to use the 2L=20 > events ABI. >=20 > After some debugging, I think I have an idea what's went wrong. The=20 > problem happens when the event is initially bound from vCPU0 to a=20 > different vCPU. >=20 > From the comment in xen_rebind_evtchn_to_cpu(), we are masking the=20 > event to prevent it being delivered on an unexpected vCPU. However, I=20 > believe the following can happen: >=20 > vCPU0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0 | vCPU1 > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0 | > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0 | Call xen_rebind_evtchn_to_cpu() > receive event X=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0 | > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0 | mask event X > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0 | bind to vCPU1 > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 | unmask e= vent X > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0 | > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0 | receive event X > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0 | > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0 | handle_edge_irq(X) > handle_edge_irq(X)=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 |=C2=A0 ->= handle_irq_event() > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0 |=C2=A0=C2=A0 -> set IRQD_IN_PROGRESS > =C2=A0-> set IRQS_PENDING=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 | > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0 |=C2=A0=C2=A0 -> evtchn_interrupt() > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0 |=C2=A0=C2=A0 -> clear IRQD_IN_PROGRESS > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0 |=C2=A0 -> IRQS_PENDING is set > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0 |=C2=A0 -> handle_irq_event() > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0 |=C2=A0=C2=A0 -> evtchn_interrupt() > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0 |=C2=A0=C2=A0=C2=A0=C2=A0 -> WARN() > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0 | >=20 > All the lateeoi handlers expect a ONESHOT semantic and=20 > evtchn_interrupt() is doesn't tolerate any deviation. >=20 > I think the problem was introduced by 7f874a0447a9 ("xen/events: fix=20 > lateeoi irq acknowledgment") because the interrupt was disabled=20 > previously. Therefore we wouldn't do another iteration in=20 > handle_edge_irq(). I think you picked the wrong commit for blaming, as this is just the last patch of the three patches you were testing. > Aside the handlers, I think it may impact the defer EOI mitigation=20 > because in theory if a 3rd vCPU is joining the party (let say vCPU A=20 > migrate the event from vCPU B to vCPU C). So info->{eoi_cpu, irq_epoch,= =20 > eoi_time} could possibly get mangled? >=20 > For a fix, we may want to consider to hold evtchn_rwlock with the write= =20 > permission. Although, I am not 100% sure this is going to prevent=20 > everything. It will make things worse, as it would violate the locking hierarchy (xen_rebind_evtchn_to_cpu() is called with the IRQ-desc lock held). On a first glance I think we'll need a 3rd masking state ("temporarily masked") in the second patch in order to avoid a race with lateeoi. In order to avoid the race you outlined above we need an "event is being handled" indicator checked via test_and_set() semantics in handle_irq_for_port() and reset only when calling clear_evtchn(). > Does my write-up make sense to you? Yes. What about my reply? ;-) Juergen --------------2346595A18135BE727B08B51 Content-Type: application/pgp-keys; name="OpenPGP_0xB0DE9DD628BF132F.asc" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="OpenPGP_0xB0DE9DD628BF132F.asc" -----BEGIN PGP PUBLIC KEY BLOCK----- xsBNBFOMcBYBCACgGjqjoGvbEouQZw/ToiBg9W98AlM2QHV+iNHsEs7kxWhKMjrioyspZKOBy= cWx w3ie3j9uvg9EOB3aN4xiTv4qbnGiTr3oJhkB1gsb6ToJQZ8uxGq2kaV2KL9650I1SJvedYm8O= f8Z d621lSmoKOwlNClALZNew72NjJLEzTalU1OdT7/i1TXkH09XSSI8mEQ/ouNcMvIJNwQpd369y= 9bf IhWUiVXEK7MlRgUG6MvIj6Y3Am/BBLUVbDa4+gmzDC9ezlZkTZG2t14zWPvxXP3FAp2pkW0xq= G7/ 377qptDmrk42GlSKN4z76ELnLxussxc7I2hx18NUcbP8+uty4bMxABEBAAHNHEp1ZXJnZW4gR= 3Jv c3MgPGpnQHBmdXBmLm5ldD7CwHkEEwECACMFAlOMcBYCGwMHCwkIBwMCAQYVCAIJCgsEFgIDA= QIe AQIXgAAKCRCw3p3WKL8TL0KdB/93FcIZ3GCNwFU0u3EjNbNjmXBKDY4FUGNQH2lvWAUy+dnyT= hpw dtF/jQ6j9RwE8VP0+NXcYpGJDWlNb9/JmYqLiX2Q3TyevpB0CA3dbBQp0OW0fgCetToGIQrg0= MbD 1C/sEOv8Mr4NAfbauXjZlvTj30H2jO0u+6WGM6nHwbh2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OU8lYFpZXTXIHb+559UqvIB8AdgR3SAJGHHt4RKA0F7f5ipYBBrC6cyXJyyoprT10EMvU8= VGi wXvTyJz3fjoYsdFzpWPlJEBRMedCot60g5dmbdrZ5DWClAr0yau47zpWj3enf1tLWaqcsuylW= svi uGjKGw7KHQd3bxALOknAp4dN3QwBYCKuZ7AddY9yjynVaD5X7nF9nO5BjR/i1DG86lem3iBDX= zXs ZDn8R38=3D =3D2wuH -----END PGP PUBLIC KEY BLOCK----- --------------2346595A18135BE727B08B51-- --WsIzMPvAKA2367z5Rpwd77YJ5fV8xFlI0-- --jbyJhFnNSEXLNH4hAQuvMm4TNC9cM8aAU Content-Type: application/pgp-signature; name="OpenPGP_signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="OpenPGP_signature" -----BEGIN PGP SIGNATURE----- wsB5BAABCAAjFiEEhRJncuj2BJSl0Jf3sN6d1ii/Ey8FAmAf4+wFAwAAAAAACgkQsN6d1ii/Ey/K wAf/TDFYrTVsLzXeGxzeWtu1WaVoa4Ox7JPKEZSm8YJEojQtmVLPl+srPzcEDNlv3AAuecZNf2JB 5itbzEBHszyYZFVlr/uWRtkGM6d6wiiDngAo+sQHw7HUM3izmn+CxiwEXVjIitUvDOzsLm6ORRDy sqJ71jM50C9fP7f+mCAlK3CJ3SnIULeMnuisSyu/QNwpYNXf8KJa9WhB5UAwBYN1rielG0LFQTeH 7gSZqmDj+5ahj9ZFXKAcwjHRjoz8eOqKHA1SYoSL2Hl2HjnuBCjK/zzFUzAaDzXUxAZHtkArREZZ D2ttbvrl1JzUc4Nhf5iaKCJbCSeu+ET0u+AVKHIwFQ== =TWlv -----END PGP SIGNATURE----- --jbyJhFnNSEXLNH4hAQuvMm4TNC9cM8aAU--