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

Re: [XEN v3] xen/arm: vGICv3: Emulate properly 32-bit access on GICR_PENDBASER


  • To: Julien Grall <julien@xxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • From: Ayan Kumar Halder <ayankuma@xxxxxxx>
  • Date: Wed, 26 Oct 2022 18:26:34 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=e/c89O2RN4c7grri9y0r8ZWkE5NdGSrl5/WAIN50Q3w=; b=BpZyPwFKqNYwdsNe06rbXelu8eMiFWyp6CyKDmR9lqcvZ8jmiKTt1DkCZKpN2In9XDX+mb5VUmQp7PMIV+daJNOVYMXJ6/QoMgXLT7sn3n9g1LOrkjhXUras0x8pLX/9f39jDrwX3Kmi9c8sXNTCzNypNk9zP0pZ59fxIHLOLinGBC+ZNzZ6/m0GEl4/iK+PJFw6q8i0NoTZZdAiVV8snO0TCljIXUQUgrGKClEf75HuWCFW95VNo5BTPAnvLrak2ZFL9QXEn/8i3S0yaUBgIWrSQD0EbaBvvmRi4QdSVJwZ+xy51mGHNQGRIyz915op/9yZJ2AzoHhmUW7UhjKQUQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AN/EZLmmdZ/Vy56e2qXhg+D38yoYGHh1EbdsyucIiTAlQpz2ail7uZi3s6G26IDXWiDDKkFadLC32jra9yhTLBKdpMGInnd1mugCrTlldygLlMXxmVf0r1RDleloYq6kfX6KCeVrGbLakgQcqNVMn86jJG2AnwNEIaeh1vvRGCzYOv+TKGqwm30S4Ym6hba0fjrFh1ukN91Nnd4yeNrBmkGAqsOsP8GLuwjifF7uCeVFVk7UEDe3mGqbXOe7LAq9Ini9iyx/5BftlIalSnXD7+UCNVLjwd9QRWnXzl3J9ctJijg9hBN1fBi/LzbHlljz1nQxrKTcSlBZOdYt+gJN1Q==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com;
  • Cc: sstabellini@xxxxxxxxxx, stefanos@xxxxxxxxxx, Volodymyr_Babchuk@xxxxxxxx, bertrand.marquis@xxxxxxx, andre.przywara@xxxxxxx, Henry.Wang@xxxxxxx
  • Delivery-date: Wed, 26 Oct 2022 17:26:51 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Hi Julien,

On 26/10/2022 17:45, Julien Grall wrote:


On 26/10/2022 16:06, Ayan Kumar Halder wrote:

... you also need to ensure that the writers are atomically setting rdist_pendbase. Please correct if I am wrong, but the callers are not using write_atomic(). So how does that work?

I think read_atomic()/write_atomic() may not be the correct approach for the following reasons :-

1. __vgic_v3_rdistr_rd_mmio_read is a static function. So 'val' has a global lifetime. Thus, all the following three lines need to be protected from concurrent access.

I don't understand this argument. 'static' means the function is not exported. The local variables will still reside on the stack.

So why does the use of 'val' needs to be protected with the lock?

Yes, you are correct. I was misunderstanding this as a static variable.

Also, I understood from Stefano that pre-emption does not occur in Xen. So there will be no context switch.

So, the only race is between __vgic_v3_rdistr_rd_mmio_read() and __vgic_v3_rdistr_rd_mmio_write() for reading/writing rdist_pendbase.

- Ayan



         val = read_atomic(&v->arch.vgic.rdist_pendbase);
         val &= ~GICR_PENDBASER_PTZ;      /* WO, reads as 0 */

         /* If a context switch happens here, then the 'val' below may potentially be incorrect. */

         *r = vreg_reg64_extract(val, info);

2. The same holds true for 'reg' as well in __vgic_v3_rdistr_rd_mmio_write()

             reg = v->arch.vgic.rdist_pendbase;
             blah, blah
             v->arch.vgic.rdist_pendbase = reg;

Same here.

Cheers,




 


Rackspace

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