From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 212A8C433F5 for ; Thu, 16 Sep 2021 18:16:03 +0000 (UTC) Received: from mm01.cs.columbia.edu (mm01.cs.columbia.edu [128.59.11.253]) by mail.kernel.org (Postfix) with ESMTP id C813361139 for ; Thu, 16 Sep 2021 18:16:02 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org C813361139 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.cs.columbia.edu Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 7DEF74B15D; Thu, 16 Sep 2021 14:16:02 -0400 (EDT) X-Virus-Scanned: at lists.cs.columbia.edu Authentication-Results: mm01.cs.columbia.edu (amavisd-new); dkim=softfail (fail, message has been altered) header.i=@google.com Received: from mm01.cs.columbia.edu ([127.0.0.1]) by localhost (mm01.cs.columbia.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Am3m3L+rspPB; Thu, 16 Sep 2021 14:16:01 -0400 (EDT) Received: from mm01.cs.columbia.edu (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 6BD634B0C0; Thu, 16 Sep 2021 14:16:01 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 00F484A98B for ; Thu, 16 Sep 2021 14:16:00 -0400 (EDT) X-Virus-Scanned: at lists.cs.columbia.edu Received: from mm01.cs.columbia.edu ([127.0.0.1]) by localhost (mm01.cs.columbia.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 1CjVsfPruXno for ; Thu, 16 Sep 2021 14:15:58 -0400 (EDT) Received: from mail-il1-f201.google.com (mail-il1-f201.google.com [209.85.166.201]) by mm01.cs.columbia.edu (Postfix) with ESMTPS id E380A49DE7 for ; Thu, 16 Sep 2021 14:15:58 -0400 (EDT) Received: by mail-il1-f201.google.com with SMTP id d17-20020a9287510000b0290223c9088c96so14981857ilm.1 for ; Thu, 16 Sep 2021 11:15:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:message-id:mime-version:subject:from:to:cc; bh=bscRkoWhCmUqrdoE9Uy2kjhDd+L+Bo5wsdZYDj09NRA=; b=Omp+Kv8GsfsAlwd+15EkIN211lfCDN3xwS6/TjRxp1OFnDfl7A1eIes+NME14D5zkU SU1gHUL1v8E0n6cZMsL67wo8sqvGKsD9s7SAvNOZvGDLm6Q71CQQNHuWGokA8r1XgKgi AWItSWtYPx3zSkTSuimrx+ZsyhJJ3hwcJ9swS7QpIrDUpLoqkYvpi8/q45gdHgnABxyx MaVI1gl2p9k3pMHxCvAHnnwwDnruhyqoLrzOHHz9CXJjJldYYy7dVW9PIPmPfTyYbr1g /wa+qgJuAp4V2Z5IFkM7m9vs2beY/BcmGVV8PiWC9wd/8DN0Z7vNI+gLLJXM+LKExJim Nktw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=bscRkoWhCmUqrdoE9Uy2kjhDd+L+Bo5wsdZYDj09NRA=; b=pcfIfOlM/wYPtMsd/6tUWj0plbP7mvNp7LgCsswIWbFwXoHNRTBkPgX8XOrN4447Fr 5OmSzMwFU8TcpPLNb1LkjG17Z72ntAbR9c4FwuxdbKa6Ok1JLHSTv3hhQaNxojrwcgfp 4tqTfX94jUgdiN900+pJaw0lzQoKnUgPTvrkCeLo3NAaPH5xIHxtFxfFJAZemdXiK4IS 2OFPyBUAko8+HS8D41nxBw3M9B0cd9FbPZual8245ZaZaQzayEHa5UuvzSaX0lWbumsB HyfenOiz4WwMx2Ti7hTAbfmAdzSKrBxMBKL7RILCUADzVYdevMV6CaXgu5SNf6fT8gWO bwmg== X-Gm-Message-State: AOAM531ADMf49PU2BYuoEZkMOY4R1LcFhiSIULZfMdZM5377DGujw9fK v7vowADV3M6Tm6lz1lhTHKgQPgFegIo= X-Google-Smtp-Source: ABdhPJw7P9q6ohfaLCYYiJQsfCZ5CUJm5aQJkALSzTzedA418ocdFUdRDhmRlqyMXq3CYS/vrg37QpBFSCc= X-Received: from oupton.c.googlers.com ([fda3:e722:ac3:cc00:2b:ff92:c0a8:404]) (user=oupton job=sendgmr) by 2002:a05:6e02:2167:: with SMTP id s7mr4906857ilv.314.1631816158433; Thu, 16 Sep 2021 11:15:58 -0700 (PDT) Date: Thu, 16 Sep 2021 18:15:46 +0000 Message-Id: <20210916181555.973085-1-oupton@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.33.0.464.g1972c5931b-goog Subject: [PATCH v8 0/9] selftests: KVM: Test offset-based counter controls From: Oliver Upton To: kvm@vger.kernel.org, kvmarm@lists.cs.columbia.edu Cc: Catalin Marinas , Will Deacon , Marc Zyngier , Peter Shier , Sean Christopherson , David Matlack , Paolo Bonzini , linux-arm-kernel@lists.infradead.org, Jim Mattson X-BeenThere: kvmarm@lists.cs.columbia.edu X-Mailman-Version: 2.1.14 Precedence: list List-Id: Where KVM/ARM decisions are made List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: kvmarm-bounces@lists.cs.columbia.edu Sender: kvmarm-bounces@lists.cs.columbia.edu This series implements new tests for the x86 and arm64 counter migration changes that I've mailed out. These are sent separately as a dependent change since there are cross-arch dependencies here. Patch 1 yanks the pvclock headers into the tools/ directory so we can make use of them within a KVM selftest guest. Patch 2 tests the new capabilities of the KVM_*_CLOCK ioctls, ensuring that the kernel accounts for elapsed time when restoring the KVM clock. Patches 3-4 add some device attribute helpers and clean up some mistakes in the assertions thereof. Patch 5 implements a test for the KVM_VCPU_TSC_OFFSET attribute, asserting that manipulation of the offset results in correct TSC values within the guest. Patch 6 adds basic arm64 support to the counter offset test, checking that the virtual counter-timer offset works correctly. Patch 7 does the same for the physical counter-timer offset. Patch 8 adds a benchmark for physical counter offsetting, since most implementations available right now will rely on emulation. Lastly, patch 9 extends the get-reg-list test to check for KVM_REG_ARM_TIMER_OFFSET if userspace opts-in to the kernel capability. This series applies cleanly to 5.15-rc1 Tests were ran against the respective architecture changes on the following systems: - Haswell (x86) - Ampere Mt. Jade (non-ECV, nVHE and VHE) v7: https://lore.kernel.org/r/20210816001246.3067312-1-oupton@google.com v7 -> v8: - Rebased to 5.15-rc1 - Dropped helper for checking if reg exists in reg list (no longer necessary) - Test and enable KVM_CAP_ARM_VTIMER_OFFSET - Add get-reg-list changes Oliver Upton (9): tools: arch: x86: pull in pvclock headers selftests: KVM: Add test for KVM_{GET,SET}_CLOCK selftests: KVM: Fix kvm device helper ioctl assertions selftests: KVM: Add helpers for vCPU device attributes selftests: KVM: Introduce system counter offset test selftests: KVM: Add support for aarch64 to system_counter_offset_test selftests: KVM: Test physical counter offsetting selftests: KVM: Add counter emulation benchmark selftests: KVM: Test vtimer offset reg in get-reg-list tools/arch/x86/include/asm/pvclock-abi.h | 48 ++++ tools/arch/x86/include/asm/pvclock.h | 103 ++++++++ tools/testing/selftests/kvm/.gitignore | 3 + tools/testing/selftests/kvm/Makefile | 4 + .../kvm/aarch64/counter_emulation_benchmark.c | 207 ++++++++++++++++ .../selftests/kvm/aarch64/get-reg-list.c | 42 ++++ .../selftests/kvm/include/aarch64/processor.h | 24 ++ .../testing/selftests/kvm/include/kvm_util.h | 11 + tools/testing/selftests/kvm/lib/kvm_util.c | 44 +++- .../kvm/system_counter_offset_test.c | 220 ++++++++++++++++++ .../selftests/kvm/x86_64/kvm_clock_test.c | 204 ++++++++++++++++ 11 files changed, 907 insertions(+), 3 deletions(-) create mode 100644 tools/arch/x86/include/asm/pvclock-abi.h create mode 100644 tools/arch/x86/include/asm/pvclock.h create mode 100644 tools/testing/selftests/kvm/aarch64/counter_emulation_benchmark.c create mode 100644 tools/testing/selftests/kvm/system_counter_offset_test.c create mode 100644 tools/testing/selftests/kvm/x86_64/kvm_clock_test.c -- 2.33.0.464.g1972c5931b-goog _______________________________________________ kvmarm mailing list kvmarm@lists.cs.columbia.edu https://lists.cs.columbia.edu/mailman/listinfo/kvmarm From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4EEE7C433EF for ; Thu, 16 Sep 2021 18:27:20 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 13A3A61139 for ; Thu, 16 Sep 2021 18:27:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 13A3A61139 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:From:Subject:Mime-Version: Message-Id:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=rrKH+7+P7IeeKXW65dToM5tZ5f536ToGGX5r0GWPHnM=; b=ZFM 2jnPJZoIodTYC1nY/Fdi4iV9Y6wo8c22NeRzHmPkRSIJZvm94fFmHSY5aorQ0TvWOsqeVuoWZ0a5I c7WiYl8n247/l/otLdCrB7rdLTd6CIgIT8YW85rXqj2jZhpBCwxouxKKdZBDq88iz2Fmr8Qqm7P81 MTAH0MjxPTF4+SFItA52pffHlyLoUGCQdoKvKXd9AZW6HJXSetvdthCcKdwIY1dGpxxPTVEAoP4wh aeTZIt/nJryCFyh6tf8hGB6jiN9wbqLUvfC2HGVjAfL5sxZcrVgidFfbNByQfnw62hcCWGML1CB+G qlrWbTaqWBcipIwOU0fZayRt3uaDB0g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mQw4Q-00C67m-8U; Thu, 16 Sep 2021 18:25:16 +0000 Received: from mail-io1-xd49.google.com ([2607:f8b0:4864:20::d49]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mQvvT-00C22b-Tt for linux-arm-kernel@lists.infradead.org; Thu, 16 Sep 2021 18:16:01 +0000 Received: by mail-io1-xd49.google.com with SMTP id 142-20020a6b1494000000b005d324a4f7c9so4750410iou.8 for ; Thu, 16 Sep 2021 11:15:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:message-id:mime-version:subject:from:to:cc; bh=bscRkoWhCmUqrdoE9Uy2kjhDd+L+Bo5wsdZYDj09NRA=; b=Omp+Kv8GsfsAlwd+15EkIN211lfCDN3xwS6/TjRxp1OFnDfl7A1eIes+NME14D5zkU SU1gHUL1v8E0n6cZMsL67wo8sqvGKsD9s7SAvNOZvGDLm6Q71CQQNHuWGokA8r1XgKgi AWItSWtYPx3zSkTSuimrx+ZsyhJJ3hwcJ9swS7QpIrDUpLoqkYvpi8/q45gdHgnABxyx MaVI1gl2p9k3pMHxCvAHnnwwDnruhyqoLrzOHHz9CXJjJldYYy7dVW9PIPmPfTyYbr1g /wa+qgJuAp4V2Z5IFkM7m9vs2beY/BcmGVV8PiWC9wd/8DN0Z7vNI+gLLJXM+LKExJim Nktw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=bscRkoWhCmUqrdoE9Uy2kjhDd+L+Bo5wsdZYDj09NRA=; b=34p9Zdrxv4zC4rI4MNxz/UdDq3m43T3pMFdrUW8YIhrZPP7HnxlxBvuPBLLvbHUClF h5tH5Ue6s1+vY4Guvr65IadTOQmjbCm4fCzRwcRqBIFuzYI3WPdBkmGtLpLrKiyH707s XSv0xOnoAUco72jFm+Dkzv20c/mEdqHXuu4Ky76Uatl6X1BLay2MT781SBl18dcGoH4N duHyUb8fLKwJG5zT17WU0MsSOjRcR4j8B7/INJkEhEZPw2dG3sa/xrY48K+19OFH7CJo Rtjy+3Yqpwv7mHuKlROf+Iwf+IIdFaFUogqVcvPpXIL8b0g6Qge8Axv551/6Cyvv0fXn fXnw== X-Gm-Message-State: AOAM530uVV0FCQdfq9U6w0IMqN94NVNSWWukk8UlDsrSZiyMvuUzgb52 Ih/waRqr0GPIGkwBW9gHw756ub0RDpk= X-Google-Smtp-Source: ABdhPJw7P9q6ohfaLCYYiJQsfCZ5CUJm5aQJkALSzTzedA418ocdFUdRDhmRlqyMXq3CYS/vrg37QpBFSCc= X-Received: from oupton.c.googlers.com ([fda3:e722:ac3:cc00:2b:ff92:c0a8:404]) (user=oupton job=sendgmr) by 2002:a05:6e02:2167:: with SMTP id s7mr4906857ilv.314.1631816158433; Thu, 16 Sep 2021 11:15:58 -0700 (PDT) Date: Thu, 16 Sep 2021 18:15:46 +0000 Message-Id: <20210916181555.973085-1-oupton@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.33.0.464.g1972c5931b-goog Subject: [PATCH v8 0/9] selftests: KVM: Test offset-based counter controls From: Oliver Upton To: kvm@vger.kernel.org, kvmarm@lists.cs.columbia.edu Cc: Paolo Bonzini , Sean Christopherson , Marc Zyngier , Peter Shier , Jim Mattson , David Matlack , Ricardo Koller , Jing Zhang , Raghavendra Rao Anata , James Morse , Alexandru Elisei , Suzuki K Poulose , linux-arm-kernel@lists.infradead.org, Andrew Jones , Will Deacon , Catalin Marinas , Oliver Upton X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210916_111600_024233_A5658CFD X-CRM114-Status: GOOD ( 15.59 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This series implements new tests for the x86 and arm64 counter migration changes that I've mailed out. These are sent separately as a dependent change since there are cross-arch dependencies here. Patch 1 yanks the pvclock headers into the tools/ directory so we can make use of them within a KVM selftest guest. Patch 2 tests the new capabilities of the KVM_*_CLOCK ioctls, ensuring that the kernel accounts for elapsed time when restoring the KVM clock. Patches 3-4 add some device attribute helpers and clean up some mistakes in the assertions thereof. Patch 5 implements a test for the KVM_VCPU_TSC_OFFSET attribute, asserting that manipulation of the offset results in correct TSC values within the guest. Patch 6 adds basic arm64 support to the counter offset test, checking that the virtual counter-timer offset works correctly. Patch 7 does the same for the physical counter-timer offset. Patch 8 adds a benchmark for physical counter offsetting, since most implementations available right now will rely on emulation. Lastly, patch 9 extends the get-reg-list test to check for KVM_REG_ARM_TIMER_OFFSET if userspace opts-in to the kernel capability. This series applies cleanly to 5.15-rc1 Tests were ran against the respective architecture changes on the following systems: - Haswell (x86) - Ampere Mt. Jade (non-ECV, nVHE and VHE) v7: https://lore.kernel.org/r/20210816001246.3067312-1-oupton@google.com v7 -> v8: - Rebased to 5.15-rc1 - Dropped helper for checking if reg exists in reg list (no longer necessary) - Test and enable KVM_CAP_ARM_VTIMER_OFFSET - Add get-reg-list changes Oliver Upton (9): tools: arch: x86: pull in pvclock headers selftests: KVM: Add test for KVM_{GET,SET}_CLOCK selftests: KVM: Fix kvm device helper ioctl assertions selftests: KVM: Add helpers for vCPU device attributes selftests: KVM: Introduce system counter offset test selftests: KVM: Add support for aarch64 to system_counter_offset_test selftests: KVM: Test physical counter offsetting selftests: KVM: Add counter emulation benchmark selftests: KVM: Test vtimer offset reg in get-reg-list tools/arch/x86/include/asm/pvclock-abi.h | 48 ++++ tools/arch/x86/include/asm/pvclock.h | 103 ++++++++ tools/testing/selftests/kvm/.gitignore | 3 + tools/testing/selftests/kvm/Makefile | 4 + .../kvm/aarch64/counter_emulation_benchmark.c | 207 ++++++++++++++++ .../selftests/kvm/aarch64/get-reg-list.c | 42 ++++ .../selftests/kvm/include/aarch64/processor.h | 24 ++ .../testing/selftests/kvm/include/kvm_util.h | 11 + tools/testing/selftests/kvm/lib/kvm_util.c | 44 +++- .../kvm/system_counter_offset_test.c | 220 ++++++++++++++++++ .../selftests/kvm/x86_64/kvm_clock_test.c | 204 ++++++++++++++++ 11 files changed, 907 insertions(+), 3 deletions(-) create mode 100644 tools/arch/x86/include/asm/pvclock-abi.h create mode 100644 tools/arch/x86/include/asm/pvclock.h create mode 100644 tools/testing/selftests/kvm/aarch64/counter_emulation_benchmark.c create mode 100644 tools/testing/selftests/kvm/system_counter_offset_test.c create mode 100644 tools/testing/selftests/kvm/x86_64/kvm_clock_test.c -- 2.33.0.464.g1972c5931b-goog _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-21.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT, USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 67EFFC433EF for ; Thu, 16 Sep 2021 18:56:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4B5A860E52 for ; Thu, 16 Sep 2021 18:56:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345629AbhIPS6D (ORCPT ); Thu, 16 Sep 2021 14:58:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51536 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245717AbhIPS5a (ORCPT ); Thu, 16 Sep 2021 14:57:30 -0400 Received: from mail-il1-x149.google.com (mail-il1-x149.google.com [IPv6:2607:f8b0:4864:20::149]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 27E48C05BD0E for ; Thu, 16 Sep 2021 11:15:59 -0700 (PDT) Received: by mail-il1-x149.google.com with SMTP id n17-20020a922611000000b0023db5ee1cafso13956555ile.10 for ; Thu, 16 Sep 2021 11:15:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:message-id:mime-version:subject:from:to:cc; bh=bscRkoWhCmUqrdoE9Uy2kjhDd+L+Bo5wsdZYDj09NRA=; b=Omp+Kv8GsfsAlwd+15EkIN211lfCDN3xwS6/TjRxp1OFnDfl7A1eIes+NME14D5zkU SU1gHUL1v8E0n6cZMsL67wo8sqvGKsD9s7SAvNOZvGDLm6Q71CQQNHuWGokA8r1XgKgi AWItSWtYPx3zSkTSuimrx+ZsyhJJ3hwcJ9swS7QpIrDUpLoqkYvpi8/q45gdHgnABxyx MaVI1gl2p9k3pMHxCvAHnnwwDnruhyqoLrzOHHz9CXJjJldYYy7dVW9PIPmPfTyYbr1g /wa+qgJuAp4V2Z5IFkM7m9vs2beY/BcmGVV8PiWC9wd/8DN0Z7vNI+gLLJXM+LKExJim Nktw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=bscRkoWhCmUqrdoE9Uy2kjhDd+L+Bo5wsdZYDj09NRA=; b=Vo8qsZsw/td/YkEvnR9n+VcqNBA3kknjeilOgd+mTonwyGyou+di4GdToI9HIynSfm ap21qtuKRJeUYBEiRtXB3vyJJVgNCzyDBcX4fO7tc5ltuA1vZkFbQzQm1frWokOza728 ouYugq2zwicfgeWI65DCfG+OyZ/e9+9Fk5nOkmspeWSchcBaXz/2Amzae5Pf1tqA9gtC 7VtmY2TyKudZ56aTc5iPJjurtdOGPGrJ3H1R9gF+lnROB3/oBFStEIWleRqRY3aoXWKd itAuxycIhf4TjUpzOgUZkxdmtkdXg1c9dbLcTKFg5AKl1CxEy006qqxbzyJmDZKv+vvt hD5g== X-Gm-Message-State: AOAM532yx7tOJ6a2suCSK1BV/ncHd0YRpPNwwf1RURP8LeluaUpxurL5 2082UIXlBcgE9re3Cp1W1s7vjBgq4nZY9ctxl1bC82IZpdOvSXZoR4mb8P3kVk9+hu9WynKE5CY jcbMBkAgVeUZqtPvPCoYrVgOl1OPgfmmFXEK1NZJBDCTDkialE4RnEfq/oQ== X-Google-Smtp-Source: ABdhPJw7P9q6ohfaLCYYiJQsfCZ5CUJm5aQJkALSzTzedA418ocdFUdRDhmRlqyMXq3CYS/vrg37QpBFSCc= X-Received: from oupton.c.googlers.com ([fda3:e722:ac3:cc00:2b:ff92:c0a8:404]) (user=oupton job=sendgmr) by 2002:a05:6e02:2167:: with SMTP id s7mr4906857ilv.314.1631816158433; Thu, 16 Sep 2021 11:15:58 -0700 (PDT) Date: Thu, 16 Sep 2021 18:15:46 +0000 Message-Id: <20210916181555.973085-1-oupton@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.33.0.464.g1972c5931b-goog Subject: [PATCH v8 0/9] selftests: KVM: Test offset-based counter controls From: Oliver Upton To: kvm@vger.kernel.org, kvmarm@lists.cs.columbia.edu Cc: Paolo Bonzini , Sean Christopherson , Marc Zyngier , Peter Shier , Jim Mattson , David Matlack , Ricardo Koller , Jing Zhang , Raghavendra Rao Anata , James Morse , Alexandru Elisei , Suzuki K Poulose , linux-arm-kernel@lists.infradead.org, Andrew Jones , Will Deacon , Catalin Marinas , Oliver Upton Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org This series implements new tests for the x86 and arm64 counter migration changes that I've mailed out. These are sent separately as a dependent change since there are cross-arch dependencies here. Patch 1 yanks the pvclock headers into the tools/ directory so we can make use of them within a KVM selftest guest. Patch 2 tests the new capabilities of the KVM_*_CLOCK ioctls, ensuring that the kernel accounts for elapsed time when restoring the KVM clock. Patches 3-4 add some device attribute helpers and clean up some mistakes in the assertions thereof. Patch 5 implements a test for the KVM_VCPU_TSC_OFFSET attribute, asserting that manipulation of the offset results in correct TSC values within the guest. Patch 6 adds basic arm64 support to the counter offset test, checking that the virtual counter-timer offset works correctly. Patch 7 does the same for the physical counter-timer offset. Patch 8 adds a benchmark for physical counter offsetting, since most implementations available right now will rely on emulation. Lastly, patch 9 extends the get-reg-list test to check for KVM_REG_ARM_TIMER_OFFSET if userspace opts-in to the kernel capability. This series applies cleanly to 5.15-rc1 Tests were ran against the respective architecture changes on the following systems: - Haswell (x86) - Ampere Mt. Jade (non-ECV, nVHE and VHE) v7: https://lore.kernel.org/r/20210816001246.3067312-1-oupton@google.com v7 -> v8: - Rebased to 5.15-rc1 - Dropped helper for checking if reg exists in reg list (no longer necessary) - Test and enable KVM_CAP_ARM_VTIMER_OFFSET - Add get-reg-list changes Oliver Upton (9): tools: arch: x86: pull in pvclock headers selftests: KVM: Add test for KVM_{GET,SET}_CLOCK selftests: KVM: Fix kvm device helper ioctl assertions selftests: KVM: Add helpers for vCPU device attributes selftests: KVM: Introduce system counter offset test selftests: KVM: Add support for aarch64 to system_counter_offset_test selftests: KVM: Test physical counter offsetting selftests: KVM: Add counter emulation benchmark selftests: KVM: Test vtimer offset reg in get-reg-list tools/arch/x86/include/asm/pvclock-abi.h | 48 ++++ tools/arch/x86/include/asm/pvclock.h | 103 ++++++++ tools/testing/selftests/kvm/.gitignore | 3 + tools/testing/selftests/kvm/Makefile | 4 + .../kvm/aarch64/counter_emulation_benchmark.c | 207 ++++++++++++++++ .../selftests/kvm/aarch64/get-reg-list.c | 42 ++++ .../selftests/kvm/include/aarch64/processor.h | 24 ++ .../testing/selftests/kvm/include/kvm_util.h | 11 + tools/testing/selftests/kvm/lib/kvm_util.c | 44 +++- .../kvm/system_counter_offset_test.c | 220 ++++++++++++++++++ .../selftests/kvm/x86_64/kvm_clock_test.c | 204 ++++++++++++++++ 11 files changed, 907 insertions(+), 3 deletions(-) create mode 100644 tools/arch/x86/include/asm/pvclock-abi.h create mode 100644 tools/arch/x86/include/asm/pvclock.h create mode 100644 tools/testing/selftests/kvm/aarch64/counter_emulation_benchmark.c create mode 100644 tools/testing/selftests/kvm/system_counter_offset_test.c create mode 100644 tools/testing/selftests/kvm/x86_64/kvm_clock_test.c -- 2.33.0.464.g1972c5931b-goog