From patchwork Wed May 19 15:15:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Righi X-Patchwork-Id: 1480993 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 4Flbz165WPz9sXF; Thu, 20 May 2021 01:15: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 1ljNup-0001qH-Qu; Wed, 19 May 2021 15:15:19 +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 1ljNuo-0001pw-UB for kernel-team@lists.ubuntu.com; Wed, 19 May 2021 15:15:18 +0000 Received: from mail-ej1-f70.google.com ([209.85.218.70]) by youngberry.canonical.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1ljNuo-0003nC-MV for kernel-team@lists.ubuntu.com; Wed, 19 May 2021 15:15:18 +0000 Received: by mail-ej1-f70.google.com with SMTP id x20-20020a1709061354b02903cff4894505so3821001ejb.14 for ; Wed, 19 May 2021 08:15:18 -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=3Qr3V8tN9A9/qmXBsM0myOC1JV++A9eMiGMfzj4XCkw=; b=G/YtfUjxgs0hKklJ4N8zCNMhxiWob1ucluxk6WewLyi9mWZ2/s17jvGD8K2I0QFXhP OUlDKyxKpWH6LGKeS19yneN8QDuV9FXmsWaRbkenDp/AAgaHMpIa/+fJzV3cn3u+veGx kdYD/A/utb/JqdsAFRNdGHXUa46MBZt2ChHex2UrUNBJRGP0xA9FWMxhvyJ52SfxWU6l 2lLHgWtUwN97uGZ67XXdUFbg/n37pwE7meL5tN09RBeUzrQs6QQxZIx7YftX6a7Ka6r4 IGiNqq/GSmp5um0dTKKfx22czQ2TnNqbWna91Q43ydAHOBhJ2/c4TmzSBLPc5yFJB0F7 b3ZA== X-Gm-Message-State: AOAM532fxIGg3slLxPZiT/iD4r5+JdNUCIB7CV5prYw8DGGtENoUiYnm 5rBDIvEcifcawEDW+w8lvg9eTLDpFDgOYwGqLhb8HXeyHdK1kmDsCQWtWdF3co6A1VlE+YHGgDx Op9HHjHFQfBRMuOKCIoXSGg+CiZwlsvrBoufPe9TuNA== X-Received: by 2002:a17:907:77c7:: with SMTP id kz7mr13577680ejc.54.1621437318415; Wed, 19 May 2021 08:15:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw7Apq+L7nKKcYbAcUPswvA7aIN9EAyDT2G+imHd0j/gEUVZDUJ6GX90MmyDZDpdtKwfT9NoQ== X-Received: by 2002:a17:907:77c7:: with SMTP id kz7mr13577658ejc.54.1621437318194; Wed, 19 May 2021 08:15: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 d17sm5624051ejp.90.2021.05.19.08.15.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 May 2021 08:15:17 -0700 (PDT) From: Andrea Righi To: kernel-team@lists.ubuntu.com Subject: [SRU][F/aws][PATCH v3 1/6] Revert "UBUNTU: SAUCE: aws: kvm: double the size of hv_clock_boot" Date: Wed, 19 May 2021 17:15:08 +0200 Message-Id: <20210519151513.309935-2-andrea.righi@canonical.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210519151513.309935-1-andrea.righi@canonical.com> References: <20210519151513.309935-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" BugLink: https://bugs.launchpad.net/bugs/1920944 This reverts commit b797d49573059dd6df7b929fa4b3eb7d02d6859e. Replace temporary workaround with a new patch set that addresses the problem in a better way (see next commits). Signed-off-by: Andrea Righi --- arch/x86/kernel/kvmclock.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/kernel/kvmclock.c b/arch/x86/kernel/kvmclock.c index 4466df2b0fed..904494b924c1 100644 --- a/arch/x86/kernel/kvmclock.c +++ b/arch/x86/kernel/kvmclock.c @@ -46,7 +46,7 @@ early_param("no-kvmclock-vsyscall", parse_no_kvmclock_vsyscall); /* Aligned to page sizes to match whats mapped via vsyscalls to userspace */ #define HV_CLOCK_SIZE (sizeof(struct pvclock_vsyscall_time_info) * NR_CPUS) #define HVC_BOOT_ARRAY_SIZE \ - ((PAGE_SIZE * 2)/ sizeof(struct pvclock_vsyscall_time_info)) + (PAGE_SIZE / sizeof(struct pvclock_vsyscall_time_info)) static struct pvclock_vsyscall_time_info hv_clock_boot[HVC_BOOT_ARRAY_SIZE] __bss_decrypted __aligned(PAGE_SIZE); From patchwork Wed May 19 15:15:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Righi X-Patchwork-Id: 1480994 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 4Flbz22fC1z9sXM; Thu, 20 May 2021 01:15: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 1ljNus-0001ri-Vj; Wed, 19 May 2021 15:15: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 1ljNup-0001q2-GW for kernel-team@lists.ubuntu.com; Wed, 19 May 2021 15:15:19 +0000 Received: from mail-ed1-f69.google.com ([209.85.208.69]) by youngberry.canonical.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1ljNup-0003nN-9R for kernel-team@lists.ubuntu.com; Wed, 19 May 2021 15:15:19 +0000 Received: by mail-ed1-f69.google.com with SMTP id u14-20020a05640207ceb029038d4bfbf3a6so4321579edy.9 for ; Wed, 19 May 2021 08:15: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=+USzRoGLyTwkNwdhuvzyOEdZMxIhm2vawvipbym8IeY=; b=L0u2giw2XluvDZKlzQrkN87HJ5I6rC1NP9bBpw5c1pbUdLezClHOWMgUhRN9IrwCr9 1UpoeJYF1jX13Xe2Zer8F6F4kVrVpnDEyMsvbus6Ab4M6Oi7KcWmVVtm7RerKEc3Nqna edlSrRAuOHs+4U1cMpx79rU4kwADIID4jQyDY5rx44rLwlEy4adh3T9l7BjcYTqmS3f3 eFjW9IepfrRAlU2pWolykBdOgwswwwqlxO7dYZd+ee+y/6T6lnhXzhNVFz3x0U6U4PyX 3/ImRHUplv/HJEw+M3g1o5RL3ATEQjYZsalOUJASrgZkaYWSByQFHHgTSboCiHWv9s+k Rh4w== X-Gm-Message-State: AOAM532Rncea85AJHgrLDp/hOaOjQMv868jgQWoYwEAUOtH0lFLvEH1y xMyBGVyJurOnFJ+XclXmftV3+neOuqsILCwh2MzVyckIvusNDO5yoAd8rg/+KtQRd5qItIy4q1Y CXKzCv0e9EVQch4rPGiF/noJr/V4qiZo1RLudInp/Bg== X-Received: by 2002:a05:6402:50c6:: with SMTP id h6mr15291522edb.327.1621437318954; Wed, 19 May 2021 08:15:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxtD5f/t/MHdf6sn37luFkJpAYXec20sRlWhwchLfZW0c2ubuSzxqrxJpFKPAFhO/EO5LpkrQ== X-Received: by 2002:a05:6402:50c6:: with SMTP id h6mr15291502edb.327.1621437318766; Wed, 19 May 2021 08:15: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 d17sm5624051ejp.90.2021.05.19.08.15.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 May 2021 08:15:18 -0700 (PDT) From: Andrea Righi To: kernel-team@lists.ubuntu.com Subject: [SRU][F/aws][PATCH v3 2/6] x86/kvm: Fix pr_info() for async PF setup/teardown Date: Wed, 19 May 2021 17:15:09 +0200 Message-Id: <20210519151513.309935-3-andrea.righi@canonical.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210519151513.309935-1-andrea.righi@canonical.com> References: <20210519151513.309935-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 'pr_fmt' already has 'kvm-guest: ' so 'KVM' prefix is redundant. "Unregister pv shared memory" is very ambiguous, it's hard to say which particular PV feature it relates to. Signed-off-by: Vitaly Kuznetsov Message-Id: <20210414123544.1060604-2-vkuznets@redhat.com> Signed-off-by: Paolo Bonzini (backported from 0a269a008f837e76ce285679ab3005059fadc2a6) Signed-off-by: Andrea Righi --- arch/x86/kernel/kvm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c index e820568ed4d5..ec7e4b9f50a5 100644 --- a/arch/x86/kernel/kvm.c +++ b/arch/x86/kernel/kvm.c @@ -321,7 +321,7 @@ static void kvm_guest_cpu_init(void) wrmsrl(MSR_KVM_ASYNC_PF_EN, pa); __this_cpu_write(apf_reason.enabled, 1); - printk(KERN_INFO"KVM setup async PF for cpu %d\n", + printk(KERN_INFO "setup async PF for cpu %d\n", smp_processor_id()); } @@ -347,7 +347,7 @@ static void kvm_pv_disable_apf(void) wrmsrl(MSR_KVM_ASYNC_PF_EN, 0); __this_cpu_write(apf_reason.enabled, 0); - printk(KERN_INFO"Unregister pv shared memory for cpu %d\n", + printk(KERN_INFO "disable async PF for cpu %d\n", smp_processor_id()); } From patchwork Wed May 19 15:15:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Righi X-Patchwork-Id: 1480996 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 4Flbz75lD3z9sW4; Thu, 20 May 2021 01:15:31 +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 1ljNux-0001uy-Nj; Wed, 19 May 2021 15:15:27 +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 1ljNuq-0001qQ-3h for kernel-team@lists.ubuntu.com; Wed, 19 May 2021 15:15:20 +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 1ljNup-0003nW-SC for kernel-team@lists.ubuntu.com; Wed, 19 May 2021 15:15:19 +0000 Received: by mail-ed1-f72.google.com with SMTP id ba15-20020a0564021acfb029038d3b33d7ffso5225396edb.23 for ; Wed, 19 May 2021 08:15: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=drGvjTbo2kCYG9vAw0ofeMkFYC60Cw7g9Ei4i+i4sY0=; b=sBNGjksxTxaZ1ycW1UODiEQvEpVE6bYSaU1PbsHa10Yp4KBCxjhfGs6E8HPPZcAuMd KOytcXwz0OvhSvj+DaBE6oE8a4/jIwScCvZYyeqzawvHQmRL2yMaW17yxq6FCg/6oi6b ytAC9uPGlqbxsoLIhZPDRzQ5BYZPdLNw+XqsAh7WlLia1HaCrV74mE+qSY7a8iS9JFeD G7kMsrjXYawtMyQah6LJW/d8683DoIqBoUqF5lryLApBs2VFlo8ZC1iEcfDFLDCbQSxl n9bbivKN30GStk2pmTW63DQ79sRqxDFZ9vQKo3mxB4iD+yLBhhCNM6dU5TItE8x/Ix0Y 6v6A== X-Gm-Message-State: AOAM530ygJmaS+bGg4LtulPnsUifqViURijrMu3rGS+4nBGcksGOrlEL /oykBWhDefVqv5uMOUaEgJsJsKiW5ri50FcCo7mJQg/1lnYcpk3GV1lj7pbvWUhLvYhB67uI8wd 3fqZ+vvGDna9KUvrpABXBYscJkTQQBbG2t8c/b96fwA== X-Received: by 2002:a17:906:1dc2:: with SMTP id v2mr3708216ejh.8.1621437319520; Wed, 19 May 2021 08:15:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwtzSNzhNpK8rrVReAVG2dfBV5mfRBj8XWLXdaeMbzGHxaVt5CqnRKbUNofDqzr1vOpSvKHtg== X-Received: by 2002:a17:906:1dc2:: with SMTP id v2mr3708203ejh.8.1621437319278; Wed, 19 May 2021 08:15:19 -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 d17sm5624051ejp.90.2021.05.19.08.15.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 May 2021 08:15:19 -0700 (PDT) From: Andrea Righi To: kernel-team@lists.ubuntu.com Subject: [SRU][F/aws][PATCH 3/6] x86/kvm: Teardown PV features on boot CPU as well Date: Wed, 19 May 2021 17:15:10 +0200 Message-Id: <20210519151513.309935-4-andrea.righi@canonical.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210519151513.309935-1-andrea.righi@canonical.com> References: <20210519151513.309935-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 Various PV features (Async PF, PV EOI, steal time) work through memory shared with hypervisor and when we restore from hibernation we must properly teardown all these features to make sure hypervisor doesn't write to stale locations after we jump to the previously hibernated kernel (which can try to place anything there). For secondary CPUs the job is already done by kvm_cpu_down_prepare(), register syscore ops to do the same for boot CPU. Signed-off-by: Vitaly Kuznetsov Message-Id: <20210414123544.1060604-3-vkuznets@redhat.com> Signed-off-by: Paolo Bonzini (backported from 8b79feffeca28c5459458fe78676b081e87c93a4) Signed-off-by: Andrea Righi --- arch/x86/kernel/kvm.c | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c index ec7e4b9f50a5..7bf47e41bb46 100644 --- a/arch/x86/kernel/kvm.c +++ b/arch/x86/kernel/kvm.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -558,17 +559,21 @@ static void kvm_guest_cpu_offline(void) static int kvm_cpu_online(unsigned int cpu) { - local_irq_disable(); + unsigned long flags; + + local_irq_save(flags); kvm_guest_cpu_init(); - local_irq_enable(); + local_irq_restore(flags); return 0; } static int kvm_cpu_down_prepare(unsigned int cpu) { - local_irq_disable(); + unsigned long flags; + + local_irq_save(flags); kvm_guest_cpu_offline(); - local_irq_enable(); + local_irq_restore(flags); return 0; } #endif @@ -606,6 +611,23 @@ static void kvm_flush_tlb_others(const struct cpumask *cpumask, native_flush_tlb_others(flushmask, info); } +static int kvm_suspend(void) +{ + kvm_guest_cpu_offline(); + + return 0; +} + +static void kvm_resume(void) +{ + kvm_cpu_online(raw_smp_processor_id()); +} + +static struct syscore_ops kvm_syscore_ops = { + .suspend = kvm_suspend, + .resume = kvm_resume, +}; + static void __init kvm_guest_init(void) { int i; @@ -649,6 +671,8 @@ static void __init kvm_guest_init(void) kvm_guest_cpu_init(); #endif + register_syscore_ops(&kvm_syscore_ops); + /* * Hard lockup detection is enabled by default. Disable it, as guests * can get false positives too easily, for example if the host is From patchwork Wed May 19 15:15: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: 1480995 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 4Flbz34V0tz9sWl; Thu, 20 May 2021 01:15:27 +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 1ljNut-0001s3-5a; Wed, 19 May 2021 15:15:23 +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 1ljNuq-0001qe-Lv for kernel-team@lists.ubuntu.com; Wed, 19 May 2021 15:15:20 +0000 Received: from mail-ed1-f70.google.com ([209.85.208.70]) by youngberry.canonical.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1ljNuq-0003nm-Ew for kernel-team@lists.ubuntu.com; Wed, 19 May 2021 15:15:20 +0000 Received: by mail-ed1-f70.google.com with SMTP id y17-20020a0564023591b02903886c26ada4so7885479edc.5 for ; Wed, 19 May 2021 08:15: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=GC92v1JQXoPtJq3VFMogDIHk7VyC/mMb9xItaa6wApo=; b=mebQNmf3L3BMRu85H/zmeO6j0bqG5cPdcl8CdNtZYnK5oE0onAlfFz0RLt2NZpoOlD WUQOTF0h2NVUIvfjdIjmPwMFTTFKau0ZrH/O8/V+xcn5gl5QdFwfZLego5bWtHWV6J8/ KpjZdS/5a1u47kQDWbtwJ15iHBM/2N+xUybagwHUTiehwKatWyEGm1THoom+smOA/upB 4AKG7MP2+UD3OS2d+dGSKMkk4FdEQSvQ/y/qpiU1pU6ZdArRte8GV76jjzP3ZJyG2mSW SxqaQW8RBbixLRpFGLOQREcaYCGQtYD4vgg3XxbuwRYHsYZR1i/QXo458ZWinMxhJ6Cv N1dA== X-Gm-Message-State: AOAM530IahnXt3oMJStD1J2wajeFjrUizJjFLVYSyRCwjMmocOQTVG39 Dy1ao6k/m4oo00Qe5Yk6TGJYO0RQl8HxTRC9zDRbLJbJFS17bhrmNLuB5gL+m/PkLp+1sq1wTHL nBdsfQwwrGupXnrh1qPFxaHHF/53riQwZqyxvozuIQw== X-Received: by 2002:a17:906:5448:: with SMTP id d8mr13071527ejp.248.1621437320101; Wed, 19 May 2021 08:15:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwU/i0K7CuC9kdG/8pVjlUFi4mphhAnSiDvo9H0IBsU+TbRFFlXzuDNj5NFZBwIlvvDEKiHhA== X-Received: by 2002:a17:906:5448:: with SMTP id d8mr13071503ejp.248.1621437319838; Wed, 19 May 2021 08:15:19 -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 d17sm5624051ejp.90.2021.05.19.08.15.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 May 2021 08:15:19 -0700 (PDT) From: Andrea Righi To: kernel-team@lists.ubuntu.com Subject: [SRU][F/aws][PATCH v3 4/6] x86/kvm: Disable kvmclock on all CPUs on shutdown Date: Wed, 19 May 2021 17:15:11 +0200 Message-Id: <20210519151513.309935-5-andrea.righi@canonical.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210519151513.309935-1-andrea.righi@canonical.com> References: <20210519151513.309935-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 Currenly, we disable kvmclock from machine_shutdown() hook and this only happens for boot CPU. We need to disable it for all CPUs to guard against memory corruption e.g. on restore from hibernate. Note, writing '0' to kvmclock MSR doesn't clear memory location, it just prevents hypervisor from updating the location so for the short while after write and while CPU is still alive, the clock remains usable and correct so we don't need to switch to some other clocksource. Signed-off-by: Vitaly Kuznetsov Message-Id: <20210414123544.1060604-4-vkuznets@redhat.com> Signed-off-by: Paolo Bonzini (backported from c02027b5742b5aa804ef08a4a9db433295533046) Signed-off-by: Andrea Righi --- arch/x86/include/asm/kvm_para.h | 4 ++-- arch/x86/kernel/kvm.c | 1 + arch/x86/kernel/kvmclock.c | 5 +---- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/arch/x86/include/asm/kvm_para.h b/arch/x86/include/asm/kvm_para.h index 9b4df6eaa11a..a617fd360023 100644 --- a/arch/x86/include/asm/kvm_para.h +++ b/arch/x86/include/asm/kvm_para.h @@ -6,8 +6,6 @@ #include #include -extern void kvmclock_init(void); - #ifdef CONFIG_KVM_GUEST bool kvm_check_and_clear_guest_paused(void); #else @@ -85,6 +83,8 @@ static inline long kvm_hypercall4(unsigned int nr, unsigned long p1, } #ifdef CONFIG_KVM_GUEST +void kvmclock_init(void); +void kvmclock_disable(void); bool kvm_para_available(void); unsigned int kvm_arch_para_features(void); unsigned int kvm_arch_para_hints(void); diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c index 7bf47e41bb46..1d6e64a32278 100644 --- a/arch/x86/kernel/kvm.c +++ b/arch/x86/kernel/kvm.c @@ -555,6 +555,7 @@ static void kvm_guest_cpu_offline(void) wrmsrl(MSR_KVM_PV_EOI_EN, 0); kvm_pv_disable_apf(); apf_task_wake_all(); + kvmclock_disable(); } static int kvm_cpu_online(unsigned int cpu) diff --git a/arch/x86/kernel/kvmclock.c b/arch/x86/kernel/kvmclock.c index 904494b924c1..bd3962953f78 100644 --- a/arch/x86/kernel/kvmclock.c +++ b/arch/x86/kernel/kvmclock.c @@ -214,11 +214,9 @@ static void kvm_crash_shutdown(struct pt_regs *regs) } #endif -static void kvm_shutdown(void) +void kvmclock_disable(void) { native_write_msr(msr_kvm_system_time, 0, 0); - kvm_disable_steal_time(); - native_machine_shutdown(); } static void __init kvmclock_init_mem(void) @@ -346,7 +344,6 @@ void __init kvmclock_init(void) #endif x86_platform.save_sched_clock_state = kvm_save_sched_clock_state; x86_platform.restore_sched_clock_state = kvm_restore_sched_clock_state; - machine_ops.shutdown = kvm_shutdown; #ifdef CONFIG_KEXEC_CORE machine_ops.crash_shutdown = kvm_crash_shutdown; #endif From patchwork Wed May 19 15:15:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Righi X-Patchwork-Id: 1480998 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 4Flbz910Zmz9sW4; Thu, 20 May 2021 01:15:33 +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 1ljNuy-0001vb-Ff; Wed, 19 May 2021 15:15:28 +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 1ljNur-0001r4-Bo for kernel-team@lists.ubuntu.com; Wed, 19 May 2021 15:15:21 +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 1ljNur-0003o1-2u for kernel-team@lists.ubuntu.com; Wed, 19 May 2021 15:15:21 +0000 Received: by mail-ej1-f71.google.com with SMTP id i23-20020a17090685d7b02903d089ab83fcso3819822ejy.19 for ; Wed, 19 May 2021 08:15:21 -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=R1v9XQ9x3lpts+HcVny5Hn+vdYCydMpOVeZouz8MaEI=; b=iZNnLkay+1qHNogna+OUocqEHv2/YE1QrFeutcyR+3U2GcgTwYEhds8q+fX+qPB1Fg ZslH9Bmp5kg0HCLuqvEpJpPVjoy5oNpicZoemwANEJ1PG1kZ3EiQ75k0Uov1NAQphR7A cofkqtrpFQB9e3tw53hQXp/quVxOack1Ib3AqQj/OOChrqjKLFJHBi+KWyOIeYgbUyjF AezDANskz5fK9eBNzyXM6cTQv5WOYbZlTNBlgQRNd7bUMnEojNI7dqarffEROTUHzena /qv/bqs+UpPYKQkVh4MESkSB9MHaw/5z16FewdtrjSPhHVN+MWQA0DF0RW/i/UDuajgq TfpA== X-Gm-Message-State: AOAM53204pnocg+6SNDUr3CS7uOa4zhlFRO0g2vuyri7Nuirsw/CASo3 5MoFpbYmZ9swN7U7PCPkw/MXxtH9r80QsvsJHrEzljl7K6PX/1xwm6rQMrDmCbosow9US1pvpGP QKAkgT9X7oRYSdinNg8TUkZjUtXHxCHWcItpgUFCUEg== X-Received: by 2002:a17:906:5388:: with SMTP id g8mr13667769ejo.413.1621437320676; Wed, 19 May 2021 08:15:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzpv2Oa8HSpokL63yGTZ+/vSrfW/+1aElxd6bvSuxlEJqGcNkYXUHHfh6XP5Zr/kQk+AKnQmg== X-Received: by 2002:a17:906:5388:: with SMTP id g8mr13667751ejo.413.1621437320434; Wed, 19 May 2021 08:15: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 d17sm5624051ejp.90.2021.05.19.08.15.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 May 2021 08:15:20 -0700 (PDT) From: Andrea Righi To: kernel-team@lists.ubuntu.com Subject: [SRU][F/aws][PATCH v3 5/6] x86/kvm: Disable all PV features on crash Date: Wed, 19 May 2021 17:15:12 +0200 Message-Id: <20210519151513.309935-6-andrea.righi@canonical.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210519151513.309935-1-andrea.righi@canonical.com> References: <20210519151513.309935-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 Crash shutdown handler only disables kvmclock and steal time, other PV features remain active so we risk corrupting memory or getting some side-effects in kdump kernel. Move crash handler to kvm.c and unify with CPU offline. Signed-off-by: Vitaly Kuznetsov Message-Id: <20210414123544.1060604-5-vkuznets@redhat.com> Signed-off-by: Paolo Bonzini (backported from 3d6b84132d2a57b5a74100f6923a8feb679ac2ce) Signed-off-by: Andrea Righi --- arch/x86/include/asm/kvm_para.h | 5 ---- arch/x86/kernel/kvm.c | 44 ++++++++++++++++++++++++--------- arch/x86/kernel/kvmclock.c | 21 ---------------- 3 files changed, 32 insertions(+), 38 deletions(-) diff --git a/arch/x86/include/asm/kvm_para.h b/arch/x86/include/asm/kvm_para.h index a617fd360023..7ff8ad490a78 100644 --- a/arch/x86/include/asm/kvm_para.h +++ b/arch/x86/include/asm/kvm_para.h @@ -91,7 +91,6 @@ unsigned int kvm_arch_para_hints(void); void kvm_async_pf_task_wait(u32 token, int interrupt_kernel); void kvm_async_pf_task_wake(u32 token); u32 kvm_read_and_reset_pf_reason(void); -extern void kvm_disable_steal_time(void); void do_async_page_fault(struct pt_regs *regs, unsigned long error_code, unsigned long address); #ifdef CONFIG_PARAVIRT_SPINLOCKS @@ -126,10 +125,6 @@ static inline u32 kvm_read_and_reset_pf_reason(void) return 0; } -static inline void kvm_disable_steal_time(void) -{ - return; -} #endif #endif /* _ASM_X86_KVM_PARA_H */ diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c index 1d6e64a32278..af04f51810d1 100644 --- a/arch/x86/kernel/kvm.c +++ b/arch/x86/kernel/kvm.c @@ -34,6 +34,7 @@ #include #include #include +#include static int kvmapf = 1; @@ -352,6 +353,14 @@ static void kvm_pv_disable_apf(void) smp_processor_id()); } +static void kvm_disable_steal_time(void) +{ + if (!has_steal_clock) + return; + + wrmsr(MSR_KVM_STEAL_TIME, 0, 0); +} + static void kvm_pv_guest_cpu_reboot(void *unused) { /* @@ -394,14 +403,6 @@ static u64 kvm_steal_clock(int cpu) return steal; } -void kvm_disable_steal_time(void) -{ - if (!has_steal_clock) - return; - - wrmsr(MSR_KVM_STEAL_TIME, 0, 0); -} - static inline void __set_percpu_decrypted(void *ptr, unsigned long size) { early_set_memory_decrypted((unsigned long) ptr, size); @@ -548,13 +549,14 @@ static void __init kvm_smp_prepare_boot_cpu(void) kvm_spinlock_init(); } -static void kvm_guest_cpu_offline(void) +static void kvm_guest_cpu_offline(bool shutdown) { kvm_disable_steal_time(); if (kvm_para_has_feature(KVM_FEATURE_PV_EOI)) wrmsrl(MSR_KVM_PV_EOI_EN, 0); kvm_pv_disable_apf(); - apf_task_wake_all(); + if (!shutdown) + apf_task_wake_all(); kvmclock_disable(); } @@ -573,7 +575,7 @@ static int kvm_cpu_down_prepare(unsigned int cpu) unsigned long flags; local_irq_save(flags); - kvm_guest_cpu_offline(); + kvm_guest_cpu_offline(false); local_irq_restore(flags); return 0; } @@ -614,7 +616,7 @@ static void kvm_flush_tlb_others(const struct cpumask *cpumask, static int kvm_suspend(void) { - kvm_guest_cpu_offline(); + kvm_guest_cpu_offline(false); return 0; } @@ -629,6 +631,20 @@ static struct syscore_ops kvm_syscore_ops = { .resume = kvm_resume, }; +/* + * After a PV feature is registered, the host will keep writing to the + * registered memory location. If the guest happens to shutdown, this memory + * won't be valid. In cases like kexec, in which you install a new kernel, this + * means a random memory location will be kept being written. + */ +#ifdef CONFIG_KEXEC_CORE +static void kvm_crash_shutdown(struct pt_regs *regs) +{ + kvm_guest_cpu_offline(true); + native_machine_crash_shutdown(regs); +} +#endif + static void __init kvm_guest_init(void) { int i; @@ -672,6 +688,10 @@ static void __init kvm_guest_init(void) kvm_guest_cpu_init(); #endif +#ifdef CONFIG_KEXEC_CORE + machine_ops.crash_shutdown = kvm_crash_shutdown; +#endif + register_syscore_ops(&kvm_syscore_ops); /* diff --git a/arch/x86/kernel/kvmclock.c b/arch/x86/kernel/kvmclock.c index bd3962953f78..4a0802af2e3e 100644 --- a/arch/x86/kernel/kvmclock.c +++ b/arch/x86/kernel/kvmclock.c @@ -20,7 +20,6 @@ #include #include #include -#include #include static int kvmclock __initdata = 1; @@ -197,23 +196,6 @@ static void kvm_setup_secondary_clock(void) } #endif -/* - * After the clock is registered, the host will keep writing to the - * registered memory location. If the guest happens to shutdown, this memory - * won't be valid. In cases like kexec, in which you install a new kernel, this - * means a random memory location will be kept being written. So before any - * kind of shutdown from our side, we unregister the clock by writing anything - * that does not have the 'enable' bit set in the msr - */ -#ifdef CONFIG_KEXEC_CORE -static void kvm_crash_shutdown(struct pt_regs *regs) -{ - native_write_msr(msr_kvm_system_time, 0, 0); - kvm_disable_steal_time(); - native_machine_crash_shutdown(regs); -} -#endif - void kvmclock_disable(void) { native_write_msr(msr_kvm_system_time, 0, 0); @@ -344,9 +326,6 @@ void __init kvmclock_init(void) #endif x86_platform.save_sched_clock_state = kvm_save_sched_clock_state; x86_platform.restore_sched_clock_state = kvm_restore_sched_clock_state; -#ifdef CONFIG_KEXEC_CORE - machine_ops.crash_shutdown = kvm_crash_shutdown; -#endif kvm_get_preset_lpj(); /* From patchwork Wed May 19 15:15:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Righi X-Patchwork-Id: 1480997 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 4Flbz91QP0z9sWp; Thu, 20 May 2021 01:15:33 +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 1ljNuz-0001wd-FY; Wed, 19 May 2021 15:15:29 +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 1ljNus-0001rP-Kh for kernel-team@lists.ubuntu.com; Wed, 19 May 2021 15:15:22 +0000 Received: from mail-ej1-f69.google.com ([209.85.218.69]) by youngberry.canonical.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1ljNus-0003oC-Be for kernel-team@lists.ubuntu.com; Wed, 19 May 2021 15:15:22 +0000 Received: by mail-ej1-f69.google.com with SMTP id x20-20020a1709061354b02903cff4894505so3821094ejb.14 for ; Wed, 19 May 2021 08:15:22 -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=Uhmi3dhibSM2tVeUb3nM8zopzlBI67JAjfUVVC3Bc+lsYBEAd151i9T0WmCRu7LE+N YOumjsdHDSV28ST7VzwB59CxRuHUV6tOqIrwvQusIXxrr8eRaij6EMsjyK4lQ4C7mckC ZKgqJlEgrXHl/1Y04NrRP8B/xRGZDHdeAJBRh+1ry+PqYj0bKUP50lbKjoE3B5yVQed8 FNaEffAFYXw+JkNuAddhoSp2NDEoS6Q8ObgzMMfCUaFa5HhQ5DwfQOY0GnCrNA6CFv3D rJSWF1PhIkNsJaoEiI7C18QwldOyW1ZmjD7of0lUO/hdQwtKRLbdxGFxv+0l5yXOgWQj 4XUQ== X-Gm-Message-State: AOAM5304Jw4Q0k9pH8T+mgN4m1on/RD0p1N9dmPu1HBqAn6wLji411Vb I9tatKlc4r06GeC34TKqLUvD1UOvj47GD7cO0T2C4MHuBZDIWic3gXJmvAcHjeO/H/SLc18Y651 CbhI1CcHlhZ+EE8UBMBtIKA8SkkJp4mNmFWGDvS99LQ== X-Received: by 2002:a17:907:3e0b:: with SMTP id hp11mr12808334ejc.171.1621437321935; Wed, 19 May 2021 08:15:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwyX5P8u4ebJGcjP37a98Q7Z7ZphwWtm22PEuplPCb3VQJdC7ezOX8ImXuSG9J9FxWPkCx4GA== X-Received: by 2002:a17:907:3e0b:: with SMTP id hp11mr12808253ejc.171.1621437321035; Wed, 19 May 2021 08:15:21 -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 d17sm5624051ejp.90.2021.05.19.08.15.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 May 2021 08:15:20 -0700 (PDT) From: Andrea Righi To: kernel-team@lists.ubuntu.com Subject: [SRU][F/aws][PATCH v3 6/6] x86/kvm: Unify kvm_pv_guest_cpu_reboot() with kvm_guest_cpu_offline() Date: Wed, 19 May 2021 17:15:13 +0200 Message-Id: <20210519151513.309935-7-andrea.righi@canonical.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210519151513.309935-1-andrea.righi@canonical.com> References: <20210519151513.309935-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