Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 55FE6C433FE for ; Sat, 25 Dec 2021 09:11:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231248AbhLYJLu (ORCPT ); Sat, 25 Dec 2021 04:11:50 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:37896 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231228AbhLYJLt (ORCPT ); Sat, 25 Dec 2021 04:11:49 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1640423508; 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=zldxMj+mOa4xEISADiWr6dy8ahQABwEEuVquONVwlSU=; b=dHRaPVDDTdKn/Z28wgdsHNReryDweiMjJmQYnPkR8WG+jnAkmER0aGBl3ZurDrwxnkK6lQ 9Rthp/v8W4zmYRi3IrRQD5KzwaHaGXz6j9/ioPZ8j6S9kDyKopOo/V3V82GvRMFT9lWdT4 8WuqE06OKGVtfNtoyYJTUa8HlXhNni8= Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-591-Tpi2xWg0OtKhCsKd9fiB6Q-1; Sat, 25 Dec 2021 04:11:47 -0500 X-MC-Unique: Tpi2xWg0OtKhCsKd9fiB6Q-1 Received: by mail-ed1-f69.google.com with SMTP id o20-20020a056402439400b003f83cf1e472so7923748edc.18 for ; Sat, 25 Dec 2021 01:11:46 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=zldxMj+mOa4xEISADiWr6dy8ahQABwEEuVquONVwlSU=; b=KTQzq9Bk1FVAWeqp2GdGTxOoXmatzrNPUbCwU+1X5sTr96mfKKcqc1JLLwsv2qXwiL lup/OoKJHsckFvxLJJtDsLmSoOqMjEs9RrCG/URupvZ0ElQqPNBHiID2yxbCttE3ZTrs wA/e6e6xfekj5SgQS0YHfY1QecuKOD9b9xfKIOqr9G8ayCCPa92hsFQ0DKCTRjocFga3 ggnJXENbahvJlHA/2YHUEaudIM9dQ2QBk3ZB8LZS6QJMu9Tz+aRdtFtTc8QnJthlTZDe iK1NEu8yl1lc4GyHyHxakx2LXarfzJYjLS0FkT6OcUyO/aGADRBuxHpUDJl4sRlOXhZ6 s7Og== X-Gm-Message-State: AOAM532Nqmbp+X8/AZrBZ98H/JJ+l/cB1qARJ8JuWg7rL0jD19Mto/T3 UmaJU2N+3qlux7koWowrcdSlse+EcDsQYGjzchZit1Kj4kUhC5y0flZ5278yaKoGcsxOFi5+NUQ piqwEa4VkWFqFAW+EBS9tFpu4 X-Received: by 2002:a17:907:9717:: with SMTP id jg23mr8342949ejc.593.1640423505854; Sat, 25 Dec 2021 01:11:45 -0800 (PST) X-Google-Smtp-Source: ABdhPJxYG9NlF9xuaeOATknk+JawNqx6o5eHic3XVZf5gR+23IdJV86It317VASJSiDbLfIH+6i+wA== X-Received: by 2002:a17:907:9717:: with SMTP id jg23mr8342924ejc.593.1640423505581; Sat, 25 Dec 2021 01:11:45 -0800 (PST) Received: from gator.home (cst2-173-70.cust.vodafone.cz. [31.30.173.70]) by smtp.gmail.com with ESMTPSA id y17sm3923961edd.31.2021.12.25.01.11.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 25 Dec 2021 01:11:44 -0800 (PST) Date: Sat, 25 Dec 2021 10:11:42 +0100 From: Andrew Jones To: Michael Roth Cc: linux-kselftest@vger.kernel.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, x86@kernel.org, Nathan Tempelman , Marc Orr , Steve Rutherford , Sean Christopherson , Mingwei Zhang , Brijesh Singh , Tom Lendacky , Varad Gautam , Shuah Khan , Vitaly Kuznetsov , David Woodhouse , Ricardo Koller , Jim Mattson , Joerg Roedel , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H . Peter Anvin" , Christian Borntraeger , Janosch Frank , David Hildenbrand , Claudio Imbrenda , Marc Zyngier , James Morse , Alexandru Elisei , Suzuki K Poulose , kvmarm@lists.cs.columbia.edu Subject: Re: [PATCH RFC 02/10] kvm: selftests: move ucall declarations into ucall_common.h Message-ID: <20211225091142.k6szpew4uatrvaus@gator.home> References: <20211210164620.11636-1-michael.roth@amd.com> <20211210164620.11636-3-michael.roth@amd.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20211210164620.11636-3-michael.roth@amd.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Dec 10, 2021 at 10:46:12AM -0600, Michael Roth wrote: > Now that core kvm_util declarations have special home in > kvm_util_base.h, move ucall-related declarations out into a separate > header. > > Signed-off-by: Michael Roth > --- > .../testing/selftests/kvm/include/kvm_util.h | 1 + > .../selftests/kvm/include/kvm_util_base.h | 49 --------------- > .../selftests/kvm/include/ucall_common.h | 59 +++++++++++++++++++ > 3 files changed, 60 insertions(+), 49 deletions(-) > create mode 100644 tools/testing/selftests/kvm/include/ucall_common.h > > diff --git a/tools/testing/selftests/kvm/include/kvm_util.h b/tools/testing/selftests/kvm/include/kvm_util.h > index c860ced3888d..c9286811a4cb 100644 > --- a/tools/testing/selftests/kvm/include/kvm_util.h > +++ b/tools/testing/selftests/kvm/include/kvm_util.h > @@ -8,5 +8,6 @@ > #define SELFTEST_KVM_UTIL_H > > #include "kvm_util_base.h" > +#include "ucall_common.h" > > #endif /* SELFTEST_KVM_UTIL_H */ Now that kvm_util.h is looking like a "libkvm.h", then we can do some more header cleanups to make that official. After this series is merged I'll send a series that - removes unnecessary includes from kvm_util_common.h and other headers - renames kvm_util.h to libkvm.h - also includes guest_modes.h and test_util.h from libkvm.h - simplify the includes of all unit tests since they'll be including libkvm.h - probably move include/sparsebit.h to lib, since no unit test needs it Thanks, drew > diff --git a/tools/testing/selftests/kvm/include/kvm_util_base.h b/tools/testing/selftests/kvm/include/kvm_util_base.h > index 8fb6aeff5469..4e2946ba3ff7 100644 > --- a/tools/testing/selftests/kvm/include/kvm_util_base.h > +++ b/tools/testing/selftests/kvm/include/kvm_util_base.h > @@ -360,55 +360,6 @@ int vm_create_device(struct kvm_vm *vm, struct kvm_create_device *cd); > > void assert_on_unhandled_exception(struct kvm_vm *vm, uint32_t vcpuid); > > -/* Common ucalls */ > -enum { > - UCALL_NONE, > - UCALL_SYNC, > - UCALL_ABORT, > - UCALL_DONE, > - UCALL_UNHANDLED, > -}; > - > -#define UCALL_MAX_ARGS 6 > - > -struct ucall { > - uint64_t cmd; > - uint64_t args[UCALL_MAX_ARGS]; > -}; > - > -void ucall_init(struct kvm_vm *vm, void *arg); > -void ucall_uninit(struct kvm_vm *vm); > -void ucall(uint64_t cmd, int nargs, ...); > -uint64_t get_ucall(struct kvm_vm *vm, uint32_t vcpu_id, struct ucall *uc); > - > -#define GUEST_SYNC_ARGS(stage, arg1, arg2, arg3, arg4) \ > - ucall(UCALL_SYNC, 6, "hello", stage, arg1, arg2, arg3, arg4) > -#define GUEST_SYNC(stage) ucall(UCALL_SYNC, 2, "hello", stage) > -#define GUEST_DONE() ucall(UCALL_DONE, 0) > -#define __GUEST_ASSERT(_condition, _condstr, _nargs, _args...) do { \ > - if (!(_condition)) \ > - ucall(UCALL_ABORT, 2 + _nargs, \ > - "Failed guest assert: " \ > - _condstr, __LINE__, _args); \ > -} while (0) > - > -#define GUEST_ASSERT(_condition) \ > - __GUEST_ASSERT(_condition, #_condition, 0, 0) > - > -#define GUEST_ASSERT_1(_condition, arg1) \ > - __GUEST_ASSERT(_condition, #_condition, 1, (arg1)) > - > -#define GUEST_ASSERT_2(_condition, arg1, arg2) \ > - __GUEST_ASSERT(_condition, #_condition, 2, (arg1), (arg2)) > - > -#define GUEST_ASSERT_3(_condition, arg1, arg2, arg3) \ > - __GUEST_ASSERT(_condition, #_condition, 3, (arg1), (arg2), (arg3)) > - > -#define GUEST_ASSERT_4(_condition, arg1, arg2, arg3, arg4) \ > - __GUEST_ASSERT(_condition, #_condition, 4, (arg1), (arg2), (arg3), (arg4)) > - > -#define GUEST_ASSERT_EQ(a, b) __GUEST_ASSERT((a) == (b), #a " == " #b, 2, a, b) > - > int vm_get_stats_fd(struct kvm_vm *vm); > int vcpu_get_stats_fd(struct kvm_vm *vm, uint32_t vcpuid); > > diff --git a/tools/testing/selftests/kvm/include/ucall_common.h b/tools/testing/selftests/kvm/include/ucall_common.h > new file mode 100644 > index 000000000000..9eecc9d40b79 > --- /dev/null > +++ b/tools/testing/selftests/kvm/include/ucall_common.h > @@ -0,0 +1,59 @@ > +/* SPDX-License-Identifier: GPL-2.0-only */ > +/* > + * tools/testing/selftests/kvm/include/kvm_util.h > + * > + * Copyright (C) 2018, Google LLC. > + */ > +#ifndef SELFTEST_KVM_UCALL_COMMON_H > +#define SELFTEST_KVM_UCALL_COMMON_H > + > +/* Common ucalls */ > +enum { > + UCALL_NONE, > + UCALL_SYNC, > + UCALL_ABORT, > + UCALL_DONE, > + UCALL_UNHANDLED, > +}; > + > +#define UCALL_MAX_ARGS 6 > + > +struct ucall { > + uint64_t cmd; > + uint64_t args[UCALL_MAX_ARGS]; > +}; > + > +void ucall_init(struct kvm_vm *vm, void *arg); > +void ucall_uninit(struct kvm_vm *vm); > +void ucall(uint64_t cmd, int nargs, ...); > +uint64_t get_ucall(struct kvm_vm *vm, uint32_t vcpu_id, struct ucall *uc); > + > +#define GUEST_SYNC_ARGS(stage, arg1, arg2, arg3, arg4) \ > + ucall(UCALL_SYNC, 6, "hello", stage, arg1, arg2, arg3, arg4) > +#define GUEST_SYNC(stage) ucall(UCALL_SYNC, 2, "hello", stage) > +#define GUEST_DONE() ucall(UCALL_DONE, 0) > +#define __GUEST_ASSERT(_condition, _condstr, _nargs, _args...) do { \ > + if (!(_condition)) \ > + ucall(UCALL_ABORT, 2 + _nargs, \ > + "Failed guest assert: " \ > + _condstr, __LINE__, _args); \ > +} while (0) > + > +#define GUEST_ASSERT(_condition) \ > + __GUEST_ASSERT(_condition, #_condition, 0, 0) > + > +#define GUEST_ASSERT_1(_condition, arg1) \ > + __GUEST_ASSERT(_condition, #_condition, 1, (arg1)) > + > +#define GUEST_ASSERT_2(_condition, arg1, arg2) \ > + __GUEST_ASSERT(_condition, #_condition, 2, (arg1), (arg2)) > + > +#define GUEST_ASSERT_3(_condition, arg1, arg2, arg3) \ > + __GUEST_ASSERT(_condition, #_condition, 3, (arg1), (arg2), (arg3)) > + > +#define GUEST_ASSERT_4(_condition, arg1, arg2, arg3, arg4) \ > + __GUEST_ASSERT(_condition, #_condition, 4, (arg1), (arg2), (arg3), (arg4)) > + > +#define GUEST_ASSERT_EQ(a, b) __GUEST_ASSERT((a) == (b), #a " == " #b, 2, a, b) > + > +#endif /* SELFTEST_KVM_UCALL_COMMON_H */ > -- > 2.25.1 >