From patchwork Thu Oct 20 05:41:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Reiji Watanabe X-Patchwork-Id: 13012632 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 E45A6C4332F for ; Thu, 20 Oct 2022 05:44:20 +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=MU3VQIy8SGW2Q2/vB3LN7lOCxygM6g8u8rV0MNF70yU=; b=R1u4zxylwx04c+xy3n64JSTsRY poqdGcI3fJuyaY3P62RFrDyVwCiS4Ac4kTsF4ZINhOSOPqBvFIvOjcNDBFZgzlgJBff2Sbp+e4mJ1 PMNWounZUknQ70hEoPMYl66KtN87ZV/r3Rg1LfZbzQK2GN3RWdgseFx+agF15mRipsaA2HUZcUEE8 zlBMlBByVj5Kx90VteLwH7QjJQtZDrl9/WZhk/F8O0kvNnWG65ClervvZJ5V/XDYNzqYfmis3H6+9 OlLEgsLl4rTioi+k/c0PBPpG+pZfCtGZhWm0BvHb6tXtzHtE/IyGJ12JaobDnMy83EaqGGBFF2a2f l3lmkTmA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1olOKq-00AVBB-QK; Thu, 20 Oct 2022 05:43:17 +0000 Received: from mail-yw1-x1149.google.com ([2607:f8b0:4864:20::1149]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1olOKm-00AV34-Sg for linux-arm-kernel@lists.infradead.org; Thu, 20 Oct 2022 05:43:14 +0000 Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-367f94b9b16so17887207b3.11 for ; Wed, 19 Oct 2022 22:43:11 -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:message-id:reply-to; bh=gJ7DW6FMrS3/XjKR3IUADDixPsWjRSTHpU4QIywCQT0=; b=kGndETIJMFAPsM6o9M6DaJUd1eiJ2R4UMKlgOyP1fNzxbCIVhSLbX7CnVkqS0nZlgD qkckUwjazjcZLM/YkMuwJNmj1ry2kxAjdem3B0xhMr2Dp4mF/14rIR7QQKqF48mU8mB8 DcVOolzBRorJXy4aurbFEdEk/2+PPc1mT16TphLnIg/nGPjf1VTt5E1w2sdOQK4gJFWK SWfUUVygx2JxiN+W1eCfC/6ejAbDk16p/xlU+QRxcN9+DW5mPw4pCt5m2rJjzODbwnTl IPW0r6GYVCllZBAnh/B7sQDg2fWC80wwFFwvtnm6wbVWdEwS7OpZC3IggwH4D5drvjZp wY9Q== 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:message-id:reply-to; bh=gJ7DW6FMrS3/XjKR3IUADDixPsWjRSTHpU4QIywCQT0=; b=jUkCib9td1Xo6CRU3M9V8YcWMF2r0KdArcQ29eCmL/OXZeFr+Ikv69WpOTZwH+LYZ1 mNC8rFwsceqwE9WliGpqQP0yiOnDbMNZZpIwsBdXi0E3MaJL8zKvKn5v4cKxnipBySfE W3rB7j46ah+faIUCKbgFello4P63948n335UKJ0N6OXW3odqVq1mnBhGBw5hbaLmuKw4 xFFuzJBGfxabRXSgU+2e/RZNeizoy4Fb4uIjDD6foRzwy8JnpHSWdAZ2vYYIDqAvZLLs 8xwpzoe+oefpJopIfbsV8Boc/llcGrcq7CgHv++v2Aff6Av9TBnDXSC2keodWhJKgFE9 L+cQ== X-Gm-Message-State: ACrzQf3n2T4Z+KNlUPLKxCxPl2IzPon8fJhgxtWvFMWmXuTdpJ+leoFi r9uAz9oDivbTDTfQAEifyM7SdFMfzPw= X-Google-Smtp-Source: AMsMyM5cafI3oKmmNqdU3WwdsV2NsJ9CGbFSB+7QFWMTaiHhqL6V6IVmTaXwI0KJcvCCmksQc05HdIvzMqg= X-Received: from reijiw-west4.c.googlers.com ([fda3:e722:ac3:cc00:20:ed76:c0a8:aa1]) (user=reijiw job=sendgmr) by 2002:a25:7cc7:0:b0:6ca:3ba9:a1b8 with SMTP id x190-20020a257cc7000000b006ca3ba9a1b8mr438557ybc.206.1666244591287; Wed, 19 Oct 2022 22:43:11 -0700 (PDT) Date: Wed, 19 Oct 2022 22:41:57 -0700 In-Reply-To: <20221020054202.2119018-1-reijiw@google.com> Mime-Version: 1.0 References: <20221020054202.2119018-1-reijiw@google.com> X-Mailer: git-send-email 2.38.0.413.g74048e4d9e-goog Message-ID: <20221020054202.2119018-5-reijiw@google.com> Subject: [PATCH v2 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-20221019_224312_948366_32276CF5 X-CRM114-Status: UNSURE ( 9.16 ) 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. No functional change intended. Signed-off-by: Reiji Watanabe Reviewed-by: Ricardo Koller Reviewed-by: Oliver Upton --- .../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 608a6c8db9a2..0c237022f4d3 100644 --- a/tools/testing/selftests/kvm/aarch64/debug-exceptions.c +++ b/tools/testing/selftests/kvm/aarch64/debug-exceptions.c @@ -130,10 +130,20 @@ static void enable_os_lock(void) GUEST_ASSERT(read_sysreg(oslsr_el1) & 2); } +static void enable_monitor_debug_exceptions(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); @@ -141,28 +151,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_monitor_debug_exceptions(); } 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_monitor_debug_exceptions(); } static void install_ss(void)