[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <c5d1257c-b522-152f-cb2f-d23fd8110609@arm.com>
Date: Wed, 3 Jul 2019 18:35:23 +0100
From: James Morse <james.morse@....com>
To: Julien Grall <julien.grall@....com>
Cc: linux-kernel@...r.kernel.org, linux-arm-kernel@...ts.infradead.org,
kvmarm@...ts.cs.columbia.edu, marc.zyngier@....com,
julien.thierry@....com, suzuki.poulose@....com,
catalin.marinas@....com, will.deacon@....com
Subject: Re: [RFC v2 12/14] arm64/lib: asid: Allow user to update the context
under the lock
Hi Julien,
On 20/06/2019 14:06, Julien Grall wrote:
> Some users of the ASID allocator (e.g VMID) will require to update the
> context when a new ASID is generated. This has to be protected by a lock
> to prevent concurrent modification.
>
> Rather than introducing yet another lock, it is possible to re-use the
> allocator lock for that purpose. This patch introduces a new callback
> that will be call when updating the context.
You're using this later in the series to mask out the generation from the atomic64 to
leave just the vmid.
Where does this concurrent modification happen? The value is only written if we have a
rollover, and while its active the only bits that could change are the generation.
(subsequent vCPUs that take the slow path for the same VM will see the updated generation
and skip the new_context call)
If we did the generation filtering in update_vmid() after the call to
asid_check_context(), what would go wrong?
It happens more often than is necessary and would need a WRITE_ONCE(), but the vmid can't
change until we become preemptible and another vCPU gets a chance to make its vmid active.
This thing is horribly subtle, so I'm sure I've missed something here!
I can't see where the arch code's equivalent case is. It also filters the generation out
of the atomic64 in cpu_do_switch_mm(). This happens with interrupts masked so we can't
re-schedule and set another asid as 'active'. KVM's equivalent is !preemptible.
Thanks,
James
Powered by blists - more mailing lists