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 2150EC433F5 for ; Tue, 2 Nov 2021 23:28:54 +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 DF50A60FC4 for ; Tue, 2 Nov 2021 23:28:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org DF50A60FC4 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com 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:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=yZldYEr3zrrXXxwQ8k8TaLYaxg0I591eRKzHqfgEYJA=; b=PFM94v+e7ZK8T7 jJYjn8GuxDeod8hCs/hDJIlD9c0/t23innrgZXPP8b6UkxMl59yJnvMh/YLNxtddXjCsptZAaRgrq w6KKEYVJZ5CDQ5eXSrBmZOpl/oSr2NRq42s61pySsg47Wfbi+XU450nUWPMpqryX3pIHjcqH8Ii8o x/NEHJ+SIPtudTpzG0BvMniB5lrChO6kN8TsFgYwzPFGjwm1XF5e+vqT7LAtiB0hCfrQcnoDyO/sz iVsgbhst/+kNytYe9uLDkbZXjiRWYj8go1qWV9SY9TA+Uc3Da2N6znTIQqNt2y904zE1QwZwlJSYW MofzMx3SD78p8StG46dQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mi3Bn-003OMr-PU; Tue, 02 Nov 2021 23:27:35 +0000 Received: from mail-pj1-x1036.google.com ([2607:f8b0:4864:20::1036]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mi3Bk-003OJV-9O for linux-arm-kernel@lists.infradead.org; Tue, 02 Nov 2021 23:27:33 +0000 Received: by mail-pj1-x1036.google.com with SMTP id gx15-20020a17090b124f00b001a695f3734aso24801pjb.0 for ; Tue, 02 Nov 2021 16:27:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=W5DJlOh3hc+L8UjfPHNMx8D9ADIs8nP6bivHGdFJhmQ=; b=OLtXu6A73oWqce3ybzNuXpwiLk/iDks0iFv04fDgsj40qPWxwaYDxOfX5UV36TMYKA t/kRcBCd3aMnD0Kv9uq/l453YlsEpKwCIp27LjqPz5G39ubGXe7HZt4KGzfPjYGmWIiA Wud8YPkf2fLaJROp5qXY7mY/1GAFz1e28OqKnvp8VZJsuoXw/W7AGzxseA0zeJXWh7mQ yrnqSOIbDwaYNi9QJ6DMjj6Xl5M7FsTcPxCN7etYXqFGlyZooQs+zXm8AVkTo+9gh9hV qfRa+JtF3VGBCqlle5U5wWaO+JCMSZjF+XLmqzNgL5h30+LhSQyTWWChuA15khCIHjzM MRlg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=W5DJlOh3hc+L8UjfPHNMx8D9ADIs8nP6bivHGdFJhmQ=; b=0yDF1eqcjzsvBqcrei9z156LKx3XSc5eT8EOul9p6Fw2oAkwsgl6PTKm5FHqYxxw8S J8VaVsoD0bUFR1R3zBQd6wBmLo+VAgFN0WQiKSjkYegTAJgfGUzQoroWo0NblXb1tR82 d1NCGQ4QppaBSIve0BUpKHhylwedGRDzUB5mjApzExPJf8LS3U7pe6EV+mXT+HAo6wWy BJx/5Gt0/LcbkASdeK842kP1m+IFZdjkDUqxKGKzXbHjkmTuTSXovlGYqyolqz7kSnR8 RerhwVYA1yrbcQLTat2Au3/aTu5dEc35XvYQ8658H+JT9GcT5ylGkHbSPuzl05XaQZin o0Xw== X-Gm-Message-State: AOAM532RauGtiHzVx/8Tfvr5ydstH4wdvkb6e3n357EAayWXjaRI2d/+ kv57EYg/QLgbnlxXzMo0YpwWMA== X-Google-Smtp-Source: ABdhPJxJ0u+5qjuTDRbt7W7Gi1WSmYimwJOgsAUpXwrl9xRmgHuTximZeUjOV+f3QmnCpf6OyycfAQ== X-Received: by 2002:a17:902:8690:b0:13f:ffd6:6c63 with SMTP id g16-20020a170902869000b0013fffd66c63mr34791324plo.23.1635895647396; Tue, 02 Nov 2021 16:27:27 -0700 (PDT) Received: from google.com (150.12.83.34.bc.googleusercontent.com. [34.83.12.150]) by smtp.gmail.com with ESMTPSA id f2sm248924pfj.99.2021.11.02.16.27.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Nov 2021 16:27:26 -0700 (PDT) Date: Tue, 2 Nov 2021 16:27:22 -0700 From: Ricardo Koller To: Oliver Upton Cc: kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, Marc Zyngier , James Morse , Alexandru Elisei , Suzuki K Poulose , linux-arm-kernel@lists.infradead.org, Andrew Jones , Peter Shier , Reiji Watanabe Subject: Re: [PATCH v2 6/6] selftests: KVM: Test OS lock behavior Message-ID: References: <20211102094651.2071532-1-oupton@google.com> <20211102094651.2071532-7-oupton@google.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20211102094651.2071532-7-oupton@google.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211102_162732_366953_18C07542 X-CRM114-Status: GOOD ( 19.60 ) 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 On Tue, Nov 02, 2021 at 09:46:51AM +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); should be: write_sysreg(val, reg); > + 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); > + > + GUEST_SYNC(7); > + > + /* OS Lock blocking hardware-breakpoint */ > + reset_debug_state(); > + enable_os_lock(); > + install_hw_bp(PC(hw_bp2)); > + hw_bp_addr = 0; > + asm volatile("hw_bp2: nop"); > + GUEST_ASSERT_EQ(hw_bp_addr, 0); > + > + GUEST_SYNC(8); > + > + /* OS Lock blocking watchpoint */ > + reset_debug_state(); > + enable_os_lock(); > + write_data = '\0'; > + wp_data_addr = 0; > + install_wp(PC(write_data)); > + write_data = 'x'; > + GUEST_ASSERT_EQ(write_data, 'x'); > + GUEST_ASSERT_EQ(wp_data_addr, 0); > + > + GUEST_SYNC(9); > + > + /* OS Lock blocking single-step */ > + reset_debug_state(); > + enable_os_lock(); > + ss_addr[0] = 0; > + install_ss(); > + ss_idx = 0; > + asm volatile("mrs x0, esr_el1\n\t" > + "add x0, x0, #1\n\t" > + "msr daifset, #8\n\t" > + : : : "x0"); > + GUEST_ASSERT_EQ(ss_addr[0], 0); > + > GUEST_DONE(); > } > > @@ -223,7 +277,7 @@ int main(int argc, char *argv[]) > vm_install_sync_handler(vm, VECTOR_SYNC_CURRENT, > ESR_EC_SVC64, guest_svc_handler); > > - for (stage = 0; stage < 7; stage++) { > + for (stage = 0; stage < 11; stage++) { > vcpu_run(vm, VCPU_ID); > > switch (get_ucall(vm, VCPU_ID, &uc)) { > -- > 2.33.1.1089.g2158813163f-goog > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel