From patchwork Tue Jun 30 10:49:03 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Zhao X-Patchwork-Id: 50463 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f69.google.com (mail-la0-f69.google.com [209.85.215.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 8C964229DF for ; Tue, 30 Jun 2015 10:51:15 +0000 (UTC) Received: by lagh6 with SMTP id h6sf2336365lag.0 for ; Tue, 30 Jun 2015 03:51:14 -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=HBwnEQUZtHe54Jk++EnI8qBe36617sOiz6FVQQUMfY12e1Yf+xheWIF25YFREriFLf +osLbq/YMQayiAr7cVwsW38pLXQvgUYWk2YnikTeey/InZdYvhdxD6K+df6wLccG6sTo skDgmW3MNIX8PYaNBZBYC3Z21XrNrpqk5hLHr98mJ/naHeiotrI9TCD6PktjYS9SJJXF fOQ8JqAc+XdMI30fwzJcmgwLpBhux9GkjF+sXVVwmzuw8ltUnU9sg8tt4cdZg5QDOZ+/ yJvt40sSg8C9qHjKhlyR1kxCHb97mBi+x69YqTItyBaN5ihnMG44IF5km5UEM+7dM159 klug== X-Gm-Message-State: ALoCoQnqvvokoAmPmYxT1fLcGpgP36ye7D9W0fVclOg6f4BRX2+2hPodFc1RYKgQYXUTGZ3P8Pel X-Received: by 10.112.253.135 with SMTP id aa7mr2854013lbd.11.1435661474574; Tue, 30 Jun 2015 03:51:14 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.42.206 with SMTP id q14ls22307lal.58.gmail; Tue, 30 Jun 2015 03:51:14 -0700 (PDT) X-Received: by 10.112.137.1 with SMTP id qe1mr18642660lbb.22.1435661474405; Tue, 30 Jun 2015 03:51:14 -0700 (PDT) Received: from mail-la0-f52.google.com (mail-la0-f52.google.com. [209.85.215.52]) by mx.google.com with ESMTPS id pt2si37789548lbb.46.2015.06.30.03.51.14 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 30 Jun 2015 03:51:14 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.52 as permitted sender) client-ip=209.85.215.52; Received: by lagx9 with SMTP id x9so8166194lag.1 for ; Tue, 30 Jun 2015 03:51:14 -0700 (PDT) X-Received: by 10.152.36.102 with SMTP id p6mr18955876laj.19.1435661474228; Tue, 30 Jun 2015 03:51: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 hn6csp2353177lbb; Tue, 30 Jun 2015 03:51:13 -0700 (PDT) X-Received: by 10.67.3.193 with SMTP id by1mr892068pad.21.1435661472422; Tue, 30 Jun 2015 03:51:12 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y5si66313267par.87.2015.06.30.03.51.11; Tue, 30 Jun 2015 03:51: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 S1752220AbbF3KvK (ORCPT + 2 others); Tue, 30 Jun 2015 06:51:10 -0400 Received: from mail-pd0-f177.google.com ([209.85.192.177]:35206 "EHLO mail-pd0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752351AbbF3KvK (ORCPT ); Tue, 30 Jun 2015 06:51:10 -0400 Received: by pdbci14 with SMTP id ci14so4273515pdb.2 for ; Tue, 30 Jun 2015 03:51:09 -0700 (PDT) X-Received: by 10.68.215.66 with SMTP id og2mr41606885pbc.20.1435661469595; Tue, 30 Jun 2015 03:51:09 -0700 (PDT) Received: from localhost ([120.136.36.232]) by mx.google.com with ESMTPSA id c7sm45120268pbu.60.2015.06.30.03.51.07 (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 30 Jun 2015 03:51:08 -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 15/22] arm/arm64: KVM: Reset the HCR on each vcpu when resetting the vcpu Date: Tue, 30 Jun 2015 18:49:03 +0800 Message-Id: <1435661350-8060-16-git-send-email-shannon.zhao@linaro.org> X-Mailer: git-send-email 1.9.5.msysgit.1 In-Reply-To: <1435661350-8060-1-git-send-email-shannon.zhao@linaro.org> References: <1435661350-8060-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.52 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; }