Received: by 2002:ab2:7a55:0:b0:1f4:4a7d:290d with SMTP id u21csp674105lqp; Fri, 5 Apr 2024 05:50:50 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWvbDcAgEqbIUSkNsiCbWckJ94vaKE2vwzBH+/ROtngZMfVlQZp8qhULOxLYJRbM7A3DmDblNGC+PK7VcOT/TAgZWRfe9mce5TafeiH7Q== X-Google-Smtp-Source: AGHT+IEOf6nBn8W9sPyYWorivG/aUuvNKLeNM1fSqu8Pq9HE5IiP0Tpg6RlybjeLZZtkvkjm1uoI X-Received: by 2002:a50:9e44:0:b0:56e:2a6a:8d3a with SMTP id z62-20020a509e44000000b0056e2a6a8d3amr1466873ede.15.1712321450585; Fri, 05 Apr 2024 05:50:50 -0700 (PDT) Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id es16-20020a056402381000b0056e2b7c2656si720848edb.584.2024.04.05.05.50.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Apr 2024 05:50:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-133020-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@ventanamicro.com header.s=google header.b=a8TNQw8f; arc=fail (body hash mismatch); spf=pass (google.com: domain of linux-kernel+bounces-133020-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-133020-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 2C3171F21E34 for ; Fri, 5 Apr 2024 12:50:50 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5712D16D327; Fri, 5 Apr 2024 12:50:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b="a8TNQw8f" Received: from mail-ej1-f53.google.com (mail-ej1-f53.google.com [209.85.218.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AFEEC16C86F for ; Fri, 5 Apr 2024 12:50:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.53 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712321436; cv=none; b=ev62Ct6USxMvUMppY/leosMeGO8cIfFsaNLTCwRG5MGuFtcC29WcgoMErAAA10Tl/7VQtYtuim2lU0U+EP1KoQEIhbT68YNY3oihwItLlSyflraPvdS4wpCSQyoU0VqCKSdZjv20zAmY5uBtBCGdqF0t8XWHbcXXAv34lkynOo8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712321436; c=relaxed/simple; bh=Vqv3W2/VCBye3UEJwCHMOm8a0FVjlz+y/cOCepR8BTE=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=fOXKM1wgTGFEqcdD9++nPJ+E6bIGYix8hvecPhBND1lzHw09WnTT/84MOZT0PjJjSDyxFlhNhpXcsaf9iw/rEWOWBMVto2G5U9CvKU2PLslXeoDHzdetnuwpTqhDMgcHvW92jV1HYKEwhMkt1VrRLrzQOYZxTNAgr5N1plKkNCs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ventanamicro.com; spf=pass smtp.mailfrom=ventanamicro.com; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b=a8TNQw8f; arc=none smtp.client-ip=209.85.218.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ventanamicro.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ventanamicro.com Received: by mail-ej1-f53.google.com with SMTP id a640c23a62f3a-a47385a4379so587888466b.0 for ; Fri, 05 Apr 2024 05:50:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1712321433; x=1712926233; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=d+KZChT2cdzkHkVrpBT1mwN6D5B3F3KpgiaxmMWQvAA=; b=a8TNQw8fKNLDEP9/Dl2mGdotjhamMETYCk6tpjPG7zQr2asSHu3ZUEWiYYmDOXHItS BIYAGR1pzAgk0OXZ+8hL88hsc9kwpZq8ZbR44IpqKVpcuHezI71wjSQGTKVSSfvcZ90o xk5N/VjQ3omwUNnWlcah56qbGg4v5RI0Ot5pNTbapEQ1atBXqYdlcr+BKIRMagYejUIv Rs4geJ85pcT36lvH0EP4ODcE+qAwEBv779SGelazVOeqh8njxOUaXpGKsopHt5EqkYnH 9TDNw30NXtHHIbe7NA/lCfxyeyNILlEjeNzZqOYoY8Kd6wJEBNejRMwJayta5LHomx/h 4xSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712321433; x=1712926233; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=d+KZChT2cdzkHkVrpBT1mwN6D5B3F3KpgiaxmMWQvAA=; b=GqzN5qOnpEL4nU3LTrgmq8zts9LP/gp23Z5ETWVGer2Y0AkZvPctcqsAuEME1rkVdV Qp9xnQFM8zW7aaPH1g99MnewiLA7Rz0UVJsmPeLdrdbEe1I6cFCVxrt1669DXLTl+pYF zs6okiyi1askYhq3QMfClNKkKN9WcLujmi4NzrBDoyH5z1GanhTcaFEyFMxYBKz+Owk2 Oe326Gf5IOj4zEs3wt0ST4cybEIFM193G8j9cRImXWOLbNe2HEY/+qwbG44oYkBii9Uw PquD1N2qwiKwnvi87ZudTpOLYvCfNReYiPNhOcXT4W0cG6csOqOXl3LyoDdf3YKmYeGt B9MQ== X-Gm-Message-State: AOJu0YwEyRbtY4m9oUMQNGd4PPW0qzJTEEU3cl2qahdRj1isqjmPBEEV h1mVRdx8TYFMNtNcKyDVIoaCQP2oW90+NlDJxKk4Ve32YjPGo8mIoZ+BOoeHNWw= X-Received: by 2002:a17:907:1711:b0:a51:8a0c:cf39 with SMTP id le17-20020a170907171100b00a518a0ccf39mr1906632ejc.20.1712321432731; Fri, 05 Apr 2024 05:50:32 -0700 (PDT) Received: from localhost (2001-1ae9-1c2-4c00-20f-c6b4-1e57-7965.ip6.tmcz.cz. [2001:1ae9:1c2:4c00:20f:c6b4:1e57:7965]) by smtp.gmail.com with ESMTPSA id jy5-20020a170907762500b00a466af74ef2sm806704ejc.2.2024.04.05.05.50.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Apr 2024 05:50:32 -0700 (PDT) Date: Fri, 5 Apr 2024 14:50:31 +0200 From: Andrew Jones To: Atish Patra Cc: linux-kernel@vger.kernel.org, Anup Patel , Ajay Kaher , Alexandre Ghiti , Alexey Makhalov , Conor Dooley , Juergen Gross , kvm-riscv@lists.infradead.org, kvm@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-riscv@lists.infradead.org, Mark Rutland , Palmer Dabbelt , Paolo Bonzini , Paul Walmsley , Shuah Khan , virtualization@lists.linux.dev, VMware PV-Drivers Reviewers , Will Deacon , x86@kernel.org Subject: Re: [PATCH v5 20/22] KVM: riscv: selftests: Add SBI PMU selftest Message-ID: <20240405-d1a4cb9a441a05a9d2f8b1c8@orel> References: <20240403080452.1007601-1-atishp@rivosinc.com> <20240403080452.1007601-21-atishp@rivosinc.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240403080452.1007601-21-atishp@rivosinc.com> On Wed, Apr 03, 2024 at 01:04:49AM -0700, Atish Patra wrote: .. > +static void test_pmu_basic_sanity(void) > +{ > + long out_val = 0; > + bool probe; > + struct sbiret ret; > + int num_counters = 0, i; > + union sbi_pmu_ctr_info ctrinfo; > + > + probe = guest_sbi_probe_extension(SBI_EXT_PMU, &out_val); > + GUEST_ASSERT(probe && out_val == 1); > + > + num_counters = get_num_counters(); > + > + for (i = 0; i < num_counters; i++) { > + ret = sbi_ecall(SBI_EXT_PMU, SBI_EXT_PMU_COUNTER_GET_INFO, i, > + 0, 0, 0, 0, 0); > + > + /* There can be gaps in logical counter indicies*/ > + if (ret.error) > + continue; > + GUEST_ASSERT_NE(ret.value, 0); > + > + ctrinfo.value = ret.value; > + > + /** > + * Accesibillity check of hardware and read capability of firmware counters. Accessibility > + * The spec doesn't mandate any initial value. No need to check any value. > + */ > + read_counter(i, ctrinfo); > + } > + > + GUEST_DONE(); > +} > + > +static void run_vcpu(struct kvm_vcpu *vcpu) > +{ > + struct ucall uc; > + > + vcpu_run(vcpu); > + switch (get_ucall(vcpu, &uc)) { > + case UCALL_ABORT: > + REPORT_GUEST_ASSERT(uc); > + break; > + case UCALL_DONE: > + case UCALL_SYNC: > + break; > + default: > + TEST_FAIL("Unknown ucall %lu", uc.cmd); > + break; > + } > +} > + > +void test_vm_destroy(struct kvm_vm *vm) > +{ > + memset(ctrinfo_arr, 0, sizeof(union sbi_pmu_ctr_info) * RISCV_MAX_PMU_COUNTERS); > + counter_mask_available = 0; > + kvm_vm_free(vm); > +} > + > +static void test_vm_basic_test(void *guest_code) > +{ > + struct kvm_vm *vm; > + struct kvm_vcpu *vcpu; > + > + vm = vm_create_with_one_vcpu(&vcpu, guest_code); > + __TEST_REQUIRE(__vcpu_has_sbi_ext(vcpu, KVM_RISCV_SBI_EXT_PMU), > + "SBI PMU not available, skipping test"); > + vm_init_vector_tables(vm); > + /* Illegal instruction handler is required to verify read access without configuration */ > + vm_install_exception_handler(vm, EXC_INST_ILLEGAL, guest_illegal_exception_handler); I still don't see where the "verify" part is. The handler doesn't record that it had to handle anything. > + > + vcpu_init_vector_tables(vcpu); > + run_vcpu(vcpu); > + > + test_vm_destroy(vm); > +} > + > +static void test_vm_events_test(void *guest_code) > +{ > + struct kvm_vm *vm = NULL; > + struct kvm_vcpu *vcpu = NULL; > + > + vm = vm_create_with_one_vcpu(&vcpu, guest_code); > + __TEST_REQUIRE(__vcpu_has_sbi_ext(vcpu, KVM_RISCV_SBI_EXT_PMU), > + "SBI PMU not available, skipping test"); > + run_vcpu(vcpu); > + > + test_vm_destroy(vm); > +} > + > +int main(void) > +{ > + test_vm_basic_test(test_pmu_basic_sanity); > + pr_info("SBI PMU basic test : PASS\n"); > + > + test_vm_events_test(test_pmu_events); > + pr_info("SBI PMU event verification test : PASS\n"); > + > + return 0; > +} > -- > 2.34.1 > Thanks, drew