Received: by 2002:a05:6500:1b45:b0:1f5:f2ab:c469 with SMTP id cz5csp167571lqb; Tue, 16 Apr 2024 11:51:20 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVichCbWSN+m9xsfF0ro8NT0O0sN2pXxzIgwf+qECpAXRLN0IMKUoISWyy90epFho/qRbX1q/+IMHFuEkZzT4FBqUh4m2F8k8HRZfKrzA== X-Google-Smtp-Source: AGHT+IH+0iKOV+h9kngFGySW4vPOqsDhq3ZyIPLRMSnlNWiBh33U7KHeYGIlt+DmghnGJjIB3iUf X-Received: by 2002:a17:903:27c3:b0:1e0:a2cf:62e8 with SMTP id km3-20020a17090327c300b001e0a2cf62e8mr3767953plb.10.1713293480100; Tue, 16 Apr 2024 11:51:20 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713293480; cv=pass; d=google.com; s=arc-20160816; b=k8C1gUg1nbgw2jZwbDH55U5S5Ma8QBNL9HrNRyfwT3WssZR5uz3jCzn5QB0gWDs5zv 0rdIGQ6w+ANFC9iokcEMvGMzDj1fVMuW893ApdbWwd0HJEtA6nwrwDY6SP1IRhmpNJ0i VPfYmbMv9aMZcEkoztXD+m3y/r7at0Tpgo43wOSg/C6j30v8OW6ha0UGbiZytk7JIc/T LIAVR3WNwlfGsjjYweMTGTPGg0YyX0YJ75OPMcCjcjSTx+ZIsnmKrKTtLf3OTVAYDWfM ymm0JxngRfVWfcRCGB06UhJf5YsIEex0Q6vQgX4PsUteOxzrxMMhxwgnkwPSkq5FEiNS KMdg== 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=Rp1+u4PMjowggwvpRu96VEneDwGpmH5BAOjZCbMCQT4=; b=VZ5Jr9/beJq2infhmYCf4D7rLMF4LPbttfG+cwnmb2JNsINOqgQ7xW3Q1FY0MeoNU2 xCMAjPaQy/ltZgpxRzHyw8B2pBclWlgn9A07qsP3bn7SEnuWSqU93JJ0A4xRtQ6HcJWK FuRSOEpTA6yAp1cJX+9cybAlU2NN9tA0+SIfqebIxswvE0WDxqYeeWVZFrWNK5k8g8xc 0UVN26nOshrNStRUeULelEIa5KjTwU1hGGCthCHWs7OItBTH0TjOO1lkZjs7yl5ETsLU 7EokARfccDt96JanATFuCe8ceEvTjKz5lDlxVtKF077oldv8LkxjujAkM/ZMoO9cI1Qe QywA==; 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=snwywB6x; 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-147417-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-147417-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id c18-20020a170902d49200b001e5a3b2a419si8582589plg.33.2024.04.16.11.51.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Apr 2024 11:51:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-147417-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=snwywB6x; 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-147417-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-147417-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id A508E281C6E for ; Tue, 16 Apr 2024 18:51:19 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A2D7E13FD9B; Tue, 16 Apr 2024 18:45:10 +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="snwywB6x" Received: from mail-pj1-f44.google.com (mail-pj1-f44.google.com [209.85.216.44]) (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 5E21613D539 for ; Tue, 16 Apr 2024 18:45:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.44 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713293109; cv=none; b=QI5eeieWh0SN5py4TMvKJ8tGh7Xq4ZxV6PiDYN5JyMV186aKiSeWPukDEJa6SdOEMtjl3xjWQ1Jct/q0wHS3NApbQ6mNU9KER0kqx3+deG+6KLuEZb1XOOyx+J1GZYbqoR7pVf9kDMM6Vyri9WepeJI2i0FRoVkP4Ry549Z0pd8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713293109; c=relaxed/simple; bh=RcVsdOTpWmQDe3QFQB057eZKtxuHNPDvA9mLhc2A9Tw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=AKc7Uc8sOX+zkyENFobMcixSMLuOZ7jI74X9Mbuz1242KQzrAxV+wESKaziGxNBesZl4lFTrwujHznV7GRdn+bgvdTH1kSkvuPEtpqJttoM870VuXgYndiyf+15I+sRl8Mbtjf2veT43Ugt46B6mxqQPVx0utNhwJgBuK8ux6HU= 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=snwywB6x; arc=none smtp.client-ip=209.85.216.44 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-pj1-f44.google.com with SMTP id 98e67ed59e1d1-2a2d0ca3c92so47639a91.0 for ; Tue, 16 Apr 2024 11:45:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1713293107; x=1713897907; 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=snwywB6x/3UYo6Sz2k/vaH6cYHfVblxy4eiN9A0CLwoitN8wmbLafPdvyXRVGVeQhk Hyz2dcCSctc8pwk6cfhBRob2ORmU1ApcAnc3i7La9eX5UlOKIRvCbxx9dbAVzFYIH18h mAWJRhZMYBgsf4EyPk+SFCql4ReGh5bcZ4RhEZwh2ZK4PcknxW5VTi4e21BDzIRluQvv 84dG0jZLcUonrVg4FSLe524JTsE6/FzHUMsVfKEg/S1VvEE7ue+qSxtBmeWmjd7rtJSi x7A4d1rlJPNz+2mIJ0Dn3Rs+PU4U9hra6wjYUjin2gZVBnkPMSb/tDH035uJXu3qMdig Okqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713293107; x=1713897907; 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=efr2PqQvEz1VxnfMFDhEKyEH6Z9hVzcY9E8lHbdVh5sTHo7JxBxdWSr2He5TYt8t2X NswVYHhPqMTcR1ddvmi+mBiJMq2Qpp6gz8gBk4s05zcQYJ8Htj6kb1gcdeirbO3EZX0R 3ZCiFswZMtFbpgconIz7uST1MKaxwiLEQLYKDS3ZXCXesh0qjGYtWk11FBZBI5VD79Sv uuDhRXi5+a/M5sOZbzSsK73t/ihjHW0UlVvt08QK0GmP6c7AVu8QpJEF67Z4R/0yJQJG 7vtQjfEvjNfIzM19dv4sjX9HEdZvo8v4cVVAfxZqKWX3tGkWZJ9dbXqTHFRZ20TLxW6d W9dw== X-Gm-Message-State: AOJu0YwNID0fsd8WOuLEyYEfpzu2e/vZ1K9xxwoDvp0FliHp55kAZCHM zeEhRprQmaOdnDfILKnvu9npKYZ3A2sAbkbRb2bnzToGeBQ4JSryk2sutvBN/GSi3BfwTTGvZl2 S X-Received: by 2002:a17:90a:bc1:b0:2a1:64a:bb63 with SMTP id x1-20020a17090a0bc100b002a1064abb63mr4135416pjd.2.1713293106909; Tue, 16 Apr 2024 11:45:06 -0700 (PDT) Received: from atishp.ba.rivosinc.com ([64.71.180.162]) by smtp.gmail.com with ESMTPSA id o19-20020a17090aac1300b002a269828bb8sm8883645pjq.40.2024.04.16.11.45.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Apr 2024 11:45:06 -0700 (PDT) From: Atish Patra To: linux-kernel@vger.kernel.org Cc: Atish Patra , Andrew Jones , Ajay Kaher , Albert Ou , Alexandre Ghiti , Anup Patel , 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 v7 18/24] KVM: riscv: selftests: Add helper functions for extension checks Date: Tue, 16 Apr 2024 11:44:15 -0700 Message-Id: <20240416184421.3693802-19-atishp@rivosinc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240416184421.3693802-1-atishp@rivosinc.com> References: <20240416184421.3693802-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