From patchwork Thu May 20 13:41:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Righi X-Patchwork-Id: 1481648 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Fm9rV5pRbz9ssP; Thu, 20 May 2021 23:41:46 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1ljivk-0002bh-OJ; Thu, 20 May 2021 13:41:40 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1ljivg-0002YK-Nf for kernel-team@lists.ubuntu.com; Thu, 20 May 2021 13:41:36 +0000 Received: from mail-ej1-f71.google.com ([209.85.218.71]) by youngberry.canonical.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1ljivg-0000sr-G1 for kernel-team@lists.ubuntu.com; Thu, 20 May 2021 13:41:36 +0000 Received: by mail-ej1-f71.google.com with SMTP id bi3-20020a170906a243b02903933c4d9132so5035593ejb.11 for ; Thu, 20 May 2021 06:41:36 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=v94kv0VaKIqgUGzoyATIUfzXHLgVrJzn/O/ymf2kgqs=; b=UU3gkZUcFM4B4Ykn7M0vW8uVW00ymJlcoTalmXXemQKUTfKRDwQiX/uGgSwxg1cqe0 CzJnrtw6ThgnMmNgyWfaxIZtzOVwe4XOtvT5kCT3GMcCcFL8MZMyJFE6lfH7eZU7f4WF SzRcDGl31ZS9OWzi9rt6u/5eRvLJZBQFVIxA9sXXt6C0Rmo1q0Aw2bYoigQ8WiYkxzR3 obf+OEzVR/93abZ8XBCzk+c46GKq8CftRr3/idyR5u2SaK8vE9UpNSGKz2n/4gx++t9H CWS3W09wdecAjyKUFmkuxYDJdpMpNAFHChUNqHDly09nBcWi1c4SDKuD6UfbQqFaPZgc 5CAA== X-Gm-Message-State: AOAM531H/AhATLBfWlghwGqeHRLOR8Ormimnyu2a+xW4wAk03tMVb/Ps ZnC1OtiYTCsf8YKzylEtZMaUfUmSlhLO6F6mEwrRH7p7ZCGBkj7m0n+ZhVYDzWdZ20QApKXUx1G PuDNtJh25wQFWVLHbwqn41EjAi4wtS/jtu/PHlw6BBQ== X-Received: by 2002:a17:906:7c9:: with SMTP id m9mr4715491ejc.98.1621518096197; Thu, 20 May 2021 06:41:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx+fLdB3v7IequYTHePGwT8E1P4SKWSn3vojYD+cNwUrbZy6euCQLkO20XDh3BtNUUCbuan3A== X-Received: by 2002:a17:906:7c9:: with SMTP id m9mr4715472ejc.98.1621518095895; Thu, 20 May 2021 06:41:35 -0700 (PDT) Received: from xps-13-7390.homenet.telecomitalia.it (host-87-19-3-42.retail.telecomitalia.it. [87.19.3.42]) by smtp.gmail.com with ESMTPSA id l6sm1417576ejc.92.2021.05.20.06.41.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 May 2021 06:41:35 -0700 (PDT) From: Andrea Righi To: kernel-team@lists.ubuntu.com Subject: [SRU][H][PATCH 5/5] x86/kvm: Unify kvm_pv_guest_cpu_reboot() with kvm_guest_cpu_offline() Date: Thu, 20 May 2021 15:41:30 +0200 Message-Id: <20210520134130.40105-6-andrea.righi@canonical.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210520134130.40105-1-andrea.righi@canonical.com> References: <20210520134130.40105-1-andrea.righi@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Vitaly Kuznetsov Simplify the code by making PV features shutdown happen in one place. Signed-off-by: Vitaly Kuznetsov Message-Id: <20210414123544.1060604-6-vkuznets@redhat.com> Signed-off-by: Paolo Bonzini (backported from commit 384fc672f528d3b84eacd9a86ecf35df3363b8ba) Signed-off-by: Andrea Righi --- arch/x86/kernel/kvm.c | 42 +++++++++++++++++------------------------- 1 file changed, 17 insertions(+), 25 deletions(-) diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c index 147281852ca9..478e43c55cb3 100644 --- a/arch/x86/kernel/kvm.c +++ b/arch/x86/kernel/kvm.c @@ -384,31 +384,6 @@ static void kvm_disable_steal_time(void) wrmsr(MSR_KVM_STEAL_TIME, 0, 0); } -static void kvm_pv_guest_cpu_reboot(void *unused) -{ - /* - * We disable PV EOI before we load a new kernel by kexec, - * since MSR_KVM_PV_EOI_EN stores a pointer into old kernel's memory. - * New kernel can re-enable when it boots. - */ - if (kvm_para_has_feature(KVM_FEATURE_PV_EOI)) - wrmsrl(MSR_KVM_PV_EOI_EN, 0); - kvm_pv_disable_apf(); - kvm_disable_steal_time(); -} - -static int kvm_pv_reboot_notify(struct notifier_block *nb, - unsigned long code, void *unused) -{ - if (code == SYS_RESTART) - on_each_cpu(kvm_pv_guest_cpu_reboot, NULL, 1); - return NOTIFY_DONE; -} - -static struct notifier_block kvm_pv_reboot_nb = { - .notifier_call = kvm_pv_reboot_notify, -}; - static u64 kvm_steal_clock(int cpu) { u64 steal; @@ -665,6 +640,23 @@ static void kvm_flush_tlb_others(const struct cpumask *cpumask, native_flush_tlb_others(flushmask, info); } +static void kvm_pv_guest_cpu_reboot(void *unused) +{ + kvm_guest_cpu_offline(true); +} + +static int kvm_pv_reboot_notify(struct notifier_block *nb, + unsigned long code, void *unused) +{ + if (code == SYS_RESTART) + on_each_cpu(kvm_pv_guest_cpu_reboot, NULL, 1); + return NOTIFY_DONE; +} + +static struct notifier_block kvm_pv_reboot_nb = { + .notifier_call = kvm_pv_reboot_notify, +}; + /* * After a PV feature is registered, the host will keep writing to the * registered memory location. If the guest happens to shutdown, this memory