From patchwork Wed May 26 05:15:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Righi X-Patchwork-Id: 1483872 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 4FqfLK0vfqz9sWW; Wed, 26 May 2021 15:16:08 +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 1llltj-0001jI-G5; Wed, 26 May 2021 05:16:03 +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 1lllth-0001hg-GS for kernel-team@lists.ubuntu.com; Wed, 26 May 2021 05:16:01 +0000 Received: from mail-ed1-f72.google.com ([209.85.208.72]) by youngberry.canonical.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1lllth-0004DP-5j for kernel-team@lists.ubuntu.com; Wed, 26 May 2021 05:16:01 +0000 Received: by mail-ed1-f72.google.com with SMTP id h18-20020a05640250d2b029038cc3938914so18667348edb.17 for ; Tue, 25 May 2021 22:16:01 -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=alf6IFyQSuQl77FnfeOkt/pSpJewyeh8BG5wTmiNw7E=; b=LmVhN77AqtlA/XRTsO9WaqWPFUdloycESHkHK7/p0Hy9PXS+hYIIJQO0QdgScYW4eU XG6HYz9pTG+U/0q11gho2B09yomFE1P5DLMisteKXZjbeKjjOxCbPV9M5FhpMBOcgEq1 Vic2typs3LzTmsOwUchSkcvG5rY27eRPgTEUXSaJbr2CajZaSDEziKcBmIMHPF+XeioU JUK8wX0EbbvhT1lJeR1Xn/d7tXGxtmDtNCivHRyXmSLH94Q8ePWp8zddXrUk+Y84CPx5 NWdmdOek5dJSPeKpbau9Y+vJ8RcK/6P1vNsgykq3GJDDb3ObiZdrntUnW/2sVMhAMep0 CWHw== X-Gm-Message-State: AOAM53392n9Y4pqHqAunUmQ1/JinkqPKdJ85esiPtalrpak6BSiBwmvN sRijucZzCAxeaT22VUlm3EhN/5Lhq0euVM2Mng70cuCKCZ9XNtoAVuwQQyQVcSsCAJxG4abijBR 4mjf9ri0rS0q0xGp2U99yHksKW6Oq1Z8Xy+UPq5ggWw== X-Received: by 2002:aa7:c7cd:: with SMTP id o13mr13212581eds.269.1622006160851; Tue, 25 May 2021 22:16:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxATyg+TB+Et4lEuvzapIY4ayxyvb8eVEvUj9TqCBRSyVzq/qjawBZNk03KVcm20P8eyioLhw== X-Received: by 2002:aa7:c7cd:: with SMTP id o13mr13212563eds.269.1622006160654; Tue, 25 May 2021 22:16:00 -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 z4sm11704098edc.1.2021.05.25.22.16.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 May 2021 22:16:00 -0700 (PDT) From: Andrea Righi To: kernel-team@lists.ubuntu.com Subject: [SRU][F][PATCH v2 5/5] x86/kvm: Unify kvm_pv_guest_cpu_reboot() with kvm_guest_cpu_offline() Date: Wed, 26 May 2021 07:15:47 +0200 Message-Id: <20210526051547.217632-6-andrea.righi@canonical.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210526051547.217632-1-andrea.righi@canonical.com> References: <20210526051547.217632-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 BugLink: https://bugs.launchpad.net/bugs/1920944 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 3bba064da7ff..4d895bbe9f1e 100644 --- a/arch/x86/kernel/kvm.c +++ b/arch/x86/kernel/kvm.c @@ -359,31 +359,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; @@ -630,6 +605,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