From patchwork Mon May 4 01:52:40 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Zhao X-Patchwork-Id: 47983 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f198.google.com (mail-wi0-f198.google.com [209.85.212.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 3F9DE2121F for ; Mon, 4 May 2015 01:57:14 +0000 (UTC) Received: by wiun10 with SMTP id n10sf30530054wiu.1 for ; Sun, 03 May 2015 18:57:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=rgRdCNdSmf+Kz3SIHIAPsFQ4v7V+gT0nX4gxQVQhK1A=; b=I2zCojbVoSiOJBEus7WpOKceo3XAKv1Dba/USjh7/7GSx0M3AwWLhS4/jHTf01q/LQ iMHRPIT2XfNISEmox5Muy+1VyahskOm8ZYd+MF7nzlQLBaqSNcGswgiofkd9qIlpWlpM TELc+Xj7iiRB8+y04a5k2mXOJ/n6rxBGazO9PbqsaTZ7MNsj1o05Zu9PzSfs67KIOQPs iPQXNjLROXOd3gPmm8OP+ufMjzgAO3yjOVGMKZ6ZBEwk4tNCBlNBFWv/H3yj9eMO8QVu +IUCD1qu8ovS26CmlCxRHWej1cicwA9c+D8Hcu3rne/tasUi9OsiqLsi3TiXQWOUMZDG 0k1Q== X-Gm-Message-State: ALoCoQk1xJv06/Jq7Nz/AqQrOlyildgQc5wX1Elpz+xkoDfv0QbLD5M1LTLFbo5qVpkk9fSIFMf8 X-Received: by 10.112.14.101 with SMTP id o5mr16881907lbc.3.1430704633545; Sun, 03 May 2015 18:57:13 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.153.7.167 with SMTP id dd7ls594459lad.28.gmail; Sun, 03 May 2015 18:57:13 -0700 (PDT) X-Received: by 10.152.238.43 with SMTP id vh11mr17681239lac.45.1430704633409; Sun, 03 May 2015 18:57:13 -0700 (PDT) Received: from mail-lb0-f170.google.com (mail-lb0-f170.google.com. [209.85.217.170]) by mx.google.com with ESMTPS id u1si9110081lau.12.2015.05.03.18.57.13 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 03 May 2015 18:57:13 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.170 as permitted sender) client-ip=209.85.217.170; Received: by lbbuc2 with SMTP id uc2so95622553lbb.2 for ; Sun, 03 May 2015 18:57:13 -0700 (PDT) X-Received: by 10.112.219.70 with SMTP id pm6mr17286433lbc.41.1430704633322; Sun, 03 May 2015 18:57:13 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.67.65 with SMTP id l1csp1413373lbt; Sun, 3 May 2015 18:57:12 -0700 (PDT) X-Received: by 10.70.38.195 with SMTP id i3mr38620590pdk.82.1430704630391; Sun, 03 May 2015 18:57:10 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ix6si17838787pac.46.2015.05.03.18.57.09; Sun, 03 May 2015 18:57:10 -0700 (PDT) Received-SPF: none (google.com: stable-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751984AbbEDB5J (ORCPT + 2 others); Sun, 3 May 2015 21:57:09 -0400 Received: from mail-pa0-f45.google.com ([209.85.220.45]:36249 "EHLO mail-pa0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751983AbbEDB5I (ORCPT ); Sun, 3 May 2015 21:57:08 -0400 Received: by pabsx10 with SMTP id sx10so147801031pab.3 for ; Sun, 03 May 2015 18:57:08 -0700 (PDT) X-Received: by 10.68.136.134 with SMTP id qa6mr38451334pbb.66.1430704628112; Sun, 03 May 2015 18:57:08 -0700 (PDT) Received: from localhost ([180.150.153.1]) by mx.google.com with ESMTPSA id ef3sm11023138pbc.26.2015.05.03.18.57.06 (version=TLSv1 cipher=RC4-SHA bits=128/128); Sun, 03 May 2015 18:57:07 -0700 (PDT) From: shannon.zhao@linaro.org To: stable@vger.kernel.org Cc: gregkh@linuxfoundation.org, christoffer.dall@linaro.org, shannon.zhao@linaro.org, Marc Zyngier , Paolo Bonzini Subject: [PATCH for 3.14.y stable 45/47] arm64: KVM: Fix HCR setting for 32bit guests Date: Mon, 4 May 2015 09:52:40 +0800 Message-Id: <1430704362-6292-46-git-send-email-shannon.zhao@linaro.org> X-Mailer: git-send-email 1.9.5.msysgit.1 In-Reply-To: <1430704362-6292-1-git-send-email-shannon.zhao@linaro.org> References: <1430704362-6292-1-git-send-email-shannon.zhao@linaro.org> Sender: stable-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: stable@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: shannon.zhao@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.170 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , From: Marc Zyngier commit 801f6772cecea6cfc7da61aa197716ab64db5f9e upstream. Commit b856a59141b1 (arm/arm64: KVM: Reset the HCR on each vcpu when resetting the vcpu) moved the init of the HCR register to happen later in the init of a vcpu, but left out the fixup done in kvm_reset_vcpu when preparing for a 32bit guest. As a result, the 32bit guest is run as a 64bit guest, but the rest of the kernel still manages it as a 32bit. Fun follows. Moving the fixup to vcpu_reset_hcr solves the problem for good. Signed-off-by: Marc Zyngier Signed-off-by: Christoffer Dall Signed-off-by: Paolo Bonzini Signed-off-by: Shannon Zhao --- arch/arm64/include/asm/kvm_emulate.h | 2 ++ arch/arm64/kvm/reset.c | 1 - 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/arm64/include/asm/kvm_emulate.h b/arch/arm64/include/asm/kvm_emulate.h index 681cb90..91f33c2 100644 --- a/arch/arm64/include/asm/kvm_emulate.h +++ b/arch/arm64/include/asm/kvm_emulate.h @@ -41,6 +41,8 @@ void kvm_inject_pabt(struct kvm_vcpu *vcpu, unsigned long addr); static inline void vcpu_reset_hcr(struct kvm_vcpu *vcpu) { vcpu->arch.hcr_el2 = HCR_GUEST_FLAGS; + if (test_bit(KVM_ARM_VCPU_EL1_32BIT, vcpu->arch.features)) + vcpu->arch.hcr_el2 &= ~HCR_RW; } static inline unsigned long *vcpu_pc(const struct kvm_vcpu *vcpu) diff --git a/arch/arm64/kvm/reset.c b/arch/arm64/kvm/reset.c index 70a7816..0b43265 100644 --- a/arch/arm64/kvm/reset.c +++ b/arch/arm64/kvm/reset.c @@ -90,7 +90,6 @@ int kvm_reset_vcpu(struct kvm_vcpu *vcpu) if (!cpu_has_32bit_el1()) return -EINVAL; cpu_reset = &default_regs_reset32; - vcpu->arch.hcr_el2 &= ~HCR_RW; } else { cpu_reset = &default_regs_reset; }