Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp938553rwb; Thu, 10 Nov 2022 09:07:55 -0800 (PST) X-Google-Smtp-Source: AMsMyM5DIvc8v9ZBPxL7bBjX5KfakvMcpANzrJ8rnLX0CoXVWEW0jzCSFdSKf+69io284KmliC4h X-Received: by 2002:a17:902:d2c6:b0:17c:1c61:4aec with SMTP id n6-20020a170902d2c600b0017c1c614aecmr1589759plc.112.1668100074807; Thu, 10 Nov 2022 09:07:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668100074; cv=none; d=google.com; s=arc-20160816; b=dzTlu/jusfSinjIpFrWB1z3xp1f+2hD5u8mBzIgLh1MTU6/Kzo2JctewDoxz7p7pSC faMZby2UPQwGepFgKDgNqKALlUEAyumqwGnmOgcIj+RZ62JqJNRkSoRblAYU6joQF0h+ BniGdwBD4O6imUQiyc0rulAL7sIoDnXbUU71g4gPeBEzSvnfDKp/EMFR0dEHMpRQpXwb WOc0pDyKA98Z/lT/KeIH2pIkFCua5ZHlA3vcYCCK7A8r5FKSGBv21N+g1YvuL+UsqkDq SMdwr1XgKDyYdPqzEmM5+UCj9b8wcABTUZ7iDQjBlK5lkuaD00pvsSm+b/uRspUs3NyP L2Vw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=rPjVc+C4keVB9JNeySRKdiTbUPe13351AhOJe9TtZf8=; b=QN+/QNjMoNt5nxAp31n75U6bwHBkLUf57qei/2udMXkr1lrVXLU5ZFFcB81ykNq242 RZOcleGL4YtplqkfCaKtzF0E6rO5G1VyVuLzKWgHuNBpQWcRcVyhRl/8w5Atn7KulRKC eoebvPrGKoArB1mXOsYs0QPWsY1wrmM+vjYcLhkQ0fMcXbtg6EuhGi116W0+/wZW0bHv xRXbmQcnVABqwvLDzjVg4DiMGefRyzVA6K/duQ2FhRWWj9fk1t+3sbJeI/3POpO6lYoR Ydkzm1SYffhfpOV3aYA6HhPiQ06gnTHap9nNRMmdUDupjTj+OUNQvs7KjN8SgPvGEEL6 PB5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=OOR4bwRU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v18-20020a63f852000000b0046fd4b828b4si18650631pgj.354.2022.11.10.09.07.35; Thu, 10 Nov 2022 09:07:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=OOR4bwRU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232426AbiKJQua (ORCPT + 92 others); Thu, 10 Nov 2022 11:50:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49318 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232086AbiKJQuI (ORCPT ); Thu, 10 Nov 2022 11:50:08 -0500 Received: from mail-pj1-x1032.google.com (mail-pj1-x1032.google.com [IPv6:2607:f8b0:4864:20::1032]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BD622A474 for ; Thu, 10 Nov 2022 08:49:34 -0800 (PST) Received: by mail-pj1-x1032.google.com with SMTP id gw22so1992202pjb.3 for ; Thu, 10 Nov 2022 08:49:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=rPjVc+C4keVB9JNeySRKdiTbUPe13351AhOJe9TtZf8=; b=OOR4bwRUplBbyMMh2BEwu+86VP3qxijSJnezQ7clymoLz9HUcLonm3WyVFc88kB5fY O/E+L3vna3lCH6PwuGGALEpEbdqf//FCQPJXnQH0fruVZmuKpiXxpksMlHLNli5FBIVk yHcqF3ftlcFWSWpaRO18yKIRlZ4MLKYwLTrjNA/qL4cv528Rj8wkmrotYw4AfXaxmJus pcCX78Uh4a0+xqNPkY5yiRwsOaQfBATcwvX2XL8kq2aQkn5xXT0ESqE2s4sWnkM2XUP1 lN0YUhWFEsDiU77d2rUZObTRDQeLPD96HT9QdyztVtB+kfc9jl7KnKnrsPBskzRSRVH/ XRTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=rPjVc+C4keVB9JNeySRKdiTbUPe13351AhOJe9TtZf8=; b=j1i39vbAZAKgRUfhuDpKp31mtmzkCWq9M4OzjptNm7Bd6o7ent+qZhVQl2nRP8irbN 2qfb9lQcko8rWAcocvCCDBX4zM0ivHCEogUrKYamUcJHIHdA6hRjzBku2gXYJEDXZHLp xYp8LrAP8c+96pHQcS6Wd3sVPs2foqnfa9xsaRqraMpEMMoP7F+JCrCX0JZodQ+/vnd1 ua36WHZbWvMrEhLCv5wwaXhowh0/PbNO2DMJux60UjjHsNtDyNdX5CHAnUlX5HeP6L+e Xnrt3ZSn/s2da5erI2NwMlVzGybuh0oAtWyOWJxE+6mM8eMHdL/fEFTpv1mJqREYJEmW l9kQ== X-Gm-Message-State: ACrzQf1DQiBLAm94IlFpzXkrzudguq0fMR+LBhehW4Ql81FvTWWdk1JJ wyjxAKHCKI87EsXb/0jLY9OcTg== X-Received: by 2002:a17:902:d50c:b0:187:460:bf9c with SMTP id b12-20020a170902d50c00b001870460bf9cmr65545589plg.4.1668098974180; Thu, 10 Nov 2022 08:49:34 -0800 (PST) Received: from google.com (7.104.168.34.bc.googleusercontent.com. [34.168.104.7]) by smtp.gmail.com with ESMTPSA id c3-20020a17090a020300b00205d85cfb30sm3288107pjc.20.2022.11.10.08.49.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Nov 2022 08:49:33 -0800 (PST) Date: Thu, 10 Nov 2022 16:49:29 +0000 From: Sean Christopherson To: Robert Hoo Cc: Paolo Bonzini , Marc Zyngier , Huacai Chen , Aleksandar Markovic , Anup Patel , Paul Walmsley , Palmer Dabbelt , Albert Ou , Christian Borntraeger , Janosch Frank , Claudio Imbrenda , Matthew Rosato , Eric Farman , Vitaly Kuznetsov , James Morse , Alexandru Elisei , Suzuki K Poulose , Oliver Upton , Atish Patra , David Hildenbrand , kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, kvmarm@lists.cs.columbia.edu, linux-mips@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, Isaku Yamahata , Fabiano Rosas , Michael Ellerman , Chao Gao , Thomas Gleixner , Yuan Yao Subject: Re: [PATCH 37/44] KVM: Rename and move CPUHP_AP_KVM_STARTING to ONLINE section Message-ID: References: <20221102231911.3107438-1-seanjc@google.com> <20221102231911.3107438-38-seanjc@google.com> <301a8a33a5cbe5b4fd3efe03b05bb8410a46e9f5.camel@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <301a8a33a5cbe5b4fd3efe03b05bb8410a46e9f5.camel@linux.intel.com> X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=unavailable 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 On Thu, Nov 10, 2022, Robert Hoo wrote: > > -static int kvm_starting_cpu(unsigned int cpu) > > +static int kvm_online_cpu(unsigned int cpu) > > { > > + int ret = 0; > > + > > raw_spin_lock(&kvm_count_lock); > > - if (kvm_usage_count) > > + /* > > + * Abort the CPU online process if hardware virtualization > > cannot > > + * be enabled. Otherwise running VMs would encounter > > unrecoverable > > + * errors when scheduled to this CPU. > > + */ > > + if (kvm_usage_count) { > > + WARN_ON_ONCE(atomic_read(&hardware_enable_failed)); > > + > > hardware_enable_nolock(NULL); > > + if (atomic_read(&hardware_enable_failed)) { > > + atomic_set(&hardware_enable_failed, 0); > > I see other places using this hardware_enable_failed with atomic_inc(), > should here use atomic_dec() instead of straightly set to 0? Meh, both options are flawed. E.g. if hardware_enable_failed was left dangling (the WARN above), then atomic_dec() won't remedy the problem and KVM will reject onlining CPUs indefinitely. Forcing the atomic back to '0' will remedy that particular issue, but could lead to problems if there are other bugs. > Though here is embraced by spin_lock, hardware_enable_nolock() can be > invoked in other places in parallel? Only because of a KVM bug, which gets fixed in the next patch: KVM: Disable CPU hotplug during hardware enabling