kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Palmer Dabbelt <palmer@dabbelt.com>
To: mark.rutland@arm.com
Cc: linux-kernel@vger.kernel.org, aleksandar.qemu.devel@gmail.com,
	alexandru.elisei@arm.com, anup@brainfault.org,
	aou@eecs.berkeley.edu, Atish Patra <atishp@rivosinc.com>,
	benh@kernel.crashing.org, borntraeger@linux.ibm.com,
	bp@alien8.de, catalin.marinas@arm.com, chenhuacai@kernel.org,
	dave.hansen@linux.intel.com, david@redhat.com,
	frankja@linux.ibm.com, frederic@kernel.org, gor@linux.ibm.com,
	hca@linux.ibm.com, imbrenda@linux.ibm.com, james.morse@arm.com,
	jmattson@google.com, joro@8bytes.org, kvm@vger.kernel.org,
	mark.rutland@arm.com, Marc Zyngier <maz@kernel.org>,
	mingo@redhat.com, mpe@ellerman.id.au, nsaenzju@redhat.com,
	paulmck@kernel.org, paulus@samba.org,
	Paul Walmsley <paul.walmsley@sifive.com>,
	pbonzini@redhat.com, seanjc@google.com, suzuki.poulose@arm.com,
	tglx@linutronix.de, tsbogend@alpha.franken.de,
	vkuznets@redhat.com, wanpengli@tencent.com,
	Will Deacon <will@kernel.org>
Subject: Re: [PATCH 0/5] kvm: fix latent guest entry/exit bugs
Date: Tue, 11 Jan 2022 10:47:38 -0800 (PST)	[thread overview]
Message-ID: <mhng-d83df857-7865-4514-a339-68439336974a@palmer-ri-x1c9> (raw)
In-Reply-To: <20220111153539.2532246-1-mark.rutland@arm.com>

On Tue, 11 Jan 2022 07:35:34 PST (-0800), mark.rutland@arm.com wrote:
> Several architectures have latent bugs around guest entry/exit, most
> notably:
>
> 1) Several architectures enable interrupts between guest_enter() and
>    guest_exit(). As this period is an RCU extended quiescent state (EQS) this
>    is unsound unless the irq entry code explicitly wakes RCU, which most
>    architectures only do for entry from usersapce or idle.
>
>    I believe this affects: arm64, riscv, s390
>
>    I am not sure about powerpc.
>
> 2) Several architectures permit instrumentation of code between
>    guest_enter() and guest_exit(), e.g. KASAN, KCOV, KCSAN, etc. As
>    instrumentation may directly o indirectly use RCU, this has the same
>    problems as with interrupts.
>
>    I believe this affects: arm64, mips, powerpc, riscv, s390

Moving to Atish and Anup's new email addresses, looks like MAINTAINERS 
hasn't been updated yet.  I thought I remembering seeing patches getting 
picked up for these, but LMK if you guys were expecting me to send them 
along -- sorry if I misunderstood!

>
> 3) Several architectures do not inform lockdep and tracing that
>    interrupts are enabled during the execution of the guest, or do so in
>    an incorrect order. Generally
>    this means that logs will report IRQs being masked for much longer
>    than is actually the case, which is not ideal for debugging. I don't
>    know whether this affects the correctness of lockdep.
>
>    I believe this affects: arm64, mips, powerpc, riscv, s390
>
> This was previously fixed for x86 specifically in a series of commits:
>
>   87fa7f3e98a1310e ("x86/kvm: Move context tracking where it belongs")
>   0642391e2139a2c1 ("x86/kvm/vmx: Add hardirq tracing to guest enter/exit")
>   9fc975e9efd03e57 ("x86/kvm/svm: Add hardirq tracing on guest enter/exit")
>   3ebccdf373c21d86 ("x86/kvm/vmx: Move guest enter/exit into .noinstr.text")
>   135961e0a7d555fc ("x86/kvm/svm: Move guest enter/exit into .noinstr.text")
>   160457140187c5fb ("KVM: x86: Defer vtime accounting 'til after IRQ handling")
>   bc908e091b326467 ("KVM: x86: Consolidate guest enter/exit logic to common helpers")
>
> But other architectures were left broken, and the infrastructure for
> handling this correctly is x86-specific.
>
> This series introduces generic helper functions which can be used to
> handle the problems above, and migrates architectures over to these,
> fixing the latent issues.
>
> I wasn't able to figure my way around powerpc and s390, so I have not
> altered these. I'd appreciate if anyone could take a look at those
> cases, and either have a go at patches or provide some feedback as to
> any alternative approaches which work work better there.
>
> I have build-tested the arm64, mips, riscv, and x86 cases, but I don't
> have a suitable HW setup to test these, so any review and/or testing
> would be much appreciated.
>
> I've pushed the series (based on v5.16) to my kvm/entry-rework branch:
>
>   https://git.kernel.org/pub/scm/linux/kernel/git/mark/linux.git/log/?h=kvm/entry-rework
>   git://git.kernel.org/pub/scm/linux/kernel/git/mark/linux.git kvm/entry-rework
>
> ... also tagged as kvm-entry-rework-20210111
>
> Thanks,
> Mark.
>
> Mark Rutland (5):
>   kvm: add exit_to_guest_mode() and enter_from_guest_mode()
>   kvm/arm64: rework guest entry logic
>   kvm/mips: rework guest entry logic
>   kvm/riscv: rework guest entry logic
>   kvm/x86: rework guest entry logic
>
>  arch/arm64/kvm/arm.c     |  51 +++++++++++-------
>  arch/mips/kvm/mips.c     |  37 ++++++++++++--
>  arch/riscv/kvm/vcpu.c    |  44 ++++++++++------
>  arch/x86/kvm/svm/svm.c   |   4 +-
>  arch/x86/kvm/vmx/vmx.c   |   4 +-
>  arch/x86/kvm/x86.c       |   4 +-
>  arch/x86/kvm/x86.h       |  45 ----------------
>  include/linux/kvm_host.h | 108 +++++++++++++++++++++++++++++++++++++--
>  8 files changed, 206 insertions(+), 91 deletions(-)

  parent reply	other threads:[~2022-01-11 18:47 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-11 15:35 [PATCH 0/5] kvm: fix latent guest entry/exit bugs Mark Rutland
2022-01-11 15:35 ` [PATCH 1/5] kvm: add exit_to_guest_mode() and enter_from_guest_mode() Mark Rutland
2022-01-11 17:54   ` Marc Zyngier
2022-01-13 11:01     ` Mark Rutland
2022-01-13 11:55       ` Marc Zyngier
2022-01-13 13:01         ` Mark Rutland
2022-01-13 20:32   ` Sean Christopherson
2022-01-14 11:48     ` Mark Rutland
2022-01-14 16:11       ` Sean Christopherson
2022-01-18 13:01         ` Mark Rutland
2022-01-11 15:35 ` [PATCH 2/5] kvm/arm64: rework guest entry logic Mark Rutland
2022-01-11 17:55   ` Marc Zyngier
2022-01-13 11:17     ` Mark Rutland
2022-01-13 11:43       ` Marc Zyngier
2022-01-13 12:58         ` Mark Rutland
2022-01-11 15:35 ` [PATCH 3/5] kvm/mips: " Mark Rutland
2022-01-11 15:35 ` [PATCH 4/5] kvm/riscv: " Mark Rutland
2022-01-11 15:35 ` [PATCH 5/5] kvm/x86: " Mark Rutland
2022-01-13 20:50   ` Sean Christopherson
2022-01-14 12:05     ` Mark Rutland
2022-01-14 16:49       ` Sean Christopherson
2022-01-11 18:47 ` Palmer Dabbelt [this message]
2022-01-13 15:20 ` [PATCH 0/5] kvm: fix latent guest entry/exit bugs Christian Borntraeger
2022-01-14 12:19   ` Mark Rutland
2022-01-14 12:29     ` Christian Borntraeger
2022-01-14 13:32       ` Mark Rutland
2022-01-14 13:51         ` Christian Borntraeger
2022-01-14 15:19           ` Mark Rutland
2022-01-17 17:45             ` Paolo Bonzini
2022-01-18 12:02               ` Mark Rutland
2022-01-18 12:08                 ` Christian Borntraeger
2022-01-18 12:42                 ` Christian Borntraeger
2022-01-18 13:12                   ` Mark Rutland
2022-01-18 14:15                     ` Christian Borntraeger
2022-01-18 15:43                       ` Mark Rutland
2022-01-18 16:09                     ` Sven Schnelle
2022-01-18 17:50                       ` Mark Rutland
2022-01-18 18:12                         ` Mark Rutland
2022-01-19  6:41                         ` Sven Schnelle

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=mhng-d83df857-7865-4514-a339-68439336974a@palmer-ri-x1c9 \
    --to=palmer@dabbelt.com \
    --cc=aleksandar.qemu.devel@gmail.com \
    --cc=alexandru.elisei@arm.com \
    --cc=anup@brainfault.org \
    --cc=aou@eecs.berkeley.edu \
    --cc=atishp@rivosinc.com \
    --cc=benh@kernel.crashing.org \
    --cc=borntraeger@linux.ibm.com \
    --cc=bp@alien8.de \
    --cc=catalin.marinas@arm.com \
    --cc=chenhuacai@kernel.org \
    --cc=dave.hansen@linux.intel.com \
    --cc=david@redhat.com \
    --cc=frankja@linux.ibm.com \
    --cc=frederic@kernel.org \
    --cc=gor@linux.ibm.com \
    --cc=hca@linux.ibm.com \
    --cc=imbrenda@linux.ibm.com \
    --cc=james.morse@arm.com \
    --cc=jmattson@google.com \
    --cc=joro@8bytes.org \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=maz@kernel.org \
    --cc=mingo@redhat.com \
    --cc=mpe@ellerman.id.au \
    --cc=nsaenzju@redhat.com \
    --cc=paul.walmsley@sifive.com \
    --cc=paulmck@kernel.org \
    --cc=paulus@samba.org \
    --cc=pbonzini@redhat.com \
    --cc=seanjc@google.com \
    --cc=suzuki.poulose@arm.com \
    --cc=tglx@linutronix.de \
    --cc=tsbogend@alpha.franken.de \
    --cc=vkuznets@redhat.com \
    --cc=wanpengli@tencent.com \
    --cc=will@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).