From patchwork Fri Sep 9 04:46:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Reiji Watanabe X-Patchwork-Id: 12971018 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 F39ECECAAA1 for ; Fri, 9 Sep 2022 04:48:34 +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=0o8nle2HUies6aqXRMJlMZxmt2mjYDo105XFLJpxqhw=; b=UPWRza53sGbH/MKTXDg37COCP/ r/zVSktTGM1tJbGBobWEeQo5CzeiSLQjec04V7jJN3nhG38IoeUUsXabTNnzPGZjJxz5itVlmwkbv fa98ghK4RVuv00jkM5fjS00yHbjx5SisSRQTHWUkKI062DBEFXBFWRca2EB1YTv5SIyE1rfb65Y32 aCrrCKNIQah+lxy4GKdhSjm0ACDsPJMBuxhaJrT7t7aoTITgaiRO2JYTtCK6RbJ0vsOkgtK+1ua5o F/7NamoRKMqKrfJa4Ly0z191YZwAK+JpPn95MUIKGQUDa7UM0vmYkPXPrEqLB52mVe2crpj6fONNJ oZlCh4hg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oWVvQ-00COAK-91; Fri, 09 Sep 2022 04:47:32 +0000 Received: from mail-yw1-x114a.google.com ([2607:f8b0:4864:20::114a]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oWVv6-00CNzN-Sa for linux-arm-kernel@lists.infradead.org; Fri, 09 Sep 2022 04:47:15 +0000 Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-3328a211611so6275707b3.5 for ; Thu, 08 Sep 2022 21:47:09 -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=cdmIqcLKbdujO9E0CyTHIQ8voTZsLtjL+NYg8vJd0vA=; b=cF3DR/sd0Wgsk/iGGH2d2gEDKFgjIg01OYfZMpnzvPrEAkaGz8AIJvL4s5mw+Nc0M8 TN57/dyFDmY7Mih5VeJg2n7zTILQr7Z60pR9Ad3OqdHVl6hLeq4jjI0iOKLLBff2mbH2 zuJaPOzq5hFBBbanpuK3JTsDOf12MxffmatefGt7Jv4VRIFMUQy949BHMEBXFg9eP0Rw K1Q8Pt4W4dkbazK+4K8UpIm0x3H+grQxr7mwcrTKI9WAaftcEl/JNJVJFuy/SEFGLs6P C25YPwSvZwjJCbFh3uRod4ipWKvVsBizabkX5Hwnit3V6MbbDvuvAPQ5a5pWGA4S7CwE hCPg== 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=cdmIqcLKbdujO9E0CyTHIQ8voTZsLtjL+NYg8vJd0vA=; b=am1wq/sSEWKTO9rhfdbc07AAHBdpIkWVnAj1ftWEwtYjaK4VwPtqk28qc/NmS+taPF QxXUSaDh2MiMQqggpxmgTB3bJtsgjp1OcwuXZVZIyVbYEj35GN2j2OmwReF4t8W0lkYz yMJ5DJtkJ4RydcSV8oHjq8OzhFGH85D9wXWMJ6w0M5y0aWy6xBi2O9K3A+qrxLtsE/zo nHE6Q5yldBAqilPF0RdUKmEC7Ll6zTSB6rpCIpDMxIpSgriZIoZtwlE3ZVLLJbXKckgV qngt1H1GiGm3v0jwR+Ij6YgxK/VaXmo6TRdhlrEgw0MMq5T8QWQaOJ870Ch6eDeSp1jO +JtQ== X-Gm-Message-State: ACgBeo0kc12WeiO5u0I5pHz17ohEvZaTohmXSFZv3AVAHNFCXtQLaCRU 90hKRptIEneN/qhmI0/GoAPvT4PQzXI= X-Google-Smtp-Source: AA6agR6fFEzordzXyp1eqlP2xn60Bj2CFzQfdITIpFijrIWoJ+bbNsN9lfrixj3WQl3w9vPwLiX971lXrz4= X-Received: from reijiw-west4.c.googlers.com ([fda3:e722:ac3:cc00:20:ed76:c0a8:aa1]) (user=reijiw job=sendgmr) by 2002:a5b:a0d:0:b0:689:9eee:348f with SMTP id k13-20020a5b0a0d000000b006899eee348fmr10500385ybq.111.1662698828939; Thu, 08 Sep 2022 21:47:08 -0700 (PDT) Date: Thu, 8 Sep 2022 21:46:35 -0700 In-Reply-To: <20220909044636.1997755-1-reijiw@google.com> Mime-Version: 1.0 References: <20220909044636.1997755-1-reijiw@google.com> X-Mailer: git-send-email 2.37.2.789.g6183377224-goog Message-ID: <20220909044636.1997755-3-reijiw@google.com> Subject: [PATCH 2/3] 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-20220908_214712_957405_368C6A56 X-CRM114-Status: GOOD ( 12.44 ) 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; }