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: 9695057 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 52C1660245 for ; Sun, 23 Apr 2017 17:13:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3E32F26530 for ; Sun, 23 Apr 2017 17:13:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 330FA265B9; Sun, 23 Apr 2017 17:13:50 +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=-6.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D78F926530 for ; Sun, 23 Apr 2017 17:13:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1162394AbdDWRNs (ORCPT ); Sun, 23 Apr 2017 13:13:48 -0400 Received: from mail-wm0-f54.google.com ([74.125.82.54]:36775 "EHLO mail-wm0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1162294AbdDWRKj (ORCPT ); Sun, 23 Apr 2017 13:10:39 -0400 Received: by mail-wm0-f54.google.com with SMTP id u65so7508353wmu.1 for ; Sun, 23 Apr 2017 10:10:39 -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=nsmVUgfL/JmDnTth2QqmTqDhbc6SaTLwpB3qht3sjDS4T70vQV0kC+YWXh7uSN4YSQ ba8+EIP6zCGTylPrTxC0U07LnbaFlf0um/efQng7f9qi2zKWls94yDJVhP1eTII50V2o WiHknlGbZbtMytN/jIx6nA0Mw+5tDFAqUMoUlrnzM50uqbUSLmtRAJcNA3s8O1WeCjgQ bjrenzsrr8PL5bJLfs2MjncUc9gSWENhvG+iq816EFpYb+cea1KtyAMH7QnjQXndikxH exOuxIeR7gEacmAzkk1qSrEvcuK528JSm0TDnRbHsGpMF8SMnHvW1xCG1K+/Ewfovw26 h/yw== X-Gm-Message-State: AN3rC/7rUTzpAucI/gVu6flW09KC7s6FIeMvwoq0cqaZw3l5xtDE/nhm gdib4pS6DQj7eIiT 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?= Cc: Marc Zyngier , kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Christoffer Dall 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> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.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) {