From patchwork Mon May 4 01:52:35 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Zhao X-Patchwork-Id: 47978 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f198.google.com (mail-lb0-f198.google.com [209.85.217.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 754BB2121F for ; Mon, 4 May 2015 01:56:46 +0000 (UTC) Received: by lbcne10 with SMTP id ne10sf38822837lbc.1 for ; Sun, 03 May 2015 18:56:45 -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=iy3wInVtAwL9s9SW+4iD5RqfMBB7KXHmsqmNBHmAN7lhEbbImw+ryBqRCxBvqRC4ew glNWVQj97ZeLVv1DMf1QFegA/9Lkj/LLI8RWD7UsXzuDmqIonaoa3yAXI2RRPrC6A5KW pBFHNNrpXNEZFMsHDFJMwuh8hqsCh3MgX/X8cf5vshrAlBs11LRHZknY0wSvQsKTVayS 6hdzGHLB8xTvgVZbaYw3wtZq7xYGwSJFcZEK8j4aaSLBUPYaCU5/JBy1BVdwOvnhGflR aZUkLldRm1wdlgHJlvHdIhqhT3ymhALv/1tFvJgdRb0ERaPpL6tYL7igN8o1LO15iLdI AnTg== X-Gm-Message-State: ALoCoQnTiAzBAp2GYz9xvbZECJKaFmwmVZADalLqcVBkDSE4HatUbvX4ivulnzNYnA3WYK083Tqb X-Received: by 10.180.11.101 with SMTP id p5mr6894502wib.3.1430704605462; Sun, 03 May 2015 18:56:45 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.29.66 with SMTP id i2ls715257lah.19.gmail; Sun, 03 May 2015 18:56:45 -0700 (PDT) X-Received: by 10.112.78.105 with SMTP id a9mr17562214lbx.70.1430704605303; Sun, 03 May 2015 18:56:45 -0700 (PDT) Received: from mail-la0-f45.google.com (mail-la0-f45.google.com. [209.85.215.45]) by mx.google.com with ESMTPS id yi7si9113966lbb.14.2015.05.03.18.56.45 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 03 May 2015 18:56:45 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.45 as permitted sender) client-ip=209.85.215.45; Received: by lagv1 with SMTP id v1so94976782lag.3 for ; Sun, 03 May 2015 18:56:45 -0700 (PDT) X-Received: by 10.112.16.196 with SMTP id i4mr17375676lbd.72.1430704605119; Sun, 03 May 2015 18:56:45 -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 l1csp1413269lbt; Sun, 3 May 2015 18:56:44 -0700 (PDT) X-Received: by 10.67.3.3 with SMTP id bs3mr27526804pad.51.1430704603309; Sun, 03 May 2015 18:56:43 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ix6si17838787pac.46.2015.05.03.18.56.42; Sun, 03 May 2015 18:56:43 -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 S1751968AbbEDB4m (ORCPT + 2 others); Sun, 3 May 2015 21:56:42 -0400 Received: from mail-pd0-f171.google.com ([209.85.192.171]:35347 "EHLO mail-pd0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751977AbbEDB4l (ORCPT ); Sun, 3 May 2015 21:56:41 -0400 Received: by pdbqd1 with SMTP id qd1so150115465pdb.2 for ; Sun, 03 May 2015 18:56:41 -0700 (PDT) X-Received: by 10.70.52.103 with SMTP id s7mr37688605pdo.117.1430704601350; Sun, 03 May 2015 18:56:41 -0700 (PDT) Received: from localhost ([180.150.153.1]) by mx.google.com with ESMTPSA id lb1sm11076647pab.39.2015.05.03.18.56.39 (version=TLSv1 cipher=RC4-SHA bits=128/128); Sun, 03 May 2015 18:56:40 -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 40/47] arm/arm64: KVM: Reset the HCR on each vcpu when resetting the vcpu Date: Mon, 4 May 2015 09:52:35 +0800 Message-Id: <1430704362-6292-41-git-send-email-shannon.zhao@linaro.org> X-Mailer: git-send-email 1.9.5.msysgit.1 In-Reply-To: <1430704362-6292-1-git-send-email-shannon.zhao@linaro.org> References: <1430704362-6292-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.45 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; }