Re: [PATCH 04/16] KVM: arm64: Add MMIO checking infrastructure

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

 



On Wed, Jul 28, 2021 at 10:57:30AM +0100, Marc Zyngier wrote:
> On Tue, 27 Jul 2021 19:11:08 +0100,
> Will Deacon <will@xxxxxxxxxx> wrote:
> > On Thu, Jul 15, 2021 at 05:31:47PM +0100, Marc Zyngier wrote:
> > > +bool kvm_install_ioguard_page(struct kvm_vcpu *vcpu, gpa_t ipa)
> > > +{
> > > +	struct kvm_mmu_memory_cache *memcache;
> > > +	struct kvm_memory_slot *memslot;
> > > +	int ret, idx;
> > > +
> > > +	if (!test_bit(KVM_ARCH_FLAG_MMIO_GUARD, &vcpu->kvm->arch.flags))
> > > +		return false;
> > > +
> > > +	/* Must be page-aligned */
> > > +	if (ipa & ~PAGE_MASK)
> > > +		return false;
> > > +
> > > +	/*
> > > +	 * The page cannot be in a memslot. At some point, this will
> > > +	 * have to deal with device mappings though.
> > > +	 */
> > > +	idx = srcu_read_lock(&vcpu->kvm->srcu);
> > > +	memslot = gfn_to_memslot(vcpu->kvm, ipa >> PAGE_SHIFT);
> > > +	srcu_read_unlock(&vcpu->kvm->srcu, idx);
> > 
> > What does this memslot check achieve? A new memslot could be added after
> > you've checked, no?
> 
> If you start allowing S2 annotations to coexist with potential memory
> mappings, you're in for trouble. The faulting logic will happily
> overwrite the annotation, and that's probably not what you want.

I don't disagree, but the check above appears to be racy.

> As for new (or moving) memslots, I guess they should be checked
> against existing annotations.

Something like that, but the devil is in the details as it will need to
synchronize with this check somehow.

Will
_______________________________________________
kvmarm mailing list
kvmarm@xxxxxxxxxxxxxxxxxxxxx
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm



[Index of Archives]     [Linux KVM]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux