From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1BBA7C12002 for ; Wed, 21 Jul 2021 15:37:41 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D405E61003 for ; Wed, 21 Jul 2021 15:37:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D405E61003 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=kbDOTQ6NldB02v6r/5x9TZsFEEzpAvFvBxrtB2UvRjI=; b=YTRNl23yTA/XwP 9/F2ZbwontWgSgdjOJ01M4wZ9bxYR1KW5OdfvaW+pwIZkTwSSeanlVFsCwdvD7BYnTay//2jng3ml WdJK3rGC+C8g6IAsMua6h99F04uTf5a+D6ST/N0O/M0TB53BNmCpYBv9lMBDDrzyyas0nwM00a3PT k84iKKlwRWGsuHfXg/vAJQWY5mYE3gBK/luxCanL2NSk1pWIdxIHTVOdHJ1oEjKPHksddmpDnu4KT pZ+KlSjFcFxM+jc9BKu/6U7mu4JuoCvZnmovQVO0+Fuyq8f4tNrrP8ByGNJPdJUuyb8ZV1QQz1GkR 8GAL/s6WjN6FBdWdnHKg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1m6EFv-00GLdm-SE; Wed, 21 Jul 2021 15:35:33 +0000 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1m6DwA-00GEgn-U2 for linux-arm-kernel@lists.infradead.org; Wed, 21 Jul 2021 15:15:08 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1626880505; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=QaTP1Yo6qFFIt4Y2xC3JPRyG4PRe8kuKhGKAihywiRs=; b=Gzuac4TGVwY1idv6sM3eG7qo6UGOrsnGLnz/4ttRBze7qHrUpBSDgFTRKEaSoOw/QVLm5n XLmS5zOWRQXTfqI6zWoz5ffgu3yYwb0YsC+3mMWekOpToj/O+GWxEWHlImtEN0mPobC9pl zYqFoMP4nIxNSMhj1CIleYpd0MA2JPM= Received: from mail-il1-f199.google.com (mail-il1-f199.google.com [209.85.166.199]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-104-mUAOl8lgN5yaKN1RalCOiQ-1; Wed, 21 Jul 2021 11:15:02 -0400 X-MC-Unique: mUAOl8lgN5yaKN1RalCOiQ-1 Received: by mail-il1-f199.google.com with SMTP id s12-20020a056e02216cb02901f9cee02769so1753442ilv.11 for ; Wed, 21 Jul 2021 08:15:02 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=QaTP1Yo6qFFIt4Y2xC3JPRyG4PRe8kuKhGKAihywiRs=; b=gi6eiQCDnSAD6oJ4/w+/2ZbXoqQcPeSW+i+EOK5Q+EQRVSHk8TqHGCHc30wXACRQ8K Zvp/hDFkFOIAx5i4oYR2iDdPpwtI2Um5gY4WVZe7QUuO3SMTFjJ/bD84Emc0VBdhK2Ha 3oG8o+K8eNJBatmp9ng0z+madd9OOlt+6TuVSqrSxw0SU81P2U4lSw75zaOxtwBxCMwi BdgCbfq1ulwpbTroBAOdNcp6jM75KfIgX/28S5H/Jy6zlg0D/GIApxd09fyxs3qEPWg3 XWdbxUcnEhKZ+e6Z/b6KI1683MamUQepIifgb4CjcfKROVERpPPAZnqr1MNS0PqympME bt6g== X-Gm-Message-State: AOAM530cxkcM0YmZikTsyHy9TRi9iDZUvm5gV8X5bQO75p7wEghHiuYO ZKOIjVbbyAYlgQ36+gpLjfRqjNmOc6TCohFrTV/RufjCVMgWNdoj9rxHVQlEFBUw98fX31DK6sW CCCsLOHeEjzhgtJGnv5XwOGWKfOQ/5SnWV/Y= X-Received: by 2002:a92:cb52:: with SMTP id f18mr24584237ilq.97.1626880501558; Wed, 21 Jul 2021 08:15:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzd/FbgpVsG1uAQQs/xRFLiKXf0pWWdYmq3RBA6j5gX0EFKv9+U0ZQHs17k7En54hjmVGaIUw== X-Received: by 2002:a92:cb52:: with SMTP id f18mr24584222ilq.97.1626880501393; Wed, 21 Jul 2021 08:15:01 -0700 (PDT) Received: from gator ([140.82.166.162]) by smtp.gmail.com with ESMTPSA id p18sm13090910ile.25.2021.07.21.08.15.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Jul 2021 08:15:00 -0700 (PDT) Date: Wed, 21 Jul 2021 17:14:58 +0200 From: Andrew Jones To: Oliver Upton Cc: kvm@vger.kernel.org, kvmarm@lists.cs.columbia.edu, Marc Zyngier , Raghavendra Rao Anata , Peter Shier , Sean Christopherson , David Matlack , Paolo Bonzini , linux-arm-kernel@lists.infradead.org, Jim Mattson Subject: Re: [PATCH v2 06/12] selftests: KVM: Add helpers for vCPU device attributes Message-ID: <20210721151458.bsfbjtk7rmlupfve@gator> References: <20210716212629.2232756-1-oupton@google.com> <20210716212629.2232756-7-oupton@google.com> MIME-Version: 1.0 In-Reply-To: <20210716212629.2232756-7-oupton@google.com> Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=drjones@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210721_081507_197069_ED96C6D0 X-CRM114-Status: GOOD ( 19.54 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Fri, Jul 16, 2021 at 09:26:23PM +0000, Oliver Upton wrote: > vCPU file descriptors are abstracted away from test code in KVM > selftests, meaning that tests cannot directly access a vCPU's device > attributes. Add helpers that tests can use to get at vCPU device > attributes. > > Signed-off-by: Oliver Upton > --- > .../testing/selftests/kvm/include/kvm_util.h | 9 +++++ > tools/testing/selftests/kvm/lib/kvm_util.c | 38 +++++++++++++++++++ > 2 files changed, 47 insertions(+) > > diff --git a/tools/testing/selftests/kvm/include/kvm_util.h b/tools/testing/selftests/kvm/include/kvm_util.h > index a8ac5d52e17b..1b3ef5757819 100644 > --- a/tools/testing/selftests/kvm/include/kvm_util.h > +++ b/tools/testing/selftests/kvm/include/kvm_util.h > @@ -240,6 +240,15 @@ int _kvm_device_access(int dev_fd, uint32_t group, uint64_t attr, > int kvm_device_access(int dev_fd, uint32_t group, uint64_t attr, > void *val, bool write); > > +int _vcpu_has_device_attr(struct kvm_vm *vm, uint32_t vcpuid, uint32_t group, > + uint64_t attr); > +int vcpu_has_device_attr(struct kvm_vm *vm, uint32_t vcpuid, uint32_t group, > + uint64_t attr); > +int _vcpu_access_device_attr(struct kvm_vm *vm, uint32_t vcpuid, uint32_t group, > + uint64_t attr, void *val, bool write); > +int vcpu_access_device_attr(struct kvm_vm *vm, uint32_t vcpuid, uint32_t group, > + uint64_t attr, void *val, bool write); > + > const char *exit_reason_str(unsigned int exit_reason); > > void virt_pgd_alloc(struct kvm_vm *vm); > diff --git a/tools/testing/selftests/kvm/lib/kvm_util.c b/tools/testing/selftests/kvm/lib/kvm_util.c > index 10a8ed691c66..b595e7dc3fc5 100644 > --- a/tools/testing/selftests/kvm/lib/kvm_util.c > +++ b/tools/testing/selftests/kvm/lib/kvm_util.c > @@ -2040,6 +2040,44 @@ int kvm_device_access(int dev_fd, uint32_t group, uint64_t attr, > return ret; > } > > +int _vcpu_has_device_attr(struct kvm_vm *vm, uint32_t vcpuid, uint32_t group, > + uint64_t attr) > +{ > + struct vcpu *vcpu = vcpu_find(vm, vcpuid); > + > + TEST_ASSERT(vcpu, "nonexistent vcpu id: %d", vcpuid); > + > + return _kvm_device_check_attr(vcpu->fd, group, attr); > +} > + > +int vcpu_has_device_attr(struct kvm_vm *vm, uint32_t vcpuid, uint32_t group, > + uint64_t attr) > +{ > + int ret = _vcpu_has_device_attr(vm, vcpuid, group, attr); > + > + TEST_ASSERT(!ret, "KVM_HAS_DEVICE_ATTR IOCTL failed, rc: %i errno: %i", ret, errno); > + return ret; > +} > + > +int _vcpu_access_device_attr(struct kvm_vm *vm, uint32_t vcpuid, uint32_t group, > + uint64_t attr, void *val, bool write) > +{ > + struct vcpu *vcpu = vcpu_find(vm, vcpuid); > + > + TEST_ASSERT(vcpu, "nonexistent vcpu id: %d", vcpuid); > + > + return _kvm_device_access(vcpu->fd, group, attr, val, write); > +} > + > +int vcpu_access_device_attr(struct kvm_vm *vm, uint32_t vcpuid, uint32_t group, > + uint64_t attr, void *val, bool write) > +{ > + int ret = _vcpu_access_device_attr(vm, vcpuid, group, attr, val, write); > + > + TEST_ASSERT(!ret, "KVM_SET|GET_DEVICE_ATTR IOCTL failed, rc: %i errno: %i", ret, errno); > + return ret; > +} Reviewed-by: Andrew Jones The 'assert !ret's are correct here. I see they are not correct in kvm_device_check_attr kvm_create_device kvm_device_access though, as they are 'assert ret >= 0', but the documentation says 0 on success. It'd be nice to get that fixed before we build more API on top of it. Thanks, drew > + > /* > * VM Dump > * > -- > 2.32.0.402.g57bb445576-goog > > _______________________________________________ > kvmarm mailing list > kvmarm@lists.cs.columbia.edu > https://lists.cs.columbia.edu/mailman/listinfo/kvmarm > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel