Received: by 2002:a19:f614:0:0:0:0:0 with SMTP id x20csp54793lfe; Fri, 15 Apr 2022 19:11:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxLqz7PRVFn1uid35+YGq3prY74XpdRr1o8NxjMl0AKUAD8CXIsrGHWUw0oz92aov7/2QeX X-Received: by 2002:aa7:9419:0:b0:50a:3eaa:2841 with SMTP id x25-20020aa79419000000b0050a3eaa2841mr1629476pfo.63.1650075098758; Fri, 15 Apr 2022 19:11:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650075098; cv=none; d=google.com; s=arc-20160816; b=mDcJRz/kvILGo5JU2by8KeMXNOJrozikKnj31zH2DatRrDyuoLRuot0A34T+VXHEYa cb+M/qK5yQomqu0Py4JnSd/KXx6hRYftnP2RJnoNhtd1j/lxC3CEe0OawspXJ1dGUjy8 T9oWsMhEcOdIrd9bLCfSDaNrRWBlRqhU9R9l+9AGbNp1V+kP9TQy2EVeVd6PbE9Iu9Px nXeQiqQVJx35lo/8/QuAooLgA5xuFus8erIkvI3YjigWVrppfuulsPI2kZBtSnK9fumh sTfHpKj1g25qu0CKFMZr/2Dc67Jh1oihQMRMbe6KphiH9S4OxJxbAfCgYCs1puh6Zt0J w4cA== 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=XpMI5o1rh+ASC743fTR6XcDs+QqXkiVRQcevUp4zbQE=; b=gMQWHcMAOV0HfH73Ia5O6EVZ+0dtXXwaxJXn+ZRs+7GcTKATVtBxEUQczMYsihBtPb WOYsH4kSvhVDKA8QD3ERcH/XBaUsoqPa5Id1jJh9KkWjQ+6fnPRJ8U+ZATWF3ofpwt6A ppwPIa+KPODaQpDUgSmGJW7UHXepjS2YiwbCh4Q8nUaGsy12dgf9171GA93ju3fl75Oo BLuO4uU5czBm559TTLS33XyXDAgI8BAkKzOBpsjH5X4H9k+Ej2IDjvSJKDZPbLpyu62P XNy9qYeMKsz9jenCCaoIEpJD40RnIMjnBi6Zh2siCc3faIk+E3rlq0nOqzsvOxDvL8iS OJzA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=Pw9QlbYB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id l194-20020a633ecb000000b0039da58b2667si2964744pga.681.2022.04.15.19.11.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Apr 2022 19:11:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=Pw9QlbYB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 3A2721EC9A1; Fri, 15 Apr 2022 18:28:46 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1354858AbiDOPNo (ORCPT + 99 others); Fri, 15 Apr 2022 11:13:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57648 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1354864AbiDOPNn (ORCPT ); Fri, 15 Apr 2022 11:13:43 -0400 Received: from mail-pl1-x634.google.com (mail-pl1-x634.google.com [IPv6:2607:f8b0:4864:20::634]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3E1CF9D4CC for ; Fri, 15 Apr 2022 08:11:13 -0700 (PDT) Received: by mail-pl1-x634.google.com with SMTP id 12so7304433pll.12 for ; Fri, 15 Apr 2022 08:11:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=XpMI5o1rh+ASC743fTR6XcDs+QqXkiVRQcevUp4zbQE=; b=Pw9QlbYBEdNuOSpCDdRCElWVqIH9UdeidruHkQv62YDy+yRw3YBIONulcDGLIEJDVs Ch5Sistmn0s2JtIVfPTuBi3h6qeth8GDo4+SJ4aeyfMGqK5tfI8yc6OxhJyAaoqckGeQ elSD03uyypngyXnD1dfEsXnJKNRco3mTL8g0+DF6/E2U4YbF8K1WWzhgTBmXEVbPXLko 6K5d6cS+ntxAuA05y9t19IyFMDcGX4jdQPKlCn+/ig8uCGzjOCQYtT16klslidzGHn0V V0D+gY2DMs3uoK0fGvmYmPn3b/CI4GfmOAq3jNaALPweh9hTmVKPIR/gh8CrJV1o2C11 sggg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=XpMI5o1rh+ASC743fTR6XcDs+QqXkiVRQcevUp4zbQE=; b=SM4GkSsXtsy0Mi67C0T/JDUA+DsEu+HNPwxf4Ete7MCR8AvO7/kvaOKQqPIzOGM3Oy W+SiMYFEFGJ/qucXhum/V7fPwYVIfttFCPNqOyyEX0gOr3mcHpgvu5XX47m4IW/k1JXJ Om5W6IkNpK8NJ4dF+npoRgzftRyDXZAQ/WsTzwlAgFVBtLutd9IjuOLMTg16icLMBEu+ 9GdYeuRr2n3rQ/+anfgcN50b6gPxEy53b9IWn7ylZmcD+FKzV8Sr+YbcsqufTuGTpqrr ja33uariEpEIx391fww7qh0K6AaAGaQLgYJwCsmsO3K+3u/mMyaGKYitCorcgdC/H9C3 UcfA== X-Gm-Message-State: AOAM5312+MzEUvMiK9MvSDFpaQOzB7oP+FcSNOw2lFi6lxiFt6efUNfX HP/13lEjQBQLtTUk3ecBfY8ALQ== X-Received: by 2002:a17:902:7001:b0:158:43ba:56cc with SMTP id y1-20020a170902700100b0015843ba56ccmr29258356plk.135.1650035472580; Fri, 15 Apr 2022 08:11:12 -0700 (PDT) Received: from google.com (157.214.185.35.bc.googleusercontent.com. [35.185.214.157]) by smtp.gmail.com with ESMTPSA id l22-20020a17090aaa9600b001ca7a005620sm4933327pjq.49.2022.04.15.08.11.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Apr 2022 08:11:11 -0700 (PDT) Date: Fri, 15 Apr 2022 15:11:08 +0000 From: Sean Christopherson To: Zeng Guang Cc: Paolo Bonzini , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , kvm@vger.kernel.org, Dave Hansen , Tony Luck , Kan Liang , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , Kim Phillips , Jarkko Sakkinen , Jethro Beekman , Kai Huang , x86@kernel.org, linux-kernel@vger.kernel.org, Robert Hu , Gao Chao , Marc Zyngier , James Morse , Alexandru Elisei , Suzuki K Poulose , Christian Borntraeger , Janosch Frank , Claudio Imbrenda , David Hildenbrand Subject: Re: [PATCH v8 7/9] KVM: Move kvm_arch_vcpu_precreate() under kvm->lock Message-ID: References: <20220411090447.5928-1-guang.zeng@intel.com> <20220411090447.5928-8-guang.zeng@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-9.5 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE, USER_IN_DEF_DKIM_WL 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 On Fri, Apr 15, 2022, Sean Christopherson wrote: > > It's safe to invoke kvm_arch_vcpu_precreate() within the protection of > > kvm->lock directly rather than take into account in the implementation for > > each architecture. > > This absolutely needs to explain _why_ it's safe, e.g. only arm64, x86, and s390 > have non-nop implementations and they're all simple and short with no tendrils > into other code that might take kvm->lock. > > And as before, I suspect arm64 needs this protection, the vgic_initialized() > check looks racy. Though it's hard to tell if doing the check under kvm->lock > actually fixes anything. Ah, I bet this code in vgic_init() provides the necessary protection. /* Are we also in the middle of creating a VCPU? */ if (kvm->created_vcpus != atomic_read(&kvm->online_vcpus)) return -EBUSY;