[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200311174422.GI479302@xz-x1>
Date: Wed, 11 Mar 2020 13:44:22 -0400
From: Peter Xu <peterx@...hat.com>
To: Andrew Jones <drjones@...hat.com>
Cc: linux-kernel@...r.kernel.org, kvm@...r.kernel.org,
Yan Zhao <yan.y.zhao@...el.com>,
Jason Wang <jasowang@...hat.com>,
Alex Williamson <alex.williamson@...hat.com>,
Vitaly Kuznetsov <vkuznets@...hat.com>,
"Dr . David Alan Gilbert" <dgilbert@...hat.com>,
Christophe de Dinechin <dinechin@...hat.com>,
"Michael S . Tsirkin" <mst@...hat.com>,
Kevin Tian <kevin.tian@...el.com>,
Paolo Bonzini <pbonzini@...hat.com>,
Sean Christopherson <sean.j.christopherson@...el.com>
Subject: Re: [PATCH v6 12/14] KVM: selftests: Add dirty ring buffer test
On Tue, Mar 10, 2020 at 09:18:47AM +0100, Andrew Jones wrote:
> On Mon, Mar 09, 2020 at 06:25:29PM -0400, Peter Xu wrote:
> > +void *vcpu_map_dirty_ring(struct kvm_vm *vm, uint32_t vcpuid)
> > +{
> > + struct vcpu *vcpu;
> > + uint32_t size = vm->dirty_ring_size;
> > +
> > + TEST_ASSERT(size > 0, "Should enable dirty ring first");
> > +
> > + vcpu = vcpu_find(vm, vcpuid);
> > +
> > + TEST_ASSERT(vcpu, "Cannot find vcpu %u", vcpuid);
> > +
> > + if (!vcpu->dirty_gfns) {
> > + void *addr;
> > +
> > + addr = mmap(NULL, size, PROT_READ,
> > + MAP_PRIVATE, vcpu->fd,
> > + vm->page_size * KVM_DIRTY_LOG_PAGE_OFFSET);
> > + TEST_ASSERT(addr == MAP_FAILED, "Dirty ring mapped private");
> > +
> > + addr = mmap(NULL, size, PROT_READ | PROT_EXEC,
> > + MAP_PRIVATE, vcpu->fd,
> > + vm->page_size * KVM_DIRTY_LOG_PAGE_OFFSET);
> > + TEST_ASSERT(addr == MAP_FAILED, "Dirty ring mapped exec");
> > +
> > + addr = mmap(NULL, size, PROT_READ | PROT_WRITE,
> > + MAP_SHARED, vcpu->fd,
> > + vm->page_size * KVM_DIRTY_LOG_PAGE_OFFSET);
>
> No TEST_ASSERT for this mmap?
It'll be used (verified) later. :) Though never harm to add one!
Thanks,
>
> > +
> > + vcpu->dirty_gfns = addr;
> > + vcpu->dirty_gfns_count = size / sizeof(struct kvm_dirty_gfn);
> > + }
> > +
> > + return vcpu->dirty_gfns;
> > +}
>
--
Peter Xu
Powered by blists - more mailing lists