Received: by 2002:a05:6a10:7420:0:0:0:0 with SMTP id hk32csp592335pxb; Tue, 15 Feb 2022 23:07:58 -0800 (PST) X-Google-Smtp-Source: ABdhPJzaO+z/KZe/eAjrFY4sETGBe1A+q3OLUxgUyi+VGgBLPPetCEUYYNPxFB4xgnzuOprgG2/a X-Received: by 2002:a17:90b:3443:b0:1b8:cd4e:ad81 with SMTP id lj3-20020a17090b344300b001b8cd4ead81mr231965pjb.154.1644995278717; Tue, 15 Feb 2022 23:07:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644995278; cv=none; d=google.com; s=arc-20160816; b=Frkh0dMq1JPDCzyaTIB1NY0JzeGkLCorCOKenl+De2mPd7zS+EZ3cJJfLz970NiWBq 7dhYWmDCxQoQXWBNvCu6Y9mT+5fEp56z0ZrNQSvh8WZsqGeRxpHJsM5oTRKT6p099Mhb AGRwcaJUfSX9AmLr6TU4R2AjVGrOZAuqGr3DZroqQzdLMR9qJkv9nAqwtE6W4sC/jwE8 uZJ6rzj2olV8GTCCOL4+zxiMbGkNGUJ7MmlLKoUrj15Tb+Ev6rmuEKLMehYTqnvxzoVC 381iqo3hU0lZAcGPtzjth6g6tOoesVnWkyMrQDtXzVJ1+4vnQSsmgk4yCDTXlX2FMy4t Qobg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=XQjd8CA3vCh9qPlrhMr0TSXV3eV16bTwFR8dKt4WVOw=; b=RZ4Hjz1YxDmSlD6rCT3VfAZ/u+tbHgHEEtGKvdTPztsOPhxso7C1b6srWIrmmaQctn ozR8m9tw60alFqghxSrWxoaMUbj4Xuzs7DdT4Pxvjfek3uEe1YcXT7OAt9z4ys/cqgAt eOj+1qUYRLt9fQsDetTOy9TwBJoeOl+TPc+IufSjcLmScmkqVIc9vFkut9lnrJwkr6pa 7HY62A+NME48m0ZLCS52h/D6cuBBaBv3Kz32gQwDlFa4FiXpSMPKOCuzzY8V1pPVs8bN OZFUPDEBWIJhB+GTIvt7Ku78443tFR6HTNaHR0UVwelXAaIp+mPNM1OvhAu6Srs4mq1x 2Fgw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=JwBB0Dby; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id n2si19598540plf.378.2022.02.15.23.07.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Feb 2022 23:07:58 -0800 (PST) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=JwBB0Dby; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id B0F001CFF9; Tue, 15 Feb 2022 22:44:58 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344168AbiBPDQB (ORCPT + 99 others); Tue, 15 Feb 2022 22:16:01 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:57986 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344182AbiBPDQA (ORCPT ); Tue, 15 Feb 2022 22:16:00 -0500 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 78491DCE07; Tue, 15 Feb 2022 19:15:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1644981349; x=1676517349; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=QTNgfjCEcX1QhsvTX1L+Tjbtrc8LR7Y4aspA8SJiUsY=; b=JwBB0DbylUBY2K3e//TrI8m1LQawXcoZwceWmpubMWe0giVf7YIPEwUe duP7lcXCIOm9A0lnVIotI0XiHMTlbn6gEVIxnrVtFKk/xectxV0djtRuJ A9v0PfXFmDtJjm/wnwqqtuqALzL0+UDHdBddGebkPTGjzfF73sIS8quKw AkbSYG116omhG4VzRlqLH/PeafkFHaLC6heTiK2eDWkR9dJxKmx8F1RC8 ELDfIQYflM0ZjCXATv/t14EbgA4je8RVIOwDaaPOThRrIFMr3YeAubZ2D ybISafQCEeBomQsPKrkd6a+MLiVq2W2/I5Dq2LeLIbBDSqNf8Wb3cRutc w==; X-IronPort-AV: E=McAfee;i="6200,9189,10259"; a="250250392" X-IronPort-AV: E=Sophos;i="5.88,371,1635231600"; d="scan'208";a="250250392" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Feb 2022 19:15:48 -0800 X-IronPort-AV: E=Sophos;i="5.88,371,1635231600"; d="scan'208";a="773798119" Received: from hyperv-sh4.sh.intel.com ([10.239.48.22]) by fmsmga006-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Feb 2022 19:15:36 -0800 From: Chao Gao To: seanjc@google.com, maz@kernel.org, kvm@vger.kernel.org, pbonzini@redhat.com, kevin.tian@intel.com, tglx@linutronix.de Cc: Chao Gao , Albert Ou , Aleksandar Markovic , Alexander Gordeev , Alexandru Elisei , Andrew Jones , Anup Patel , Atish Patra , Benjamin Herrenschmidt , Bharata B Rao , Borislav Petkov , Catalin Marinas , Christian Borntraeger , Claudio Imbrenda , "Darrick J. Wong" , Dave Hansen , David Hildenbrand , Eric Auger , Hector Martin , Heiko Carstens , "H. Peter Anvin" , Huacai Chen , Ingo Molnar , James Morse , Janosch Frank , Jia He , Jim Mattson , Joerg Roedel , John Garry , Juergen Gross , kvmarm@lists.cs.columbia.edu, kvm-riscv@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mips@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, "Maciej S. Szmigiero" , Michael Ellerman , Nathan Chancellor , Nicholas Piggin , Nick Desaulniers , Palmer Dabbelt , Paul Mackerras , Paul Walmsley , Qi Liu , Shaokun Zhang , Sumanth Korikkar , Suzuki K Poulose , Sven Schnelle , Thomas Bogendoerfer , Thomas Richter , Tom Zanussi , Vasily Gorbik , Vitaly Kuznetsov , Wanpeng Li , Will Deacon , x86@kernel.org Subject: [PATCH v4 0/6] Improve KVM's interaction with CPU hotplug Date: Wed, 16 Feb 2022 11:15:15 +0800 Message-Id: <20220216031528.92558-1-chao.gao@intel.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Changes from v3->v4: - rebased to the lastest kvm/next branch. - add Sean's reviewed-by tags - add Marc's patch to simplify ARM's cpu hotplug logic in KVM Changes from v2->v3: - rebased to the latest kvm/next branch. - patch 1: rename {svm,vmx}_check_processor_compat to follow the name convention - patch 3: newly added to provide more information when hardware enabling fails - patch 4: reset hardware_enable_failed if hardware enabling fails. And remove redundent kernel log. - patch 5: add a pr_err() for setup_vmcs_config() path. Changes from v1->v2: (all comments/suggestions on v1 are from Sean, thanks) - Merged v1's patch 2 into patch 1, and v1's patch 5 into patch 6. - Use static_call for check_processor_compatibility(). - Generate patch 2 with "git revert" and do manual changes based on that. - Loosen the WARN_ON() in kvm_arch_check_processor_compat() instead of removing it. - KVM always prevent incompatible CPUs from being brought up regardless of running VMs. - Use pr_warn instead of pr_info to emit logs when KVM finds offending CPUs. KVM registers its CPU hotplug callback to CPU starting section. And in the callback, KVM enables hardware virtualization on hotplugged CPUs if any VM is running on existing CPUs. There are two problems in the process: 1. KVM doesn't do compatibility checks before enabling hardware virtualization on hotplugged CPUs. This may cause #GP if VMX isn't supported or vmentry failure if some in-use VMX features are missing on hotplugged CPUs. Both break running VMs. 2. Callbacks in CPU STARTING section cannot fail. So, even if KVM finds some incompatible CPUs, its callback cannot block CPU hotplug. This series improves KVM's interaction with CPU hotplug to avoid incompatible CPUs breaking running VMs. Following changes are made: 1. move KVM's CPU hotplug callback to ONLINE section (suggested by Thomas) 2. do compatibility checks on hotplugged CPUs. 3. abort onlining incompatible CPUs This series is a follow-up to the discussion about KVM and CPU hotplug https://lore.kernel.org/lkml/3d3296f0-9245-40f9-1b5a-efffdb082de9@redhat.com/T/ Note: this series is tested only on Intel systems. Chao Gao (4): KVM: x86: Move check_processor_compatibility from init ops to runtime ops Partially revert "KVM: Pass kvm_init()'s opaque param to additional arch funcs" KVM: Rename and move CPUHP_AP_KVM_STARTING to ONLINE section KVM: Do compatibility checks on hotplugged CPUs Marc Zyngier (1): KVM: arm64: Simplify the CPUHP logic Sean Christopherson (1): KVM: Provide more information in kernel log if hardware enabling fails arch/arm64/kvm/arch_timer.c | 27 ++++------- arch/arm64/kvm/arm.c | 6 ++- arch/arm64/kvm/vgic/vgic-init.c | 19 +------- arch/mips/kvm/mips.c | 2 +- arch/powerpc/kvm/powerpc.c | 2 +- arch/riscv/kvm/main.c | 2 +- arch/s390/kvm/kvm-s390.c | 2 +- arch/x86/include/asm/kvm-x86-ops.h | 1 + arch/x86/include/asm/kvm_host.h | 2 +- arch/x86/kvm/svm/svm.c | 4 +- arch/x86/kvm/vmx/evmcs.c | 2 +- arch/x86/kvm/vmx/evmcs.h | 2 +- arch/x86/kvm/vmx/vmx.c | 22 +++++---- arch/x86/kvm/x86.c | 16 +++++-- include/kvm/arm_arch_timer.h | 4 ++ include/kvm/arm_vgic.h | 4 ++ include/linux/cpuhotplug.h | 5 +- include/linux/kvm_host.h | 2 +- virt/kvm/kvm_main.c | 73 +++++++++++++++++++----------- 19 files changed, 107 insertions(+), 90 deletions(-) -- 2.25.1