mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [v2] KVM: x86: Question on lock protection in handle_ept_misconfig
@ 2025-07-09  6:50 zoudongjie (A)
  2025-07-09 13:01 ` Paolo Bonzini
  0 siblings, 1 reply; 2+ messages in thread
From: zoudongjie (A) @ 2025-07-09  6:50 UTC (permalink / raw)
  To: seanjc, pbonzini, tglx, mingo, bp, dave.hansen, x86, hpa, kvm,
	linux-kernel
  Cc: Chenzhendong (alex), luolongmin, Mujinsheng (DxJanesir),
	chenjianfei (D), Fangyi (Eric), lishan (E),
	Renxuming, suxiaodong, caijunjie (A), zoudongjie (A)

Resending as plain text to fix formatting issues.
---

Hi all,

I noticed that in handle_ept_misconfig(), kvm_io_bus_write() is called. And 
within kvm_io_bus_write(), BUS is obtained through srcu_dereference(). During 
this process, kvm->slots_lock is not acquired, nor is srcu_read_lock() called 
for protection. If another process is synchronizing BUS at the same time, 
synchronize_srcu_expedited() cannot safely reclaim space(it cannot protect 
srcu_dereference() outside the critical section?), how can we ensure that BUS 
obtained by kvm_io_bus_write() is the latest?

Thanks,
Junjie Cai

Reported by: Junjie Cai <mailto:caijunjie15@h-partners.com>


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [v2] KVM: x86: Question on lock protection in handle_ept_misconfig
  2025-07-09  6:50 [v2] KVM: x86: Question on lock protection in handle_ept_misconfig zoudongjie (A)
@ 2025-07-09 13:01 ` Paolo Bonzini
  0 siblings, 0 replies; 2+ messages in thread
From: Paolo Bonzini @ 2025-07-09 13:01 UTC (permalink / raw)
  To: zoudongjie (A)
  Cc: Sean Christopherson, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Dave Hansen, the arch/x86 maintainers, Anvin,
	H. Peter, kvm, Kernel Mailing List, Linux, Chenzhendong (alex),
	luolongmin, Mujinsheng (DxJanesir), chenjianfei (D),
	Fangyi (Eric), lishan (E), Renxuming, suxiaodong, caijunjie (A)

Il mer 9 lug 2025, 08:50 zoudongjie (A) <zoudongjie@huawei.com> ha scritto:
>
> Resending as plain text to fix formatting issues.
> ---
>
> Hi all,
>
> I noticed that in handle_ept_misconfig(), kvm_io_bus_write() is called. And
> within kvm_io_bus_write(), BUS is obtained through srcu_dereference(). During
> this process, kvm->slots_lock is not acquired, nor is srcu_read_lock() called
> for protection.


Hi, srcu_read_lock() is guaranteed by the caller (see vcpu_enter_guest
in arch/x86/kvm/x86.c).

In fact, almost all of KVM_RUN is covered by a SRCU read critical
section, except for:

1) the part where the processor is in guest mode and the nearby
preparations (that's vcpu_enter_guest)

2) when the vCPU goes to a non-runnable state, for example waiting for
an interrupt (search for kvm_vcpu_block and kvm_vcpu_halt)

Thanks,

Paolo

> If another process is synchronizing BUS at the same time,
> synchronize_srcu_expedited() cannot safely reclaim space(it cannot protect
> srcu_dereference() outside the critical section?), how can we ensure that BUS
> obtained by kvm_io_bus_write() is the latest?
>
> Thanks,
> Junjie Cai
>
> Reported by: Junjie Cai <mailto:caijunjie15@h-partners.com>
>


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-07-09 13:01 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-07-09  6:50 [v2] KVM: x86: Question on lock protection in handle_ept_misconfig zoudongjie (A)
2025-07-09 13:01 ` Paolo Bonzini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®