[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YSAsLShyWK3xgxse@google.com>
Date: Fri, 20 Aug 2021 22:26:53 +0000
From: Sean Christopherson <seanjc@...gle.com>
To: Mathieu Desnoyers <mathieu.desnoyers@...icios.com>
Cc: "Russell King, ARM Linux" <linux@...linux.org.uk>,
Catalin Marinas <catalin.marinas@....com>,
Will Deacon <will@...nel.org>, Guo Ren <guoren@...nel.org>,
Thomas Bogendoerfer <tsbogend@...ha.franken.de>,
Michael Ellerman <mpe@...erman.id.au>,
Heiko Carstens <hca@...ux.ibm.com>, gor <gor@...ux.ibm.com>,
Christian Borntraeger <borntraeger@...ibm.com>,
Oleg Nesterov <oleg@...hat.com>, rostedt <rostedt@...dmis.org>,
Ingo Molnar <mingo@...hat.com>,
Thomas Gleixner <tglx@...utronix.de>,
Peter Zijlstra <peterz@...radead.org>,
Andy Lutomirski <luto@...nel.org>,
paulmck <paulmck@...nel.org>, Boqun Feng <boqun.feng@...il.com>,
Paolo Bonzini <pbonzini@...hat.com>, shuah <shuah@...nel.org>,
Benjamin Herrenschmidt <benh@...nel.crashing.org>,
Paul Mackerras <paulus@...ba.org>,
linux-arm-kernel <linux-arm-kernel@...ts.infradead.org>,
linux-kernel <linux-kernel@...r.kernel.org>,
linux-csky <linux-csky@...r.kernel.org>,
linux-mips <linux-mips@...r.kernel.org>,
linuxppc-dev <linuxppc-dev@...ts.ozlabs.org>,
linux-s390 <linux-s390@...r.kernel.org>,
KVM list <kvm@...r.kernel.org>,
linux-kselftest <linux-kselftest@...r.kernel.org>,
Peter Foley <pefoley@...gle.com>,
Shakeel Butt <shakeelb@...gle.com>,
Ben Gardon <bgardon@...gle.com>
Subject: Re: [PATCH 1/5] KVM: rseq: Update rseq when processing NOTIFY_RESUME
on xfer to KVM guest
On Fri, Aug 20, 2021, Mathieu Desnoyers wrote:
> Without the lazy clear scheme, a rseq c.s. would look like:
>
> * init(rseq_cs)
> * cpu = TLS->rseq::cpu_id_start
> * [1] TLS->rseq::rseq_cs = rseq_cs
> * [start_ip] ----------------------------
> * [2] if (cpu != TLS->rseq::cpu_id)
> * goto abort_ip;
> * [3] <last_instruction_in_cs>
> * [post_commit_ip] ----------------------------
> * [4] TLS->rseq::rseq_cs = NULL
>
> But as a fast-path optimization, [4] is not entirely needed because the rseq_cs
> descriptor contains information about the instruction pointer range of the critical
> section. Therefore, userspace can omit [4], but if the kernel never clears it, it
> means that it will have to re-read the rseq_cs descriptor's content each time it
> needs to check it to confirm that it is not nested over a rseq c.s..
>
> So making the kernel lazily clear the rseq_cs pointer is just an optimization which
> ensures that the kernel won't do useless work the next time it needs to check
> rseq_cs, given that it has already validated that the userspace code is currently
> not within the rseq c.s. currently advertised by the rseq_cs field.
Thanks for the explanation, much appreciated!
Powered by blists - more mailing lists