From patchwork Tue Sep 27 18:05:26 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 9352461 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 84B686086A for ; Tue, 27 Sep 2016 18:06:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7B5DA29250 for ; Tue, 27 Sep 2016 18:06:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 703F32926D; Tue, 27 Sep 2016 18:06:33 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,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 0023929250 for ; Tue, 27 Sep 2016 18:06:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935416AbcI0SG2 (ORCPT ); Tue, 27 Sep 2016 14:06:28 -0400 Received: from mail-wm0-f53.google.com ([74.125.82.53]:37905 "EHLO mail-wm0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756141AbcI0SGE (ORCPT ); Tue, 27 Sep 2016 14:06:04 -0400 Received: by mail-wm0-f53.google.com with SMTP id l132so26941174wmf.1 for ; Tue, 27 Sep 2016 11:06:04 -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=lf66nWntcgwkYQb+VbdYJwyQdJ7Uu4sQ7OEQ7cMhT00=; b=OsSnMNbqlz+junHqzZ8o8BMGOkPnSyQsI5WQEKMOodbNhdzEAFNsQFL2Zw5naDQ4mT KcYb9crU+rpsP4eUxhT5ejtuY5gS6lyaCOZd6BkWScoNUx1XdjsHV8A9aPIZUSshsu0s MG+Pk86Q/fwov2p9RRTDsIgIY70vqV8HJUpVE= 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=lf66nWntcgwkYQb+VbdYJwyQdJ7Uu4sQ7OEQ7cMhT00=; b=AP+B9Ad/vga9s1gsEY1+j1ELEL7ncJJQwLwOpjClZTv1P6mVGcJ1iCyrtkyc2KX/3M XfeP61UWzmX7mXsMMXMLj5QPwvT23JL7Imk5D33ieyranlQrOVSZT6Bf+V21jGnKGGrp 4RixDnLGNa4TdmTdGPHTSekayQDWgns0lnuuWrHujHXA0SY0vWnphtIDqIHdauff1ESv A0ejbeyfFNd+plEjAwiDl54zf93LAuAWU3FlvN2gMv8zLXa1zy/tVpIKQtKw4NhIgXQd w5QsaTaTslaibi9W4Q5aXY1HTq2vVU/tjZ33Uo1bttDci6IS+J2S6A0uXX+jD1ctOGSm 62mg== X-Gm-Message-State: AA6/9RlQxoYfejIeJsrram9VQAtJDSWRohbN/RJFGDvw2KPhPlIOzYeJpIr5OE0f/8Oi2Apt X-Received: by 10.28.54.193 with SMTP id y62mr4080576wmh.96.1474999563622; Tue, 27 Sep 2016 11:06:03 -0700 (PDT) Received: from localhost.localdomain ([94.18.191.146]) by smtp.gmail.com with ESMTPSA id k2sm17932539wmg.23.2016.09.27.11.06.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 27 Sep 2016 11:06:02 -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 18/50] arm64: KVM: Preserve pending vSError in world switch Date: Tue, 27 Sep 2016 20:05:26 +0200 Message-Id: <20160927180558.14699-19-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 The HCR_EL2.VSE bit is used to signal an SError to a guest, and has the peculiar feature of getting cleared when the guest has taken the abort (this is the only bit that behaves as such in this register). This means that if we signal such an abort, we must leave it in the guest context until it disappears from HCR_EL2, and at which point it must be cleared from the context. This is achieved by reading back from HCR_EL2 until the guest takes the fault. Signed-off-by: Marc Zyngier Signed-off-by: Christoffer Dall --- arch/arm64/kvm/hyp/switch.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/arch/arm64/kvm/hyp/switch.c b/arch/arm64/kvm/hyp/switch.c index b3a66c5..8246de2 100644 --- a/arch/arm64/kvm/hyp/switch.c +++ b/arch/arm64/kvm/hyp/switch.c @@ -110,6 +110,15 @@ static hyp_alternate_select(__deactivate_traps_arch, static void __hyp_text __deactivate_traps(struct kvm_vcpu *vcpu) { + /* + * If we pended a virtual abort, preserve it until it gets + * cleared. See D1.14.3 (Virtual Interrupts) for details, but + * the crucial bit is "On taking a vSError interrupt, + * HCR_EL2.VSE is cleared to 0." + */ + if (vcpu->arch.hcr_el2 & HCR_VSE) + vcpu->arch.hcr_el2 = read_sysreg(hcr_el2); + __deactivate_traps_arch()(); write_sysreg(0, hstr_el2); write_sysreg(read_sysreg(mdcr_el2) & MDCR_EL2_HPMN_MASK, mdcr_el2);