Received: by 2002:ab2:6203:0:b0:1f5:f2ab:c469 with SMTP id o3csp963935lqt; Fri, 19 Apr 2024 16:53:27 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWS2Hsh6c9EkD3NDvsKksoKkgxT1rSahKhLjQc08b6yZrQ2ZES53tE4zmxgPVo6t3wP2ib7V/5gTa8cK8ySLrbMgb4q76W9/kVxgtmFUw== X-Google-Smtp-Source: AGHT+IGJlaMcsw0PqLR+qy92okZt2IoI4jyTsHoo6QFauA0KflyiA0nuGPw22ZjxleTYXpuq50S6 X-Received: by 2002:a50:ab1a:0:b0:56e:2b31:b111 with SMTP id s26-20020a50ab1a000000b0056e2b31b111mr2297423edc.7.1713570807799; Fri, 19 Apr 2024 16:53:27 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713570807; cv=pass; d=google.com; s=arc-20160816; b=hnn+aqTcdYliUvSgfHuZbellndKBz/gY7vTSTVXRtv28ZUFV+pQta6huQw7l/qLeMA GR/qn2ad3j4E964IPuFOWQZ3WBwsgKbkcKmqYGi9txxBI+39jgYzcHxvZG4muXtQxbBc 3fAmGEFbaXj5UlmU/Ju0WeTYiIlri/dAfThbYsdfbzWm+RLckW/YRtM3OTAnLM2DMzxc vsUhzrvDUQ98J91V80sbGpwjqxDWVD3FVhRnFutR4WU7vcBKQCY2PqwStX+IhEJ38BMv Qo59yyYMiQGGqxBnf/1x6yyIrDx4zC9An7C61o2M07bKoPlHLnS6gtxHh7VzkQGiyE6q FhJw== 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=z7fJWkZ4T7GjqwnZHLiFaBRNsKIE6v81MvuCrwEofW0=; b=01TUQ55AHOXT2A+R6FG8VOqGpMpZcg4l8OjxOTpG0PGj/6pKBXcDgB9ecN6r9u0wK3 /PzgIBC/r5jiDTc26fHEuorzFIqebahHyJwH8E6zHhdo6IrB3sr5oYHgRQjw1nvg1eo0 ZpMHRO8GMvtnPXpAQx+SpkWZWDHsGBf79cXpzqr9e04vyAqwuS/NyU8+MY70aZn2deDn 60oMpk6uWHsOeH4jyVl+/d16kkDXRT7CKVIZ+zli2p7M4Cm9p7sqvv2ZKV8r3hb5uBT6 GHjtYo6kZUyD3pw9NhsJLlG5wev+ti2syE+h4Lw7pJZMnlDJeEwKU/GBTonP2/P3Fmo/ YBFg==; 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=xieOb0ar; 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-152041-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-152041-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 y25-20020a50e619000000b0056c1cc96ba0si2745432edm.642.2024.04.19.16.53.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Apr 2024 16:53:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-152041-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=xieOb0ar; 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-152041-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-152041-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 860601F21F80 for ; Fri, 19 Apr 2024 23:53:27 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C546E14A633; Fri, 19 Apr 2024 23:48:20 +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="xieOb0ar" 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 977D514A4D2 for ; Fri, 19 Apr 2024 23:48:18 +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=1713570499; cv=none; b=MYputyNsjIE7CBofwTJmjK/sobp70RaK/J9TLOshH9RQvhii/7wVNcnhFt6sJMsQnbWQS9y1wHslm6L7KzEFExyWnerEiXzZGLwj3cG8RXJtRQdApflvpT4MV9cATsrJjqWmNbxZjqwJesn/MhLCHFpKqAgzSp/wpXdwWeCTUp0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713570499; c=relaxed/simple; bh=RcVsdOTpWmQDe3QFQB057eZKtxuHNPDvA9mLhc2A9Tw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=nME/cDSYN/b55LpPZmmjrAQ6PnD5fwvwzyaRXaszJkrhe0ztfkZCz32Y4BbMJzAHEh1kIk43Oq73n48/43hu9Fq3swVaXPiEN5xJ85GtU6MLkitiPpfbjFKm43ad4LWc1OxX6bY7GSEJ/7RkR4TJG0KgLreEigg0nL7rBFVADQQ= 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=xieOb0ar; 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-1e411e339b8so20031695ad.3 for ; Fri, 19 Apr 2024 16:48:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1713570497; x=1714175297; 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=xieOb0arWyTG6+lGAyk1WTWhj2l1/GFbZH7Huk6wYnGLBf5LhRPwPuLqsp9/ZLWPsQ 2cQLfz4jhYs78kXeUcV2vwWpezXV/60OzetILkrzht4FVMF3tVuJyaVloLDHi0wezCqd hlnJXhcQGmJEufHKM2q5RXrLtTBC2vQFj0rt0mC+sVe622QINRKtCecqYcQ+JdUxT4wz 2MLZNjGevgKvQGo/BYw/hM5TN86wHibK5fONtXmYF65HWOAR37WSrKsoJHxkacLILBkG bYGXJkJ4t1q5X9jHBqwyievOUhyWki/Oy29nKBMuUfiUueWGiZgax+eijpA/e9IrD0Ga 9Y8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713570497; x=1714175297; 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=IKh+WM7eZNUv0LaMmU8XniHFQjUGR3bSTImUIGENWwdl+oMnLQ5gvTrcH7U7ZN2u3L GVO+f0/GpVG5wMmqC9rnt9t+9KSilRpJNSY31/M1FQfKi2ddyM+s4TR4e+BBWO+DNbdw X6H0MQv1zwDqHCcH2yd6zWX229ZBWGdCCJKvQaCaQXUJEZ55tgRZFw6D0ejcZKulYJa4 hoxWKdas/fnw09F6NFniPQ55QXjOhNTxgt20tGcSA8UHnGhg/mQIEqvyhe0aV9bL7+c8 GEXA8gdieomXUsZhGRsKkfVlNBFWLfNQBlxMHWxu0eMKEL5SBcPkMCc1RQJwJPEmrNrC z8jg== X-Gm-Message-State: AOJu0YwI9NdGLFpO497DOLA+j2SygyqXC5l0dBlNkCkm1pctOcguxYdM r/O5ziivW8SoHEgeaikjeKOUB92WxS7TVeaaoUkbdOFuYfhz7CXz0fzqq9u3ZvPAZ2pulTVs8/h R X-Received: by 2002:a17:902:da89:b0:1e4:2d13:cf68 with SMTP id j9-20020a170902da8900b001e42d13cf68mr5056407plx.17.1713570497604; Fri, 19 Apr 2024 16:48:17 -0700 (PDT) Received: from atishp.ba.rivosinc.com ([64.71.180.162]) by smtp.gmail.com with ESMTPSA id w17-20020a170902d11100b001e42f215f33sm3924017plw.85.2024.04.19.16.48.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Apr 2024 16:48:17 -0700 (PDT) From: Atish Patra To: linux-kernel@vger.kernel.org Cc: Atish Patra , Andrew Jones , Ajay Kaher , Albert Ou , Alexandre Ghiti , Anup Patel , samuel.holland@sifive.com, 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 v8 18/24] KVM: riscv: selftests: Add helper functions for extension checks Date: Sat, 20 Apr 2024 08:17:34 -0700 Message-Id: <20240420151741.962500-19-atishp@rivosinc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240420151741.962500-1-atishp@rivosinc.com> References: <20240420151741.962500-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