Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp3136318pxb; Mon, 9 Nov 2020 03:41:17 -0800 (PST) X-Google-Smtp-Source: ABdhPJwuv65yLuPA0gJM5DufHFJUBU8gC0tnXXuj2Wo6cxLYocJOefZclCrl/23XIJ0Jeyrc74KT X-Received: by 2002:a17:906:1c8f:: with SMTP id g15mr14290057ejh.179.1604922077219; Mon, 09 Nov 2020 03:41:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604922077; cv=none; d=google.com; s=arc-20160816; b=yDxOF31yaFpKm9RW/gn4vPnGFnqoONKzvJuDK5InQ5ofY6H8ZvBOZtOA0fFgLvwErG 1ynBK4dfc/Wsw0FSwvdu8LxJO5gewa7U5jcNB2DdpG88ZZ+2PRSDd2M8pBijvtF+DkvV E8zS6hoEXXAW22U9P+44cgQJd5Uvn5hc/bThgcwKMCvlJKRaM2GgESNAd0iLAispEmVZ aD9wGweixN69eB+0j5/lGh3zNSuYiCoNu7s5cUSdUaYiy7jEVgK6/F5ZlETu+8UaYw1R KAZShUijoj79FUxGLAA2N/zpLfZYcA7BoMnKzrqOrvth/TeWlEP2zjJNigxQJgMuEu75 u3aw== 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=ng0v5HeSJQOeKhcFpXVkzmD2sfhDn/uEl/qiO47ffRU=; b=o81RZoq2f+zixNpIbErX7oVxgX9zEIn7ykf/NcDjstAesgmjkbmHjeJvDmGSPK34O9 q5tQwynYQDsEhlRjd77i2Sz7KTdyKPN1U1G17/wDlzEnkaXtyLb11a0x7WSiD/GYHr0t o0oqdx+B7rwKWHloewzEJ+cCV4A5ONH+0Gu999CT3V3w5DIzlbl513HKxex9mYX12+VH VzSIjue74OvLB/4o1y9W5jgjOScBReu9j/0LbqcFpy80K0Fu52poXxLNosoM5FEgJMyz 5+eMj2waBSLShcZV6cq9pduSGEwAYC1d1/JSGASvX02FE9KUef5/aKe8QxCjiDS0cpte Qh7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=nXf0x2ZQ; 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 y23si6680478eju.563.2020.11.09.03.40.54; Mon, 09 Nov 2020 03:41:17 -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=nXf0x2ZQ; 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 S1729741AbgKILgZ (ORCPT + 99 others); Mon, 9 Nov 2020 06:36:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35644 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729755AbgKILd1 (ORCPT ); Mon, 9 Nov 2020 06:33:27 -0500 Received: from mail-wr1-x441.google.com (mail-wr1-x441.google.com [IPv6:2a00:1450:4864:20::441]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EEE4DC0613CF for ; Mon, 9 Nov 2020 03:33:25 -0800 (PST) Received: by mail-wr1-x441.google.com with SMTP id l1so3908366wrb.9 for ; Mon, 09 Nov 2020 03:33:25 -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=ng0v5HeSJQOeKhcFpXVkzmD2sfhDn/uEl/qiO47ffRU=; b=nXf0x2ZQSANVYisqiO9zumbyu9XHWzxdyz1ZSIY8GyuKuYfxct4fnI5pSbGiSTFOKJ mveF3t9cZcHU35ZFthj7l3KTs3ZcYkKdoe3VKEu83Sfd5kxl+FtXCFTOixquF4EcYCgw EH0rMfup2e0PVd7xLQh+emTzeQ/efWcJu+mp62Fe+olt7hUpIucBmUJATKQb/DAJa7b0 XskNC0gzRIE8PphGvVPd2oXvFvUt/iF9drRDgP9i7TwTUi1unqdrwycwXbWED+9mzRWy kNVDQRYVy53qymYwRdxJpoF98BHEStzuuxGL2CLfGvP7cUiWsVkbQbbzm86kWZ9LMPPT 4fmw== 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=ng0v5HeSJQOeKhcFpXVkzmD2sfhDn/uEl/qiO47ffRU=; b=YCkuSAVjSzxU+vVg8TxEcgAa4zsa0S7kbLio80/n5Yn6QhQnKMrx0s/oXBi8CunDPl AI8SpEaGfuyEP6RrWTUuHUkR4DaUH8RsNlM0w0vXcJEgCIKk2h22r7NVSEqoCVONlcA2 Kl+N22pFZXNiBYaTgh6oaLyDw730M8pow1EKo+PlzaystwrOKtESUnuug7EV7GR1qaEX FUlwI1RVQxMVKtuPnwR/epa1DJitAUFhWFicnTukaodmUuJnEDLmLb1sqSW6N5y44PZl Xv5I5F8h4m+kBFs34N9D6zlSytzLT5TchLH1ixwQxyNSrfyyM7lIyXOF4KZQ1ajG+0d+ 9dqQ== X-Gm-Message-State: AOAM533SxTanPQwE5cmfeabSSBhGD9Wgz6Gx2HJ1xCCgzRzMc+pjY4tn e3eSmTOtvGdo3CcuQyjYJ2r9IA== X-Received: by 2002:adf:fcc8:: with SMTP id f8mr4853268wrs.331.1604921604594; Mon, 09 Nov 2020 03:33:24 -0800 (PST) Received: from localhost ([2a01:4b00:8523:2d03:209d:10b7:c480:3e1f]) by smtp.gmail.com with ESMTPSA id d3sm12903725wre.91.2020.11.09.03.33.23 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 09 Nov 2020 03:33:23 -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 , Andrew Walbran , kernel-team@android.com, David Brazdil Subject: [PATCH v1 22/24] kvm: arm64: Keep nVHE EL2 vector installed Date: Mon, 9 Nov 2020 11:32:31 +0000 Message-Id: <20201109113233.9012-23-dbrazdil@google.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201109113233.9012-1-dbrazdil@google.com> References: <20201109113233.9012-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 if the kernel was given the protected KVM command line parameter. Signed-off-by: David Brazdil --- arch/arm64/kvm/arm.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c index 452a01afaf33..574aa2d026e6 100644 --- a/arch/arm64/kvm/arm.c +++ b/arch/arm64/kvm/arm.c @@ -1431,7 +1431,8 @@ static void _kvm_arch_hardware_disable(void *discard) void kvm_arch_hardware_disable(void) { - _kvm_arch_hardware_disable(NULL); + if (!is_kvm_protected_mode()) + _kvm_arch_hardware_disable(NULL); } #ifdef CONFIG_CPU_PM @@ -1474,11 +1475,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 (!is_kvm_protected_mode()) + 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 (!is_kvm_protected_mode()) + cpu_pm_unregister_notifier(&hyp_init_cpu_pm_nb); } #else static inline void hyp_cpu_pm_init(void) @@ -1576,7 +1579,8 @@ static int init_subsystems(void) kvm_coproc_table_init(); out: - on_each_cpu(_kvm_arch_hardware_disable, NULL, 1); + if (err || !is_kvm_protected_mode()) + on_each_cpu(_kvm_arch_hardware_disable, NULL, 1); return err; } -- 2.29.2.222.g5d2a92d10f8-goog