Received: by 2002:a05:6500:1b45:b0:1f5:f2ab:c469 with SMTP id cz5csp167404lqb; Tue, 16 Apr 2024 11:51:02 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXzINotnmeF5GVhJinuNFxvAzKd8whYY9qGcgAzGSpEi6jctPnGmIotOGFt7/dkoSodjdYXgoaoftq1ml78t2HtnWoiywXJlTs/yHjd0Q== X-Google-Smtp-Source: AGHT+IGjh8oVaQeHc3yrEp6VHjlnbQotSCy8NJZuLXXTGYqSMEr+2W21+PRCfkupbBW6PJbcQsUI X-Received: by 2002:a05:6512:1290:b0:518:b5af:5f64 with SMTP id u16-20020a056512129000b00518b5af5f64mr8310807lfs.46.1713293462666; Tue, 16 Apr 2024 11:51:02 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713293462; cv=pass; d=google.com; s=arc-20160816; b=jHQ/QwJZvTvx8H/NjNgfqdHYtzMNO5C/p+4OurGPfYPvCjRkGtiGDlL00QF2xLIWlq NNi8pgyH9TKNB1LDw1Joo/fZaF4dtZlzbFTtDn+WqPkVbJUvX+6uYcfV7f9uPfpYWRFl sT3Dg9i5GSccVFzbsULJbUngjF6m8mObH/SucYfbAqeMceuWIu/O3Au++UVJBBZMhBXl jMsGOptILAjaIi2FylacUX0gnqbZHYYzf0PyOCaI2iTZGNEXOu7DKCtZ27ZzryG3HaHl W4M8hQ/QOTEK+/Loq32JWH+Icd2leGtrF682xS9+Iims6GjT/PYUIzytFjYIHCDmXyFb A3aA== 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=BPwZXE2XSKrr96afFvE5Ak7Tq3sKjSlK1s+9Ond0wds=; fh=Rp1+u4PMjowggwvpRu96VEneDwGpmH5BAOjZCbMCQT4=; b=s2nAnB6mTqvyKybsdU2iQy4cXdMZlHlY2GXJw7/y74Ghbo3Bj5/hMHLr37qCaZ7cqw nBibADvGgumE/VnatlFgZWOAKoT6ft8gSyOSXRSRKM59dwa9YKCYnxw8H/iLchSSCmSJ jVy69SFnA0UraN/M0W6kBt9h+86LF8LfOktXe/m4NSXtXTSwDUYfAYX7ZVdZvbAOBqw3 E8gw73I8zXVZZOisGCoAp/Aw3sfX7eyvHWinz5EnAEeCiX+AsN/iK0v5drCvoit4vUkh H9t+CWhVYjEL9IccffGarBjIr0E2Qs4jGBCcRZ2qDNUa9i5gXS0k6XLCiMe68rTiTeY5 kVQA==; 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=nBK8Bb51; 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-147416-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-147416-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id do14-20020a170906c10e00b00a526b7742bfsi2464642ejc.259.2024.04.16.11.51.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Apr 2024 11:51:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-147416-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=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=nBK8Bb51; 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-147416-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-147416-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 061681F22263 for ; Tue, 16 Apr 2024 18:51:02 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id ABFB713E02A; Tue, 16 Apr 2024 18:45:09 +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="nBK8Bb51" Received: from mail-pg1-f172.google.com (mail-pg1-f172.google.com [209.85.215.172]) (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 0710A13D265 for ; Tue, 16 Apr 2024 18:45:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713293108; cv=none; b=p1d+m33C/1BHygpVIy4bUqhtX1SL1VE+qLjnaeVrIXSw/d8gqQe0YjV59mLpEmltYZ406EZYwlYAw15wmwJE7g9WoHhsea20lSM/P6ZJYA4TgVTv1rImBPHPWSJMAHPlbhKwQHoi64JaKZCi1eQpeKhOXCwv3OG/BpeD6pm7APw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713293108; c=relaxed/simple; bh=UaK2BRG2cCYtJekJX1v+X6A/okSCrPqUNYx/jYqyhvE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=YcwAzFujouDHi1L0EEs6ocsMSYIvjU53o98B0PWvcEjhG+fekow7ClDttGfNk1kM3U1lCJQxMreiKH6IVMbljJ/m+PCah1EUQ+PP1cCE4Z4WK+O68QYK0uXb/MFFXBaM+w0p1g9pN/cxL7EkmBp90bS7FPF4ajTKonGEwJaM9FE= 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=nBK8Bb51; arc=none smtp.client-ip=209.85.215.172 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-pg1-f172.google.com with SMTP id 41be03b00d2f7-5dcc4076c13so42490a12.0 for ; Tue, 16 Apr 2024 11:45:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1713293105; x=1713897905; 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=BPwZXE2XSKrr96afFvE5Ak7Tq3sKjSlK1s+9Ond0wds=; b=nBK8Bb51pMPkSr1/8vCRWz+6Hb+3pPsr0W+x/jX/0YUyOK3Q08IQVfzbOTHh8wZzoi 8zVaUeI97OImFXVTgVjS/PGIsuxy25oUVg0uh7eMpOf+FSN5ddGxQQXGnnoUe5i48fCQ oovS/+7IjlS2GW3ro8CEp+WKNeH8niAQQhNhH90sGPgEWUECXMcJIDb8UA7U1e1Gyhy1 hkD+VlDOAJivSpAl1waW/ATa17r6KAqmwo3r9yUoi1qb+ZUHvlS0qvSqknrCeBxvbdPm nNZrG2L4RD0RH93blIl3T0Onf5uU9xUU+5IqM34S7dc8yjjILo3alyh6+nbKyVQkWZGq /trA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713293105; x=1713897905; 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=BPwZXE2XSKrr96afFvE5Ak7Tq3sKjSlK1s+9Ond0wds=; b=mNeAp85D02aagmatsegn/E05hJNT7oq3J/bmwvyDNWrEHahsXHi7tClAcYjKb1E+5q rgG1h2R6EBIui0mL7M5E1gS3blMaLHN0VM8UCN68id4AAbd/wB5Dj3VxyJJSFZJwII1F l6dMiIVQkytS5hXrQJ7s42rX0g52BHpeFfqn9y+sSl/lHcsBOW85ON/YbP7ttFFGudQL HmUgmTPuAvqhZSohsJo69W+Rq4qlUTDjgcDC3OMBr/6IAr2SJXBfdJl+ciOpfVOXjpJ8 fUQI3llKa6X/gMgx8r0ee1JtQtpaxNl44QQu2LjP7RlhbnhboyF9o/QgowlQahxBllnE Q0qg== X-Gm-Message-State: AOJu0YxBEJHiDy75WkRmwUuqpIty6RtgAzqPyY/NRH05kv2oSFKRNYFa Td8zRL+hPlFShQ8GZhlAkZmdIK5FSspns8pLsDB4InoHvzr0c1XwQdNotnZ8WD0najYCVsGufHp O X-Received: by 2002:a17:90a:f105:b0:2a7:8674:a0c8 with SMTP id cc5-20020a17090af10500b002a78674a0c8mr4586203pjb.1.1713293105488; Tue, 16 Apr 2024 11:45:05 -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.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Apr 2024 11:45:05 -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 17/24] KVM: riscv: selftests: Move sbi definitions to its own header file Date: Tue, 16 Apr 2024 11:44:14 -0700 Message-Id: <20240416184421.3693802-18-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 The SBI definitions will continue to grow. Move the sbi related definitions to its own header file from processor.h Suggested-by: Andrew Jones Reviewed-by: Andrew Jones Signed-off-by: Atish Patra --- .../selftests/kvm/include/riscv/processor.h | 39 --------------- .../testing/selftests/kvm/include/riscv/sbi.h | 50 +++++++++++++++++++ .../selftests/kvm/include/riscv/ucall.h | 1 + tools/testing/selftests/kvm/steal_time.c | 4 +- 4 files changed, 54 insertions(+), 40 deletions(-) create mode 100644 tools/testing/selftests/kvm/include/riscv/sbi.h diff --git a/tools/testing/selftests/kvm/include/riscv/processor.h b/tools/testing/selftests/kvm/include/riscv/processor.h index ce473fe251dd..3b9cb39327ff 100644 --- a/tools/testing/selftests/kvm/include/riscv/processor.h +++ b/tools/testing/selftests/kvm/include/riscv/processor.h @@ -154,45 +154,6 @@ void vm_install_interrupt_handler(struct kvm_vm *vm, exception_handler_fn handle #define PGTBL_PAGE_SIZE PGTBL_L0_BLOCK_SIZE #define PGTBL_PAGE_SIZE_SHIFT PGTBL_L0_BLOCK_SHIFT -/* SBI return error codes */ -#define SBI_SUCCESS 0 -#define SBI_ERR_FAILURE -1 -#define SBI_ERR_NOT_SUPPORTED -2 -#define SBI_ERR_INVALID_PARAM -3 -#define SBI_ERR_DENIED -4 -#define SBI_ERR_INVALID_ADDRESS -5 -#define SBI_ERR_ALREADY_AVAILABLE -6 -#define SBI_ERR_ALREADY_STARTED -7 -#define SBI_ERR_ALREADY_STOPPED -8 - -#define SBI_EXT_EXPERIMENTAL_START 0x08000000 -#define SBI_EXT_EXPERIMENTAL_END 0x08FFFFFF - -#define KVM_RISCV_SELFTESTS_SBI_EXT SBI_EXT_EXPERIMENTAL_END -#define KVM_RISCV_SELFTESTS_SBI_UCALL 0 -#define KVM_RISCV_SELFTESTS_SBI_UNEXP 1 - -enum sbi_ext_id { - SBI_EXT_BASE = 0x10, - SBI_EXT_STA = 0x535441, -}; - -enum sbi_ext_base_fid { - SBI_EXT_BASE_PROBE_EXT = 3, -}; - -struct sbiret { - long error; - long value; -}; - -struct sbiret sbi_ecall(int ext, int fid, unsigned long arg0, - unsigned long arg1, unsigned long arg2, - unsigned long arg3, unsigned long arg4, - unsigned long arg5); - -bool guest_sbi_probe_extension(int extid, long *out_val); - static inline void local_irq_enable(void) { csr_set(CSR_SSTATUS, SR_SIE); diff --git a/tools/testing/selftests/kvm/include/riscv/sbi.h b/tools/testing/selftests/kvm/include/riscv/sbi.h new file mode 100644 index 000000000000..ba04f2dec7b5 --- /dev/null +++ b/tools/testing/selftests/kvm/include/riscv/sbi.h @@ -0,0 +1,50 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * RISC-V SBI specific definitions + * + * Copyright (C) 2024 Rivos Inc. + */ + +#ifndef SELFTEST_KVM_SBI_H +#define SELFTEST_KVM_SBI_H + +/* SBI return error codes */ +#define SBI_SUCCESS 0 +#define SBI_ERR_FAILURE -1 +#define SBI_ERR_NOT_SUPPORTED -2 +#define SBI_ERR_INVALID_PARAM -3 +#define SBI_ERR_DENIED -4 +#define SBI_ERR_INVALID_ADDRESS -5 +#define SBI_ERR_ALREADY_AVAILABLE -6 +#define SBI_ERR_ALREADY_STARTED -7 +#define SBI_ERR_ALREADY_STOPPED -8 + +#define SBI_EXT_EXPERIMENTAL_START 0x08000000 +#define SBI_EXT_EXPERIMENTAL_END 0x08FFFFFF + +#define KVM_RISCV_SELFTESTS_SBI_EXT SBI_EXT_EXPERIMENTAL_END +#define KVM_RISCV_SELFTESTS_SBI_UCALL 0 +#define KVM_RISCV_SELFTESTS_SBI_UNEXP 1 + +enum sbi_ext_id { + SBI_EXT_BASE = 0x10, + SBI_EXT_STA = 0x535441, +}; + +enum sbi_ext_base_fid { + SBI_EXT_BASE_PROBE_EXT = 3, +}; + +struct sbiret { + long error; + long value; +}; + +struct sbiret sbi_ecall(int ext, int fid, unsigned long arg0, + unsigned long arg1, unsigned long arg2, + unsigned long arg3, unsigned long arg4, + unsigned long arg5); + +bool guest_sbi_probe_extension(int extid, long *out_val); + +#endif /* SELFTEST_KVM_SBI_H */ diff --git a/tools/testing/selftests/kvm/include/riscv/ucall.h b/tools/testing/selftests/kvm/include/riscv/ucall.h index be46eb32ec27..a695ae36f3e0 100644 --- a/tools/testing/selftests/kvm/include/riscv/ucall.h +++ b/tools/testing/selftests/kvm/include/riscv/ucall.h @@ -3,6 +3,7 @@ #define SELFTEST_KVM_UCALL_H #include "processor.h" +#include "sbi.h" #define UCALL_EXIT_REASON KVM_EXIT_RISCV_SBI diff --git a/tools/testing/selftests/kvm/steal_time.c b/tools/testing/selftests/kvm/steal_time.c index bae0c5026f82..2ff82c7fd926 100644 --- a/tools/testing/selftests/kvm/steal_time.c +++ b/tools/testing/selftests/kvm/steal_time.c @@ -11,7 +11,9 @@ #include #include #include -#ifndef __riscv +#ifdef __riscv +#include "sbi.h" +#else #include #endif -- 2.34.1