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

Re: [RESEND][PATCH] xen/arm: sched: Ensure the vCPU context is seen before vcpu_pause() returns


  • To: Julien Grall <julien@xxxxxxx>
  • From: Bertrand Marquis <Bertrand.Marquis@xxxxxxx>
  • Date: Wed, 23 Sep 2020 13:52:02 +0000
  • Accept-language: en-GB, en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.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=fh2UsWyHJu7X4q4SgAcaUfEdPDN8i0uSm/RLBQ3ZzXo=; b=PRvX1TVGTD3bKEEcyOUvmwRMPNv9LdT28Ndcov0QLz0vyf7gKzniUUyKZ8K7Y2ATP9POIvm0gZ4HoL7NX6YmkqjDMgxmXuz0mHwSeCSF9Rd5aFffxwSatVNNomFyqzfDuL3SeA08HDbZu4sDU153ouxdmuZQpHk/0FeXL8Czkdx8hyfwMwjWhzBLFvz74R9/DITAswXtfKnb38Kvh9SLRktITBEocn3oaA6yaykbGDXdhA9+Q3+k6JmrxUyxCTtsCV9D/q4acBX0i5cY2+be+aTdh4Qm0WQhqpC69ipXY1Ytmyeeig4Tima+sit2K7s5fS7H/+UtqfmodGvKzpobDA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ALz9m8I7NYKY7/8JokHIN8btF9/guz3j/CQz3xYOMw5wZuhM/iq2+NTDwyLSazWZwUFNM+yAlP6yGupBSTtBniS/jWXqtyQAZW30yWjoq2r7tAkboAUCErYWlApiwtoWsPUFErzTVnvpvfs6cViIOl9ugF1Dkhbi0u8tKjK6ncSdjXLh4R27sG9Byx36FVkKnmvxbRVHWXfqFCsymC6E760S7MtTv6x52FW+IaygWU616W85v+p9H6BnSb1XEF0Zbn5MafIcrIB0JcsOfXUZDH+oirHtJ2cMEW8/rm63atwq0nEEcEUkJoyAz9RyZOLqv3fRuAQlcPxZLJ0r0QcKrQ==
  • Authentication-results-original: xen.org; dkim=none (message not signed) header.d=none;xen.org; dmarc=none action=none header.from=arm.com;
  • Cc: "open list:X86" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Julien Grall <jgrall@xxxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, Dario Faggioli <dfaggioli@xxxxxxxx>
  • Delivery-date: Wed, 23 Sep 2020 13:52:23 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Nodisclaimer: true
  • Original-authentication-results: xen.org; dkim=none (message not signed) header.d=none;xen.org; dmarc=none action=none header.from=arm.com;
  • Thread-index: AQHWkRb3YbUANCat5069iZiL+rQxOal2EYaAgAAFd4CAAChBgA==
  • Thread-topic: [RESEND][PATCH] xen/arm: sched: Ensure the vCPU context is seen before vcpu_pause() returns


> On 23 Sep 2020, at 12:27, Julien Grall <julien@xxxxxxx> wrote:
> 
> 
> 
> On 23/09/2020 12:08, Bertrand Marquis wrote:
>> Hi Julien,
>>> On 22 Sep 2020, at 20:31, Julien Grall <julien@xxxxxxx> wrote:
>>> 
>>> From: Julien Grall <jgrall@xxxxxxxxxx>
>>> 
>>> Some callers of vcpu_pause() will expect to access the latest vcpu
>>> context when the function returns (see XENDOMCTL_{set,get}vcpucontext}.
>>> 
>>> However, the latest vCPU context can only be observed after
>>> v->is_running has been observed to be false.
>>> 
>>> As there is no memory barrier instruction generated, a processor could
>>> try to speculatively access the vCPU context before it was observed.
>> The function vcpu_context_saved does contain a memory barrier already.
> 
> Memory barriers usually work in pair. We have a write barrier in 
> vcpu_context_saved() but no read barrier in the code relying on the 
> v->is_running.

Ok.

> 
>> Shouldn’t we make sure instead that any time is_running is modified to
>> false there is a barrier before (which is the case in vcpu_context_saved) ?
>> I understand the goal here but the barrier seem very far from the 
>> modification
>> of is_running.
> 
> That's not what I am trying to fix (see above). Instead, this patch will 
> ensure that when a pCPU observe v->is_running = false, then it can rely on 
> the context of the vCPU to be valid.

Ok you need a memory barrier after setting is_running to false, got it.

Cheers
Bertrand

> 
> Cheers,
> 
> -- 
> Julien Grall


 


Rackspace

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