From patchwork Thu Jul 27 07:20:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haibo Xu X-Patchwork-Id: 12677 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a985:0:b0:3e4:2afc:c1 with SMTP id t5csp921409vqo; Thu, 27 Jul 2023 00:37:39 -0700 (PDT) X-Google-Smtp-Source: APBJJlEAnwjuKCID1N3ty4DwE4KXx7ggyzLpfLq0O+BkxVfKRDYxlJFjs9PmDvwc++k6WxoOIxhG X-Received: by 2002:a05:6a21:3389:b0:131:6464:217b with SMTP id yy9-20020a056a21338900b001316464217bmr4432240pzb.16.1690443458619; Thu, 27 Jul 2023 00:37:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690443458; cv=none; d=google.com; s=arc-20160816; b=Ox5ZS4XuA1Y6WItbUsPijI1TNyCEUj66nppYMvqWVb/+lf+rU50I+8zq3pA9M4aajY raRHwAvx1176XMb9lANxhSwdhB4hg0P+kmcy+Rx7LlV9/D0fTlaYjY5OgK/b0WmEb0P0 qtmIdpFl9pZdogTg8uSag8fx0/70tGrg+u5dxxkUlHMRk4UjJ9zX+PerIVU/QHS1n5gu 5vlzif8hlET4ER4ibuRCm0CB26rULy9ZLhZFzyd/2OsDaLTkzD2tY5NcRkP5YE+yzv+w urHY+znFbEcIgWr/Z00JYToYjxCuf5ofpst9WaPi44g5XaUUrS9NF4qwCOmr6t4wZEtq m9wg== 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=AFAir8P+qd6OOVypdfXY9ucqytO167f+E2+ziRisjQs=; fh=WoDkCPClHY1BxT+HuXaYYmUcPmzWf0zE3QNsc7zMQlg=; b=q4zIbCaE2eHTovbBgvyckJCR5BwszCobalTIsdwxuaVXEa0i+XlqZ8IBnt4vPZtdrj q0BSsBmLF39auPJ+PcXxXVbRud80sd7s+G/aUBUq22yjxj/1PRzTm5LHVoHSfIISzdHh fBs7pTmKrzlCXNtB/ekZKqpIhUgTRph5j6O2f/eli4TjgB2PNiRIgVYJ2U2uKLrVi90X qjz0rOSvf5BCqWG450BHNApzRcKcc8WaW0Z9AkpFp+tDjEU7LD20l5xIOMea0aDBSHsL cCKeH0dN+z/IWPT8KAeEDlJg4Roc/SomvpzDQ3O55aO4elYdJZORXQ3glbMQDZ1+FNjY 4yVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@intel.com header.s=Intel header.b=Q8zGkq7P; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p28-20020a637f5c000000b0053eee173733si449579pgn.227.2023.07.27.00.37.25; Thu, 27 Jul 2023 00:37:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=fail header.i=@intel.com header.s=Intel header.b=Q8zGkq7P; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233330AbjG0HZr (ORCPT + 99 others); Thu, 27 Jul 2023 03:25:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40164 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233290AbjG0HYN (ORCPT ); Thu, 27 Jul 2023 03:24:13 -0400 Received: from mgamail.intel.com (mga04.intel.com [192.55.52.120]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 22E336591; Thu, 27 Jul 2023 00:15:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1690442122; x=1721978122; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=BAACILCTxyqMs2Tae391dkKNJN/XDjDizeOYFsgg42A=; b=Q8zGkq7PeQe9jti7KiHDsDYNAF+jBh6svKrMNGuu0AM2TlHU682TY/Qz Buc61xQWaMJzC3fez9Wvk9wI7rLcMeRogtuoRyvoj8G539E7nsSIdMlKU SMEBX6TW5XFVJdImSu6ln15HZ9wqi14NuKqPvk1J7KpL6QtuNmgoTZP/E Sz5Vel6uXnFGu2u99ikIhqGWfmSPiO3bLOjmejo7/hw75YVdhXXf26fw9 nc9aXrAJAdG5VY7pfIm0k2srzdKumSSkGRFKJmfqavsHKoEJwS9x5qJTp 36lNyizwrVAjOUGypbAt1cdFqCIoxXpTHNFN4J/HmHWeft+Q3/iv1GdoR w==; X-IronPort-AV: E=McAfee;i="6600,9927,10783"; a="367102049" X-IronPort-AV: E=Sophos;i="6.01,234,1684825200"; d="scan'208";a="367102049" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Jul 2023 00:14:14 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10783"; a="720785797" X-IronPort-AV: E=Sophos;i="6.01,234,1684825200"; d="scan'208";a="720785797" Received: from haibo-optiplex-7090.sh.intel.com ([10.239.159.132]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Jul 2023 00:14:08 -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 , Anup Patel , Atish Patra , Sean Christopherson , Vipin Sharma , Colton Lewis , Marc Zyngier , Andrew Jones , Vishal Annapurve , linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, kvm@vger.kernel.org, linux-kselftest@vger.kernel.org, kvm-riscv@lists.infradead.org Subject: [PATCH 0/4] RISCV: Add kvm Sstc timer selftest Date: Thu, 27 Jul 2023 15:20:04 +0800 Message-Id: X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1772558440062037241 X-GMAIL-MSGID: 1772558440062037241 The sstc_timer selftest 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 selftest was ported from aarch64 arch_timer and tested with Linux v6.5-rc3 on a Qemu riscv64 virt machine. Haibo Xu (4): tools: riscv: Add header file csr.h KVM: riscv: selftests: Add exception handling support KVM: riscv: selftests: Add guest helper to get vcpu id KVM: riscv: selftests: Add sstc_timer test tools/arch/riscv/include/asm/csr.h | 127 ++++++ tools/testing/selftests/kvm/Makefile | 2 + .../selftests/kvm/include/riscv/processor.h | 76 ++++ .../selftests/kvm/include/riscv/sstc_timer.h | 70 ++++ .../selftests/kvm/lib/riscv/handlers.S | 101 +++++ .../selftests/kvm/lib/riscv/processor.c | 74 ++++ .../testing/selftests/kvm/riscv/sstc_timer.c | 382 ++++++++++++++++++ 7 files changed, 832 insertions(+) create mode 100644 tools/arch/riscv/include/asm/csr.h create mode 100644 tools/testing/selftests/kvm/include/riscv/sstc_timer.h create mode 100644 tools/testing/selftests/kvm/lib/riscv/handlers.S create mode 100644 tools/testing/selftests/kvm/riscv/sstc_timer.c