From patchwork Tue Jun 30 10:49:08 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Zhao X-Patchwork-Id: 50468 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f69.google.com (mail-wg0-f69.google.com [74.125.82.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 980CB229DF for ; Tue, 30 Jun 2015 10:51:55 +0000 (UTC) Received: by wgfk9 with SMTP id k9sf2503214wgf.1 for ; Tue, 30 Jun 2015 03:51:54 -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=VeTDI3rM3ohzSqlBWfD6RqFEbh/mgxO/Jeb8zpEsGeknJuZ7kofZW8RUZtFS9Egqn8 eFkAUJRByepOXQqNvMZ/FtVzmHxus44eKkf/VjEtCxq3EhrAtVvIhuvP9bFFmsuJs5vt g7cLBOKVbBMqlC8W5aGJ3D3ubZka9ydltVrzcFmwTOrOwF8E0CEuDtRlpEZwfLeHN/fI UZbh8fTNnGqWzA1fOxnQFgWXu2RNR5mLcva2FddlcoxiGxFm/4fhJFLAmHUAAQDhGQ7b 0ArmnK2MjU7nFA4OtqAdashcbtKuF3UbC4Cjl1nGpKGTGTfMM2QanDqfDRNE0bUXUZzn C1SA== X-Gm-Message-State: ALoCoQnbGc+Co/tkZBRuZQeGBw76lTAmXlsnXmGTrw5e86RNlVj/rtYEt3464pUL3Zo5cH7OxBoH X-Received: by 10.112.55.104 with SMTP id r8mr13780629lbp.18.1435661514938; Tue, 30 Jun 2015 03:51:54 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.19.39 with SMTP id b7ls27355lae.85.gmail; Tue, 30 Jun 2015 03:51:54 -0700 (PDT) X-Received: by 10.112.168.165 with SMTP id zx5mr18633186lbb.111.1435661514661; Tue, 30 Jun 2015 03:51:54 -0700 (PDT) Received: from mail-la0-f47.google.com (mail-la0-f47.google.com. [209.85.215.47]) by mx.google.com with ESMTPS id j8si37779897lah.14.2015.06.30.03.51.54 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 30 Jun 2015 03:51:54 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.47 as permitted sender) client-ip=209.85.215.47; Received: by lagx9 with SMTP id x9so8185303lag.1 for ; Tue, 30 Jun 2015 03:51:54 -0700 (PDT) X-Received: by 10.112.126.101 with SMTP id mx5mr19300021lbb.35.1435661514557; Tue, 30 Jun 2015 03:51:54 -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.108.230 with SMTP id hn6csp2353595lbb; Tue, 30 Jun 2015 03:51:53 -0700 (PDT) X-Received: by 10.68.134.226 with SMTP id pn2mr42090424pbb.86.1435661501854; Tue, 30 Jun 2015 03:51:41 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id lj11si69631040pab.25.2015.06.30.03.51.41; Tue, 30 Jun 2015 03:51:41 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753143AbbF3Kvj (ORCPT + 2 others); Tue, 30 Jun 2015 06:51:39 -0400 Received: from mail-pd0-f170.google.com ([209.85.192.170]:34593 "EHLO mail-pd0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753141AbbF3Kvi (ORCPT ); Tue, 30 Jun 2015 06:51:38 -0400 Received: by pdbep18 with SMTP id ep18so4317673pdb.1 for ; Tue, 30 Jun 2015 03:51:38 -0700 (PDT) X-Received: by 10.68.167.197 with SMTP id zq5mr42401287pbb.85.1435661498500; Tue, 30 Jun 2015 03:51:38 -0700 (PDT) Received: from localhost ([120.136.36.232]) by mx.google.com with ESMTPSA id zb14sm45363361pab.20.2015.06.30.03.51.36 (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 30 Jun 2015 03:51:37 -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 20/22] arm64: KVM: Fix HCR setting for 32bit guests Date: Tue, 30 Jun 2015 18:49:08 +0800 Message-Id: <1435661350-8060-21-git-send-email-shannon.zhao@linaro.org> X-Mailer: git-send-email 1.9.5.msysgit.1 In-Reply-To: <1435661350-8060-1-git-send-email-shannon.zhao@linaro.org> References: <1435661350-8060-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.215.47 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; }