From patchwork Mon May 4 01:25:20 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Zhao X-Patchwork-Id: 47932 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f70.google.com (mail-wg0-f70.google.com [74.125.82.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 2A21320553 for ; Mon, 4 May 2015 01:28:10 +0000 (UTC) Received: by wgiv13 with SMTP id v13sf40352344wgi.3 for ; Sun, 03 May 2015 18:28:09 -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=rCGF6alv4d4mRHuc2IRn0e5UME61hR6M/7DCv9JIsSY=; b=fubFpwnDfBlAySOeYGZol5drZbWh+oAJlWiFEyMl9eQToA5dG4TrbM0s7OXkiwND6e 25nDDTge0YhFM1C+0nuNaxgLv77KxqSHI0GZxaHI1fGH2XKf/GIkse7Hkq5XArLGx3VZ XTN72i4G9RfYeY7KTOOhEaw7ZUuD0YpfsxPbgnTkkzBO/sZ9rnxYgsyPLlHFH4ACGe4i NUjVgVrddmHb3fOHiBZW96mJCnqD1z/noW4mDQ7cvcpmAAvQWENvKW8TBE7rlllF8e1O C3SVkM2Gd2O+plROYGRXb+wQGvxIwBLKXfhUyMK2v93PmWUkJUxbiWrVl7I/9vmyNVxH oFkg== X-Gm-Message-State: ALoCoQlxC6Iy6uB1HtFjaJLX3uzHEsifclAIkY30uIB+dLfn3oyJ4/DJqLyWo2ykhxHthUpezwJO X-Received: by 10.112.219.200 with SMTP id pq8mr16931254lbc.7.1430702889432; Sun, 03 May 2015 18:28:09 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.87.171 with SMTP id az11ls717518lab.107.gmail; Sun, 03 May 2015 18:28:09 -0700 (PDT) X-Received: by 10.112.146.97 with SMTP id tb1mr17975483lbb.12.1430702889294; Sun, 03 May 2015 18:28:09 -0700 (PDT) Received: from mail-la0-f42.google.com (mail-la0-f42.google.com. [209.85.215.42]) by mx.google.com with ESMTPS id bc7si9037423lbc.144.2015.05.03.18.28.09 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 03 May 2015 18:28:09 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.42 as permitted sender) client-ip=209.85.215.42; Received: by labbd9 with SMTP id bd9so94868015lab.2 for ; Sun, 03 May 2015 18:28:09 -0700 (PDT) X-Received: by 10.152.2.227 with SMTP id 3mr17352884lax.73.1430702889081; Sun, 03 May 2015 18:28:09 -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 l1csp1406110lbt; Sun, 3 May 2015 18:28:08 -0700 (PDT) X-Received: by 10.70.36.42 with SMTP id n10mr38411148pdj.118.1430702886477; Sun, 03 May 2015 18:28:06 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id es7si17680936pbd.123.2015.05.03.18.28.05; Sun, 03 May 2015 18:28:06 -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 S1751613AbbEDB2F (ORCPT + 2 others); Sun, 3 May 2015 21:28:05 -0400 Received: from mail-pd0-f177.google.com ([209.85.192.177]:34237 "EHLO mail-pd0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751578AbbEDB2E (ORCPT ); Sun, 3 May 2015 21:28:04 -0400 Received: by pdbqa5 with SMTP id qa5so149511344pdb.1 for ; Sun, 03 May 2015 18:28:04 -0700 (PDT) X-Received: by 10.66.138.109 with SMTP id qp13mr25346695pab.57.1430702884094; Sun, 03 May 2015 18:28:04 -0700 (PDT) Received: from localhost ([180.150.153.1]) by mx.google.com with ESMTPSA id da3sm11018116pdb.8.2015.05.03.18.28.02 (version=TLSv1 cipher=RC4-SHA bits=128/128); Sun, 03 May 2015 18:28:02 -0700 (PDT) From: shannon.zhao@linaro.org To: stable@vger.kernel.org Cc: sasha.levin@oracle.com, christoffer.dall@linaro.org, shannon.zhao@linaro.org, Marc Zyngier , Paolo Bonzini Subject: [PATCH for 3.18.y stable 16/22] arm64: KVM: Fix HCR setting for 32bit guests Date: Mon, 4 May 2015 09:25:20 +0800 Message-Id: <1430702726-2056-17-git-send-email-shannon.zhao@linaro.org> X-Mailer: git-send-email 1.9.5.msysgit.1 In-Reply-To: <1430702726-2056-1-git-send-email-shannon.zhao@linaro.org> References: <1430702726-2056-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.42 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 8127e45..865a7e2 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; }