From patchwork Thu May 20 13:36:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Righi X-Patchwork-Id: 1481631 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 4Fm9kK6xQ4z9sj1; Thu, 20 May 2021 23:36:25 +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 1ljiqb-0001db-Op; Thu, 20 May 2021 13:36:21 +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 1ljiqZ-0001cH-RQ for kernel-team@lists.ubuntu.com; Thu, 20 May 2021 13:36:19 +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 1ljiqZ-0000M3-I9 for kernel-team@lists.ubuntu.com; Thu, 20 May 2021 13:36:19 +0000 Received: by mail-ed1-f72.google.com with SMTP id cy15-20020a0564021c8fb029038d26976787so8100931edb.0 for ; Thu, 20 May 2021 06:36:19 -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=KWBH0tVXNgdPmX/G7hwjrcAvCxOadHv8ebbRVu9uAiY=; b=Ixo2YXVT80LoJXto9HXXTK0nrwHMkmyJuU1JOmSq9hH0+Io53UwzThtTSLfS5z6Byq juompVwVRQg47f6JxdGhiiZtMfJtYsw3tC7Fww7COOstDEDDlzcdG4K5SEnvpsYYcHq2 9qUpjmN5TWSxi1cCrs93FK1Pkx+EUC0yClOqZnK8S7UNA4YwKXzDd37Gca8uY94yeslH 0KHXgyT3aFIn2kQS4mGoFG35DW+FZy+GcUhChjSCRQmbWJ7Tv/dhidrPfIKS+2To0HnI QhoCeZA9rXysXThAdstgEHIKvEHyHh3jP/CocoxLxuTaSL0dCm6JjDDpJnCJTpQrbd5V wG8w== X-Gm-Message-State: AOAM533rhUZjnG4f3h+obVJ9y6saPoRTBCral6BHknTARzB/EmsucMhm fKNg4SI6mphRviwGBOktTbDqblAeA06y6G+4x1K1a/1klK+po1bzes+guMBSIv2hwAQAh7kouZl AGu8VDA30g/K97EOW0YEV2eaPyCI5mHJ2sLbCxITCVQ== X-Received: by 2002:a17:906:fb88:: with SMTP id lr8mr4743122ejb.429.1621517779221; Thu, 20 May 2021 06:36:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxLQsaYZnUt2d8FvtGrODtMqw+xJh7qNQDgFcOxtppFkk0iOW2ahC/iWOWWBHBdwzfM7gwdjA== X-Received: by 2002:a17:906:fb88:: with SMTP id lr8mr4743098ejb.429.1621517778946; Thu, 20 May 2021 06:36:18 -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 gw6sm936959ejb.86.2021.05.20.06.36.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 May 2021 06:36:18 -0700 (PDT) From: Andrea Righi To: kernel-team@lists.ubuntu.com Subject: [SRU][F][PATCH 5/5] x86/kvm: Unify kvm_pv_guest_cpu_reboot() with kvm_guest_cpu_offline() Date: Thu, 20 May 2021 15:36:11 +0200 Message-Id: <20210520133611.39540-6-andrea.righi@canonical.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210520133611.39540-1-andrea.righi@canonical.com> References: <20210520133611.39540-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 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 af04f51810d1..cdd24da7da21 100644 --- a/arch/x86/kernel/kvm.c +++ b/arch/x86/kernel/kvm.c @@ -361,31 +361,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; @@ -631,6 +606,23 @@ static struct syscore_ops kvm_syscore_ops = { .resume = kvm_resume, }; +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