From patchwork Tue Jun 2 14:48:25 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Zhao X-Patchwork-Id: 49405 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f72.google.com (mail-wg0-f72.google.com [74.125.82.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id B02CB20BD1 for ; Tue, 2 Jun 2015 14:52:15 +0000 (UTC) Received: by wgme6 with SMTP id e6sf41077828wgm.3 for ; Tue, 02 Jun 2015 07:52:15 -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=Lwa/OXI36xPqstjXzQERFGEwZFv7OBXtYqYnWP1Bpe6u4UAY4+Hv20reJDVJCjNIAj ljdWNUEWiZ1cLUQCcTfyaWpWwj5WlhZ3gRBCql3hSWbd1gqONN/8z1ZMh8j7OPd6NfYK rBAkiC2zbTgATlQn0dtq4x0IGSTSZgmfhD+iLzY95lAyVSiB1UvdkpUte2YIvcTGBvo6 KGd4T5cpMsBeu9MsJG753A3QxOl3Qr51vErvGxsO5uw7TOfsr15M62YElliJNDrt70D9 Zv2QBUJv24EAbsQ8v/KFtGj3iWQSCm7ZDFpHzrumqG/sUN4t7dBWSkIzmYICj8stsPpR Ey/Q== X-Gm-Message-State: ALoCoQmNoxNczzXb7kKVWCB0af/95FUrSMQi1wsgVuC7ofLy8q6QoVWC7UadJaxutti1rgNCyJf3 X-Received: by 10.180.221.203 with SMTP id qg11mr13253327wic.7.1433256734991; Tue, 02 Jun 2015 07:52:14 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.116.7 with SMTP id js7ls730066lab.34.gmail; Tue, 02 Jun 2015 07:52:14 -0700 (PDT) X-Received: by 10.152.3.97 with SMTP id b1mr5661290lab.54.1433256734812; Tue, 02 Jun 2015 07:52:14 -0700 (PDT) Received: from mail-lb0-f177.google.com (mail-lb0-f177.google.com. [209.85.217.177]) by mx.google.com with ESMTPS id xi9si15305011lbb.4.2015.06.02.07.52.14 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 02 Jun 2015 07:52:14 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.177 as permitted sender) client-ip=209.85.217.177; Received: by lbbqq2 with SMTP id qq2so106037560lbb.3 for ; Tue, 02 Jun 2015 07:52:14 -0700 (PDT) X-Received: by 10.112.198.74 with SMTP id ja10mr26662918lbc.19.1433256734712; Tue, 02 Jun 2015 07:52:14 -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 hn6csp3130248lbb; Tue, 2 Jun 2015 07:52:13 -0700 (PDT) X-Received: by 10.70.48.141 with SMTP id l13mr9723155pdn.101.1433256732895; Tue, 02 Jun 2015 07:52:12 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id po1si26750474pac.52.2015.06.02.07.52.12; Tue, 02 Jun 2015 07:52:12 -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 S932338AbbFBOwL (ORCPT + 2 others); Tue, 2 Jun 2015 10:52:11 -0400 Received: from mail-oi0-f50.google.com ([209.85.218.50]:35286 "EHLO mail-oi0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759006AbbFBOwK (ORCPT ); Tue, 2 Jun 2015 10:52:10 -0400 Received: by oihd6 with SMTP id d6so127456296oih.2 for ; Tue, 02 Jun 2015 07:52:10 -0700 (PDT) X-Received: by 10.60.132.234 with SMTP id ox10mr23066954oeb.16.1433256730266; Tue, 02 Jun 2015 07:52:10 -0700 (PDT) Received: from localhost ([167.160.116.34]) by mx.google.com with ESMTPSA id u196sm9611838oia.18.2015.06.02.07.52.07 (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 02 Jun 2015 07:52:09 -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 30/32] arm64: KVM: Fix HCR setting for 32bit guests Date: Tue, 2 Jun 2015 22:48:25 +0800 Message-Id: <1433256507-7856-31-git-send-email-shannon.zhao@linaro.org> X-Mailer: git-send-email 1.9.5.msysgit.1 In-Reply-To: <1433256507-7856-1-git-send-email-shannon.zhao@linaro.org> References: <1433256507-7856-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.177 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; }