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: 9352561 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 E648060757 for ; Tue, 27 Sep 2016 18:15:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D8C41287F3 for ; Tue, 27 Sep 2016 18:15:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CB4FA29193; Tue, 27 Sep 2016 18:15:41 +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=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 3B5AB28AD3 for ; Tue, 27 Sep 2016 18:15:41 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1bowtO-00042M-3H; Tue, 27 Sep 2016 18:14:10 +0000 Received: from mail-wm0-x232.google.com ([2a00:1450:400c:c09::232]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bowlo-0005QR-Mr for linux-arm-kernel@lists.infradead.org; Tue, 27 Sep 2016 18:06:22 +0000 Received: by mail-wm0-x232.google.com with SMTP id w84so190351953wmg.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=PqucYawJ72/hyDc4x+oeFiQyoxngKo3ybNaQyzkgnGlwRKq8viCX3oTxv/UliLTWlP 6ch4D3ig9L+DEwhVeVwFSkKAaTwnqDH0jkHSBM9pXfABRuq47+bdBcqfDBvO2+LVOVzU 0fCcHkvjaEwDWG+EgVWAqjQaREswfSAqvZxLpOInKuTUzjn4Y8SCVA+O7E1ivUWeRJQs Jlb5f0S7+nfAS84vYglB1t01xNzjUv7Tlnqw7LpHDSNohgsLzV0kJ7WD/5Z6NkHiLbbj rgDYYrCblPMHeSZXkfVzMfN4UHih/bzpL+vbxgfkEsxEqLzYs6P+RXkrW6IKUA/dmH3z TtcA== X-Gm-Message-State: AA6/9RkLEA1/aVyu2zRrDuJGP9Uw58PvkQXAEvELjnAjCnMLW/aKOC961zJEvSsQtlqpmraW 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?= 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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160927_110621_103438_1837B324 X-CRM114-Status: GOOD ( 13.32 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Marc Zyngier , Christoffer Dall , kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.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);