[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] xen/events: Fix race in set_evtchn_to_irq


  • To: Maximilian Heyne <mheyne@xxxxxxxxx>
  • From: Boris Ostrovsky <boris.ostrovsky@xxxxxxxxxx>
  • Date: Wed, 11 Aug 2021 11:05:33 -0400
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=IDo6EbQYrFmrwedcp0gCuD2MALZNysVxehj98xOOmVc=; b=QO+7BHN6vTAZ05d2FFpsvCMmtdi3PDgaM+F4NbQ9q8qlhDlCqFa/RhbCyvNxIa2CNA9nAJtQVelgHlidNynblldIkyAjSyTHUaZdn/KAujnNWKLuEtsE05S7I/Fi/FPALTjFI3zcVTAq6yQD5msRcKuUCizOpjxVgEbUp2amU65Ve3Jdk/ZmNYB1BsORmtmYSwV1pFCMjc63o8+bXefP1U1ZTyrIn7FTFFOGef3+UWHC86XjyfI1hmfGfk204hEf+PEI5t/BD68/voOOiVLHL3RnlWjdKdG1qWStg1KsvuI5wf0jL500dBcKOXluHK49mRRuurYIuG1qv4ncBZN54A==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eWBdar1msZVvkQucbytL54g2ldkHkH15KgL2f2fjPHYXqO+0fAg4z2D/PfZZqKbXd+5Fa1AkTFJkqCJ9UtxkV3kMmcTG3hqie/xnhoIw+0PiZtRDtuOxIQZ8KsFYHW5vmtwHXfoeN+6qmOlFrTvRJuxFm8mQGJ0ouwai4WsDKZjcTKlqIxGddAGU9kZO1S//UTN6sVK+5z4MJKHxq2H5LXny6HPF40QHmWo4r+96df6dBfLLJm8SIumsdxT+mQlEK+rngFB/38XAyTjzQyepWkpM1oIOHoMRZ4YR3Zdvk2B9bpMaJei3rvbMkuhw3sRGB5C7xvcCxyHmilC0E0YIBQ==
  • Authentication-results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=oracle.com;
  • Cc: Amit Shah <aams@xxxxxxxxx>, Juergen Gross <jgross@xxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Wei Liu <wei.liu@xxxxxxxxxx>, Thomas Gleixner <tglx@xxxxxxxxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, Malcolm Crossley <malcolm.crossley@xxxxxxxxxx>, David Vrabel <david.vrabel@xxxxxxxxxx>, Konrad Rzeszutek Wilk <konrad.wilk@xxxxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx, linux-kernel@xxxxxxxxxxxxxxx
  • Delivery-date: Wed, 11 Aug 2021 15:06:17 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 8/11/21 10:08 AM, Maximilian Heyne wrote:
>
> This patch sets evtchn_to_irq rows via a cmpxchg operation so that they
> will be set only once. Clearing the row was moved up before writing the
> row to evtchn_to_irq in order to not create a race once the row is
> visible for other threads. Accesses to the rows are now guarded by
> READ_ONCE and WRITE_ONCE just as for the columns in the data structure.


Is this last part really needed? We needed to do that for array elements to 
avoid an interrupt handler from seeing a partially updated entry but I am not 
sure I see how this can happen to the row pointer. The only place where it 
might be important is when we update the pointer to the new page but you are 
using cmpxchg there already.


>  
> -             evtchn_to_irq[row] = (int *)get_zeroed_page(GFP_KERNEL);
> -             if (evtchn_to_irq[row] == NULL)
> +             evtchn_row = (int *) get_zeroed_page(GFP_KERNEL);


Not directly related to this patch but I don't think we need to get a zeroed 
page --- we will initialize it to -1 immediately below.



-boris




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.