From patchwork Sat Sep 17 01:05:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Reiji Watanabe X-Patchwork-Id: 12978940 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 76231ECAAD8 for ; Sat, 17 Sep 2022 01:08:21 +0000 (UTC) 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:Message-ID: References:Mime-Version: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=VjDEPaymN5+YRTQluudoFNk7fIn4ykPIUvGHFpuPMgI=; b=DhP7SJBSTzR2FUsALHcr+WIahq OfEmAEYwmvpB9OsG3Qdd/NtnStqk1izRFCmQaF3o3KxPlTo60PfjN5rL4S1+O/ptVO/iYElUgxbFR AbCyXtx0ft7zg8QoOH2wz8vJkExjOiLU6APrHuEFch7I9q06pfbkEthcvDdeCoPk8A1P5HIVMAd+8 BzBDrHNe/jMrb6Y7zOoT5vDi5ajxm2AD25QM9EpvGi3LUJNO1o6MaXnIgD4UwgwKCm+7xvSbLAYEc ftB8Xf5nAScHBMVTVjPsB88M/ue1Xd7VChvDniM9zuJ6fR+7dvk66J4WSn9aiiOPrUP7zDKL26/PD JhuLgLrw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oZMIM-001CiD-LG; Sat, 17 Sep 2022 01:06:58 +0000 Received: from mail-yb1-xb49.google.com ([2607:f8b0:4864:20::b49]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oZMHl-001CMm-Gt for linux-arm-kernel@lists.infradead.org; Sat, 17 Sep 2022 01:06:23 +0000 Received: by mail-yb1-xb49.google.com with SMTP id bu13-20020a056902090d00b00671743601f1so20101944ybb.0 for ; Fri, 16 Sep 2022 18:06:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date; bh=P62ArTPc7+3A2J+iBFhu2NmzpTO392tFyQSa9B00I7o=; b=gQs+pUloXH7vOfPonPzkbtOTB0jf3YMXQ5CPD6RCnsFqnwdAK0hZcwcz8NJSzxtoZS 5JVD0qCmjbGE7+CyAGZ9v8Ff55/Sw+zC+IJFh5lewEXB2sICf2UY/EfgeBSfz24rEOSm 3MC07gAnmDTxVNZUCfnPvjzK9B5J9r5vXVm5zFzp7gzIe5qWTqWFrl7XvlZiZMyDTd4q uUGKlEycSRb+rJl819tg6lf2P3gKsYED9B1ycNpzItfGRbUW7q+0xEKANLXW7Ak+gzo9 NMYMTrvb8Dm3TRe+3D1y+Xfc8ychf4aUlPWoh+35PnOKy5T0EyUrA9mP3yaA1VCTFh88 mkhQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date; bh=P62ArTPc7+3A2J+iBFhu2NmzpTO392tFyQSa9B00I7o=; b=Zp7DiQwOIQ3lZq+bZ5DSiLR8dehtQ19MJJzCF8TiqLFGHOBnLdY7uqu+kYkAQbDzks Sfgz2j+FLlll5+dB/cpc1DaaqVMOO57OVe2m2nCF98QH6sPhGd75lqVK6WKBIzYFmqQd ptxjsBPYUeeHmbOWSAgoO4JiKhC1XsLyAY0bKh4GF7AAwHjY6Vjv9L5jgEbkp4VqGgNF gM4AuGGElg8U93bUGVu545QBS/xiPYKvp79BedvE/xa9C1RqBpMTbhLuh+j59VggsEYn P8WhtKg9/6ne1v/suIcC9bOAm7XXgjIIKyGFq/t96BCYSxpDgFi0sRyqxBCK0xqohI60 VDFQ== X-Gm-Message-State: ACrzQf0JUBZ4W0Ft/XUar52IGwvRkPJMaeJT2yKexDTv7vqYDKywkDnN MjcfQZC50xn/WoHaNy8mtIphSsVRIhg= X-Google-Smtp-Source: AMsMyM5VgruCN2bvpzdWSE6f5BHhOI/uXg4nOMM6u0Ll+ZOiBxNJUH3SUKeI4ewiHSJGbviPr/4BGR3kHWY= X-Received: from reijiw-west4.c.googlers.com ([fda3:e722:ac3:cc00:20:ed76:c0a8:aa1]) (user=reijiw job=sendgmr) by 2002:a25:bc7:0:b0:6af:d9a3:d721 with SMTP id 190-20020a250bc7000000b006afd9a3d721mr6478800ybl.47.1663376776016; Fri, 16 Sep 2022 18:06:16 -0700 (PDT) Date: Fri, 16 Sep 2022 18:05:59 -0700 In-Reply-To: <20220917010600.532642-1-reijiw@google.com> Mime-Version: 1.0 References: <20220917010600.532642-1-reijiw@google.com> X-Mailer: git-send-email 2.37.3.968.ga6b4b080e4-goog Message-ID: <20220917010600.532642-4-reijiw@google.com> Subject: [PATCH v2 3/4] KVM: arm64: selftests: Refactor debug-exceptions to make it amenable to new test cases From: Reiji Watanabe To: Marc Zyngier , kvmarm@lists.cs.columbia.edu Cc: kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, James Morse , Alexandru Elisei , Suzuki K Poulose , Paolo Bonzini , Ricardo Koller , Oliver Upton , Jing Zhang , Raghavendra Rao Anata , Reiji Watanabe X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220916_180621_612850_BA40B800 X-CRM114-Status: GOOD ( 11.69 ) 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 Split up the current test into a helper, but leave the debug version checking in main(), to make it convenient to add a new debug exception test case in a subsequent patch. Signed-off-by: Reiji Watanabe --- .../selftests/kvm/aarch64/debug-exceptions.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/tools/testing/selftests/kvm/aarch64/debug-exceptions.c b/tools/testing/selftests/kvm/aarch64/debug-exceptions.c index 2ee35cf9801e..e6e83b895fd5 100644 --- a/tools/testing/selftests/kvm/aarch64/debug-exceptions.c +++ b/tools/testing/selftests/kvm/aarch64/debug-exceptions.c @@ -246,7 +246,7 @@ static int debug_version(struct kvm_vcpu *vcpu) return id_aa64dfr0 & 0xf; } -int main(int argc, char *argv[]) +static void test_guest_debug_exceptions(void) { struct kvm_vcpu *vcpu; struct kvm_vm *vm; @@ -259,9 +259,6 @@ int main(int argc, char *argv[]) vm_init_descriptor_tables(vm); vcpu_init_descriptor_tables(vcpu); - __TEST_REQUIRE(debug_version(vcpu) >= 6, - "Armv8 debug architecture not supported."); - vm_install_sync_handler(vm, VECTOR_SYNC_CURRENT, ESR_EC_BRK_INS, guest_sw_bp_handler); vm_install_sync_handler(vm, VECTOR_SYNC_CURRENT, @@ -294,5 +291,18 @@ int main(int argc, char *argv[]) done: kvm_vm_free(vm); +} + +int main(int argc, char *argv[]) +{ + struct kvm_vcpu *vcpu; + struct kvm_vm *vm; + + vm = vm_create_with_one_vcpu(&vcpu, guest_code); + __TEST_REQUIRE(debug_version(vcpu) >= 6, + "Armv8 debug architecture not supported."); + kvm_vm_free(vm); + test_guest_debug_exceptions(); + return 0; }