Received: by 2002:ab2:1149:0:b0:1f3:1f8c:d0c6 with SMTP id z9csp2555396lqz; Wed, 3 Apr 2024 01:10:39 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUCgzjekglPvBiQUl1DMdwyb3kXz4wxV2VqzJ4f6xWR08Wn9td3kBSB1lzLudA6PV/ex6SKYRqrW0pNBYZRULiZ89xUs6hKn5o5cSYtKg== X-Google-Smtp-Source: AGHT+IFWH+1m3tnADhRUWRl+dNUuWSPrPg5nyjJpcujFBaqXxS4ZJPlsR4Q1AUn98fr9TiTTFU1Q X-Received: by 2002:a50:aac3:0:b0:56c:1735:57a2 with SMTP id r3-20020a50aac3000000b0056c173557a2mr3370932edc.31.1712131838850; Wed, 03 Apr 2024 01:10:38 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712131838; cv=pass; d=google.com; s=arc-20160816; b=d0ltD7fw7zHekW5akmxaEHj+co6BEqhdHctJk46MutDZHUjbiupKXo/DMXDnlinbWd spZ+r8kyyPoSNCytvOirVPQeMaSMKDWqp9ySe+6nDZ3pRDcAKDT+BtL/HdmrH3S4ZumQ OwNNg7JDM2LfQuO4vtv0HFE/Vjf6pvle04H2Ca9qAHLjGkK0Uf0T5ya4NHUE3VezBsSq eZKpBBBxVOjEjm5u3BVgO9FxEhj5h0IC2U3AGbnDcv7/TaDo7D3Whu4Jy3abF9wAooKQ NoeBvpYdzgjbIMtLr55XZq9bSt4y5br4G5CPYvykypuVSiaIPZ9A1/xml95+0njxNgBx SQAw== 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=iiceCABnvA1jknfstt9FkxftBmpWokdNdmMlEhNsfyg=; fh=iEgamv6dbODmscQv2wzZN1BSfdyVgGmpVc4xUNBH9RU=; b=RAjb0TmViIzwjj6ZKL13u/YSmVolQs4iSZN61J7Mfd9j8N5XqmuH6Je01RCsqIRE0d 8RDwTKM18fIfKDJ6jjy61Gmb3+vnQ4It/Q+VZqqBbWptbmLL3Mgh6BBbjKxtURCbmz+d FXX2/x5DwlILHW/nlcieSCBxJwdIGjT4c8fooSVABTWUNB08AQ0jc1kGS5E6tR2jeBwy PFMJ1S8yzzuzqfF0ka41bWo530U/4/LAhpffWPoRN4MmPTWPQDJZlULDiATBQXiMGdxY MQEbtK5b+wbV41JN9KCanp63t13l9ggyVkX16ZKJ9mUy6KlkiZzgkQGqoYawEm5y2x04 YoJQ==; 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=qrZNpmB4; 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-129257-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-129257-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 e14-20020a056402190e00b0056dc91c2e27si3687477edz.27.2024.04.03.01.10.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Apr 2024 01:10:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-129257-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=qrZNpmB4; 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-129257-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-129257-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 8BDC11F25933 for ; Wed, 3 Apr 2024 08:10:38 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D4263129A66; Wed, 3 Apr 2024 08:05:51 +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="qrZNpmB4" Received: from mail-pl1-f177.google.com (mail-pl1-f177.google.com [209.85.214.177]) (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 7AA1512C80F for ; Wed, 3 Apr 2024 08:05:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.177 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712131550; cv=none; b=FJpqpKBfUB+JM6j/s4CB8DyvNW2YkNaqsH3GDZoDOXG4M9HEvhehJZtU8h9SEgoTIWbu+WsPzANKK0AaU5PnxDMIgY+zqKn63LTSO6A2ycqx7jL+yK0JiuMhvCqRDw6PNjQoiHXZDjrsvOJXjYr4ssqTMgpZgaMqHmltmbKCydc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712131550; c=relaxed/simple; bh=evlE8hTl45MyJIsfxvr/2bRxoIA3bwQv3sS8gzvU/GA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=E8NuH32OI/9ZzKkq067WaKU8s+k1IBY1TBkO/wt8+AShFVrdMBhMV2xhLx/kraMIsGq2X/Vy/oShoVGGzmOWW/CF+1Ij2xT3yUy9MGeF5nGmAugiMoErnckKiZNrFR2SP68mf/fu2miYoZzkMNGbNqebCW7J5Q1LtIZrnrS9+lw= 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=qrZNpmB4; arc=none smtp.client-ip=209.85.214.177 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-f177.google.com with SMTP id d9443c01a7336-1e0878b76f3so5697995ad.0 for ; Wed, 03 Apr 2024 01:05:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1712131548; x=1712736348; 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=iiceCABnvA1jknfstt9FkxftBmpWokdNdmMlEhNsfyg=; b=qrZNpmB4r8FVIKopd0jjyxjIxIdnf4x4wviyHS9shXYzJV4XaMpmInQsbIFO0XCMSs a94P0h5iGIIKHFlWZf8KtZDQ7MDxG0CWZXXuNBJza2XxApNnP+hdqFwCT5PPtmpZacVH xaHpwZdF2wubbvVBI8C3DKvqXGiDebPLtnMnLF87Q1bguL9C+LQoD3A3Jf73cG03/Cii ymIS0+W90OiS4SjSwbWIaPAl/fSnaNxDPnc1+fQktlJvDTdFukiNMokDb5FHosJBSHmD IH6bQUJ/82pF4J1cLtua3sSMak+Ey9ntxdkVD0kaETrkjaGmUtY0nhukh38YHqeVfUaO GOKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712131548; x=1712736348; 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=iiceCABnvA1jknfstt9FkxftBmpWokdNdmMlEhNsfyg=; b=kudc5E9ipfN9y1W4S0cX/K4xmQOQetV60trQPQ1by92RGKByoeXwDKnqDaCoWVQoPB qcQzR/XqN24SnBf1Uj0fti5898s99zD/I2OLgn7PaXpHW4zk0Ksx462gEcix/GPcnTB2 hByeKbwioU55bmqMZpfS7qe3K2kvJzAh1NLX8HE/wAzdlnJhzLYgwQrqPJhO1JED/mBi jDOno3OxinMRDYdyWva1t7dSF7FNY0VTEmSOSLORGrKP+/zWBlYheUWgyhDB/Zmrb2UA 1tMg2DEBNcTM4s7+TmhLwK7qP97eCPk7XFg3LGYRUO1yFDcAm+MzgxXQVV1vC1lDNDZ2 milg== X-Gm-Message-State: AOJu0YwjQgXjJQfysD3YHicJcYFMJQWLDT/vPQ5EoPk8UFW4/5IESd3X knvIoz8M6WCSQ7n78r9A8H+fiA64gM1IAOMTlOSNR4qP4eQlzJUnnCXiyagilnEFq5uxgTJxXl6 q X-Received: by 2002:a17:903:181:b0:1e0:e85c:72dc with SMTP id z1-20020a170903018100b001e0e85c72dcmr2464037plg.19.1712131548509; Wed, 03 Apr 2024 01:05:48 -0700 (PDT) Received: from atishp.ba.rivosinc.com ([64.71.180.162]) by smtp.gmail.com with ESMTPSA id c12-20020a170902d48c00b001e0b5d49fc7sm12557229plg.161.2024.04.03.01.05.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Apr 2024 01:05:46 -0700 (PDT) From: Atish Patra To: linux-kernel@vger.kernel.org Cc: Atish Patra , Ajay Kaher , Alexandre Ghiti , Alexey Makhalov , Andrew Jones , 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, VMware PV-Drivers Reviewers , Will Deacon , x86@kernel.org Subject: [PATCH v5 17/22] KVM: riscv: selftests: Add helper functions for extension checks Date: Wed, 3 Apr 2024 01:04:46 -0700 Message-Id: <20240403080452.1007601-18-atishp@rivosinc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240403080452.1007601-1-atishp@rivosinc.com> References: <20240403080452.1007601-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. 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 e22848f747c0..6a3e97ead824 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