From patchwork Wed Nov 4 18:36:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Brazdil X-Patchwork-Id: 11881923 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 95190C2D0A3 for ; Wed, 4 Nov 2020 18:42:50 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 15C86206C1 for ; Wed, 4 Nov 2020 18:42:50 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="XiQsLc1U"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=google.com header.i=@google.com header.b="Wd2U/unp" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 15C86206C1 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version: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=pyQsG0Ruz0OpRYTI4tEcyCVltw5cXpqR9bG8dN06IVQ=; b=XiQsLc1UfZdwYlReLgSGndobn P9hSXRIJJEre6NUa3HCQo2RKDnpclbkVJI8FEkwVW2c7o97Xdqn9EiMVjG7KLnQspV20+uqilN9sN dGfkYjA0DSvlgL6IW1ibPH9mV6IIikvgWODLOr09u0tEwkkmws03ruOOIebKMWyoA2Mq/FBEaz398 saBXHuS3hLa13C5HKQSTPEwuBhjiGBEAi56Yf/JhEXVbjKVkJXTHIup1DqkUOEqonSBmIlpVrrh6F hJRQ/G22rlx11W3Xv61W10RDMrC7Ho2dK4IAHnvvLDIHkY+itI4l11FpjRyXFlOGvRBqWLQXtdi6N 3X/Dag8Aw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kaNiM-0004Cj-OY; Wed, 04 Nov 2020 18:40:58 +0000 Received: from mail-wm1-x344.google.com ([2a00:1450:4864:20::344]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kaNf1-0001yM-BF for linux-arm-kernel@lists.infradead.org; Wed, 04 Nov 2020 18:37:32 +0000 Received: by mail-wm1-x344.google.com with SMTP id k18so3266875wmj.5 for ; Wed, 04 Nov 2020 10:37:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=EXNwt+3vSlZrX0Tc14BJDd1gNrfJjl5kGrrEIH8XAj4=; b=Wd2U/unpY3ZmVHfcTbXAiJY7KLJhty+qkCnEOe1v+9gF7Tk+esJECns+5NE7xRADVQ rb4jMmrIrDFF3Uqc+kw+TsQP0kUBbP0Q60mBlfNxiHzEXnQZF440tMQx2el8T+naYfSe nl6S2po85sezmLtPjaY/udhRbTngUIYz9zKldqnrNaoNQummnBHmMim25jYYlhSDGnMB Cuq7Q+xfCJoLb+/MPsBLXPPSxHnCmLW/mhKnoYOoXXFQRNHjTAzA522j5kTSmzHtOXCP IKtntiI2vPQxFCCjANt2TbA2A8r58wUouHeIdCcZ/vjLL7AFsxzBAHJM1tvSTiqOAKAb /xjQ== 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:mime-version:content-transfer-encoding; bh=EXNwt+3vSlZrX0Tc14BJDd1gNrfJjl5kGrrEIH8XAj4=; b=ebWrXbI/yLJ4aDcieUoZKbJs8AQSZveWPwppcweR+w0UK79vTRnx4DDvbzTxNmr0fU 89ZL9uwPJNjM+3eQKpPnd99Uo4eGkME8qTIzxBYb1L+49GKQw8zfyEh3YVKrnK40U4KR GWaTUCIvNlKWkCa5gihiOq2Yd0gWPsH1Wdf8y/s4ryEk3l/z3rMQ5ZpFczyEd8OE0mpz IWEHDFxKJ0SRY986fBIX1r0HdMnfu0BlFhJFbqtmxZV57ElVR5w5z6eZ6o4NZHyDIIAb 0pPmHfjwBOZ4paOyeQycfI/hWsgA1ZskjikxIseZF8ftZLhSnwnQxJoH3UQu1nzJjHER EAjA== X-Gm-Message-State: AOAM530IZ4EZu5aNLCpSuTnjJPSeW9daKQg3P8jo3nx8lBtE25oPB6vI pDAcE9i5MOIECd5XP3ddxBjLpg== X-Google-Smtp-Source: ABdhPJwYR8Ha03TCz1M7oXikmCAwIAt1jt3ItFF9iYz0IjOXIOyB9xrETMaJm4+yQW9aUe1KTMy7ig== X-Received: by 2002:a7b:c401:: with SMTP id k1mr5901008wmi.120.1604515050112; Wed, 04 Nov 2020 10:37:30 -0800 (PST) Received: from localhost ([2a01:4b00:8523:2d03:c8d2:30f2:53c6:bc2]) by smtp.gmail.com with ESMTPSA id h4sm3635371wrp.52.2020.11.04.10.37.28 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 04 Nov 2020 10:37:28 -0800 (PST) From: David Brazdil To: kvmarm@lists.cs.columbia.edu Subject: [RFC PATCH 24/26] kvm: arm64: Keep nVHE EL2 vector installed Date: Wed, 4 Nov 2020 18:36:28 +0000 Message-Id: <20201104183630.27513-25-dbrazdil@google.com> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201104183630.27513-1-dbrazdil@google.com> References: <20201104183630.27513-1-dbrazdil@google.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201104_133731_451107_01D62BBE X-CRM114-Status: GOOD ( 16.74 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , Lorenzo Pieralisi , kernel-team@android.com, Suzuki K Poulose , Marc Zyngier , Quentin Perret , linux-kernel@vger.kernel.org, James Morse , linux-arm-kernel@lists.infradead.org, Catalin Marinas , Tejun Heo , Dennis Zhou , Christoph Lameter , David Brazdil , Will Deacon , Julien Thierry , Andrew Scull Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org KVM by default keeps the stub vector installed and installs the nVHE vector only briefly for init and later on demand. Change this policy to install the vector at init and then never uninstall it. Signed-off-by: David Brazdil --- arch/arm64/kvm/arm.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c index 6fbda652200b..3dff6af69eca 100644 --- a/arch/arm64/kvm/arm.c +++ b/arch/arm64/kvm/arm.c @@ -64,6 +64,11 @@ static bool vgic_present; static DEFINE_PER_CPU(unsigned char, kvm_arm_hardware_enabled); DEFINE_STATIC_KEY_FALSE(userspace_irqchip_in_use); +static bool keep_hyp_installed(void) +{ + return !is_kernel_in_hyp_mode(); +} + int kvm_arch_vcpu_should_kick(struct kvm_vcpu *vcpu) { return kvm_vcpu_exiting_guest_mode(vcpu) == IN_GUEST_MODE; @@ -1430,7 +1435,8 @@ static void _kvm_arch_hardware_disable(void *discard) void kvm_arch_hardware_disable(void) { - _kvm_arch_hardware_disable(NULL); + if (!keep_hyp_installed()) + _kvm_arch_hardware_disable(NULL); } #ifdef CONFIG_CPU_PM @@ -1473,11 +1479,13 @@ static struct notifier_block hyp_init_cpu_pm_nb = { static void __init hyp_cpu_pm_init(void) { - cpu_pm_register_notifier(&hyp_init_cpu_pm_nb); + if (!keep_hyp_installed()) + cpu_pm_register_notifier(&hyp_init_cpu_pm_nb); } static void __init hyp_cpu_pm_exit(void) { - cpu_pm_unregister_notifier(&hyp_init_cpu_pm_nb); + if (!keep_hyp_installed()) + cpu_pm_unregister_notifier(&hyp_init_cpu_pm_nb); } #else static inline void hyp_cpu_pm_init(void) @@ -1580,7 +1588,8 @@ static int init_subsystems(void) kvm_coproc_table_init(); out: - on_each_cpu(_kvm_arch_hardware_disable, NULL, 1); + if (err || !keep_hyp_installed()) + on_each_cpu(_kvm_arch_hardware_disable, NULL, 1); return err; }