From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1830BC433EF for ; Mon, 27 Dec 2021 08:17:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235565AbhL0IRN (ORCPT ); Mon, 27 Dec 2021 03:17:13 -0500 Received: from mga12.intel.com ([192.55.52.136]:31598 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231358AbhL0IRM (ORCPT ); Mon, 27 Dec 2021 03:17:12 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1640593032; x=1672129032; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=tCJzGvAoR9V3Cf25Th6SaPQVLQdtAnnLPINob5E2Vys=; b=CLSXoNF7DAYhlP6g9oHvqqHNlL25wbeXn08/h+oC8mbY1WOaOYL7uyKB n5MjyUOfcA8xE5vcoyZP/95gcA5nmA/VdanDXxOORd85F8zQs0SCuYddK g92KAAuC0ffcvQPc/PnJHVCYauF/MOROgSXkFtfYx9p+Lc/ZkUoSW/d8D kZLJF8BWwZCIA3fCLaOk+Wj8HRSZnnvbFjIsRhTgHHDcGxf+CYbhoEGCI Ld3X3cmk+1SxKfqhXhTfmC37k/wKgnSJ8Acplv1ht4005b7lYzPr2GZVT yf523CC+7ZyKHfKjSekbj0y7qYaLgMVd7wcND9FEMTMmS6pUnahNXTHQj A==; X-IronPort-AV: E=McAfee;i="6200,9189,10209"; a="221182045" X-IronPort-AV: E=Sophos;i="5.88,239,1635231600"; d="scan'208";a="221182045" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Dec 2021 00:17:12 -0800 X-IronPort-AV: E=Sophos;i="5.88,239,1635231600"; d="scan'208";a="523207964" Received: from unknown (HELO hyperv-sh4.sh.intel.com) ([10.239.48.22]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Dec 2021 00:16:56 -0800 From: Chao Gao To: 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 , Anup Patel , Atish Patra , Benjamin Herrenschmidt , Bharata B Rao , Borislav Petkov , Catalin Marinas , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Christian Borntraeger , Claudio Imbrenda , Dave Hansen , David Hildenbrand , Fabiano Rosas , Guo Ren , Heiko Carstens , "H. Peter Anvin" , Huacai Chen , Ingo Molnar , James Morse , Janosch Frank , Jim Mattson , Joerg Roedel , John Garry , 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" , Marc Zyngier , Mel Gorman , Michael Ellerman , Nicholas Piggin , Nick Desaulniers , Palmer Dabbelt , Paul Mackerras , Paul Walmsley , Ravi Bangoria , Sean Christopherson , Shaokun Zhang , Sumanth Korikkar , Suzuki K Poulose , Thomas Bogendoerfer , Thomas Richter , Vasily Gorbik , Vitaly Kuznetsov , Wanpeng Li , Will Deacon , x86@kernel.org Subject: [PATCH 0/6] Improve KVM's interaction with CPU hotplug Date: Mon, 27 Dec 2021 16:15:06 +0800 Message-Id: <20211227081515.2088920-1-chao.gao@intel.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 if there is a running VM. 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 (6): KVM: x86: Move check_processor_compatibility from init ops to runtime ops KVM: x86: Use kvm_x86_ops in kvm_arch_check_processor_compat KVM: Remove opaque from kvm_arch_check_processor_compat KVM: Rename and move CPUHP_AP_KVM_STARTING to ONLINE section KVM: x86: Remove WARN_ON in kvm_arch_check_processor_compat KVM: Do compatibility checks on hotplugged CPUs arch/arm64/kvm/arm.c | 2 +- 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_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 | 12 +++--- arch/x86/kvm/x86.c | 7 +--- include/linux/cpuhotplug.h | 2 +- include/linux/kvm_host.h | 2 +- virt/kvm/kvm_main.c | 74 ++++++++++++++++++++++++--------- 14 files changed, 74 insertions(+), 43 deletions(-) -- 2.25.1 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BBD5AC433EF for ; Mon, 27 Dec 2021 08:17:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=AYRLRb6fXbhYvVmJgOqZ8fh96D9+ZviH/OiWKLqPRRk=; b=1FiQZfESDt3GZ0 GRTLgSWRZmKM4v80wxR6Gxq+tRK5BCtronvgGf5SAbTVFJN0X0i3sI4BApz74O2f0wzCyn5lA6mpK lQZK+NmdwDtfAHSGDWD4pEQgWSfRG1B08bfDgSb1IyYssFxI0mykkxTumio8M/cpdi/BZ5ntVc6dT szjVqDhg2Te7Mj/pBq8CLrMt1uBSBFcG/ykrHlL4efhjAW06LScxZ8+Qotq07X40AxTNFMDbJRHkP 2XU2uR91R8fw4L04SDVF5mEx7rNhkpCzCOMv3ugjNmDBfFZFCCRlENESisZcaM2t7obkcmkv/MYOs vuTiXWLTkO9vY5VrePdA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1n1lC0-00GM5P-AO; Mon, 27 Dec 2021 08:17:16 +0000 Received: from mga17.intel.com ([192.55.52.151]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1n1lBx-00GM4x-Qh; Mon, 27 Dec 2021 08:17:15 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1640593033; x=1672129033; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=tCJzGvAoR9V3Cf25Th6SaPQVLQdtAnnLPINob5E2Vys=; b=RXV3TFHXVyh2oG96Erac847w+s9TXkyX91FRqj7Tp+KUucvNPu9/NABs pyNxLdhJcYbp2cbkmzH+CLAon3MIGyhwxZhxCsIO1d0D/D8j2GXh0RSyz rzp1Z4s4f81gLgoR35Edj8R+aha9uHq4PLQdvqROTM8G9YDLHB3bcHHQW KZ/b+Jk3oABmAI1nCWCImIKg2R2+eSt1tU8b6GXSDUq6eeUj2hG981Sol SpWES6K8p+u8VN7RkC3LHsJb5ntKbx6NyZP+GFV9zMg4OcVqaNzKo6Awy 1p2ctmy4nc8cpWnI+mvCcgxPvsHaH7uRToLiRdimWyN0WZ1+zQmO1teGz A==; X-IronPort-AV: E=McAfee;i="6200,9189,10209"; a="221848350" X-IronPort-AV: E=Sophos;i="5.88,239,1635231600"; d="scan'208";a="221848350" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Dec 2021 00:17:12 -0800 X-IronPort-AV: E=Sophos;i="5.88,239,1635231600"; d="scan'208";a="523207964" Received: from unknown (HELO hyperv-sh4.sh.intel.com) ([10.239.48.22]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Dec 2021 00:16:56 -0800 From: Chao Gao To: 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 , Anup Patel , Atish Patra , Benjamin Herrenschmidt , Bharata B Rao , Borislav Petkov , Catalin Marinas , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Christian Borntraeger , Claudio Imbrenda , Dave Hansen , David Hildenbrand , Fabiano Rosas , Guo Ren , Heiko Carstens , "H. Peter Anvin" , Huacai Chen , Ingo Molnar , James Morse , Janosch Frank , Jim Mattson , Joerg Roedel , John Garry , 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" , Marc Zyngier , Mel Gorman , Michael Ellerman , Nicholas Piggin , Nick Desaulniers , Palmer Dabbelt , Paul Mackerras , Paul Walmsley , Ravi Bangoria , Sean Christopherson , Shaokun Zhang , Sumanth Korikkar , Suzuki K Poulose , Thomas Bogendoerfer , Thomas Richter , Vasily Gorbik , Vitaly Kuznetsov , Wanpeng Li , Will Deacon , x86@kernel.org Subject: [PATCH 0/6] Improve KVM's interaction with CPU hotplug Date: Mon, 27 Dec 2021 16:15:06 +0800 Message-Id: <20211227081515.2088920-1-chao.gao@intel.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211227_001713_962126_C5BA3974 X-CRM114-Status: UNSURE ( 7.72 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org 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 if there is a running VM. 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 (6): KVM: x86: Move check_processor_compatibility from init ops to runtime ops KVM: x86: Use kvm_x86_ops in kvm_arch_check_processor_compat KVM: Remove opaque from kvm_arch_check_processor_compat KVM: Rename and move CPUHP_AP_KVM_STARTING to ONLINE section KVM: x86: Remove WARN_ON in kvm_arch_check_processor_compat KVM: Do compatibility checks on hotplugged CPUs arch/arm64/kvm/arm.c | 2 +- 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_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 | 12 +++--- arch/x86/kvm/x86.c | 7 +--- include/linux/cpuhotplug.h | 2 +- include/linux/kvm_host.h | 2 +- virt/kvm/kvm_main.c | 74 ++++++++++++++++++++++++--------- 14 files changed, 74 insertions(+), 43 deletions(-) -- 2.25.1 _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mm01.cs.columbia.edu (mm01.cs.columbia.edu [128.59.11.253]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6382AC433F5 for ; Mon, 27 Dec 2021 09:57:12 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id C0767411BD; Mon, 27 Dec 2021 04:57:11 -0500 (EST) X-Virus-Scanned: at lists.cs.columbia.edu Authentication-Results: mm01.cs.columbia.edu (amavisd-new); dkim=softfail (fail, message has been altered) header.i=@intel.com Received: from mm01.cs.columbia.edu ([127.0.0.1]) by localhost (mm01.cs.columbia.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id vU3gxb9IYqPh; Mon, 27 Dec 2021 04:57:10 -0500 (EST) Received: from mm01.cs.columbia.edu (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 1AAA64120D; Mon, 27 Dec 2021 04:57:10 -0500 (EST) Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id D795E40BDC for ; Mon, 27 Dec 2021 03:17:15 -0500 (EST) X-Virus-Scanned: at lists.cs.columbia.edu Received: from mm01.cs.columbia.edu ([127.0.0.1]) by localhost (mm01.cs.columbia.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id KtSDD0BbFkYx for ; Mon, 27 Dec 2021 03:17:14 -0500 (EST) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by mm01.cs.columbia.edu (Postfix) with ESMTPS id D06BD40C80 for ; Mon, 27 Dec 2021 03:17:13 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1640593033; x=1672129033; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=tCJzGvAoR9V3Cf25Th6SaPQVLQdtAnnLPINob5E2Vys=; b=RXV3TFHXVyh2oG96Erac847w+s9TXkyX91FRqj7Tp+KUucvNPu9/NABs pyNxLdhJcYbp2cbkmzH+CLAon3MIGyhwxZhxCsIO1d0D/D8j2GXh0RSyz rzp1Z4s4f81gLgoR35Edj8R+aha9uHq4PLQdvqROTM8G9YDLHB3bcHHQW KZ/b+Jk3oABmAI1nCWCImIKg2R2+eSt1tU8b6GXSDUq6eeUj2hG981Sol SpWES6K8p+u8VN7RkC3LHsJb5ntKbx6NyZP+GFV9zMg4OcVqaNzKo6Awy 1p2ctmy4nc8cpWnI+mvCcgxPvsHaH7uRToLiRdimWyN0WZ1+zQmO1teGz A==; X-IronPort-AV: E=McAfee;i="6200,9189,10209"; a="241396750" X-IronPort-AV: E=Sophos;i="5.88,239,1635231600"; d="scan'208";a="241396750" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Dec 2021 00:17:12 -0800 X-IronPort-AV: E=Sophos;i="5.88,239,1635231600"; d="scan'208";a="523207964" Received: from unknown (HELO hyperv-sh4.sh.intel.com) ([10.239.48.22]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Dec 2021 00:16:56 -0800 From: Chao Gao To: kvm@vger.kernel.org, pbonzini@redhat.com, kevin.tian@intel.com, tglx@linutronix.de Subject: [PATCH 0/6] Improve KVM's interaction with CPU hotplug Date: Mon, 27 Dec 2021 16:15:06 +0800 Message-Id: <20211227081515.2088920-1-chao.gao@intel.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Mailman-Approved-At: Mon, 27 Dec 2021 04:57:09 -0500 Cc: Guo Ren , Wanpeng Li , David Hildenbrand , Benjamin Herrenschmidt , "Maciej S. Szmigiero" , Dave Hansen , x86@kernel.org, linux-mips@vger.kernel.org, Atish Patra , Paul Mackerras , "H. Peter Anvin" , Alexander Gordeev , Claudio Imbrenda , Will Deacon , kvmarm@lists.cs.columbia.edu, linux-s390@vger.kernel.org, Janosch Frank , Marc Zyngier , Joerg Roedel , Huacai Chen , linux-riscv@lists.infradead.org, Aleksandar Markovic , Ingo Molnar , Catalin Marinas , Palmer Dabbelt , Christian Borntraeger , Chao Gao , Ravi Bangoria , Albert Ou , Vasily Gorbik , Heiko Carstens , John Garry , Nicholas Piggin , Shaokun Zhang , Borislav Petkov , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Paul Walmsley , Sumanth Korikkar , linux-arm-kernel@lists.infradead.org, Jim Mattson , Thomas Bogendoerfer , Fabiano Rosas , Mel Gorman , Anup Patel , Nick Desaulniers , linux-kernel@vger.kernel.org, Bharata B Rao , kvm-riscv@lists.infradead.org, Michael Ellerman , Vitaly Kuznetsov , linuxppc-dev@lists.ozlabs.org, Thomas Richter X-BeenThere: kvmarm@lists.cs.columbia.edu X-Mailman-Version: 2.1.14 Precedence: list List-Id: Where KVM/ARM decisions are made List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: kvmarm-bounces@lists.cs.columbia.edu Sender: kvmarm-bounces@lists.cs.columbia.edu 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 if there is a running VM. 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 (6): KVM: x86: Move check_processor_compatibility from init ops to runtime ops KVM: x86: Use kvm_x86_ops in kvm_arch_check_processor_compat KVM: Remove opaque from kvm_arch_check_processor_compat KVM: Rename and move CPUHP_AP_KVM_STARTING to ONLINE section KVM: x86: Remove WARN_ON in kvm_arch_check_processor_compat KVM: Do compatibility checks on hotplugged CPUs arch/arm64/kvm/arm.c | 2 +- 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_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 | 12 +++--- arch/x86/kvm/x86.c | 7 +--- include/linux/cpuhotplug.h | 2 +- include/linux/kvm_host.h | 2 +- virt/kvm/kvm_main.c | 74 ++++++++++++++++++++++++--------- 14 files changed, 74 insertions(+), 43 deletions(-) -- 2.25.1 _______________________________________________ kvmarm mailing list kvmarm@lists.cs.columbia.edu https://lists.cs.columbia.edu/mailman/listinfo/kvmarm From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 19590C433EF for ; Tue, 28 Dec 2021 08:49:55 +0000 (UTC) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4JNSsF1xHkz3017 for ; Tue, 28 Dec 2021 19:49:53 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=VhBPscMe; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=intel.com (client-ip=192.55.52.115; helo=mga14.intel.com; envelope-from=chao.gao@intel.com; receiver=) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=VhBPscMe; dkim-atps=neutral Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4JMrCL3blrz2yJV for ; Mon, 27 Dec 2021 19:18:16 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1640593102; x=1672129102; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=tCJzGvAoR9V3Cf25Th6SaPQVLQdtAnnLPINob5E2Vys=; b=VhBPscMeLk+9XUXgAJJh18QxsKLLXSh1ZtxZ9YahYKngt0Z3jKDNs73F IxVb8m0Fp7tb3upa5bSNbgKflOvQDmc1c8+qAgXZaQzuJsBbDGpOp859d 8Bh5+TW4QfODrAx5T3VyDUx/kMyP2YrSDrqGX8wULbBaxJYTuZq9x3fvd y8trr1dudrttuOJrAGXvO6gDECHZhC5fEK+x0arPYkbL5GhFU4ukiFp4o FbvxeBWxzdUfd4rtjSFJsNEHBTCpCs0KxWaYnxwvlcL+e9KVseapPHMii xfUhwdDZCrgOfQybZLOkpSIGLtxNPnwUtETL5t/C3OGiBpuVBe6LDnNMp g==; X-IronPort-AV: E=McAfee;i="6200,9189,10209"; a="241396749" X-IronPort-AV: E=Sophos;i="5.88,239,1635231600"; d="scan'208";a="241396749" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Dec 2021 00:17:12 -0800 X-IronPort-AV: E=Sophos;i="5.88,239,1635231600"; d="scan'208";a="523207964" Received: from unknown (HELO hyperv-sh4.sh.intel.com) ([10.239.48.22]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Dec 2021 00:16:56 -0800 From: Chao Gao To: kvm@vger.kernel.org, pbonzini@redhat.com, kevin.tian@intel.com, tglx@linutronix.de Subject: [PATCH 0/6] Improve KVM's interaction with CPU hotplug Date: Mon, 27 Dec 2021 16:15:06 +0800 Message-Id: <20211227081515.2088920-1-chao.gao@intel.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Mailman-Approved-At: Tue, 28 Dec 2021 19:49:15 +1100 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Guo Ren , Wanpeng Li , David Hildenbrand , "Maciej S. Szmigiero" , Dave Hansen , x86@kernel.org, linux-mips@vger.kernel.org, Atish Patra , Paul Mackerras , "H. Peter Anvin" , Alexander Gordeev , Claudio Imbrenda , Will Deacon , kvmarm@lists.cs.columbia.edu, linux-s390@vger.kernel.org, Janosch Frank , Marc Zyngier , Joerg Roedel , Huacai Chen , linux-riscv@lists.infradead.org, Aleksandar Markovic , Ingo Molnar , Catalin Marinas , Palmer Dabbelt , Christian Borntraeger , Chao Gao , Ravi Bangoria , Albert Ou , Vasily Gorbik , Suzuki K Poulose , Heiko Carstens , John Garry , Nicholas Piggin , Shaokun Zhang , Borislav Petkov , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Paul Walmsley , Sumanth Korikkar , Sean Christopherson , Alexandru Elisei , linux-arm-kernel@lists.infradead.org, Jim Mattson , Thomas Bogendoerfer , Fabiano Rosas , Mel Gorman , Anup Patel , Nick Desaulniers , linux-kernel@vger.kernel.org, Bharata B Rao , James Morse , kvm-riscv@lists.infradead.org, Vitaly Kuznetsov , linuxppc-dev@lists.ozlabs.org, Thomas Richter Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" 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 if there is a running VM. 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 (6): KVM: x86: Move check_processor_compatibility from init ops to runtime ops KVM: x86: Use kvm_x86_ops in kvm_arch_check_processor_compat KVM: Remove opaque from kvm_arch_check_processor_compat KVM: Rename and move CPUHP_AP_KVM_STARTING to ONLINE section KVM: x86: Remove WARN_ON in kvm_arch_check_processor_compat KVM: Do compatibility checks on hotplugged CPUs arch/arm64/kvm/arm.c | 2 +- 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_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 | 12 +++--- arch/x86/kvm/x86.c | 7 +--- include/linux/cpuhotplug.h | 2 +- include/linux/kvm_host.h | 2 +- virt/kvm/kvm_main.c | 74 ++++++++++++++++++++++++--------- 14 files changed, 74 insertions(+), 43 deletions(-) -- 2.25.1