From patchwork Thu Sep 16 18:15:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oliver Upton X-Patchwork-Id: 12499971 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=-17.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,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 ED928C433F5 for ; Thu, 16 Sep 2021 18:35:26 +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 B9467610A6 for ; Thu, 16 Sep 2021 18:35:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org B9467610A6 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:References: Mime-Version:Message-Id:In-Reply-To:Date:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=pRz9REBLYCk9sh1SEafykLFOzRY3DdoDNPLdPA7ao88=; b=3t+QKwE6IbabR6ViZtD7a9Nk1l uF00x0d80fHE2rhUixku8EG4juh69P5KpLJqWziJ+xZNjGZ/bPjW/9gDk9g8tAAkRdlhQhsEw7F+6 i9J+AMbSFCwO/wgMap/nCBNhAHCvinPT6voelBfT00nWCj8HYs/I4uty0NFaGsruIEvtD58pzfF0R hZ3J//Ue+p9xbwRLr+ttG90aubCJxIJH531G7zpJn14lmfDUvqqJSR1NzfueovbMKymOFX99Hh9Ad ZmG+yntkyu/oyf/xWw37+8qADB89VOG6X4ByW59m7z6bVbz+vuw0/hLLL+qR98J4WeMijeJqb5F1y w9U3+C8A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mQwCT-00C9Qw-Gu; Thu, 16 Sep 2021 18:33:35 +0000 Received: from mail-qt1-x849.google.com ([2607:f8b0:4864:20::849]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mQvvd-00C26m-C4 for linux-arm-kernel@lists.infradead.org; Thu, 16 Sep 2021 18:16:10 +0000 Received: by mail-qt1-x849.google.com with SMTP id o3-20020a05622a008300b002a480a6b8f4so63314733qtw.15 for ; Thu, 16 Sep 2021 11:16:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=Xw4+tgKVLmvm8JQWsGHVEpFbMf77zCGqq8rbz5yrSuw=; b=aqj3HRCmfQvWoQtSN5RzC1ysFfx+mQMpaBU2bf9JiwokiR0SsR1mjFVZwlMsYRWd5F S1wO4hvUJBxqXeG0m7E3iOLmvRhccSonfYKnGvnrmcxRXwiajJF8WrW/0OjYx2jBhPNg mSeQYdEI69TgXBb0UzLjUrlsKeOQachsm67AH76Wx+H8gHYl2PSGhNNq6W7jYvQM/XC3 LXaisjjlREFlx0rMPKJ2YsgTBksZdWAA2o3kTilLBfa1XqxawES6tGn2os4UI+BOIu19 gZFLCmlXEaeNDs7eyflXYmGj3j9j1rvbHboi2PjGfs2Sd46TUcfd88SDJvadas/9BxEe FnxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=Xw4+tgKVLmvm8JQWsGHVEpFbMf77zCGqq8rbz5yrSuw=; b=B4lcjGnZZQrX29BLCLo0+RpfxlB7zVx5UonxKruFPnVDeEC8WpM+QymH+ZnzrvOCWT /nB/XtliIkIL3Z+CKuyep1bXXUBDyE448AwHcSBsXF5Lv1g7+6gY3zEfFMBrncXwgXYM m3alcD2f0negFYtXwkcB6uq+0YxNOBiyqz6KAta49vMttFGDoME5sp7AVUQpVsie2Wmw oPa5T2OYNTL2HGEfBrFWwy5hzg5Qz5Kd8H8a8jee3JDVQeczsKf2FJrRlz3nMNT9SLuh Yn5CYpMEWNZHs/igr/NRcK8F7hr7oEyrdTrB2Y3AwwmHoDZ2I8EJxpTkdAxmHKUXXYDa 48jw== X-Gm-Message-State: AOAM533CKK/j68p3zblJb9fFV3I6p3J9oeTHyhIUTKozjhX96WryHIxm E1e6kUAKDx+PNmyTpEmWwVhXFTYOa78= X-Google-Smtp-Source: ABdhPJwwEMjf9bn2Y68JHX2UcSLI5bYpoUc13K4VaVdU55eP01YXVcQ93R0zLYLdVbktp7FtkAMXNw1xICs= X-Received: from oupton.c.googlers.com ([fda3:e722:ac3:cc00:2b:ff92:c0a8:404]) (user=oupton job=sendgmr) by 2002:a05:6214:1372:: with SMTP id c18mr4801098qvw.28.1631816167832; Thu, 16 Sep 2021 11:16:07 -0700 (PDT) Date: Thu, 16 Sep 2021 18:15:55 +0000 In-Reply-To: <20210916181555.973085-1-oupton@google.com> Message-Id: <20210916181555.973085-10-oupton@google.com> Mime-Version: 1.0 References: <20210916181555.973085-1-oupton@google.com> X-Mailer: git-send-email 2.33.0.464.g1972c5931b-goog Subject: [PATCH v8 9/9] selftests: KVM: Test vtimer offset reg in get-reg-list 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_111609_473801_2E773592 X-CRM114-Status: GOOD ( 12.58 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Assert that KVM exposes KVM_REG_ARM_TIMER_OFFSET in the KVM_GET_REG_LIST ioctl when userspace buys in to the new behavior. Signed-off-by: Oliver Upton Reviewed-by: Andrew Jones --- .../selftests/kvm/aarch64/get-reg-list.c | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/tools/testing/selftests/kvm/aarch64/get-reg-list.c b/tools/testing/selftests/kvm/aarch64/get-reg-list.c index cc898181faab..4f337d8b793a 100644 --- a/tools/testing/selftests/kvm/aarch64/get-reg-list.c +++ b/tools/testing/selftests/kvm/aarch64/get-reg-list.c @@ -40,6 +40,7 @@ static __u64 *blessed_reg, blessed_n; struct reg_sublist { const char *name; long capability; + long enable_capability; int feature; bool finalize; __u64 *regs; @@ -397,6 +398,19 @@ static void check_supported(struct vcpu_config *c) } } +static void enable_caps(struct kvm_vm *vm, struct vcpu_config *c) +{ + struct kvm_enable_cap cap = {0}; + struct reg_sublist *s; + + for_each_sublist(c, s) { + if (s->enable_capability) { + cap.cap = s->enable_capability; + vm_enable_cap(vm, &cap); + } + } +} + static bool print_list; static bool print_filtered; static bool fixup_core_regs; @@ -412,6 +426,8 @@ static void run_test(struct vcpu_config *c) check_supported(c); vm = vm_create(VM_MODE_DEFAULT, DEFAULT_GUEST_PHY_PAGES, O_RDWR); + enable_caps(vm, c); + prepare_vcpu_init(c, &init); aarch64_vcpu_add_default(vm, 0, &init, NULL); finalize_vcpu(vm, 0, c); @@ -1014,6 +1030,10 @@ static __u64 sve_rejects_set[] = { KVM_REG_ARM64_SVE_VLS, }; +static __u64 vtimer_offset_regs[] = { + KVM_REG_ARM_TIMER_OFFSET, +}; + #define BASE_SUBLIST \ { "base", .regs = base_regs, .regs_n = ARRAY_SIZE(base_regs), } #define VREGS_SUBLIST \ @@ -1025,6 +1045,10 @@ static __u64 sve_rejects_set[] = { { "sve", .capability = KVM_CAP_ARM_SVE, .feature = KVM_ARM_VCPU_SVE, .finalize = true, \ .regs = sve_regs, .regs_n = ARRAY_SIZE(sve_regs), \ .rejects_set = sve_rejects_set, .rejects_set_n = ARRAY_SIZE(sve_rejects_set), } +#define VTIMER_OFFSET_SUBLIST \ + { "vtimer_offset", .capability = KVM_CAP_ARM_VTIMER_OFFSET, \ + .enable_capability = KVM_CAP_ARM_VTIMER_OFFSET, .regs = vtimer_offset_regs, \ + .regs_n = ARRAY_SIZE(vtimer_offset_regs), } static struct vcpu_config vregs_config = { .sublists = { @@ -1041,6 +1065,14 @@ static struct vcpu_config vregs_pmu_config = { {0}, }, }; +static struct vcpu_config vregs_vtimer_config = { + .sublists = { + BASE_SUBLIST, + VREGS_SUBLIST, + VTIMER_OFFSET_SUBLIST, + {0}, + }, +}; static struct vcpu_config sve_config = { .sublists = { BASE_SUBLIST, @@ -1056,11 +1088,21 @@ static struct vcpu_config sve_pmu_config = { {0}, }, }; +static struct vcpu_config sve_vtimer_config = { + .sublists = { + BASE_SUBLIST, + SVE_SUBLIST, + VTIMER_OFFSET_SUBLIST, + {0}, + }, +}; static struct vcpu_config *vcpu_configs[] = { &vregs_config, &vregs_pmu_config, + &vregs_vtimer_config, &sve_config, &sve_pmu_config, + &sve_vtimer_config, }; static int vcpu_configs_n = ARRAY_SIZE(vcpu_configs);