From patchwork Wed May 26 05:19:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Righi X-Patchwork-Id: 1483882 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 4FqfQ66WB6z9sW8; Wed, 26 May 2021 15:19:26 +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 1lllww-0002R8-Jd; Wed, 26 May 2021 05:19:22 +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 1lllwv-0002Q9-7T for kernel-team@lists.ubuntu.com; Wed, 26 May 2021 05:19:21 +0000 Received: from mail-ed1-f71.google.com ([209.85.208.71]) by youngberry.canonical.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1lllwu-0004Sy-W9 for kernel-team@lists.ubuntu.com; Wed, 26 May 2021 05:19:21 +0000 Received: by mail-ed1-f71.google.com with SMTP id i3-20020aa7dd030000b029038ce772ffe4so18767799edv.12 for ; Tue, 25 May 2021 22:19:20 -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=HmJa7XiuduQ6fZYu95Dcnb9dN8tmy3tEsAwkvb6vQO4=; b=hu/CSBStd9dDSo5szD3B+lnUDpMAOHAoGkTmLhTFylXt9CBqtzdX5fgc0lPqr9YcSl KqQdm/tWR292XzToe/E1F+F+2STPG3jk4r50uSbbyC76GXjiFoldYAvG6M4Yokt4RE9a BZmKCnUCx4F2ub1ik97WNe6Q9UJyIilibMoEwN+iapHQEgZ6m0tQZIz+Bbj28rWTd/3I 3+4BsM7dNjoa/3U9Dq5nOZB1BlQh+co5stqr1s5Jsx97ioVMMlbMDJZzIR4xF2cGMUoq BKeVF+8FdAv0n8gZjJVZYAobj6OeaG6zL/Rn+Ieyd/KMOVXoVi3KKSDqiOi/ojDwh55h Nltw== X-Gm-Message-State: AOAM533IE2k9u9e53JbO+5FJJiDDMzpXw08JSu0coMdEtokN/E0zJiE3 zsPYrzrC6/rj0JqgCYyN8JkG7y2kuwjcAumWbuD2AgPWl6kiXsT/DnbhB1bO/FGkS1XlbrgYVOh UNIBlMQvVTW+yIKJT0N2vux1JOV68IMBwGQbf6G0zDg== X-Received: by 2002:a05:6402:3488:: with SMTP id v8mr34960168edc.51.1622006360736; Tue, 25 May 2021 22:19:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz8XghhSzL0H5XbKULP+cjJqSxS9P5S4QHPlW7t062YV0iYGRe+fWjooa0dooE7lXNqCGb2Ig== X-Received: by 2002:a05:6402:3488:: with SMTP id v8mr34960156edc.51.1622006360564; Tue, 25 May 2021 22:19:20 -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 t19sm12131888eds.4.2021.05.25.22.19.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 May 2021 22:19:20 -0700 (PDT) From: Andrea Righi To: kernel-team@lists.ubuntu.com Subject: [SRU][H][PATCH v2 5/5] x86/kvm: Unify kvm_pv_guest_cpu_reboot() with kvm_guest_cpu_offline() Date: Wed, 26 May 2021 07:19:15 +0200 Message-Id: <20210526051915.218316-6-andrea.righi@canonical.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210526051915.218316-1-andrea.righi@canonical.com> References: <20210526051915.218316-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 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