From mboxrd@z Thu Jan 1 00:00:00 1970 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=-20.4 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT,USER_IN_DEF_DKIM_WL 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 1D672C2D0A3 for ; Mon, 9 Nov 2020 11:36:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 85D51205CA for ; Mon, 9 Nov 2020 11:36:27 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="nXf0x2ZQ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729811AbgKILgZ (ORCPT ); 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-Google-Smtp-Source: ABdhPJwGtO+bLBkGK5zcf5ADJI23gPkHLtLWoYJFJD2sI6sOe+pvFe7IA5c+39hGs9VXzBBrk6IBZQ== 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 From mboxrd@z Thu Jan 1 00:00:00 1970 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.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,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 17A01C388F7 for ; Mon, 9 Nov 2020 11:33:33 +0000 (UTC) Received: from mm01.cs.columbia.edu (mm01.cs.columbia.edu [128.59.11.253]) by mail.kernel.org (Postfix) with ESMTP id 83F5B20731 for ; Mon, 9 Nov 2020 11:33:32 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=google.com header.i=@google.com header.b="nXf0x2ZQ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 83F5B20731 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvmarm-bounces@lists.cs.columbia.edu Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 205DA4B888; Mon, 9 Nov 2020 06:33:32 -0500 (EST) X-Virus-Scanned: at lists.cs.columbia.edu Authentication-Results: mm01.cs.columbia.edu (amavisd-new); dkim=softfail (fail, message has been altered) header.i=@google.com Received: from mm01.cs.columbia.edu ([127.0.0.1]) by localhost (mm01.cs.columbia.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id umJRf6LPc2VD; Mon, 9 Nov 2020 06:33:31 -0500 (EST) Received: from mm01.cs.columbia.edu (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 115D04B75B; Mon, 9 Nov 2020 06:33:30 -0500 (EST) Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 3AB7D4B75B for ; Mon, 9 Nov 2020 06:33:27 -0500 (EST) X-Virus-Scanned: at lists.cs.columbia.edu Received: from mm01.cs.columbia.edu ([127.0.0.1]) by localhost (mm01.cs.columbia.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id bgI4IVqKIyu3 for ; Mon, 9 Nov 2020 06:33:26 -0500 (EST) Received: from mail-wr1-f68.google.com (mail-wr1-f68.google.com [209.85.221.68]) by mm01.cs.columbia.edu (Postfix) with ESMTPS id CDA554B56B for ; Mon, 9 Nov 2020 06:33:25 -0500 (EST) Received: by mail-wr1-f68.google.com with SMTP id c17so8291118wrc.11 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=h8iswIUzUR0be+7LXA0dpUXkyY7EnrWHy8rM5O/xLZjJ+m9VJwq3+wzFIs0gSHfQiJ rbF44ZMFRwpj4mbS9Ar49cg/awviF9ogakVYan5ZG6O8t9ZqCdrGHrhtOLZ1wHQBaHTe 2r3fcxh0oM4u8WDaYXGuRDLGwIgll2UtAs+w9z4wU0kh/gkLVBERGpEoJnUQQVVRdPIY QSyIriK3tyyAUqGH9GkqQeFkryMR+YGlzXWEMQ/sq/a6Mwm+NSxVBFagsTgYMOBLFi2A hldveQd29j94qaYlqqv8usMjKfCfhYPpOGigrols1Dz8pGEQ+kz1OCVIa0eghdw8XVfL M/Dw== X-Gm-Message-State: AOAM532jk66nLaAktZhFw7i9C1dJQqnwdvR0HdMSrkjVvhBm8p9yocko +5nGh0zthe6Uu0lYCfup3YmlH0hIQTqGMvvf X-Google-Smtp-Source: ABdhPJwGtO+bLBkGK5zcf5ADJI23gPkHLtLWoYJFJD2sI6sOe+pvFe7IA5c+39hGs9VXzBBrk6IBZQ== 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 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 Cc: kernel-team@android.com, Lorenzo Pieralisi , Andrew Walbran , Marc Zyngier , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Catalin Marinas , Tejun Heo , Dennis Zhou , Christoph Lameter , Will Deacon X-BeenThere: kvmarm@lists.cs.columbia.edu X-Mailman-Version: 2.1.14 Precedence: list List-Id: Where KVM/ARM decisions are made List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: kvmarm-bounces@lists.cs.columbia.edu Sender: kvmarm-bounces@lists.cs.columbia.edu 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 _______________________________________________ kvmarm mailing list kvmarm@lists.cs.columbia.edu https://lists.cs.columbia.edu/mailman/listinfo/kvmarm From mboxrd@z Thu Jan 1 00:00:00 1970 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.8 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 A1C0AC388F7 for ; Mon, 9 Nov 2020 11:41:42 +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 16EAE20684 for ; Mon, 9 Nov 2020 11:41:42 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="DMGTFFie"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=google.com header.i=@google.com header.b="nXf0x2ZQ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 16EAE20684 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=CHVQi7foJVC5wzPov1R4jUcitAUHv73GjjJQYb/9POI=; b=DMGTFFieJ1HvoZdW/u7SUjqgr HXukMAYchs3E/p/IpnJtZuMB1K7O+rPtsa0txsuKi92YlygXZZXlaPy6u6veqDC0YpxWvGtPVImrn KxiWOS38Jqwz5x0BP2sdwALtakPeWylkSCOe0jfTMY7xhv8DcA8iYl1uydjUnvjY8TWnnQXpI2ZG1 XF3Acf8y8HNMPtEjTKFehZwdUcCFNCT9pxDve3bM3RzHOtNAg2El+v24LMwBKnDrspf61Ow4rMYiH DL824m883U5AvRKKovpj/SQ5DQn3coQBkOjN8P+FIq6M6A6Wkqr9lwlWIWFkf1YQSGFt7QDOuQrPW 1iSJ2cfLg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kc5WF-0007Xi-ND; Mon, 09 Nov 2020 11:39:31 +0000 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kc5QM-0004aD-WA for linux-arm-kernel@lists.infradead.org; Mon, 09 Nov 2020 11:33:39 +0000 Received: by mail-wr1-x441.google.com with SMTP id k2so4916322wrx.2 for ; Mon, 09 Nov 2020 03:33:26 -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=dkHxIV1bWpzEBOYkyF/IuChlm81Za99P+EpuKZpalHr+FiHTXe/vWMofVAHTg+rt00 kizSnTt9GXw4vmdY4PSxXHUyJWPL/3G2ZOn80KFNNlqmM7/0fw4/iT6LrK7TOKC4097B vtKh49s+Sx0dZ7FLIsS64pMRBCJO4PsgFPlCv2vAIDqpVL9MG+pk24EDBzOVb/U9pVxf 8ZyfzIHT2cFAIZ+aVdhF15071N8YwxuSdevDuuBaUO1SOnuPzE3AU6DfSBIK2mxm/PrT 3be5UFq2KZDuMB5eJ2fgabTVsHYaW3Gxc2AkTn5sYIBItuZfeFkOsaLKKMd77Lk7iM1g +oLg== X-Gm-Message-State: AOAM531h1qdXP1b+Gjpx7mk4i0nf5FcBzf810K1I5MKqBMPTlrKmc/uU zRtjqjMdSOEDIW6ApyTxry8vZg== X-Google-Smtp-Source: ABdhPJwGtO+bLBkGK5zcf5ADJI23gPkHLtLWoYJFJD2sI6sOe+pvFe7IA5c+39hGs9VXzBBrk6IBZQ== 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 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201109_063327_406336_5315AA4D X-CRM114-Status: GOOD ( 16.94 ) 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 , kernel-team@android.com, Lorenzo Pieralisi , Andrew Walbran , 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 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 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 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 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel