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 5E580C433FE for ; Fri, 15 Apr 2022 15:11:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1354868AbiDOPNq (ORCPT ); Fri, 15 Apr 2022 11:13:46 -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-Google-Smtp-Source: ABdhPJwRXN1RrezyBqEZ+IY/VFhjmhlZMehG7cvvOaL9gxMM5+8b7OuhIia8rfhpjyKECtKZUzAh/g== 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: 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;