From patchwork Fri Apr 24 05:27:59 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Zhao X-Patchwork-Id: 47546 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f199.google.com (mail-lb0-f199.google.com [209.85.217.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 0334420553 for ; Fri, 24 Apr 2015 05:35:24 +0000 (UTC) Received: by lbcne10 with SMTP id ne10sf8861950lbc.1 for ; Thu, 23 Apr 2015 22:35:23 -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=xOO+oiI1tQhLdlOXKnnyytWrvXH5wgVWQYOvKWbGxgo=; b=JDn0C/lQYmkLkTspx2rqU12HWuJvsRJ51FXggyuytoNx73argg2dEE9C6neiRxysr8 VZFckCKITin9YJeFLluz7iEy75PwfKLNjWmvnxh8HUKwQUOiWVgYoXS6Vxcl9ySmZ9TZ BDXbTtCz0noo95tNMU7dsydrzmZnBaZNfB6Dt5/zwoVbnTnSzi24/6/bH/Ty0XIgmZ6l XVHTH5Uj4FV4QUkoYuP60AI66UjWxFL1sgqh4zlAwc7E4i5jHAzKvOPQZKiItrwG3auw yml/zxSFujxHpT8QHO2vbSAG750z1NPaDYefkmf9xHh9GnANYdU5ZQ5h6fQeq0xHIeoO PXrg== X-Gm-Message-State: ALoCoQmx/XV0ejpicyIKylRPfS09JwGWPWk8zbMxSYOXRPLBkxqb8SOzzgcI/+d2R9OS1Uuvq+eS X-Received: by 10.180.73.137 with SMTP id l9mr161360wiv.5.1429853722977; Thu, 23 Apr 2015 22:35:22 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.27.194 with SMTP id v2ls494053lag.59.gmail; Thu, 23 Apr 2015 22:35:22 -0700 (PDT) X-Received: by 10.112.145.136 with SMTP id su8mr5415034lbb.61.1429853722675; Thu, 23 Apr 2015 22:35:22 -0700 (PDT) Received: from mail-lb0-f181.google.com (mail-lb0-f181.google.com. [209.85.217.181]) by mx.google.com with ESMTPS id q16si7486004laa.25.2015.04.23.22.35.22 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 23 Apr 2015 22:35:22 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.181 as permitted sender) client-ip=209.85.217.181; Received: by lbbqq2 with SMTP id qq2so28577425lbb.3 for ; Thu, 23 Apr 2015 22:35:22 -0700 (PDT) X-Received: by 10.112.184.70 with SMTP id es6mr5354988lbc.117.1429853722583; Thu, 23 Apr 2015 22:35:22 -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 l1csp979113lbt; Thu, 23 Apr 2015 22:35:21 -0700 (PDT) X-Received: by 10.68.135.4 with SMTP id po4mr11887807pbb.12.1429853720852; Thu, 23 Apr 2015 22:35:20 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id bd10si15800741pdb.178.2015.04.23.22.35.20; Thu, 23 Apr 2015 22:35:20 -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 S1754582AbbDXFfT (ORCPT + 2 others); Fri, 24 Apr 2015 01:35:19 -0400 Received: from mail-ob0-f181.google.com ([209.85.214.181]:33342 "EHLO mail-ob0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754588AbbDXFfS (ORCPT ); Fri, 24 Apr 2015 01:35:18 -0400 Received: by oblw8 with SMTP id w8so30303519obl.0 for ; Thu, 23 Apr 2015 22:35:17 -0700 (PDT) X-Received: by 10.202.209.148 with SMTP id i142mr5466321oig.113.1429853717823; Thu, 23 Apr 2015 22:35:17 -0700 (PDT) Received: from localhost ([167.160.116.36]) by mx.google.com with ESMTPSA id su4sm6074597obc.20.2015.04.23.22.35.15 (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 23 Apr 2015 22:35:16 -0700 (PDT) From: shannon.zhao@linaro.org To: stable@vger.kernel.org Cc: jslaby@suse.cz, christoffer.dall@linaro.org, shannon.zhao@linaro.org, Marc Zyngier , Paolo Bonzini Subject: [PATCH for 3.12.y stable 61/63] arm64: KVM: Fix HCR setting for 32bit guests Date: Fri, 24 Apr 2015 13:27:59 +0800 Message-Id: <1429853281-6136-62-git-send-email-shannon.zhao@linaro.org> X-Mailer: git-send-email 1.9.5.msysgit.1 In-Reply-To: <1429853281-6136-1-git-send-email-shannon.zhao@linaro.org> References: <1429853281-6136-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.181 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 45d8633..2b01e2b 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; }