From mboxrd@z Thu Jan 1 00:00:00 1970 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 704CFC433EF for ; Tue, 2 Nov 2021 11:11:24 +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 2ED5D60C51 for ; Tue, 2 Nov 2021 11:11:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 2ED5D60C51 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org 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:MIME-Version:References:In-Reply-To: Subject:Cc:To:From:Message-ID:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=VPWIKO0qfpDuXnOhh86j/3reRVpt7ZGUEBucDdgNU/U=; b=d0xS1p2obnJ0Xe SRqwhi9dOxGgblQXamcD39AKneeo/dI1YXT/A3G0GfiniocjqV7aDSJEKSMrpFZOyKgfOnu2LypOz kaKqnNGG6HXL+3NnXFOC6KlJIzyNJWscjADu+tTWHIJpBRg+0imUx8dMZBufQsG3qw3CtagR/SXGl OI5y0lPM2dtjqImgQfD1aOsqwsNkfy7+D1x43YEenG4j8DzwP9AiLU2Jn6Fvspe4pAqQgapPHPL6x tV7NeWuNY6Ua6+Tj2exIARNIf7Zue4moGONZvS4twnMn2Zhh/Aa0tslWYaMHCitEysslYoB70Y8WO eBUSyUEtaGy8jJEY+ZnQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mhrfk-001T66-ST; Tue, 02 Nov 2021 11:09:45 +0000 Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mhrfg-001T4g-HK for linux-arm-kernel@lists.infradead.org; Tue, 02 Nov 2021 11:09:41 +0000 Received: from disco-boy.misterjones.org (disco-boy.misterjones.org [51.254.78.96]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A183B60C41; Tue, 2 Nov 2021 11:09:39 +0000 (UTC) Received: from sofa.misterjones.org ([185.219.108.64] helo=why.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1mhrfd-0032WN-EO; Tue, 02 Nov 2021 11:09:37 +0000 Date: Tue, 02 Nov 2021 11:09:37 +0000 Message-ID: <875ytaak5q.wl-maz@kernel.org> From: Marc Zyngier To: Oliver Upton Cc: kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, James Morse , Alexandru Elisei , Suzuki K Poulose , linux-arm-kernel@lists.infradead.org, Andrew Jones , Peter Shier , Ricardo Koller , Reiji Watanabe Subject: Re: [PATCH v2 6/6] selftests: KVM: Test OS lock behavior In-Reply-To: <20211102094651.2071532-7-oupton@google.com> References: <20211102094651.2071532-1-oupton@google.com> <20211102094651.2071532-7-oupton@google.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/27.1 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: oupton@google.com, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, james.morse@arm.com, alexandru.elisei@arm.com, suzuki.poulose@arm.com, linux-arm-kernel@lists.infradead.org, drjones@redhat.com, pshier@google.com, ricarkol@google.com, reijiw@google.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211102_040940_680211_2E4B890A X-CRM114-Status: GOOD ( 23.50 ) 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: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi Oliver, On Tue, 02 Nov 2021 09:46:51 +0000, Oliver Upton wrote: > > KVM now correctly handles the OS Lock for its guests. When set, KVM > blocks all debug exceptions originating from the guest. Add test cases > to the debug-exceptions test to assert that software breakpoint, > hardware breakpoint, watchpoint, and single-step exceptions are in fact > blocked. > > Signed-off-by: Oliver Upton > --- > .../selftests/kvm/aarch64/debug-exceptions.c | 58 ++++++++++++++++++- > 1 file changed, 56 insertions(+), 2 deletions(-) > > diff --git a/tools/testing/selftests/kvm/aarch64/debug-exceptions.c b/tools/testing/selftests/kvm/aarch64/debug-exceptions.c > index e5e6c92b60da..6b6ff81cdd23 100644 > --- a/tools/testing/selftests/kvm/aarch64/debug-exceptions.c > +++ b/tools/testing/selftests/kvm/aarch64/debug-exceptions.c > @@ -23,7 +23,7 @@ > #define SPSR_D (1 << 9) > #define SPSR_SS (1 << 21) > > -extern unsigned char sw_bp, hw_bp, bp_svc, bp_brk, hw_wp, ss_start; > +extern unsigned char sw_bp, hw_bp, hw_bp2, bp_svc, bp_brk, hw_wp, ss_start; > static volatile uint64_t sw_bp_addr, hw_bp_addr; > static volatile uint64_t wp_addr, wp_data_addr; > static volatile uint64_t svc_addr; > @@ -47,6 +47,14 @@ static void reset_debug_state(void) > isb(); > } > > +static void enable_os_lock(void) > +{ > + write_sysreg(oslar_el1, 1); > + isb(); > + > + GUEST_ASSERT(read_sysreg(oslsr_el1) & 2); > +} > + > static void install_wp(uint64_t addr) > { > uint32_t wcr; > @@ -99,6 +107,7 @@ static void guest_code(void) > GUEST_SYNC(0); > > /* Software-breakpoint */ > + reset_debug_state(); > asm volatile("sw_bp: brk #0"); > GUEST_ASSERT_EQ(sw_bp_addr, PC(sw_bp)); > > @@ -152,6 +161,51 @@ static void guest_code(void) > GUEST_ASSERT_EQ(ss_addr[1], PC(ss_start) + 4); > GUEST_ASSERT_EQ(ss_addr[2], PC(ss_start) + 8); > > + GUEST_SYNC(6); > + > + /* OS Lock blocking software-breakpoint */ > + reset_debug_state(); > + enable_os_lock(); > + sw_bp_addr = 0; > + asm volatile("brk #0"); > + GUEST_ASSERT_EQ(sw_bp_addr, 0); I haven't had a change to properly review the series, but this one definitely caught my eye. My expectations are that BRK is *not* affected by the OS Lock. The ARMv8 ARM goes as far as saying: Breakpoint Instruction exceptions are enabled regardless of the state of the OS Lock and the OS Double Lock. as well as: There is no enable control for Breakpoint Instruction exceptions. They are always enabled, and cannot be masked. I wonder how your test succeeds, though. Thanks, M. -- Without deviation from the norm, progress is not possible. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel