Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp3609553rdb; Wed, 13 Sep 2023 18:28:13 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFGcsZ0oG27C8xOGS1qseB1ZZaiZHVg1uNzhYfrwHSA3tb/EH/iA3MBvkA9p9qc0hFLEb3G X-Received: by 2002:a05:6a21:19b:b0:152:efa4:228 with SMTP id le27-20020a056a21019b00b00152efa40228mr4706313pzb.20.1694654893330; Wed, 13 Sep 2023 18:28:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694654893; cv=none; d=google.com; s=arc-20160816; b=ID/rWGbTxFbT3jCm3S9IBGH1Pnuzm1nSgIfTOqq4edzLl6pn0KaMIHPkggjsi7ScYb 6WOs/8Qt/R46vQP75f0CEn1Vka425Mf1tZiojz1AXT9/hIcZWFVfZFua10M/9x5nQ3N4 ajRJWpLWMkzpmNsmH6aSveeVCSXA5raL90VW30p4LXJ4xWNxy0R3JGrjv8s+m21CUpeN W+Gw6fMHGbIgq9ni9PX5wZwbR/iU5sA2zuLffyoe3Mic27a+I77/kjjg+gwxYxJ/TlOz D5UhUfuGps6CKVByMqPrJII1XXs0IHv0JHE/dGz3zqlBKgjRSpP28nTY1CBbuoGblrTR oC8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:content-transfer-encoding:mime-version :message-id:date:subject:cc:from:dkim-signature; bh=l+fwbpavSkAZPSl+XVTqDznLjf2cgBMhWSY6K9+8hNg=; fh=aK12dqerEdGGYUMcynk+qD7To8Y/YNXaA+l0gxa06S8=; b=w81UVQE+y6R/ClXPRk9ezm6Trw8C5B4DwMmGYVs0uCDkPVfQ4Ch0eqyoUKTQ9+Q1Bc L35KitHw/+EGOdvPEFaUT7nqO9KFeWK2X4oq9tgeTDqshSxJzmEQ8MzQjQ2Jc22cmNcl rwjyztGQkaGkJIHxZjMC206jYJbRyh7mMX3uPzertvNit1FSC/W2lRHb3klcvurgu32D VZxQdlOQopjyoD1GGeB4769E3MycDg5rb9kyaQAdqs/lJDmFQOmiNgTsZTSb7g+SOItX FoTs2ikbFRltFmUYHkCPTWing8FjAUOAuEfidLZnbqpOOCrE3eOO85YbKlVc5txbuMLn vA5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@intel.com header.s=Intel header.b=DfQuoVf5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id v5-20020a17090a898500b00253555e5f95si508090pjn.153.2023.09.13.18.28.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 18:28:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=fail header.i=@intel.com header.s=Intel header.b=DfQuoVf5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id DB393807C5EE; Wed, 13 Sep 2023 18:28:10 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233590AbjINB2B (ORCPT + 99 others); Wed, 13 Sep 2023 21:28:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58306 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233400AbjINB2A (ORCPT ); Wed, 13 Sep 2023 21:28:00 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.120]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 79FAD1BD1; Wed, 13 Sep 2023 18:27:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1694654876; x=1726190876; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=ueE/011k9DiwV0Anf9SWAZccz4IuGXFEGSyhfc+Fk0k=; b=DfQuoVf5XhvkZwpdK1eoYwINamWBmIwKEM8v2zvkqyJvs0jRrukzeC1G GLh7IVjm7cQaLit+KIUKVlImqK/7VQzcywhCA0FjENG52xqtivS2DdRyS bVIQRcbm+4Dt8P1mWmWgSTILE+4wdP3eOogXAlPY4MQzI7Z56qirQpb+M XoubkjgdATql7y8+S3w35PrJIugrA2jXs3ax266DfwU602BOdvxUclgXn RYXszGcLCjH2/mOAs+LfUv+XpEXC6eZXWj+oh8a2lYqt+9tewvRV5TEUk 55qECN7f5eQGFefAyDzxcmuqhygpVayLugyqKdo9ia8yjVCVsZkEbfHDT A==; X-IronPort-AV: E=McAfee;i="6600,9927,10832"; a="377733953" X-IronPort-AV: E=Sophos;i="6.02,144,1688454000"; d="scan'208";a="377733953" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Sep 2023 18:27:55 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10832"; a="694048860" X-IronPort-AV: E=Sophos;i="6.02,144,1688454000"; d="scan'208";a="694048860" Received: from haibo-optiplex-7090.sh.intel.com ([10.239.159.132]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Sep 2023 18:27:48 -0700 From: Haibo Xu Cc: xiaobo55x@gmail.com, haibo1.xu@intel.com, ajones@ventanamicro.com, Paul Walmsley , Palmer Dabbelt , Albert Ou , Paolo Bonzini , Shuah Khan , Marc Zyngier , Oliver Upton , James Morse , Suzuki K Poulose , Zenghui Yu , Anup Patel , Atish Patra , Sean Christopherson , Ricardo Koller , Vishal Annapurve , Like Xu , Vipin Sharma , David Matlack , Thomas Huth , Colton Lewis , Aaron Lewis , linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, kvm@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, kvm-riscv@lists.infradead.org Subject: [PATCH v3 0/9] RISCV: Add kvm Sstc timer selftests Date: Thu, 14 Sep 2023 09:36:54 +0800 Message-Id: X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Wed, 13 Sep 2023 18:28:11 -0700 (PDT) X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email The RISC-V arch_timer selftests is used to validate Sstc timer functionality in a guest, which sets up periodic timer interrupts and check the basic interrupt status upon its receipt. This KVM selftests was ported from aarch64 arch_timer and tested with Linux v6.6-rc1 on a Qemu riscv64 virt machine. --- Changed since v2: * Rebase to Linux 6.6-rc1 * Add separate patch for kvm/Makefile improvement * Move aarch64 specific macros to aarch64/arch_timer.c * Add -DCONFIG_64BIT to kvm/Makefile CFLAGS to ensure only 64bit registers were available in csr.h * Avoid some #ifdef in kvm/arch_timer.c by setting some aarch64 specific variable to 0 on risc-v Haibo Xu (9): KVM: selftests: Unify the codes for guest exception handling KVM: selftests: Unify the makefile rule for split targets KVM: arm64: selftests: Split arch_timer test code tools: riscv: Add header file csr.h KVM: riscv: selftests: Switch to use macro from csr.h KVM: riscv: selftests: Add exception handling support KVM: riscv: selftests: Add guest helper to get vcpu id KVM: riscv: selftests: Change vcpu_has_ext to a common function KVM: riscv: selftests: Add sstc timer test tools/arch/riscv/include/asm/csr.h | 521 ++++++++++++++++++ tools/testing/selftests/kvm/Makefile | 14 +- .../selftests/kvm/aarch64/arch_timer.c | 291 +--------- .../selftests/kvm/aarch64/debug-exceptions.c | 4 +- .../selftests/kvm/aarch64/page_fault_test.c | 4 +- .../testing/selftests/kvm/aarch64/vgic_irq.c | 4 +- tools/testing/selftests/kvm/arch_timer.c | 250 +++++++++ .../selftests/kvm/include/aarch64/processor.h | 12 +- .../selftests/kvm/include/kvm_util_base.h | 9 + .../selftests/kvm/include/riscv/arch_timer.h | 80 +++ .../selftests/kvm/include/riscv/processor.h | 63 ++- .../testing/selftests/kvm/include/test_util.h | 2 + .../selftests/kvm/include/timer_test.h | 43 ++ .../selftests/kvm/include/x86_64/processor.h | 5 - .../selftests/kvm/lib/aarch64/processor.c | 6 +- .../selftests/kvm/lib/riscv/handlers.S | 101 ++++ .../selftests/kvm/lib/riscv/processor.c | 86 +++ .../selftests/kvm/lib/x86_64/processor.c | 4 +- .../testing/selftests/kvm/riscv/arch_timer.c | 107 ++++ .../selftests/kvm/riscv/get-reg-list.c | 16 +- tools/testing/selftests/kvm/x86_64/amx_test.c | 4 +- .../selftests/kvm/x86_64/fix_hypercall_test.c | 4 +- .../selftests/kvm/x86_64/hyperv_evmcs.c | 4 +- .../selftests/kvm/x86_64/hyperv_features.c | 8 +- .../testing/selftests/kvm/x86_64/hyperv_ipi.c | 6 +- .../selftests/kvm/x86_64/kvm_pv_test.c | 4 +- .../selftests/kvm/x86_64/monitor_mwait_test.c | 4 +- .../kvm/x86_64/pmu_event_filter_test.c | 8 +- .../smaller_maxphyaddr_emulation_test.c | 4 +- .../selftests/kvm/x86_64/svm_int_ctl_test.c | 4 +- .../kvm/x86_64/svm_nested_shutdown_test.c | 4 +- .../kvm/x86_64/svm_nested_soft_inject_test.c | 4 +- .../kvm/x86_64/ucna_injection_test.c | 8 +- .../kvm/x86_64/userspace_msr_exit_test.c | 4 +- .../vmx_exception_with_invalid_guest_state.c | 4 +- .../selftests/kvm/x86_64/vmx_pmu_caps_test.c | 4 +- .../selftests/kvm/x86_64/xapic_ipi_test.c | 4 +- .../selftests/kvm/x86_64/xcr0_cpuid_test.c | 4 +- .../selftests/kvm/x86_64/xen_shinfo_test.c | 4 +- 39 files changed, 1338 insertions(+), 374 deletions(-) create mode 100644 tools/arch/riscv/include/asm/csr.h create mode 100644 tools/testing/selftests/kvm/arch_timer.c create mode 100644 tools/testing/selftests/kvm/include/riscv/arch_timer.h create mode 100644 tools/testing/selftests/kvm/include/timer_test.h create mode 100644 tools/testing/selftests/kvm/lib/riscv/handlers.S create mode 100644 tools/testing/selftests/kvm/riscv/arch_timer.c -- 2.34.1