Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp1524557pxb; Wed, 4 Nov 2020 11:14:58 -0800 (PST) X-Google-Smtp-Source: ABdhPJyPvi9tqkLUiVbmmEYbNF77P29mGxiWBn4IMs5fsuMALYWmJeIVgR5C7o4J3RAW9PnIzJNB X-Received: by 2002:a50:b5e1:: with SMTP id a88mr18904818ede.5.1604517298686; Wed, 04 Nov 2020 11:14:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604517298; cv=none; d=google.com; s=arc-20160816; b=YdeSF39n5pHw4okrXhJjVyh2s1GBIXKFCV9J3uqCMyfYZF3UvD/C2en3RP8vJOrSnm CxPCuKbpRSFqbGu6ECB6S+YULzEFDTai8L1Q244iG8zDtUITP3ikRS6Y9BEeIasnuoE3 QDCtZC9sM6IpAuyFYzYPf0teW7p5SvfHDqvW0pI+LOCS5WfmXMPFtqARZ+6Y4Q2xdEvM 6x4WswjUiEoVilIRN1GCYGaL8RWRNSn0o2OJ0fLgbt2WVdIqeRGSeHpVZJzCkHzMhdvK wrDSg0gJKybLnoFOnPb2qB16iOGdjUgcVgDn8fJUh3nGjrcr+14sakYNayYz+0G/fCV/ vIpA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=EXNwt+3vSlZrX0Tc14BJDd1gNrfJjl5kGrrEIH8XAj4=; b=cnaOJpK159+RxSrJyGB7lQUySwnhIYQewEP5HoMxSd7900CAo9JyqBacIOD89Ngg/1 4D4ZxE9Q/ZX+bpZzihVQaC2Q/XHK9AodlMxbjtXQM6+vKLEorZkMVr6FF2uiPL0EsWi2 so/pmUPPqAKYFVCw4p3Z3evBq7VC2elTwFj6WV6eFmv5UD9XXaWZKl713iFQRJ9SuKhC +X06SvTaDcDOMkD9jI9g8EF58RYvGgofSbUPfBo1+RADp1x+pgIjB2Wet0Z2IkPVBhxA A+t1zEc1wHg7curAhxf10QpciKmzlXoO2OnSPg4F+hQVyYCS+icKBfOj3TplsLY/L5UI eSRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="Wd2U/unp"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j25si1906165edp.225.2020.11.04.11.14.36; Wed, 04 Nov 2020 11:14:58 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="Wd2U/unp"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731307AbgKDShe (ORCPT + 99 others); Wed, 4 Nov 2020 13:37:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56592 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732597AbgKDShc (ORCPT ); Wed, 4 Nov 2020 13:37:32 -0500 Received: from mail-wm1-x341.google.com (mail-wm1-x341.google.com [IPv6:2a00:1450:4864:20::341]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9117DC0613D3 for ; Wed, 4 Nov 2020 10:37:31 -0800 (PST) Received: by mail-wm1-x341.google.com with SMTP id h62so3288185wme.3 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=pJDbsyRFs4JFfXsFfZQ1QuCm1+0z+r4bFBuXVAMxyv7HNRlO0s2RYAXxU4GPEySihi /9ZpJuE3tYHUsJKJ5YC6Nq7xt+/boafnBFOoYSkPQfjrUgQyIPjr+9SAXFsoLNoNc1jR ZqNY1WDiwCk5DEMsLLfA+GC1IH4YjGvp0s0cTo4M2aGEFTwB2BTG+aW/++7j0JmfrIof 6x1KZp13qKe9Tkay3wfKJoIB/n/ztny2fM3uSTSI783DUU0rd1bjehujsQSi9bkX+JFp jWyNLlZeu6XKnxBD05Mu6Ij7HbEHOUvwgDaROf5bkC9wbwsROZXYxEp42HWJURnz2e1j AbkQ== X-Gm-Message-State: AOAM530+/vqNpolSjY7Ycs442XDnvXw2JfauGxQnfqsMQYgnLF8z8Nst 1Jerk6jQhUYNd+3RDLtx90T/TQ== 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 Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Marc Zyngier , James Morse , Julien Thierry , Suzuki K Poulose , Catalin Marinas , Will Deacon , Dennis Zhou , Tejun Heo , Christoph Lameter , Mark Rutland , Lorenzo Pieralisi , Quentin Perret , Andrew Scull , kernel-team@android.com, David Brazdil 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 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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; } -- 2.29.1.341.ge80a0c044ae-goog