From nobody Mon Apr 27 12:16:45 2026 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 5CF69CCA47D for ; Mon, 13 Jun 2022 19:00:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346572AbiFMTAy (ORCPT ); Mon, 13 Jun 2022 15:00:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49332 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345547AbiFMTAV (ORCPT ); Mon, 13 Jun 2022 15:00:21 -0400 Received: from mail-pf1-x44a.google.com (mail-pf1-x44a.google.com [IPv6:2607:f8b0:4864:20::44a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5DCE399699 for ; Mon, 13 Jun 2022 09:19:47 -0700 (PDT) Received: by mail-pf1-x44a.google.com with SMTP id y66-20020a62ce45000000b0051bb4d19f5fso2529074pfg.18 for ; Mon, 13 Jun 2022 09:19:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=reply-to:date:in-reply-to:message-id:mime-version:references :subject:from:to:cc; bh=sy+hmtF7QKGhId1UgWThmfgFGGqtRHfIUJnJ5VlAWU0=; b=qrtFAHt9rp+72ySJkfHU7Fg5FmipHO1J6AWR5Swn2IiWMy2/NArZiMfakO3QjNb3B0 GmjpctXxY4ozxNYdvp2wSgh09QgpjtMaIgjT1WIg90tbaktKV7yTsGpfOd2gaYI5xuQB kGPRBBtzQvy8WGwGe5wa2B0nZj5Gmc40dfzLhCPC8caKQnFlajkHevIoUpRhYJibO5Yl EIYL+U9VCoXKvpNF+1UjtfJlpK2J9aIlGi4gJmeGivVGYEa5j7asTZ0KmZ07pF5+Nhdr UXk7SGoTA0wkvw/PdN+7adsuXp6nExu+mo4SCI5aThjSUedxIF1z2QFwdQB0Hg2Pnasc E7jg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:reply-to:date:in-reply-to:message-id :mime-version:references:subject:from:to:cc; bh=sy+hmtF7QKGhId1UgWThmfgFGGqtRHfIUJnJ5VlAWU0=; b=LuTT+xI8AuqF/hew1qjqNSLUWs9lafuxC3ns6PeRPSUqSHEJSu3qJW+Ctzx+/bVYGV zWE803/OPr0bltt/jqOgkRvrsvN8ysaspC5rdop0ssddU/C3JF9za6WMTz8ulbZwDwiP XwfWFUBgJjsk7VIDTzbzyrXYp89eqh2seNfOVYvvtx7VnGpnrF8vjDEPOnnv9h4a7VHq yEbUE5NEjp/0ddRqvTpKiHPMnQC3WtJL5mNiDNSD7tDoEbuk8nl80gXEX80rPEYLFrpW DpTvppbrj2sDmoIjORsaVxve8Rm76SAiFTJKE0OSWcM/3BFGezJocw6ff16iW/pyg4i4 LQGA== X-Gm-Message-State: AJIora8kpIQJndxL1zq4fpH8J3XPg45c44DvGgw8fJKpnybICyCf9YkC CuKoTnFECtBkM/P6YqVo7Lj0ZBrLRnc= X-Google-Smtp-Source: AGRyM1vE38OcLZYRVPHib6kgCVJ/M2iTypkcdODR6DxYQT/Af3g0vj733jESj1NcLT/9Rd2w3OiIJl6JOxs= X-Received: from seanjc.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:3e5]) (user=seanjc job=sendgmr) by 2002:a17:902:d50f:b0:166:41a8:abf5 with SMTP id b15-20020a170902d50f00b0016641a8abf5mr100470plg.17.1655137186866; Mon, 13 Jun 2022 09:19:46 -0700 (PDT) Reply-To: Sean Christopherson Date: Mon, 13 Jun 2022 16:19:39 +0000 In-Reply-To: <20220613161942.1586791-1-seanjc@google.com> Message-Id: <20220613161942.1586791-2-seanjc@google.com> Mime-Version: 1.0 References: <20220613161942.1586791-1-seanjc@google.com> X-Mailer: git-send-email 2.36.1.476.g0c4daa206d-goog Subject: [PATCH 1/4] KVM: selftests: Add a missing apostrophe in comment to show ownership From: Sean Christopherson To: Paolo Bonzini Cc: Andrew Jones , kvm@vger.kernel.org, linux-kernel@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add an apostrophe in a comment about it being the caller's, not callers, responsibility to free an object. Reported-by: Andrew Jones Fixes: 768e9a61856b ("KVM: selftests: Purge vm+vcpu_id =3D=3D vcpu sillines= s") Signed-off-by: Sean Christopherson Reviewed-by: Andrew Jones --- tools/testing/selftests/kvm/lib/kvm_util.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/testing/selftests/kvm/lib/kvm_util.c b/tools/testing/sel= ftests/kvm/lib/kvm_util.c index 39f2f5f1338f..0c550fb0dab2 100644 --- a/tools/testing/selftests/kvm/lib/kvm_util.c +++ b/tools/testing/selftests/kvm/lib/kvm_util.c @@ -1434,7 +1434,7 @@ void vcpu_run_complete_io(struct kvm_vcpu *vcpu) /* * Get the list of guest registers which are supported for * KVM_GET_ONE_REG/KVM_SET_ONE_REG ioctls. Returns a kvm_reg_list pointer, - * it is the callers responsibility to free the list. + * it is the caller's responsibility to free the list. */ struct kvm_reg_list *vcpu_get_reg_list(struct kvm_vcpu *vcpu) { --=20 2.36.1.476.g0c4daa206d-goog From nobody Mon Apr 27 12:16:45 2026 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 1CF30CCA47B for ; Mon, 13 Jun 2022 19:01:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346740AbiFMTBC (ORCPT ); Mon, 13 Jun 2022 15:01:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44936 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346266AbiFMTAV (ORCPT ); Mon, 13 Jun 2022 15:00:21 -0400 Received: from mail-pf1-x44a.google.com (mail-pf1-x44a.google.com [IPv6:2607:f8b0:4864:20::44a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 43A539969A for ; Mon, 13 Jun 2022 09:19:49 -0700 (PDT) Received: by mail-pf1-x44a.google.com with SMTP id x19-20020aa78f13000000b0051bdda60a06so2547734pfr.2 for ; Mon, 13 Jun 2022 09:19:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=reply-to:date:in-reply-to:message-id:mime-version:references :subject:from:to:cc; bh=WzGiy8MvhiIUMi0s+wtsSIHmWc5cSwuMnyGQLZRW9iE=; b=TmRZ8aVm8k7OvscC44C/b2jeDc4I79KMJqDidpu3fidjaRCDoHLjhsWb/Vr5AiMZTf cYPhbxDt12l+cE3KFcvcEa5obW/XZsdbPKAx+2BliPFQIyKy0DePwMuknXTWQMVRf6Ed QJw6IZfHxdVp+FEa2WnNHrxENVPpEzIH9VjXFoZZf+wPZH221AWWvXkvQv4YHeG+Ek44 bV8JTq23EsoRQyFSXipy4q7+fnGnu62yHj3vPpOCKUxgyJ8th5exzKEnDGvmoDc5arLu JXgJLz6cmOKwTiyYPTkjsG80WWC99rp/aWetKZjQ6LK9KpqGhuP0AWxY6XgkEMzTYIWA Onlg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:reply-to:date:in-reply-to:message-id :mime-version:references:subject:from:to:cc; bh=WzGiy8MvhiIUMi0s+wtsSIHmWc5cSwuMnyGQLZRW9iE=; b=mG0Yl5ry13ENxrafmaIzH+GDEdcivtJONjgbkiHTvCzdvSAa52yNTWPYepbLSAneY7 q2BBhPWEjg5oCPDUkVoyB7lBUv6CZUozoy4UfvC8iaNHZg7gCWCy0EXgdHRLAwqvyyo1 ReZn4xFfMUkGM+qhGjccrrIrduc9TZG8Xz99IVmIHNesNsI6cCMlXxg/kLvilhYlRt0V iKOK/nb8y3CRrwQjmY29G2IW6K0fE0OZlWR0YwwYcaGi+RLVskmWjLfBqbZNIkR9hQnv 2uf3L79CcJbKMfLtEPtzDgIx+MDzNLzlQyZpLb7v0SRbSY4h3IgfmQGCZ+UmP3SuOXl+ EW1g== X-Gm-Message-State: AJIora83Ko79LTOfF0OpEVVxzZyn72kBye38WzsovtIfLmZL7eveB4fV wNWnm5eMq/iyth5ECXRc6XOGwnTlZDg= X-Google-Smtp-Source: AGRyM1tYM/Hx79fv6bDuIWPkGeu+wRbTZRlEQXOt3Rbnug4Kp1EytPfKuwr/kETntYYPlu30Xh55c7O7jd4= X-Received: from seanjc.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:3e5]) (user=seanjc job=sendgmr) by 2002:a17:902:d551:b0:168:93b6:a94a with SMTP id z17-20020a170902d55100b0016893b6a94amr77699plf.149.1655137188739; Mon, 13 Jun 2022 09:19:48 -0700 (PDT) Reply-To: Sean Christopherson Date: Mon, 13 Jun 2022 16:19:40 +0000 In-Reply-To: <20220613161942.1586791-1-seanjc@google.com> Message-Id: <20220613161942.1586791-3-seanjc@google.com> Mime-Version: 1.0 References: <20220613161942.1586791-1-seanjc@google.com> X-Mailer: git-send-email 2.36.1.476.g0c4daa206d-goog Subject: [PATCH 2/4] KVM: selftests: Call a dummy helper in VM/vCPU ioctls() to enforce type From: Sean Christopherson To: Paolo Bonzini Cc: Andrew Jones , kvm@vger.kernel.org, linux-kernel@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Replace the goofy static_assert on the size of the @vm/@vcpu parameters with a call to a dummy helper, i.e. let the compiler naturally complain about an incompatible type instead of homebrewing a poor replacement. Reported-by: Andrew Jones Fixes: fcba483e8246 ("KVM: selftests: Sanity check input to ioctls() at bui= ld time") Signed-off-by: Sean Christopherson Reviewed-by: Andrew Jones --- .../selftests/kvm/include/kvm_util_base.h | 57 ++++++++++--------- 1 file changed, 31 insertions(+), 26 deletions(-) diff --git a/tools/testing/selftests/kvm/include/kvm_util_base.h b/tools/te= sting/selftests/kvm/include/kvm_util_base.h index cdaea2383543..7ebfc8c7de17 100644 --- a/tools/testing/selftests/kvm/include/kvm_util_base.h +++ b/tools/testing/selftests/kvm/include/kvm_util_base.h @@ -186,50 +186,55 @@ static inline bool kvm_has_cap(long cap) ioctl(fd, cmd, arg); \ }) =20 -#define __kvm_ioctl(kvm_fd, cmd, arg) \ +#define __kvm_ioctl(kvm_fd, cmd, arg) \ kvm_do_ioctl(kvm_fd, cmd, arg) =20 =20 -#define _kvm_ioctl(kvm_fd, cmd, name, arg) \ -({ \ - int ret =3D __kvm_ioctl(kvm_fd, cmd, arg); \ - \ - TEST_ASSERT(!ret, __KVM_IOCTL_ERROR(name, ret)); \ +#define _kvm_ioctl(kvm_fd, cmd, name, arg) \ +({ \ + int ret =3D __kvm_ioctl(kvm_fd, cmd, arg); \ + \ + TEST_ASSERT(!ret, __KVM_IOCTL_ERROR(name, ret)); \ }) =20 #define kvm_ioctl(kvm_fd, cmd, arg) \ _kvm_ioctl(kvm_fd, cmd, #cmd, arg) =20 -#define __vm_ioctl(vm, cmd, arg) \ -({ \ - static_assert(sizeof(*(vm)) =3D=3D sizeof(struct kvm_vm), ""); \ - kvm_do_ioctl((vm)->fd, cmd, arg); \ +static __always_inline void static_assert_is_vm(struct kvm_vm *vm) { } + +#define __vm_ioctl(vm, cmd, arg) \ +({ \ + static_assert_is_vm(vm); \ + kvm_do_ioctl((vm)->fd, cmd, arg); \ }) =20 -#define _vm_ioctl(vm, cmd, name, arg) \ -({ \ - int ret =3D __vm_ioctl(vm, cmd, arg); \ - \ - TEST_ASSERT(!ret, __KVM_IOCTL_ERROR(name, ret)); \ +#define _vm_ioctl(vm, cmd, name, arg) \ +({ \ + int ret =3D __vm_ioctl(vm, cmd, arg); \ + \ + TEST_ASSERT(!ret, __KVM_IOCTL_ERROR(name, ret)); \ }) =20 -#define vm_ioctl(vm, cmd, arg) \ +#define vm_ioctl(vm, cmd, arg) \ _vm_ioctl(vm, cmd, #cmd, arg) =20 -#define __vcpu_ioctl(vcpu, cmd, arg) \ -({ \ - static_assert(sizeof(*(vcpu)) =3D=3D sizeof(struct kvm_vcpu), ""); \ - kvm_do_ioctl((vcpu)->fd, cmd, arg); \ + +static __always_inline void static_assert_is_vcpu(struct kvm_vcpu *vcpu) {= } + +#define __vcpu_ioctl(vcpu, cmd, arg) \ +({ \ + static_assert_is_vcpu(vcpu); \ + kvm_do_ioctl((vcpu)->fd, cmd, arg); \ }) =20 -#define _vcpu_ioctl(vcpu, cmd, name, arg) \ -({ \ - int ret =3D __vcpu_ioctl(vcpu, cmd, arg); \ - \ - TEST_ASSERT(!ret, __KVM_IOCTL_ERROR(name, ret)); \ +#define _vcpu_ioctl(vcpu, cmd, name, arg) \ +({ \ + int ret =3D __vcpu_ioctl(vcpu, cmd, arg); \ + \ + TEST_ASSERT(!ret, __KVM_IOCTL_ERROR(name, ret)); \ }) =20 -#define vcpu_ioctl(vcpu, cmd, arg) \ +#define vcpu_ioctl(vcpu, cmd, arg) \ _vcpu_ioctl(vcpu, cmd, #cmd, arg) =20 /* --=20 2.36.1.476.g0c4daa206d-goog From nobody Mon Apr 27 12:16:45 2026 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 BDA3DCCA47B for ; Mon, 13 Jun 2022 19:01:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345445AbiFMTA5 (ORCPT ); Mon, 13 Jun 2022 15:00:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45886 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241927AbiFMTAV (ORCPT ); Mon, 13 Jun 2022 15:00:21 -0400 Received: from mail-pl1-x649.google.com (mail-pl1-x649.google.com [IPv6:2607:f8b0:4864:20::649]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 408819969E for ; Mon, 13 Jun 2022 09:19:51 -0700 (PDT) Received: by mail-pl1-x649.google.com with SMTP id c10-20020a170903234a00b00168b5f7661bso3305593plh.6 for ; Mon, 13 Jun 2022 09:19:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=reply-to:date:in-reply-to:message-id:mime-version:references :subject:from:to:cc; bh=TaFkEEYysed0ZjHcXQwF9Zz5rGBFJVxcbzKnAkD2bLE=; b=BdyUyuAnmo6m8r1koxsfiOlsc5iBNlYySi3Y71QAYuY10veGPQMdUfMGhTfXRAD/jp SaugyRrAgCkYojFlfApB5/etcSDN8V3lOYeZbFaLsfFxquOJpuM7LqW1zpASrDwckUmz j/Z0XFHKi+sAiqu+/S7/+sdCMNhh5cz6On2RgMVy/6TzrZUxACT1WPSaoKueO5gbBNRL VT73mZjb7UOAZvch0+ny+tV5U7YNfmQEetOqihOu6tPpGN7lA/4r99PVFyO1KI8OSaLT 8ZVdkz4NMXRaVxReAL6jLw2J0RfErikAiKKvUu4FY26zUvFXv2WHfvkqNJhwloC9P74f QIKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:reply-to:date:in-reply-to:message-id :mime-version:references:subject:from:to:cc; bh=TaFkEEYysed0ZjHcXQwF9Zz5rGBFJVxcbzKnAkD2bLE=; b=12X6gJw7nd6nil3pP0cJWvS5q239WXTtCy2Cit7KSBS9ptTuJlC71SOvtnjFSA0T5W g1OGXuZpC7UlSVr4HPDOimXQ3kOuTZsjMpETQ5O5oPJaPvMtQRhY0zNHKu7wdPSjLN+I Km4MHHCpfC/nVj8Fogjql9xo6LSia5qOO2cd3jylljhF5FUVABQEO9x5GP5bn72HHfMK RClDxTbpoo8Yls220z7oZh9xey2LzUoIZglOCJZ5DWjPdR86lV6OlndqHzvDKLZhbN5W 2B+7NbvZwcQQf1nBiAZmmNQLM1WrhCTAS+BPFYjvYfTD9UdGGTqFHRuciCeBoIbE26xu zWEQ== X-Gm-Message-State: AJIora+5hV8eKQt60u2UUSMSoCIaBhJORropVKGhk/DV9iznFNMVQB0S yjor14OOipH6Kz+zTNC52tHj2kXzf5I= X-Google-Smtp-Source: AGRyM1uSISy6bunfnR8Yit2TWacf4gJnLWhGMnEplJRMVeWD2oqBzx69YnLQTZsKrF295eR0wT9fMyUouO8= X-Received: from seanjc.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:3e5]) (user=seanjc job=sendgmr) by 2002:a17:902:ead4:b0:161:c85a:8fff with SMTP id p20-20020a170902ead400b00161c85a8fffmr390270pld.97.1655137190747; Mon, 13 Jun 2022 09:19:50 -0700 (PDT) Reply-To: Sean Christopherson Date: Mon, 13 Jun 2022 16:19:41 +0000 In-Reply-To: <20220613161942.1586791-1-seanjc@google.com> Message-Id: <20220613161942.1586791-4-seanjc@google.com> Mime-Version: 1.0 References: <20220613161942.1586791-1-seanjc@google.com> X-Mailer: git-send-email 2.36.1.476.g0c4daa206d-goog Subject: [PATCH 3/4] KVM: selftests: Drop a duplicate TEST_ASSERT() in vm_nr_pages_required() From: Sean Christopherson To: Paolo Bonzini Cc: Andrew Jones , kvm@vger.kernel.org, linux-kernel@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Remove a duplicate TEST_ASSERT() on the number of runnable vCPUs in vm_nr_pages_required() that snuck in during a rebase gone bad. Reported-by: Andrew Jones Fixes: 6e1d13bf3815 ("KVM: selftests: Move per-VM/per-vCPU nr pages calcula= tion to __vm_create()") Signed-off-by: Sean Christopherson Reviewed-by: Andrew Jones --- tools/testing/selftests/kvm/lib/kvm_util.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/tools/testing/selftests/kvm/lib/kvm_util.c b/tools/testing/sel= ftests/kvm/lib/kvm_util.c index 0c550fb0dab2..bceb668f2627 100644 --- a/tools/testing/selftests/kvm/lib/kvm_util.c +++ b/tools/testing/selftests/kvm/lib/kvm_util.c @@ -284,10 +284,6 @@ static uint64_t vm_nr_pages_required(enum vm_guest_mod= e mode, */ nr_pages +=3D (nr_pages + extra_mem_pages) / PTES_PER_MIN_PAGE * 2; =20 - TEST_ASSERT(nr_runnable_vcpus <=3D kvm_check_cap(KVM_CAP_MAX_VCPUS), - "Host doesn't support %d vCPUs, max-vcpus =3D %d", - nr_runnable_vcpus, kvm_check_cap(KVM_CAP_MAX_VCPUS)); - return vm_adjust_num_guest_pages(mode, nr_pages); } =20 --=20 2.36.1.476.g0c4daa206d-goog From nobody Mon Apr 27 12:16:45 2026 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 19859C43334 for ; Mon, 13 Jun 2022 19:01:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244193AbiFMTBH (ORCPT ); Mon, 13 Jun 2022 15:01:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45310 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346283AbiFMTAV (ORCPT ); Mon, 13 Jun 2022 15:00:21 -0400 Received: from mail-pl1-x64a.google.com (mail-pl1-x64a.google.com [IPv6:2607:f8b0:4864:20::64a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E07BC996A0 for ; Mon, 13 Jun 2022 09:19:52 -0700 (PDT) Received: by mail-pl1-x64a.google.com with SMTP id h10-20020a170902f54a00b00166449db7f8so3308406plf.9 for ; Mon, 13 Jun 2022 09:19:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=reply-to:date:in-reply-to:message-id:mime-version:references :subject:from:to:cc; bh=9I7uKltHXpoc1RbLfcPLJVsVfHZ0eCsgaFUexrTgf3o=; b=leF5nhpioM8/CvtViFOo+grXyz0OsGK1bY6iZu/BgiX3CYsUWq/uconuCVaEyVjYr5 EjeWA7/uDmZOGHXjUrKh3yixhtBbyll86EkMjZNqa1MyiauusB2D9llB6uEATIyavsVK xQjQwQiuA51TaMzyY9TQQ86zjsPN/1hjSWtI6TWwKWZ0taUoUwpSZwrP8ovBgnyQX6AC aQzAYM1ZGN1/9uJmgKkgId/GOf/HIcAAIqbu3bLYph3iYAWSBkhr96IWme6uyYQpKAi+ 2eeO8Rrz/btlnjF8/hGbnJNBQk5kLysMGlgVNW1J2TMddBUG2VG4ciZEtn8n5kpiuvv+ hSFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:reply-to:date:in-reply-to:message-id :mime-version:references:subject:from:to:cc; bh=9I7uKltHXpoc1RbLfcPLJVsVfHZ0eCsgaFUexrTgf3o=; b=ZbcXp5DJ2A0TB0fR2PLZJ9qUMw3udRoTOMN3AjWzT+j/uHGlKlKGcdkd57JpVwu4/J 0spC1Dt6Lwt33KpGr1SC1cxGbxdArYHaeUoC6zmysxM8gcdy4tFHi3eWy7yFgHw4DuSx YQEGsgL9/72J9P0qMBC9h963YfKD8u8zYSZYNMNG7eJQ9mIxl7c6+dibDy5whMyxsS1w fAlD7MTt8SGpvd0j08XFHcIz+gc+zO4t3AhcK7SOpHopItiukoi5mY3MifBtgN4+30Vx s3EHn1kxU/Xx6Wg74WIQjsoM+LurzZYiADSL3FaTlLumf5t7exV1hnUveWSMLFongR8n VSMw== X-Gm-Message-State: AOAM530MMSn2aicyiE+6pFe0dl50l7Cr5dJpp9b4dFbKlHWf+8AhAniB 8Ze9LZ43VaF92H3g44bl23AnGMcITOo= X-Google-Smtp-Source: ABdhPJz8x1yIAtSxTa0tDxdlfCIfJiE7WTFroIqwwhK+N/PnOZQuD+1B2/qyzYmUbBAqlYazonHvQR7eY8w= X-Received: from seanjc.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:3e5]) (user=seanjc job=sendgmr) by 2002:a05:6a00:c5:b0:51b:c452:47ce with SMTP id e5-20020a056a0000c500b0051bc45247cemr122700pfj.52.1655137192373; Mon, 13 Jun 2022 09:19:52 -0700 (PDT) Reply-To: Sean Christopherson Date: Mon, 13 Jun 2022 16:19:42 +0000 In-Reply-To: <20220613161942.1586791-1-seanjc@google.com> Message-Id: <20220613161942.1586791-5-seanjc@google.com> Mime-Version: 1.0 References: <20220613161942.1586791-1-seanjc@google.com> X-Mailer: git-send-email 2.36.1.476.g0c4daa206d-goog Subject: [PATCH 4/4] KVM: selftests: Use kvm_has_cap(), not kvm_check_cap(), where possible From: Sean Christopherson To: Paolo Bonzini Cc: Andrew Jones , kvm@vger.kernel.org, linux-kernel@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Replace calls to kvm_check_cap() that treat its return as a boolean with calls to kvm_has_cap(). Several instances of kvm_check_cap() were missed when kvm_has_cap() was introduced. Reported-by: Andrew Jones Fixes: 3ea9b809650b ("KVM: selftests: Add kvm_has_cap() to provide syntacti= c sugar") Signed-off-by: Sean Christopherson Reviewed-by: Andrew Jones --- tools/testing/selftests/kvm/aarch64/psci_test.c | 2 +- tools/testing/selftests/kvm/lib/x86_64/processor.c | 4 ++-- tools/testing/selftests/kvm/s390x/sync_regs_test.c | 2 +- tools/testing/selftests/kvm/x86_64/pmu_event_filter_test.c | 2 +- tools/testing/selftests/kvm/x86_64/sev_migrate_tests.c | 6 +++--- tools/testing/selftests/kvm/x86_64/smm_test.c | 2 +- tools/testing/selftests/kvm/x86_64/state_test.c | 2 +- 7 files changed, 10 insertions(+), 10 deletions(-) diff --git a/tools/testing/selftests/kvm/aarch64/psci_test.c b/tools/testin= g/selftests/kvm/aarch64/psci_test.c index a889e1cf5e4d..b665b534cb78 100644 --- a/tools/testing/selftests/kvm/aarch64/psci_test.c +++ b/tools/testing/selftests/kvm/aarch64/psci_test.c @@ -192,7 +192,7 @@ static void host_test_system_suspend(void) =20 int main(void) { - TEST_REQUIRE(kvm_check_cap(KVM_CAP_ARM_SYSTEM_SUSPEND)); + TEST_REQUIRE(kvm_has_cap(KVM_CAP_ARM_SYSTEM_SUSPEND)); =20 host_test_cpu_on(); host_test_system_suspend(); diff --git a/tools/testing/selftests/kvm/lib/x86_64/processor.c b/tools/tes= ting/selftests/kvm/lib/x86_64/processor.c index 4a7de11d6f37..906132e70fa4 100644 --- a/tools/testing/selftests/kvm/lib/x86_64/processor.c +++ b/tools/testing/selftests/kvm/lib/x86_64/processor.c @@ -991,7 +991,7 @@ struct kvm_x86_state *vcpu_save_state(struct kvm_vcpu *= vcpu) vcpu_regs_get(vcpu, &state->regs); vcpu_save_xsave_state(vcpu, state); =20 - if (kvm_check_cap(KVM_CAP_XCRS)) + if (kvm_has_cap(KVM_CAP_XCRS)) vcpu_xcrs_get(vcpu, &state->xcrs); =20 vcpu_sregs_get(vcpu, &state->sregs); @@ -1022,7 +1022,7 @@ void vcpu_load_state(struct kvm_vcpu *vcpu, struct kv= m_x86_state *state) vcpu_sregs_set(vcpu, &state->sregs); vcpu_msrs_set(vcpu, &state->msrs); =20 - if (kvm_check_cap(KVM_CAP_XCRS)) + if (kvm_has_cap(KVM_CAP_XCRS)) vcpu_xcrs_set(vcpu, &state->xcrs); =20 vcpu_xsave_set(vcpu, state->xsave); diff --git a/tools/testing/selftests/kvm/s390x/sync_regs_test.c b/tools/tes= ting/selftests/kvm/s390x/sync_regs_test.c index b69710822c47..3fdb6e2598eb 100644 --- a/tools/testing/selftests/kvm/s390x/sync_regs_test.c +++ b/tools/testing/selftests/kvm/s390x/sync_regs_test.c @@ -229,7 +229,7 @@ int main(int argc, char *argv[]) struct kvm_vm *vm; int idx; =20 - TEST_REQUIRE(kvm_check_cap(KVM_CAP_SYNC_REGS)); + TEST_REQUIRE(kvm_has_cap(KVM_CAP_SYNC_REGS)); =20 /* Tell stdout not to buffer its content */ setbuf(stdout, NULL); diff --git a/tools/testing/selftests/kvm/x86_64/pmu_event_filter_test.c b/t= ools/testing/selftests/kvm/x86_64/pmu_event_filter_test.c index 786b3a794f84..530a75fee92c 100644 --- a/tools/testing/selftests/kvm/x86_64/pmu_event_filter_test.c +++ b/tools/testing/selftests/kvm/x86_64/pmu_event_filter_test.c @@ -450,7 +450,7 @@ int main(int argc, char *argv[]) /* Tell stdout not to buffer its content */ setbuf(stdout, NULL); =20 - TEST_REQUIRE(kvm_check_cap(KVM_CAP_PMU_EVENT_FILTER)); + TEST_REQUIRE(kvm_has_cap(KVM_CAP_PMU_EVENT_FILTER)); =20 TEST_REQUIRE(use_intel_pmu() || use_amd_pmu()); guest_code =3D use_intel_pmu() ? intel_guest_code : amd_guest_code; diff --git a/tools/testing/selftests/kvm/x86_64/sev_migrate_tests.c b/tools= /testing/selftests/kvm/x86_64/sev_migrate_tests.c index 76ba6fc80e37..46018b247a04 100644 --- a/tools/testing/selftests/kvm/x86_64/sev_migrate_tests.c +++ b/tools/testing/selftests/kvm/x86_64/sev_migrate_tests.c @@ -411,16 +411,16 @@ int main(int argc, char *argv[]) =20 have_sev_es =3D !!(cpuid->eax & X86_FEATURE_SEV_ES); =20 - if (kvm_check_cap(KVM_CAP_VM_MOVE_ENC_CONTEXT_FROM)) { + if (kvm_has_cap(KVM_CAP_VM_MOVE_ENC_CONTEXT_FROM)) { test_sev_migrate_from(/* es=3D */ false); if (have_sev_es) test_sev_migrate_from(/* es=3D */ true); test_sev_migrate_locking(); test_sev_migrate_parameters(); - if (kvm_check_cap(KVM_CAP_VM_COPY_ENC_CONTEXT_FROM)) + if (kvm_has_cap(KVM_CAP_VM_COPY_ENC_CONTEXT_FROM)) test_sev_move_copy(); } - if (kvm_check_cap(KVM_CAP_VM_COPY_ENC_CONTEXT_FROM)) { + if (kvm_has_cap(KVM_CAP_VM_COPY_ENC_CONTEXT_FROM)) { test_sev_mirror(/* es=3D */ false); if (have_sev_es) test_sev_mirror(/* es=3D */ true); diff --git a/tools/testing/selftests/kvm/x86_64/smm_test.c b/tools/testing/= selftests/kvm/x86_64/smm_test.c index 3cd1da388b52..921cbf117329 100644 --- a/tools/testing/selftests/kvm/x86_64/smm_test.c +++ b/tools/testing/selftests/kvm/x86_64/smm_test.c @@ -153,7 +153,7 @@ int main(int argc, char *argv[]) =20 vcpu_set_msr(vcpu, MSR_IA32_SMBASE, SMRAM_GPA); =20 - if (kvm_check_cap(KVM_CAP_NESTED_STATE)) { + if (kvm_has_cap(KVM_CAP_NESTED_STATE)) { if (nested_svm_supported()) vcpu_alloc_svm(vm, &nested_gva); else if (nested_vmx_supported()) diff --git a/tools/testing/selftests/kvm/x86_64/state_test.c b/tools/testin= g/selftests/kvm/x86_64/state_test.c index 0bcd78cf7c79..e2f1f35e51ff 100644 --- a/tools/testing/selftests/kvm/x86_64/state_test.c +++ b/tools/testing/selftests/kvm/x86_64/state_test.c @@ -169,7 +169,7 @@ int main(int argc, char *argv[]) =20 vcpu_regs_get(vcpu, ®s1); =20 - if (kvm_check_cap(KVM_CAP_NESTED_STATE)) { + if (kvm_has_cap(KVM_CAP_NESTED_STATE)) { if (nested_svm_supported()) vcpu_alloc_svm(vm, &nested_gva); else if (nested_vmx_supported()) --=20 2.36.1.476.g0c4daa206d-goog