Received: by 2002:a05:6358:bb9e:b0:b9:5105:a5b4 with SMTP id df30csp704696rwb; Sat, 3 Sep 2022 00:44:49 -0700 (PDT) X-Google-Smtp-Source: AA6agR6jWH3q6xFJ0nmE8HWWA64eRmH68CcjjA1wRueA9Y2fWFKN0N7tsDEYhCdT5YYw8F0mujsC X-Received: by 2002:a05:6402:26c6:b0:448:658e:5b32 with SMTP id x6-20020a05640226c600b00448658e5b32mr24654939edd.250.1662191088872; Sat, 03 Sep 2022 00:44:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662191088; cv=none; d=google.com; s=arc-20160816; b=hpWUaBBnHDHGXybaEUVOls+jjaYwcOq14C2Cfx+88bdh8c3ZX9V/HnUsBVwJMQLm/z gaN1tBRp7AK0az6by5gGw9uh5z4p+Qt9lKdOsJT+MIUUhfw9NXeVsir916eTdrh42IGm F9CDaoukJqFKTCgpznBMG1lPtMJBnPtnkmOctugosLzJdlPwFj8UXWYn3OOI9Dyftpcy zuWBwlepmK/xIBAwoB4DeoHEM+3IHpbACW9hDj2K76CmNsBPp8zy7Dz0fz9tFUyXk8oe DMuGEfxrEndITcDNR4pDKmE5oDhm1uG6EMHHvaIsCkl9MlvFQ5qsHV/+qg9sDEvmwBA6 v5+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=ROgdEwGTwKSezP6yTg8Bn5b9HWITXNuPp4Q731RWP+M=; b=jJttrYbju6LGmser3Pzj44kkO9dWPyxgGdOEQEW4t3R7fyKu/wgMQxXjpCjEgK4+wi LrqFD9HZrNYUs73t6RNPlQ+TzfWZw+Q0rxiqf9sJWN1F0hp5629OdZCh1kn5i1s7d5M4 L4Ipf9CF659P0eUDUgPsBTf7ch6JU+4xoDtL6mn4slhCuFawI2wVdmnPH7gMYjJ09DCs +90qNEEdeAABjXGo2XAZ5NWw7/V7ksKIjPs5JqkrSyeV7Uwx6qpMCzT4MI8vpESXQja6 xhp79vdMB9/FM9gjtt/dBM/qOcmh+816W1Ky4HO+WjImRcWkTmwdE5h4T/4IB8cPTBLW HYJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=aDZMg+5G; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gn13-20020a1709070d0d00b0073306ff26besi3624580ejc.969.2022.09.03.00.44.23; Sat, 03 Sep 2022 00:44:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=aDZMg+5G; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232330AbiICHjM (ORCPT + 99 others); Sat, 3 Sep 2022 03:39:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44782 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229626AbiICHjL (ORCPT ); Sat, 3 Sep 2022 03:39:11 -0400 Received: from mail-pf1-x431.google.com (mail-pf1-x431.google.com [IPv6:2607:f8b0:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A817D6F549; Sat, 3 Sep 2022 00:39:09 -0700 (PDT) Received: by mail-pf1-x431.google.com with SMTP id 145so3988756pfw.4; Sat, 03 Sep 2022 00:39:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date; bh=ROgdEwGTwKSezP6yTg8Bn5b9HWITXNuPp4Q731RWP+M=; b=aDZMg+5Gm5Z4KOXdcDeuVimJyU0uVQjdAQwcQwrupA3dK9GcXnOTJ1Go03nMO5UyIi FeAOY3WR4t3d4kBYiXdbh/karp3nWeMzIKPNe1GjSRWstX3jcBW+G6NKSbCfW5u/Tvg+ 5kRi8bZBQvV92jv9FWMu5Yq7yXg9X4fnz00+Ywyb6vEMoDYl10D7q2ZMToCtXPL1C0xe i4S4ZxWiI/RjCU6JKkX3JksmRs7gdmwWGLazYwyeHMTJ+bEBxJ/2TGUQ54iwSfdrxgCu kBsyEt+iDL7CP3ZUpk+gRIWGP1ZYIPLIuV5DjlxubDNmsPUdBKT/6Sl9T0UFhfL9BGe0 FuDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date; bh=ROgdEwGTwKSezP6yTg8Bn5b9HWITXNuPp4Q731RWP+M=; b=zbppJsQ4vf362KGbMZDmEkp44estlEpz1+13ReSLKdCTW20Q05Ehy2Gnwwfy3HElyY jDkG7bILRR6y6u6eFAvLtnHFknEy702kPv4VW39PTaieDSPVUDwOdLO4UQd8IE2LzmiF I8YW/NGdfb/wKpaB3BuaSBRHePXmbyMc2LszJAFQ8oI/2dvNf1sa8hJkRQEbp5/ouLvs YJ5fmtTRuwSTxJrGOrUb46YdQGR9IDnI6l+cK+Y5pCFW8hSQKr/tU09Hk5ay2yCw9gU4 j9lM4JsnMcYemKj2DPm7y8Af40CsRCC4N91sTbT0bZBo+Mnr8Sy0WcFnufDNP1MpezCE 3EJg== X-Gm-Message-State: ACgBeo1MqZfOIuwjWyj2tmMpFH7eGVYDnKEAxgd/vThS1261e+XJXFI+ vDJIWeKWW4DvUZxdkrMV/vw= X-Received: by 2002:a05:6a02:104:b0:430:93ec:776f with SMTP id bg4-20020a056a02010400b0043093ec776fmr8025194pgb.544.1662190749090; Sat, 03 Sep 2022 00:39:09 -0700 (PDT) Received: from biggie.. ([103.230.148.184]) by smtp.gmail.com with ESMTPSA id h14-20020a17090adb8e00b001fd6066284dsm2738133pjv.6.2022.09.03.00.39.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 03 Sep 2022 00:39:08 -0700 (PDT) From: Gautam Menghani To: pbonzini@redhat.com, shuah@kernel.org Cc: Gautam Menghani , seanjc@google.com, guang.zeng@intel.com, kvm@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, skhan@linuxfoundation.org, linux-kernel-mentees@lists.linuxfoundation.org Subject: [PATCH] selftests/kvm: Use num_vcpus when testing ICR in the xapic_state_test Date: Sat, 3 Sep 2022 13:09:01 +0530 Message-Id: <20220903073901.73862-1-gautammenghani201@gmail.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org A TODO in xapic_state_test asks to use number of vCPUs instead of vcpu.id + 1 in test_icr(). This patch adds support to get the number of vCPUs from the VM created and use it. Signed-off-by: Gautam Menghani --- .../selftests/kvm/x86_64/xapic_state_test.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/tools/testing/selftests/kvm/x86_64/xapic_state_test.c b/tools/testing/selftests/kvm/x86_64/xapic_state_test.c index 6f7a5ef66718..de934e8e5e41 100644 --- a/tools/testing/selftests/kvm/x86_64/xapic_state_test.c +++ b/tools/testing/selftests/kvm/x86_64/xapic_state_test.c @@ -96,9 +96,8 @@ static void __test_icr(struct xapic_vcpu *x, uint64_t val) ____test_icr(x, val & ~(u64)APIC_ICR_BUSY); } -static void test_icr(struct xapic_vcpu *x) +static void test_icr(struct xapic_vcpu *x, int num_vcpus) { - struct kvm_vcpu *vcpu = x->vcpu; uint64_t icr, i, j; icr = APIC_DEST_SELF | APIC_INT_ASSERT | APIC_DM_FIXED; @@ -110,11 +109,11 @@ static void test_icr(struct xapic_vcpu *x) __test_icr(x, icr | i); /* - * Send all flavors of IPIs to non-existent vCPUs. TODO: use number of - * vCPUs, not vcpu.id + 1. Arbitrarily use vector 0xff. + * Send all flavors of IPIs to non-existent vCPUs. Arbitrarily use vector 0xff. */ + icr = APIC_INT_ASSERT | 0xff; - for (i = vcpu->id + 1; i < 0xff; i++) { + for (i = num_vcpus; i < 0xff; i++) { for (j = 0; j < 8; j++) __test_icr(x, i << (32 + 24) | icr | (j << 8)); } @@ -137,9 +136,13 @@ int main(int argc, char *argv[]) .is_x2apic = true, }; struct kvm_vm *vm; + struct list_head *iter; + int nr_vcpus_created = 0; vm = vm_create_with_one_vcpu(&x.vcpu, x2apic_guest_code); - test_icr(&x); + list_for_each(iter, &vm->vcpus) + nr_vcpus_created++; + test_icr(&x, nr_vcpus_created); kvm_vm_free(vm); /* @@ -153,6 +156,6 @@ int main(int argc, char *argv[]) vcpu_clear_cpuid_feature(x.vcpu, X86_FEATURE_X2APIC); virt_pg_map(vm, APIC_DEFAULT_GPA, APIC_DEFAULT_GPA); - test_icr(&x); + test_icr(&x, nr_vcpus_created); kvm_vm_free(vm); } -- 2.34.1