From nobody Mon Jun 22 14:24:39 2026 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 5A928C433F5 for ; Tue, 22 Mar 2022 11:07:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234079AbiCVLJU (ORCPT ); Tue, 22 Mar 2022 07:09:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46684 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233987AbiCVLIw (ORCPT ); Tue, 22 Mar 2022 07:08:52 -0400 Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 440A17EA2F; Tue, 22 Mar 2022 04:07:24 -0700 (PDT) Received: by mail-wm1-x331.google.com with SMTP id p184-20020a1c29c1000000b0037f76d8b484so1273909wmp.5; Tue, 22 Mar 2022 04:07:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=QR1B37kNwxZ4YEDzpoJwevUk3AxgLWqrE9jQ8wOSRa0=; b=o4MPYIC6FfRP+P+cJZc2HgIpyrKC5DOpURDQWWVlloiw6BHiLlMlZF7butrX78IQp5 3ppK29Is44kUdB22yEIEpryyk4tY5Vbqf2E81vhU6PEaW1BzhKTU3Z4MF70aCUYqjv4p xkI95soUG4JkS+l8OIK/jz6mr5uSFmrW/HImuDlpJXPtJkfFrdoD1JtZk1jajhHNF9bf w8jxeA5tJpTc7IZTIuCkyUrYQ3jddqz8iO26zzFH9qzZEWUW5BoXDt4P+7u98xTNYWR4 bIeTPwTqGlmSI3pM/BzBjrAhw6CoHZc55Hwka4WAScdfGvgd5NoMtMOFjrOvg7vfjaXo aB0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=QR1B37kNwxZ4YEDzpoJwevUk3AxgLWqrE9jQ8wOSRa0=; b=F8kxzSeDOrDXchjf9X1J/9OMKiio1vFQF6Tu9i1qEzIbxxERuam/aidyh7F4c3VeeP /OlFMU/4r4kqChNYQbCT6qEHPzeOZTP8CVAq1areqeYe0jCg9mhi1zjwZE2vS95wbkI8 bwhz/A3YF1h1mYoXvIlrl07KUuHS2c+S5fPK5tTjU75BZ8tQ7TJZjfLjEf6K0QQAJwt4 5pJWX2Mtuxgo+FT1oypVk5x6XqkNseonZIlUooYQ9qUUj2CT5rvHT1WPq3GEh1RiDkor eYI181GlD8VlOJgk02pqw0lnA3elLJwJzGj6nOWQNJ7Lq2wzYrVpg4Yi0wop0+69Q62z twsA== X-Gm-Message-State: AOAM5318W9HCn31AJkivXAtu4EXnDoeVDhlnFke3Mz5a+8WwWFQM7R+i P1Ed8SfhdB8LMcR4QjjqTwtDVrhzIm8= X-Google-Smtp-Source: ABdhPJw6DgOhPATHqxexglfOBZNO6zf+4E0cjjWWsFQDrBACVtiyLjKx0tMOOg+VIzD+zFAJ+gzCHA== X-Received: by 2002:a05:6000:1848:b0:204:e90:cb55 with SMTP id c8-20020a056000184800b002040e90cb55mr8640436wri.58.1647947242808; Tue, 22 Mar 2022 04:07:22 -0700 (PDT) Received: from avogadro.lan ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id y11-20020a056000168b00b002041af9a73fsm4221856wrd.84.2022.03.22.04.07.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Mar 2022 04:07:22 -0700 (PDT) Sender: Paolo Bonzini From: Paolo Bonzini To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org Subject: [PATCH 1/2] Documentation: kvm: fixes for locking.rst Date: Tue, 22 Mar 2022 12:07:19 +0100 Message-Id: <20220322110720.222499-2-pbonzini@redhat.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220322110720.222499-1-pbonzini@redhat.com> References: <20220322110720.222499-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Separate the various locks clearly, and include the new names of blocked_vc= pu_on_cpu_lock and blocked_vcpu_on_cpu. Signed-off-by: Paolo Bonzini --- Documentation/virt/kvm/locking.rst | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/Documentation/virt/kvm/locking.rst b/Documentation/virt/kvm/lo= cking.rst index 5d27da356836..4f21063bfbd6 100644 --- a/Documentation/virt/kvm/locking.rst +++ b/Documentation/virt/kvm/locking.rst @@ -210,32 +210,41 @@ time it will be set using the Dirty tracking mechanis= m described above. 3. Reference ------------ =20 -:Name: kvm_lock +``kvm_lock`` +^^^^^^^^^^^^ + :Type: mutex :Arch: any :Protects: - vm_list =20 -:Name: kvm_count_lock +``kvm_count_lock`` +^^^^^^^^^^^^^^^^^^ + :Type: raw_spinlock_t :Arch: any :Protects: - hardware virtualization enable/disable :Comment: 'raw' because hardware enabling/disabling must be atomic /wrt migration. =20 -:Name: kvm_arch::tsc_write_lock -:Type: raw_spinlock + +``kvm_arch::tsc_write_lock`` +^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +:Type: raw_spinlock_t :Arch: x86 :Protects: - kvm_arch::{last_tsc_write,last_tsc_nsec,last_tsc_offset} - tsc offset in vmcb :Comment: 'raw' because updating the tsc offsets must not be preempted. =20 -:Name: kvm->mmu_lock -:Type: spinlock_t +``kvm->mmu_lock`` +^^^^^^^^^^^^^^^^^ +:Type: spinlock_t or rwlock_t :Arch: any :Protects: -shadow page/shadow tlb entry :Comment: it is a spinlock since it is used in mmu notifier. =20 -:Name: kvm->srcu +``kvm->srcu`` +^^^^^^^^^^^^^ :Type: srcu lock :Arch: any :Protects: - kvm->memslots @@ -246,10 +255,11 @@ time it will be set using the Dirty tracking mechanis= m described above. The srcu index can be stored in kvm_vcpu->srcu_idx per vcpu if it is needed by multiple functions. =20 -:Name: blocked_vcpu_on_cpu_lock +``wakeup_vcpus_on_cpu_lock`` +^^^^^^^^^^^^^^^^^^^^^^^^^^^^ :Type: spinlock_t :Arch: x86 -:Protects: blocked_vcpu_on_cpu +:Protects: wakeup_vcpus_on_cpu :Comment: This is a per-CPU lock and it is used for VT-d posted-interrupts. When VT-d posted-interrupts is supported and the VM has assigned devices, we put the blocked vCPU on the list blocked_vcpu_on_cpu --=20 2.35.1 From nobody Mon Jun 22 14:24:39 2026 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 42FA8C433EF for ; Tue, 22 Mar 2022 11:07:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233973AbiCVLJP (ORCPT ); Tue, 22 Mar 2022 07:09:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46716 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233989AbiCVLIx (ORCPT ); Tue, 22 Mar 2022 07:08:53 -0400 Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5E2F682D00; Tue, 22 Mar 2022 04:07:25 -0700 (PDT) Received: by mail-wm1-x334.google.com with SMTP id j13-20020a05600c1c0d00b0038c8f94aac2so1642221wms.3; Tue, 22 Mar 2022 04:07:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=7thz8A1qDZ9O9kPPviZdxO9DIiJuxrdkli/BxSR2ssw=; b=n/DsP31Ag3DGCqh9F+O3ZhVFcPBnDla0XMad+AH7nL3g2GNpOYX98M0MANxLiDA7ft WTnGACa4Ie/Jj27sjx6d4hEbGhC20DPbw3KpuEhHuUbvhk5n1p/0vHC4e8kgs4dNxG1Q /zl/yc/O43fRMTg1UgTy0LAmRm71oixqEqi9sT8fZYb3RaZW6PRSLYYEmqbaP/ruyJ5h u7LDrunerom5ZG97edOsrhuy65hCQZRxHMPncTBUTRmTK6QAmp5Py9XYdyn3wthcoW5F 3FaMcPLKri9qFypW1QHXeZKCcto5I6DaouqPT37cM/6ew8IYS8xtubc0lrCPJG2R6nfm U/dw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=7thz8A1qDZ9O9kPPviZdxO9DIiJuxrdkli/BxSR2ssw=; b=V/IjkCURh39gg/ES7njl/FsDC3Nwaa02g0EBQazwdi5LaQDoWY4aFeL8Y+3o1PQg04 qdd0MZhZv4UjtOP4czPWHZASmCepqRDgFY8JpRYUYOkWc+SaDXm0iF+ijOfUpjfhA4aX HiL70khih3cbTj+LRxZ0QnIrc3I7g7h5ZrI759V5YH6QpQ9nq9k8pE9oLpn5v8Djkgzf 6xJSgP5WSDU7mZaWWI5NgfEhxxSF1mzi+9lVc1mI36UT5rSRCUp4kZniFtWE59HfKW+C XS+tMVfZhnTXYJc6XZVXA6iPZYLUXPRM17vC20SS8TLXAl8yHYeSbCj4l+DtqyFaJbd0 ObWw== X-Gm-Message-State: AOAM533mg0KB//24CUFrKOsh3Qj3aXsev6Jh18gotM2+Kv1F0AF7pg3+ lo/BpEXiyMfXkq+Xpn94YbUyStS0RyA= X-Google-Smtp-Source: ABdhPJwlHPsjgi7u2ucteECw2jdvrPzfehXTh8hSg4hWYqw6Xpqyt9hupR+psdsbQWA/eeAP5+L6rw== X-Received: by 2002:a1c:e908:0:b0:38c:782c:2a62 with SMTP id q8-20020a1ce908000000b0038c782c2a62mr3128805wmc.135.1647947243799; Tue, 22 Mar 2022 04:07:23 -0700 (PDT) Received: from avogadro.lan ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id y11-20020a056000168b00b002041af9a73fsm4221856wrd.84.2022.03.22.04.07.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Mar 2022 04:07:23 -0700 (PDT) Sender: Paolo Bonzini From: Paolo Bonzini To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org Subject: [PATCH 2/2] Documentation: kvm: include new locks Date: Tue, 22 Mar 2022 12:07:20 +0100 Message-Id: <20220322110720.222499-3-pbonzini@redhat.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220322110720.222499-1-pbonzini@redhat.com> References: <20220322110720.222499-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" kvm->mn_invalidate_lock and kvm->slots_arch_lock were not included in the documentation, add them. Signed-off-by: Paolo Bonzini --- Documentation/virt/kvm/locking.rst | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Documentation/virt/kvm/locking.rst b/Documentation/virt/kvm/lo= cking.rst index 4f21063bfbd6..486efcd36fd6 100644 --- a/Documentation/virt/kvm/locking.rst +++ b/Documentation/virt/kvm/locking.rst @@ -226,6 +226,12 @@ time it will be set using the Dirty tracking mechanism= described above. :Comment: 'raw' because hardware enabling/disabling must be atomic /wrt migration. =20 +``kvm->mn_invalidate_lock`` +^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +:Type: spinlock_t +:Arch: any +:Protects: mn_active_invalidate_count, mn_memslots_update_rcuwait =20 ``kvm_arch::tsc_write_lock`` ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -255,6 +261,15 @@ time it will be set using the Dirty tracking mechanism= described above. The srcu index can be stored in kvm_vcpu->srcu_idx per vcpu if it is needed by multiple functions. =20 +``kvm->slots_arch_lock`` +^^^^^^^^^^^^^^^^^^^^^^^^ +:Type: mutex +:Arch: any (only needed on x86 though) +:Protects: any arch-specific fields of memslots that have to be modif= ied + in a ``kvm->srcu`` read-side critical section. +:Comment: must be held before reading the pointer to the current mem= slots, + until after all changes to the memslots are complete + ``wakeup_vcpus_on_cpu_lock`` ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ :Type: spinlock_t --=20 2.35.1