Received: by 2002:ab2:1347:0:b0:1f4:ac9d:b246 with SMTP id g7csp96611lqg; Wed, 10 Apr 2024 17:14:40 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUjwA7471zVvua9fb1qVT8cvrNjrdx4dd9LmKikHhbxQgSux4DNn+LP6IwhCSnBgDW1mTQI6X3Im2/C8SIIswL1chXD6RRlQKtN3+l8sQ== X-Google-Smtp-Source: AGHT+IGoHqRMdkubi2BANJmZbrLgTE/yF7TiVFi/bS2hGEZ7Up0QT83F7zXR8c0UPpJ0NLIlNvJl X-Received: by 2002:a50:8714:0:b0:56c:d1b:e088 with SMTP id i20-20020a508714000000b0056c0d1be088mr2209293edb.19.1712794480425; Wed, 10 Apr 2024 17:14:40 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712794480; cv=pass; d=google.com; s=arc-20160816; b=WX3TOpGzACLGKKa29+ek1ZtMWDoRxJt/42dS2NrPUYTAWafxtqQEd1P2AQpAuBML0o uQDJjSw4rpf3H6i8TikI8sHcyGEkcOYhT0kw+U4/FrlWl1DAsss6hBEYIBFfny2uFQBB /AOE9NPoosZixnJQdot/qA7RDsEkTyCxiSscJxgMJ6zv28haHituND9j/DaFPpR4ONUD AWUDJQgTxtVAex51vBm+VetFRdWws3F216oAqSC7FukjLZ48tovGUspKuql6GgBY4piA 1gq/C08G/HnrdzT7OzBNl4j5I+q0e5lx+t/aAQs0EJlyqWEJbD76NwWI0HEKRfr3fq59 7bIg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=vBWeKaYtpXhvKjSg+whNN/rWnhjngNSIx7A/W77I8WQ=; fh=TV5tejk3Dt07dcNlLLEipj9Q2R7EhRc35yPyoZNpTh8=; b=mQ1ltK2Oe6kJkfmvtO6Yhv+355rYus7jp1vnvgO0q8ZCtwZbHjoPANfpOGMfnNuEMl xBI5R2s1u5C+/x/12mnV4munbwjlzm8+/qPRDxiwls2N1SeJeW9Kb/9nGopzCf18gSR+ PVIrKvkpEgyCuRlpepatDz6KZCGGPj+wUK3h41PSopLg3SSxXDfwZ4axugIzPqnCc5FR 6iYGIyf6JZ8YFu/4CEcmEi1Aik+IjSBuJOxpLnVusCdF9UDnOTIK9fkDoZgOUcaRDUAM Qk98Qx6P9b1me5IIo12M1e12uia0z5j+YMEYFnmNh9EOWsjhVEm0gA1sQ4dp3eXD4ITj U76Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=FpH0p5iS; arc=pass (i=1 spf=pass spfdomain=rivosinc.com dkim=pass dkdomain=rivosinc-com.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-139573-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-139573-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id u8-20020a509508000000b0056e47321892si153009eda.374.2024.04.10.17.14.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Apr 2024 17:14:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-139573-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=FpH0p5iS; arc=pass (i=1 spf=pass spfdomain=rivosinc.com dkim=pass dkdomain=rivosinc-com.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-139573-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-139573-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 2D9E81F246F4 for ; Thu, 11 Apr 2024 00:14:40 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3CF8342AA2; Thu, 11 Apr 2024 00:09:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=rivosinc-com.20230601.gappssmtp.com header.i=@rivosinc-com.20230601.gappssmtp.com header.b="FpH0p5iS" Received: from mail-pl1-f179.google.com (mail-pl1-f179.google.com [209.85.214.179]) (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 D927641232 for ; Thu, 11 Apr 2024 00:08:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.179 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712794140; cv=none; b=hanyIJ04LmCqyxzWoEsFZWhCZHh7+vbFPXPk5VUPdom6P9vQ3XH7IEy1vt2HL+MzQQKu3H2kaaw9Pb4BYkxWd2nblXiJhiHB6sQOBeFsOknb/GcWvGfTQcsKPoAUaAMg6v87tBMb2joB10wxOD7udNQ6kTPbZGOnitPGKTFO4ic= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712794140; c=relaxed/simple; bh=RcVsdOTpWmQDe3QFQB057eZKtxuHNPDvA9mLhc2A9Tw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=kFnVv940vJB167X6RaIqqRDFLpFgbTjcVhY5RQL0A2Fm6yburWFpVUVRiWK3no5Eitkq9j8xZ2HF5NyDcHeJFNimmltKEZJD4sCQ8RvbYyHFoEBwO+4w6rwM/noQDLl7/HW3s5FQY1xTyT6uBFqC89fNCn2k4f3CQ6eu1+m2cTI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=rivosinc.com; spf=pass smtp.mailfrom=rivosinc.com; dkim=pass (2048-bit key) header.d=rivosinc-com.20230601.gappssmtp.com header.i=@rivosinc-com.20230601.gappssmtp.com header.b=FpH0p5iS; arc=none smtp.client-ip=209.85.214.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=rivosinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=rivosinc.com Received: by mail-pl1-f179.google.com with SMTP id d9443c01a7336-1e0bec01232so59281425ad.3 for ; Wed, 10 Apr 2024 17:08:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1712794137; x=1713398937; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=vBWeKaYtpXhvKjSg+whNN/rWnhjngNSIx7A/W77I8WQ=; b=FpH0p5iSUUKBTes14iCqY7xRdh9eUkJLOPRe4RU1aEuXcv95drpOFyI7uLT2FuNcrA hNmLslNYjTj+ZCbUlNjaIABq+poy/+3HkcOYEml2IIRBo618/QN50mTIE/3NE0SckDVt FYaV7F2M33KvBTH/QQGg68pnyhT8FB0Yrz5jf2sB3DocecriotT3p+GCOQwTFJv48gni IheCBlHkyfO6SIQneuokcFZgHxHOiNlkIpajHUPMviRynlMOH2zZBvXkalDsmmBeho6K Ir6FanMz0REog7SOcotf0o4KmKC0TW+ffttjD6PyTpYCeUCUVnTwp+NheH1EGu4oZztX 3u0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712794137; x=1713398937; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=vBWeKaYtpXhvKjSg+whNN/rWnhjngNSIx7A/W77I8WQ=; b=h+zGlY5L+DrXOmSwZJic++eLsIfgNePtBPJSqREnGPc8D6ZiK/cWaLYJ0d18tHL/k6 AGSPJ+i7dxYILi7o0nbjUi3ytMHOZMHI01tec2TgwNegVuNW8b+B4KaLfBJWnHylsvv8 WWlBFuaxwS5ZXHHDXkqJTuHy9knCA7KOBm4jwWDsNdfS3ftfm0sKWZQTcSayhXCjBdbI eLydXqcmF3W5YQn89IcgXCFPwKcnXSYZ4O53XIlfe1H1wS+pioKKcSCSP92v/FbK9dpN KURmBvEamgdWEh7iRa+UoXbuYq6tkzLj27xMtX/IQ/XxDlm26xDZ7il1Oiux968dGUqq JTjw== X-Gm-Message-State: AOJu0YwZoN8g3jl+ikWQsYmAnshfJlkjEOZN5mNsr15Zbe5DqSx8lL0j 7NEbcf2FLETv2DvtiqXyY6tybEmoNoO+U7wH4vHHUhKCaGRrZYHFwPi6GScMoQdvmr+qhx1Prm4 p X-Received: by 2002:a17:902:d2c5:b0:1e3:e0a5:4cab with SMTP id n5-20020a170902d2c500b001e3e0a54cabmr5221897plc.63.1712794137419; Wed, 10 Apr 2024 17:08:57 -0700 (PDT) Received: from atishp.ba.rivosinc.com ([64.71.180.162]) by smtp.gmail.com with ESMTPSA id f7-20020a170902684700b001e3d8a70780sm130351pln.171.2024.04.10.17.08.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Apr 2024 17:08:56 -0700 (PDT) From: Atish Patra To: linux-kernel@vger.kernel.org Cc: Atish Patra , Andrew Jones , Ajay Kaher , Albert Ou , Alexandre Ghiti , Alexey Makhalov , Anup Patel , Atish Patra , Broadcom internal kernel review list , 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, Will Deacon , x86@kernel.org Subject: [PATCH v6 18/24] KVM: riscv: selftests: Add helper functions for extension checks Date: Wed, 10 Apr 2024 17:07:46 -0700 Message-Id: <20240411000752.955910-19-atishp@rivosinc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240411000752.955910-1-atishp@rivosinc.com> References: <20240411000752.955910-1-atishp@rivosinc.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit __vcpu_has_ext can check both SBI and ISA extensions when the first argument is properly converted to SBI/ISA extension IDs. Introduce two helper functions to make life easier for developers so they don't have to worry about the conversions. Replace the current usages as well with new helpers. Reviewed-by: Andrew Jones Signed-off-by: Atish Patra --- tools/testing/selftests/kvm/include/riscv/processor.h | 10 ++++++++++ tools/testing/selftests/kvm/riscv/arch_timer.c | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/kvm/include/riscv/processor.h b/tools/testing/selftests/kvm/include/riscv/processor.h index 3b9cb39327ff..5f389166338c 100644 --- a/tools/testing/selftests/kvm/include/riscv/processor.h +++ b/tools/testing/selftests/kvm/include/riscv/processor.h @@ -50,6 +50,16 @@ static inline uint64_t __kvm_reg_id(uint64_t type, uint64_t subtype, bool __vcpu_has_ext(struct kvm_vcpu *vcpu, uint64_t ext); +static inline bool __vcpu_has_isa_ext(struct kvm_vcpu *vcpu, uint64_t isa_ext) +{ + return __vcpu_has_ext(vcpu, RISCV_ISA_EXT_REG(isa_ext)); +} + +static inline bool __vcpu_has_sbi_ext(struct kvm_vcpu *vcpu, uint64_t sbi_ext) +{ + return __vcpu_has_ext(vcpu, RISCV_SBI_EXT_REG(sbi_ext)); +} + struct ex_regs { unsigned long ra; unsigned long sp; diff --git a/tools/testing/selftests/kvm/riscv/arch_timer.c b/tools/testing/selftests/kvm/riscv/arch_timer.c index 0f9cabd99fd4..735b78569021 100644 --- a/tools/testing/selftests/kvm/riscv/arch_timer.c +++ b/tools/testing/selftests/kvm/riscv/arch_timer.c @@ -85,7 +85,7 @@ struct kvm_vm *test_vm_create(void) int nr_vcpus = test_args.nr_vcpus; vm = vm_create_with_vcpus(nr_vcpus, guest_code, vcpus); - __TEST_REQUIRE(__vcpu_has_ext(vcpus[0], RISCV_ISA_EXT_REG(KVM_RISCV_ISA_EXT_SSTC)), + __TEST_REQUIRE(__vcpu_has_isa_ext(vcpus[0], KVM_RISCV_ISA_EXT_SSTC), "SSTC not available, skipping test\n"); vm_init_vector_tables(vm); -- 2.34.1