From patchwork Thu Aug 25 05:08:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Reiji Watanabe X-Patchwork-Id: 12954194 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 DC245C04AA5 for ; Thu, 25 Aug 2022 05:11:48 +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: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=MH++ES/yZTd1iKIC/VcsAyxIg81mJN4ccLkMn21k4yg=; b=ky1YGwN0kDFzNTKPoFUVduPz/h ykW2APRdS+DXfgyx21u8Do6Yu+myviIDzYlnXt46VGJ8in3puvNu85v3VervS6w5or3PNBN1kL7n1 IxnD1MatrjccuR+gwU2UQIEzk+TQ6hHSgJ1mWvicB0Vfb2kJxlBacqr4GMPIMXBASQuBvXIM8nK1k pwSJtgDeZ83RTc7STF57zMWEoZAihhY+aiUmIwi7TvSHCbPNjIY5gRA4ska00JIDNYR/88INeaLkM Rz6LwhVMXeiFc7TbhlVNmkzdnAyi4cGIq3jqzVk42s/bYNEAU2jGMK5Vr5aoH/afXk5Rb/svOtUlC n7oBhoXw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oR58c-007Dt5-M4; Thu, 25 Aug 2022 05:10:43 +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 1oR58D-007DYG-Fk for linux-arm-kernel@lists.infradead.org; Thu, 25 Aug 2022 05:10:18 +0000 Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-33352499223so325298357b3.8 for ; Wed, 24 Aug 2022 22:10:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:references:mime-version:message-id:in-reply-to :date:from:to:cc; bh=8oX+5M8AEKJji1mM4AdRdiIeL9hn/q6yl0Bz7273pVA=; b=LeLhe13n76eUMhCg8SWeTVrWKNtcglEFQyn+mfy6n1dzAkWuQysdlKISXEtK+nMY8e KFHp3ByAxQkIys2eIl+f4hu/uA+oD6EZJNE/nEotAQeMIFarEHGOqga1SN984jZVdz/5 N4Aza75aQ6ogp2RnHch+Zsn6Jalu1DrSU4kripuc0ELF5fnewHCu0Gn3vChBs1tgDaYd ADLEDy9zjAvrnk0uMK/T8HwpKQEAjAsqwE75J8fM/9mscrSuleHrzT67O3Y+FrHMSlaM uIsU6jEl8gn0OGNrQY/Fyk8idl1C4Cd9nBvGbyaOjjPwxpFmo+kDKFVMJMHLPRiAikRk k7mQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:references:mime-version:message-id:in-reply-to :date:x-gm-message-state:from:to:cc; bh=8oX+5M8AEKJji1mM4AdRdiIeL9hn/q6yl0Bz7273pVA=; b=S58V43X6s2O8KpE8BzJAACGCj4rNO33pTGNWXfj9L2aGrlzkPoHAh32FxNASPjT7Hz r9REXOVXI5tuUjDtThWxHSo9oYgea9kgesjYKHhWxCjpMABo5OY4AttUIza0vZJadv/A amYvOvTBlh8RwvvwTprhjVBOWx15etRZ3XYj2Ozxl/0dL8rzb9It4SZ4RYc76PZfGO4q e2brIsanJzAicWo40ILukRAoEOD7BVwZ78TtwISnMs821HHF2/bPrOBOz9B0V2KUXF2o ovYMJnxHJ1cvqBwASgly7Ddytk+0mkuD1Yxwmu73tIMY5Ry4dGJQLn3iMUuMF7as/jvm SGYQ== X-Gm-Message-State: ACgBeo2EUUYrW9OwTrkXvYOK7UdwCmYHtshK3v+f8QT05MZ5AlyAtOp3 ShTGECieoPZluU3Cyeb6UFriNcnhmSU= X-Google-Smtp-Source: AA6agR52jNE2uqaO7jEYMgZLpa+TwESVpjsc/w6zjrZheJdPE8MUiS+G/MUXsFxHt1MmvGcr0ODLhNAfaxQ= X-Received: from reijiw-west4.c.googlers.com ([fda3:e722:ac3:cc00:20:ed76:c0a8:aa1]) (user=reijiw job=sendgmr) by 2002:a5b:2cb:0:b0:688:ecfc:5865 with SMTP id h11-20020a5b02cb000000b00688ecfc5865mr2015078ybp.642.1661404216176; Wed, 24 Aug 2022 22:10:16 -0700 (PDT) Date: Wed, 24 Aug 2022 22:08:41 -0700 In-Reply-To: <20220825050846.3418868-1-reijiw@google.com> Message-Id: <20220825050846.3418868-5-reijiw@google.com> Mime-Version: 1.0 References: <20220825050846.3418868-1-reijiw@google.com> X-Mailer: git-send-email 2.37.1.595.g718a3a8f04-goog Subject: [PATCH 4/9] KVM: arm64: selftests: Add helpers to enable debug exceptions 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 , Andrew Jones , 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-20220824_221017_556810_F72FCD14 X-CRM114-Status: UNSURE ( 9.06 ) X-CRM114-Notice: Please train this message. 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 Add helpers to enable breakpoint and watchpoint exceptions. Signed-off-by: Reiji Watanabe Reviewed-by: Oliver Upton Reviewed-by: Ricardo Koller --- .../selftests/kvm/aarch64/debug-exceptions.c | 25 ++++++++++--------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/tools/testing/selftests/kvm/aarch64/debug-exceptions.c b/tools/testing/selftests/kvm/aarch64/debug-exceptions.c index 183ee16acb7d..713c7240b680 100644 --- a/tools/testing/selftests/kvm/aarch64/debug-exceptions.c +++ b/tools/testing/selftests/kvm/aarch64/debug-exceptions.c @@ -128,10 +128,20 @@ static void enable_os_lock(void) GUEST_ASSERT(read_sysreg(oslsr_el1) & 2); } +static void enable_debug_bwp_exception(void) +{ + uint32_t mdscr; + + asm volatile("msr daifclr, #8"); + + mdscr = read_sysreg(mdscr_el1) | MDSCR_KDE | MDSCR_MDE; + write_sysreg(mdscr, mdscr_el1); + isb(); +} + static void install_wp(uint8_t wpn, uint64_t addr) { uint32_t wcr; - uint32_t mdscr; wcr = DBGWCR_LEN8 | DBGWCR_RD | DBGWCR_WR | DBGWCR_EL1 | DBGWCR_E; write_dbgwcr(wpn, wcr); @@ -139,28 +149,19 @@ static void install_wp(uint8_t wpn, uint64_t addr) isb(); - asm volatile("msr daifclr, #8"); - - mdscr = read_sysreg(mdscr_el1) | MDSCR_KDE | MDSCR_MDE; - write_sysreg(mdscr, mdscr_el1); - isb(); + enable_debug_bwp_exception(); } static void install_hw_bp(uint8_t bpn, uint64_t addr) { uint32_t bcr; - uint32_t mdscr; bcr = DBGBCR_LEN8 | DBGBCR_EXEC | DBGBCR_EL1 | DBGBCR_E; write_dbgbcr(bpn, bcr); write_dbgbvr(bpn, addr); isb(); - asm volatile("msr daifclr, #8"); - - mdscr = read_sysreg(mdscr_el1) | MDSCR_KDE | MDSCR_MDE; - write_sysreg(mdscr, mdscr_el1); - isb(); + enable_debug_bwp_exception(); } static void install_ss(void)