From patchwork Sun Apr 23 17:09:13 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 9695165 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 6EEAD601E9 for ; Sun, 23 Apr 2017 17:33:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 69EBB209D8 for ; Sun, 23 Apr 2017 17:33:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5C9BF262F2; Sun, 23 Apr 2017 17:33:43 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id E906C209D8 for ; Sun, 23 Apr 2017 17:33:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=OjI1/uv/OXwUtfm7mHENGHbe7qe47hfkbtQ/chW+qZ0=; b=hy5lfZBJ5RZeVSLZG9p5d7chYD fepDfCheljJv2iL3O0HNaYu7v7H2e59huA7X8a3+JftEfotMiX9DV/RPezHVduMnpL3HtwU7z5XsX ukMetgKfQ9NXfPHeNzI+de9tPRO37PnlM4NdCGG+V1123KrYl9rtNH2EflDRUfQICiG5B82cFenLy HrfqrejXj+d/jKeqETVFEbVBztU/B4gKtSbmU05RlAAa2YBOlC/TREEOOKvH9MM/blI793KGrBOWM L+uNFMui9DtxQgrOZ10+g9mOPLaEeGy7l9OHvUURCLn48JyCCBjXT71cIRe/UyaZYCiSDuPV7uP5m cy6RsMMg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1d2LOA-0005fv-Aa; Sun, 23 Apr 2017 17:33:34 +0000 Received: from merlin.infradead.org ([2001:4978:20e::2]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1d2LLu-0002ZO-1c for linux-arm-kernel@bombadil.infradead.org; Sun, 23 Apr 2017 17:31:14 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=SKMLYRSxI1OoUuC8NMH0ysRPc5AdFiW/jvswS3SzbRo=; b=MbmTVfFgL6XvUdISLK0P9iJ7d wQtiYD9HkjrDZJYV1VRtBkejv3MgvCZd2oXxlZCP70Wk63VHS7md+SZ2HyPlGZ9m9K6ldTU0dg8FB xRbU0u7VkD/t6QnP/IfoNm++FPfvoDd69A6aPHFzGDy2BAn0mZLHPpuWut/vDw7Qiz47udoTb9en3 g4W7yd7naXJXMo/TRWnVx7f7vo28wk0M4kQ90wszkXrSegf9VggfltESvvC0fXcElWJt/jcJ02+U+ +XuacZQEyaydsGQIA+GADXhmwOjX7YQk5rzwytiCJc1bMmGdwElXeKWVNah+uS5ukGTlfZKh0R6vx oYKFgFzNg==; Received: from mail-wm0-x234.google.com ([2a00:1450:400c:c09::234]) by merlin.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1d2L4G-0005R0-8w for linux-arm-kernel@lists.infradead.org; Sun, 23 Apr 2017 17:13:01 +0000 Received: by mail-wm0-x234.google.com with SMTP id w64so46380201wma.0 for ; Sun, 23 Apr 2017 10:12:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=SKMLYRSxI1OoUuC8NMH0ysRPc5AdFiW/jvswS3SzbRo=; b=DdS0YI24YnpUV2KFPnLW2tv8plWfPbfxYQd4RcQa6+oegjDO1EXR+4WnMMsxG6Mqzh BnX8S+aMeurdj2kOlY4CZfmKgXpFLEh7EWG8y2X4GvWbB4TMQteJGanJ+EBZVzNwnO4j M2L2wRpVRJ6sHKPSCO1XvUjeP6ItBDEfItvys= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=SKMLYRSxI1OoUuC8NMH0ysRPc5AdFiW/jvswS3SzbRo=; b=JXxbCaj3PMXEqmyWCiG+i1AsQ14jb5Gx61WKC1QrfrGIZ+Yu35DM3aKnCZCyNvq9S3 cZYXuDBebhzSGfn5KN/yOEehHak4nEs8zEZAGADmQ9f0L0LzJSpyE7Ksah4j5X/Lq0lS b3XCp03Zilhllg3Ve86gOhRQCJnRjk6Hi2qj8m8WiFgRuTXBKAO4eVo9X3xR+nxAtLbo kFjTK3MEqat8QLUOqNbeS48HxC32SdfPsmcnUv2uKVkyXLrpSnKCFZ560SxI27iSjS58 Wq8o8thpPg8meXmqEfe60zfcIDLtzs/iYh8IxSV2t0zujRSxQUJUVQ9FtjycZPf+1JF/ wbXQ== X-Gm-Message-State: AN3rC/46Zkb53e4raNjCdiZJefjtVL2lhsrKSEfnnQieEdMGMdy4lSF7 OS475SioyMKKI7vf X-Received: by 10.80.151.101 with SMTP id d34mr133409edb.13.1492967438482; Sun, 23 Apr 2017 10:10:38 -0700 (PDT) Received: from localhost.localdomain (xd93ddc2d.cust.hiper.dk. [217.61.220.45]) by smtp.gmail.com with ESMTPSA id 58sm2803521edz.2.2017.04.23.10.10.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 23 Apr 2017 10:10:37 -0700 (PDT) From: Christoffer Dall To: Paolo Bonzini , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= Subject: [PULL 63/79] arm/arm64: KVM: Use HVC_RESET_VECTORS to reinit HYP mode Date: Sun, 23 Apr 2017 19:09:13 +0200 Message-Id: <20170423170929.27334-64-cdall@linaro.org> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20170423170929.27334-1-cdall@linaro.org> References: <20170423170929.27334-1-cdall@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170423_131300_451540_9D834722 X-CRM114-Status: GOOD ( 14.06 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Marc Zyngier , Christoffer Dall , kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Marc Zyngier Instead of trying to compare the value given by __hyp_get_vectors(), which doesn't offer any real guarantee to be the stub's address, use HVC_RESET_VECTORS to make sure we're in a sane state to reinstall KVM across PM events. Acked-by: Catalin Marinas Signed-off-by: Marc Zyngier Signed-off-by: Christoffer Dall --- arch/arm/kvm/arm.c | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/arch/arm/kvm/arm.c b/arch/arm/kvm/arm.c index c8f4fa6..c378502 100644 --- a/arch/arm/kvm/arm.c +++ b/arch/arm/kvm/arm.c @@ -53,7 +53,6 @@ __asm__(".arch_extension virt"); static DEFINE_PER_CPU(unsigned long, kvm_arm_hyp_stack_page); static kvm_cpu_context_t __percpu *kvm_host_cpu_state; -static unsigned long hyp_default_vectors; /* Per-CPU variable containing the currently running vcpu. */ static DEFINE_PER_CPU(struct kvm_vcpu *, kvm_arm_running_vcpu); @@ -1113,8 +1112,16 @@ static void cpu_init_hyp_mode(void *dummy) kvm_arm_init_debug(); } +static void cpu_hyp_reset(void) +{ + if (!is_kernel_in_hyp_mode()) + __hyp_reset_vectors(); +} + static void cpu_hyp_reinit(void) { + cpu_hyp_reset(); + if (is_kernel_in_hyp_mode()) { /* * __cpu_init_stage2() is safe to call even if the PM @@ -1122,17 +1129,10 @@ static void cpu_hyp_reinit(void) */ __cpu_init_stage2(); } else { - if (__hyp_get_vectors() == hyp_default_vectors) - cpu_init_hyp_mode(NULL); + cpu_init_hyp_mode(NULL); } } -static void cpu_hyp_reset(void) -{ - if (!is_kernel_in_hyp_mode()) - __hyp_reset_vectors(); -} - static void _kvm_arch_hardware_enable(void *discard) { if (!__this_cpu_read(kvm_arm_hardware_enabled)) { @@ -1316,12 +1316,6 @@ static int init_hyp_mode(void) goto out_err; /* - * It is probably enough to obtain the default on one - * CPU. It's unlikely to be different on the others. - */ - hyp_default_vectors = __hyp_get_vectors(); - - /* * Allocate stack pages for Hypervisor-mode */ for_each_possible_cpu(cpu) {