From patchwork Tue Sep 27 18:05:38 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 9352481 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 364D46077B for ; Tue, 27 Sep 2016 18:06:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2D8E02924F for ; Tue, 27 Sep 2016 18:06:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 225A1292A2; Tue, 27 Sep 2016 18:06:57 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A084329272 for ; Tue, 27 Sep 2016 18:06:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S936434AbcI0SGx (ORCPT ); Tue, 27 Sep 2016 14:06:53 -0400 Received: from mail-wm0-f46.google.com ([74.125.82.46]:38112 "EHLO mail-wm0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934866AbcI0SGR (ORCPT ); Tue, 27 Sep 2016 14:06:17 -0400 Received: by mail-wm0-f46.google.com with SMTP id l132so26951637wmf.1 for ; Tue, 27 Sep 2016 11:06:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Smv3PaC7SNroo48yv3h5y8UCf8Hn/luBqFJARHZkCi0=; b=EvfGWW/qHa956rqIAnk1EXoPBgYRAsUQCIMzz59hBaFwdfCfOqjbhg9pRWH2XG88ZU yq/pG3mNMvv/dXUgZ2p77rCJEp+eyW0wSeZ+DoISPHK4RrkYSOghWj7hxFwS97CMUMT3 acCaJ2VunAGITNPJI+gaDIVVctbXcMw8Ar7Us= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Smv3PaC7SNroo48yv3h5y8UCf8Hn/luBqFJARHZkCi0=; b=F6G7j/2Wohf8/YCu/NeBOVmo1Y/bq0upenSbJ4Dno+fiAzIdhkkCq9AhkAcEL8SaCj KqF1A1Pp1pqKqgmKD0lXIbEA5j/KLsnyQtlxgKptz5pMAJQtXJjID4gjn/bZjIkZfpCK tavSEUyuYsvPD0kka3s/bpjQrHkP++KOZcGvl7IPvZReWRzPwygbI3Gpar/syKS3Cgxf yGGrCF3z2bbtJZESNOaViRO/7HWhsRkDdUUyNuj7kcSTKhqa32eWCaoVHmkAZJ/me2hD XVwCjrt/NjzhPEQxaWFsdOErk16uHFvNd2OZShLqRVSpvaW9Bo3zB5BXiSe4uua4GWQE unMw== X-Gm-Message-State: AA6/9RllBIUPXiNzz8Sv6LnZc9Moa84lqwhzJMRePsbIdcvKJFWJLLSBb5BawpTUKjcwjcfA X-Received: by 10.28.109.86 with SMTP id i83mr4116823wmc.104.1474999575383; Tue, 27 Sep 2016 11:06:15 -0700 (PDT) Received: from localhost.localdomain ([94.18.191.146]) by smtp.gmail.com with ESMTPSA id k2sm17932539wmg.23.2016.09.27.11.06.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 27 Sep 2016 11:06:14 -0700 (PDT) From: Christoffer Dall To: Paolo Bonzini , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= Cc: Marc Zyngier , kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Christoffer Dall Subject: [PULL 30/50] arm: KVM: Handle async aborts delivered while at HYP Date: Tue, 27 Sep 2016 20:05:38 +0200 Message-Id: <20160927180558.14699-31-christoffer.dall@linaro.org> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20160927180558.14699-1-christoffer.dall@linaro.org> References: <20160927180558.14699-1-christoffer.dall@linaro.org> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Marc Zyngier Just like for arm64, we can handle asynchronous aborts being delivered at HYP while being caused by the guest. We use the exact same method to catch such an abort, and soldier on. Signed-off-by: Marc Zyngier Signed-off-by: Christoffer Dall --- arch/arm/kvm/hyp/entry.S | 31 +++++++++++++++++++++++++++++++ arch/arm/kvm/hyp/hyp-entry.S | 16 +++++++++++++++- 2 files changed, 46 insertions(+), 1 deletion(-) diff --git a/arch/arm/kvm/hyp/entry.S b/arch/arm/kvm/hyp/entry.S index 21c2388..60783f3 100644 --- a/arch/arm/kvm/hyp/entry.S +++ b/arch/arm/kvm/hyp/entry.S @@ -18,6 +18,7 @@ #include #include #include +#include .arch_extension virt @@ -63,6 +64,36 @@ ENTRY(__guest_exit) ldr lr, [r0, #4] mov r0, r1 + mrs r1, SPSR + mrs r2, ELR_hyp + mrc p15, 4, r3, c5, c2, 0 @ HSR + + /* + * Force loads and stores to complete before unmasking aborts + * and forcing the delivery of the exception. This gives us a + * single instruction window, which the handler will try to + * match. + */ + dsb sy + cpsie a + + .global abort_guest_exit_start +abort_guest_exit_start: + + isb + + .global abort_guest_exit_end +abort_guest_exit_end: + + /* + * If we took an abort, r0[31] will be set, and cmp will set + * the N bit in PSTATE. + */ + cmp r0, #0 + msrmi SPSR_cxsf, r1 + msrmi ELR_hyp, r2 + mcrmi p15, 4, r3, c5, c2, 0 @ HSR + bx lr ENDPROC(__guest_exit) diff --git a/arch/arm/kvm/hyp/hyp-entry.S b/arch/arm/kvm/hyp/hyp-entry.S index 7809138..96beb53 100644 --- a/arch/arm/kvm/hyp/hyp-entry.S +++ b/arch/arm/kvm/hyp/hyp-entry.S @@ -81,7 +81,6 @@ __kvm_hyp_vector: invalid_vector hyp_undef ARM_EXCEPTION_UNDEFINED invalid_vector hyp_svc ARM_EXCEPTION_SOFTWARE invalid_vector hyp_pabt ARM_EXCEPTION_PREF_ABORT - invalid_vector hyp_dabt ARM_EXCEPTION_DATA_ABORT invalid_vector hyp_fiq ARM_EXCEPTION_FIQ ENTRY(__hyp_do_panic) @@ -164,6 +163,21 @@ hyp_irq: load_vcpu r0 @ Load VCPU pointer to r0 b __guest_exit +hyp_dabt: + push {r0, r1} + mrs r0, ELR_hyp + ldr r1, =abort_guest_exit_start +THUMB( add r1, r1, #1) + cmp r0, r1 + ldrne r1, =abort_guest_exit_end +THUMB( addne r1, r1, #1) + cmpne r0, r1 + pop {r0, r1} + bne __hyp_panic + + orr r0, r0, #(1 << ARM_EXIT_WITH_ABORT_BIT) + eret + .ltorg .popsection