From patchwork Tue Jun 2 14:48: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: 49400 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 13CC420BD1 for ; Tue, 2 Jun 2015 14:51:41 +0000 (UTC) Received: by wiam3 with SMTP id m3sf20113677wia.3 for ; Tue, 02 Jun 2015 07:51:40 -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=lP2k2Qnyq7SHJZ1xqH26WXq4bhFlo8D5Quzrc6t/Hs0=; b=OIchwYVbyrgLHa42nsG+ezq9FspzPTcVxL9WsuDEDPs+W96CCW/kTdmsVymwv5n+6S wguN7OXF/HPTK46lkMH6BSluwJ/08GPxfp+YL5QxwYCR0cWL+Ub0XZP1O273lf1wYNyQ f8jd1IfUYR7zJ9lu0uTkGwrjI5F2N0aat7zBWuK5o2M/n5ckHQEm2QH+0yL8MfJ2QwRg t0Ek3Tj5WdKMJ8QklB6Ru1yzvHReh97BUODqpfZfYVt83fuMcqhgX1OWUBqbN0SMY/ZJ ISw5DeS9CKpCaPymZL3Ci9YV1/0OkEpVSeO8Xo70UFOAFnDXgxZzzu4hSia5ySTkzpoz ugSQ== X-Gm-Message-State: ALoCoQkeosYcdQ4OFeWGVK1sKkskUKISMAVcUkEn89Cs0qMHCriiNfGfACsV1AKe1i8wqi0rarOu X-Received: by 10.194.158.134 with SMTP id wu6mr4112227wjb.6.1433256700396; Tue, 02 Jun 2015 07:51:40 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.225.134 with SMTP id rk6ls791490lac.83.gmail; Tue, 02 Jun 2015 07:51:40 -0700 (PDT) X-Received: by 10.112.159.9 with SMTP id wy9mr21987239lbb.120.1433256700228; Tue, 02 Jun 2015 07:51:40 -0700 (PDT) Received: from mail-la0-f53.google.com (mail-la0-f53.google.com. [209.85.215.53]) by mx.google.com with ESMTPS id pl9si15275467lbb.111.2015.06.02.07.51.39 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 02 Jun 2015 07:51:39 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.53 as permitted sender) client-ip=209.85.215.53; Received: by laei3 with SMTP id i3so39673984lae.3 for ; Tue, 02 Jun 2015 07:51:39 -0700 (PDT) X-Received: by 10.152.2.133 with SMTP id 5mr25231388lau.36.1433256699809; Tue, 02 Jun 2015 07:51:39 -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 hn6csp3129847lbb; Tue, 2 Jun 2015 07:51:38 -0700 (PDT) X-Received: by 10.70.40.131 with SMTP id x3mr50315216pdk.83.1433256697979; Tue, 02 Jun 2015 07:51:37 -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.51.37; Tue, 02 Jun 2015 07:51:37 -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 S1759376AbbFBOvg (ORCPT + 2 others); Tue, 2 Jun 2015 10:51:36 -0400 Received: from mail-oi0-f53.google.com ([209.85.218.53]:35763 "EHLO mail-oi0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759379AbbFBOvg (ORCPT ); Tue, 2 Jun 2015 10:51:36 -0400 Received: by oihd6 with SMTP id d6so127441913oih.2 for ; Tue, 02 Jun 2015 07:51:35 -0700 (PDT) X-Received: by 10.202.240.215 with SMTP id o206mr21598213oih.94.1433256695667; Tue, 02 Jun 2015 07:51:35 -0700 (PDT) Received: from localhost ([167.160.116.34]) by mx.google.com with ESMTPSA id os15sm9476618oeb.8.2015.06.02.07.51.33 (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 02 Jun 2015 07:51:34 -0700 (PDT) From: shannon.zhao@linaro.org To: stable@vger.kernel.org Cc: gregkh@linuxfoundation.org, christoffer.dall@linaro.org, shannon.zhao@linaro.org Subject: [PATCH for 3.14.y stable 25/32] arm/arm64: KVM: Reset the HCR on each vcpu when resetting the vcpu Date: Tue, 2 Jun 2015 22:48:20 +0800 Message-Id: <1433256507-7856-26-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.215.53 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: Christoffer Dall commit b856a59141b1066d3c896a0d0231f84dabd040af upstream. When userspace resets the vcpu using KVM_ARM_VCPU_INIT, we should also reset the HCR, because we now modify the HCR dynamically to enable/disable trapping of guest accesses to the VM registers. This is crucial for reboot of VMs working since otherwise we will not be doing the necessary cache maintenance operations when faulting in pages with the guest MMU off. Acked-by: Marc Zyngier Signed-off-by: Christoffer Dall Signed-off-by: Shannon Zhao --- arch/arm/include/asm/kvm_emulate.h | 5 +++++ arch/arm/kvm/arm.c | 2 ++ arch/arm/kvm/guest.c | 1 - arch/arm64/include/asm/kvm_emulate.h | 5 +++++ arch/arm64/kvm/guest.c | 1 - 5 files changed, 12 insertions(+), 2 deletions(-) diff --git a/arch/arm/include/asm/kvm_emulate.h b/arch/arm/include/asm/kvm_emulate.h index 0fa90c9..853e2be 100644 --- a/arch/arm/include/asm/kvm_emulate.h +++ b/arch/arm/include/asm/kvm_emulate.h @@ -33,6 +33,11 @@ void kvm_inject_undefined(struct kvm_vcpu *vcpu); void kvm_inject_dabt(struct kvm_vcpu *vcpu, unsigned long addr); void kvm_inject_pabt(struct kvm_vcpu *vcpu, unsigned long addr); +static inline void vcpu_reset_hcr(struct kvm_vcpu *vcpu) +{ + vcpu->arch.hcr = HCR_GUEST_MASK; +} + static inline bool vcpu_mode_is_32bit(struct kvm_vcpu *vcpu) { return 1; diff --git a/arch/arm/kvm/arm.c b/arch/arm/kvm/arm.c index 9c58125..077f82d0 100644 --- a/arch/arm/kvm/arm.c +++ b/arch/arm/kvm/arm.c @@ -675,6 +675,8 @@ static int kvm_arch_vcpu_ioctl_vcpu_init(struct kvm_vcpu *vcpu, if (ret) return ret; + vcpu_reset_hcr(vcpu); + /* * Handle the "start in power-off" case by marking the VCPU as paused. */ diff --git a/arch/arm/kvm/guest.c b/arch/arm/kvm/guest.c index b23a59c..2786eae 100644 --- a/arch/arm/kvm/guest.c +++ b/arch/arm/kvm/guest.c @@ -38,7 +38,6 @@ struct kvm_stats_debugfs_item debugfs_entries[] = { int kvm_arch_vcpu_setup(struct kvm_vcpu *vcpu) { - vcpu->arch.hcr = HCR_GUEST_MASK; return 0; } diff --git a/arch/arm64/include/asm/kvm_emulate.h b/arch/arm64/include/asm/kvm_emulate.h index dd8ecfc3..681cb90 100644 --- a/arch/arm64/include/asm/kvm_emulate.h +++ b/arch/arm64/include/asm/kvm_emulate.h @@ -38,6 +38,11 @@ void kvm_inject_undefined(struct kvm_vcpu *vcpu); void kvm_inject_dabt(struct kvm_vcpu *vcpu, unsigned long addr); 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; +} + static inline unsigned long *vcpu_pc(const struct kvm_vcpu *vcpu) { return (unsigned long *)&vcpu_gp_regs(vcpu)->regs.pc; diff --git a/arch/arm64/kvm/guest.c b/arch/arm64/kvm/guest.c index 0874557..a8d81fa 100644 --- a/arch/arm64/kvm/guest.c +++ b/arch/arm64/kvm/guest.c @@ -38,7 +38,6 @@ struct kvm_stats_debugfs_item debugfs_entries[] = { int kvm_arch_vcpu_setup(struct kvm_vcpu *vcpu) { - vcpu->arch.hcr_el2 = HCR_GUEST_FLAGS; return 0; }