From patchwork Tue Sep 27 18:05:34 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 9352483 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 4B3F96077B for ; Tue, 27 Sep 2016 18:06:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 419C32924F for ; Tue, 27 Sep 2016 18:06:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 362722926D; Tue, 27 Sep 2016 18:06:58 +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 59C3C29260 for ; Tue, 27 Sep 2016 18:06:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S964784AbcI0SGs (ORCPT ); Tue, 27 Sep 2016 14:06:48 -0400 Received: from mail-wm0-f48.google.com ([74.125.82.48]:38035 "EHLO mail-wm0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934727AbcI0SGN (ORCPT ); Tue, 27 Sep 2016 14:06:13 -0400 Received: by mail-wm0-f48.google.com with SMTP id l132so26947838wmf.1 for ; Tue, 27 Sep 2016 11:06:12 -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=PNht0fZBOg4TXgocMmkYdkjdX2ou+uBcFW9d21AU2Ks=; b=XyH5pJ0geIPE0ZOZ+PvYuP9oQzatukbwHj0AW9CRKM3SOh13743XXaIx3szeCzXDm2 VYTYlcl7pJFlmrdk82pPvZGxbcBF/fZEgTPR4M942lS1xz4ckNsR1SutNwmisT2d/k8d yN+4m8OxFieWgjBSbxwpkPGUPKu5l6pCuNZlo= 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=PNht0fZBOg4TXgocMmkYdkjdX2ou+uBcFW9d21AU2Ks=; b=CsGxgxxhopzb47lfBp16DSu+Tz8WjSSeH3psPa38NGnlzoFMlOVjYR7880fKzMictq kwMYmz+4cZcv6JhNB2i8DwaAs5bbeO43RnD6PKyPEQFzk0wpminHzS2ubWKQyS2W6y1o nf9Pf/ybUV42PkX68FM7SxV4UdAiGWetIM1Rj0UBnwBuz7taW9LGXX9WQcV3Fv+HPE80 2cRdQQFp947gnLSq8TuCe8CwGLMKzqGEFivnFuTnGV5/o6Vpv7iJArc56cn/F/thNuuV zPekFsychGxwn9hKdA+H/B763xvhLWg8EEMOFCq8z+xL3Qu3ggltR0/S7vpYQUXadygz UIQw== X-Gm-Message-State: AE9vXwNr0cyRtQeEMfLGq8e+WWpOF8xc9M2rVQyhgQOEW3S9AOLjjjwzbH/eJdQpJAKCw5TR X-Received: by 10.194.5.230 with SMTP id v6mr26809890wjv.92.1474999571317; Tue, 27 Sep 2016 11:06:11 -0700 (PDT) Received: from localhost.localdomain ([94.18.191.146]) by smtp.gmail.com with ESMTPSA id k2sm17932539wmg.23.2016.09.27.11.06.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 27 Sep 2016 11:06:10 -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 26/50] arm: KVM: Preserve pending Virtual Abort in world switch Date: Tue, 27 Sep 2016 20:05:34 +0200 Message-Id: <20160927180558.14699-27-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.VA bit is used to signal an Abort 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, and at which point it must be cleared from the context. Signed-off-by: Marc Zyngier Signed-off-by: Christoffer Dall --- arch/arm/kvm/hyp/switch.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/arch/arm/kvm/hyp/switch.c b/arch/arm/kvm/hyp/switch.c index 37b3365..9da16fd 100644 --- a/arch/arm/kvm/hyp/switch.c +++ b/arch/arm/kvm/hyp/switch.c @@ -54,6 +54,15 @@ static void __hyp_text __deactivate_traps(struct kvm_vcpu *vcpu) { u32 val; + /* + * If we pended a virtual abort, preserve it until it gets + * cleared. See B1.9.9 (Virtual Abort exception) for details, + * but the crucial bit is the zeroing of HCR.VA in the + * pseudocode. + */ + if (vcpu->arch.hcr & HCR_VA) + vcpu->arch.hcr = read_sysreg(HCR); + write_sysreg(0, HCR); write_sysreg(0, HSTR); val = read_sysreg(HDCR);