From patchwork Thu Aug 4 11:40:36 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 73270 Delivered-To: patch@linaro.org Received: by 10.140.29.52 with SMTP id a49csp1345691qga; Thu, 4 Aug 2016 04:45:53 -0700 (PDT) X-Received: by 10.66.62.226 with SMTP id b2mr125017997pas.119.1470311153723; Thu, 04 Aug 2016 04:45:53 -0700 (PDT) Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id k8si14384597pab.100.2016.08.04.04.45.53 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 04 Aug 2016 04:45:53 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) client-ip=2001:1868:205::9; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) smtp.mailfrom=linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org 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 1bVH4s-0005HA-9N; Thu, 04 Aug 2016 11:44:42 +0000 Received: from mail-lf0-x229.google.com ([2a00:1450:4010:c07::229]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bVH1m-00039F-NU for linux-arm-kernel@lists.infradead.org; Thu, 04 Aug 2016 11:41:32 +0000 Received: by mail-lf0-x229.google.com with SMTP id b199so180624617lfe.0 for ; Thu, 04 Aug 2016 04:41:09 -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=xEWwsE96Q+wfyj5Ai7fM5Z6LMYfApPNQxZJoV494nPQ=; b=B0CaW4Yck3kKmedrwl+rHTK0vcMPuorGnSgOnV2BLmwoyaDz6Qn8kJJgmt1y5+/GLZ g2dFwUnk3k6sPqYqRuQpYQtabazeRaXpAhmEtwTZP9FLbzblO8cP012KwF2bT4SaNLxV /lFWOVN+CiDD3JhEkhd/QuWATfXmlBybahrI8= 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=xEWwsE96Q+wfyj5Ai7fM5Z6LMYfApPNQxZJoV494nPQ=; b=D99sMUNnilTEU56O5mhRwHJ48pa626Kw6zgfDM3XaS73sBciophzaERzzfihDFVf1A 7EzZPeHtE7v9yWQs0WtA6s6h7vWhdtGDVAZlQxWoWbS5AZlD23bFF6akea/BnbDZ3fZw /1GPhYqrpBECjWm6hxJR+XI0z6h/AAs/hQKo8iW1+KjmwUAu0PxsnWL4qbQQqooWO1Jt RIQeb5R1R7Lc4yAsNlyMElgqlMRJ9p/nHBPN/WoYVkynTUbZf9qNvmGt8FUiV0i6eGfw NrfQuf2Iq4mRKqPk8foA/KbHSg15eRQed0x1HTH8z7wizqQ4wN06jSYJlsg3M9N+a7xt UeGg== X-Gm-Message-State: AEkoouvpgVHZCVYxoFtv2oK6kBedQwHIyCETiH+UsQ/ArHztjoxX+mlJi0JMf6i/NpmVw3vJ X-Received: by 10.25.16.212 with SMTP id 81mr20498099lfq.174.1470310867492; Thu, 04 Aug 2016 04:41:07 -0700 (PDT) Received: from localhost.localdomain (109.59.220.90.mobile.3.dk. [109.59.220.90]) by smtp.gmail.com with ESMTPSA id h9sm2360706lfe.8.2016.08.04.04.41.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 04 Aug 2016 04:41:06 -0700 (PDT) From: Christoffer Dall To: Paolo Bonzini , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= Subject: [PULL 8/8] arm64: KVM: Set cpsr before spsr on fault injection Date: Thu, 4 Aug 2016 13:40:36 +0200 Message-Id: <1470310836-10371-9-git-send-email-christoffer.dall@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1470310836-10371-1-git-send-email-christoffer.dall@linaro.org> References: <1470310836-10371-1-git-send-email-christoffer.dall@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160804_044130_980419_A05B8CB0 X-CRM114-Status: GOOD ( 13.55 ) X-Spam-Score: -2.0 (--) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-2.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid 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: Andrew Jones , kvm@vger.kernel.org, Marc Zyngier , stable@vger.kernel.org, kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org From: Andrew Jones We need to set cpsr before determining the spsr bank, as the bank depends on the target exception level of the injection, not the current mode of the vcpu. Normally this is one in the same (EL1), but not when we manage to trap an EL0 fault. It still doesn't really matter for the 64-bit EL0 case though, as vcpu_spsr() unconditionally uses the EL1 bank for that. However the 32-bit EL0 case gets fun, as that path will lead to the BUG() in vcpu_spsr32(). This patch fixes the assignment order and also modifies some white space in order to better group pairs of lines that have strict order. Cc: stable@vger.kernel.org # v4.5 Signed-off-by: Andrew Jones Signed-off-by: Marc Zyngier --- arch/arm64/kvm/inject_fault.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) -- 1.9.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel diff --git a/arch/arm64/kvm/inject_fault.c b/arch/arm64/kvm/inject_fault.c index e9e0e6d..898c0e6 100644 --- a/arch/arm64/kvm/inject_fault.c +++ b/arch/arm64/kvm/inject_fault.c @@ -132,16 +132,14 @@ static u64 get_except_vector(struct kvm_vcpu *vcpu, enum exception_type type) static void inject_abt64(struct kvm_vcpu *vcpu, bool is_iabt, unsigned long addr) { unsigned long cpsr = *vcpu_cpsr(vcpu); - bool is_aarch32; + bool is_aarch32 = vcpu_mode_is_32bit(vcpu); u32 esr = 0; - is_aarch32 = vcpu_mode_is_32bit(vcpu); - - *vcpu_spsr(vcpu) = cpsr; *vcpu_elr_el1(vcpu) = *vcpu_pc(vcpu); - *vcpu_pc(vcpu) = get_except_vector(vcpu, except_type_sync); + *vcpu_cpsr(vcpu) = PSTATE_FAULT_BITS_64; + *vcpu_spsr(vcpu) = cpsr; vcpu_sys_reg(vcpu, FAR_EL1) = addr; @@ -172,11 +170,11 @@ static void inject_undef64(struct kvm_vcpu *vcpu) unsigned long cpsr = *vcpu_cpsr(vcpu); u32 esr = (ESR_ELx_EC_UNKNOWN << ESR_ELx_EC_SHIFT); - *vcpu_spsr(vcpu) = cpsr; *vcpu_elr_el1(vcpu) = *vcpu_pc(vcpu); - *vcpu_pc(vcpu) = get_except_vector(vcpu, except_type_sync); + *vcpu_cpsr(vcpu) = PSTATE_FAULT_BITS_64; + *vcpu_spsr(vcpu) = cpsr; /* * Build an unknown exception, depending on the instruction