From patchwork Thu Jul 2 10:59:47 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Zhao X-Patchwork-Id: 50570 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f199.google.com (mail-wi0-f199.google.com [209.85.212.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 5E606214B3 for ; Thu, 2 Jul 2015 11:00:25 +0000 (UTC) Received: by wiar9 with SMTP id r9sf23060630wia.1 for ; Thu, 02 Jul 2015 04:00:24 -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=RIMK4AO/u2D7ohxE85EWCBhg7nz3AOVApLvFLQh6LfezfYrF+eysD3LxJM8EDZMFU+ U8cXy+IZjAwNmkTgHiWxWPsWf9KJmP0loxg8OZV9c1Jqn3a3LOf2M+JiG3cAp7CubIBP jvZxC1Mjam2nG0W5GnsrEGBV/zeKlPRLNIDwdHBeF33yc0Zs5Qvo8OWPlBwMTFLKovDK QVLpnIJuDZ0Awtr14ymDSL5c2S6rqGwZm0YJ4rkPrDQNPbIlLm5uhVGzemnU9waef/9t ovu8Y5/rD2NFwo90LdF3mtSUYLozyhxtdVjWxfMLDP6aL67Pn5xgKc+oNcPVUYuuYtJF D1/Q== X-Gm-Message-State: ALoCoQlUGXWvu1TFSqZZtZWMHjpNFlwjdJERuXJf72GNg4J5j9pM7opAu0LTdkcALZF/1ZcEpxH7 X-Received: by 10.180.81.170 with SMTP id b10mr4443503wiy.4.1435834824724; Thu, 02 Jul 2015 04:00:24 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.207.38 with SMTP id lt6ls332030lac.50.gmail; Thu, 02 Jul 2015 04:00:24 -0700 (PDT) X-Received: by 10.152.43.134 with SMTP id w6mr27109924lal.120.1435834824304; Thu, 02 Jul 2015 04:00:24 -0700 (PDT) Received: from mail-lb0-f175.google.com (mail-lb0-f175.google.com. [209.85.217.175]) by mx.google.com with ESMTPS id lv3si4155143lac.87.2015.07.02.04.00.24 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 02 Jul 2015 04:00:24 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.175 as permitted sender) client-ip=209.85.217.175; Received: by lbbpo10 with SMTP id po10so29596833lbb.3 for ; Thu, 02 Jul 2015 04:00:24 -0700 (PDT) X-Received: by 10.112.126.101 with SMTP id mx5mr30371240lbb.35.1435834824098; Thu, 02 Jul 2015 04:00:24 -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 hn6csp392700lbb; Thu, 2 Jul 2015 04:00:22 -0700 (PDT) X-Received: by 10.66.142.42 with SMTP id rt10mr64301506pab.142.1435834822221; Thu, 02 Jul 2015 04:00:22 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p3si8481613pds.160.2015.07.02.04.00.21; Thu, 02 Jul 2015 04:00:22 -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 S1751304AbbGBLAU (ORCPT + 2 others); Thu, 2 Jul 2015 07:00:20 -0400 Received: from mail-pd0-f176.google.com ([209.85.192.176]:35018 "EHLO mail-pd0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751293AbbGBLAT (ORCPT ); Thu, 2 Jul 2015 07:00:19 -0400 Received: by pdbci14 with SMTP id ci14so43336002pdb.2 for ; Thu, 02 Jul 2015 04:00:19 -0700 (PDT) X-Received: by 10.70.17.36 with SMTP id l4mr431993pdd.52.1435834819057; Thu, 02 Jul 2015 04:00:19 -0700 (PDT) Received: from localhost ([120.136.34.253]) by mx.google.com with ESMTPSA id da3sm5316279pdb.8.2015.07.02.04.00.16 (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 02 Jul 2015 04:00:17 -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 3/5] arm64: KVM: Fix HCR setting for 32bit guests Date: Thu, 2 Jul 2015 18:59:47 +0800 Message-Id: <1435834789-8020-4-git-send-email-shannon.zhao@linaro.org> X-Mailer: git-send-email 1.9.5.msysgit.1 In-Reply-To: <1435834789-8020-1-git-send-email-shannon.zhao@linaro.org> References: <1435834789-8020-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.175 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; }