Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3791766pxj; Tue, 11 May 2021 11:57:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw8UXR/uWgG4XshpIaBhbs0+91u/svkFH47PYuNVyOwHfSFckBfNOX49bHitngk+NQKDQgZ X-Received: by 2002:aa7:cc98:: with SMTP id p24mr13280167edt.353.1620759434736; Tue, 11 May 2021 11:57:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620759434; cv=none; d=google.com; s=arc-20160816; b=ugJdT1n+ZyCWoG5MLtNOqcY5NOZzgA16/g9F0U0Knl3V1ZM0nM5SKIwy+M9Na7xDg7 5xb57AmaBuFkQxgJDkYqcMS59PXt8ExzbaQlwML/LFiMUvPQrzrLpOK7tn97piEndOqu qaR7+YXgq+CSmsvxWyoDe/M37Psca04RaC9DJDSnUK9r70zKAO+dFgtp+RSs53rzBRwH jw1vRk4GJ3n+powJe4zKnFTbzvNEu2D4jkilnegR+WGVTCOSwC55pbNuOcD3sNyog3b4 uY5f58EqHUcLULNzFJ2mNFh2dVwPcaodeTGUkU3R3qij7FYPUbRpfqbbWINQR4nk1hai TNLQ== 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=6CV/Ogv2k+2pDmDGhqvW2m8g2EESP7gyWTlebIXjFfA=; b=Szbcwz5yGbZ3+QHux2bnN7F/++1XZ7Z6/KGzBw34aW4+9/AC4LBziEYGy5GXx7ALGu egmd/CmS+bbKSk8trTkdgSINlpPp6dBH60R2gUUdr0JlNpC5lWoRHHw3jOthPmYMbI16 2yYC5MPXX78VlDp3EfY3Gd1NNzys50GryqaAu5SOocUm9yPexpB7DG6hF972FKfrsP5h 4kkzTHtYNRDiBBTbUuzju8TThY6WBhIIU4aE4UmjIYJVO0qL+jGkDbl4e+VIdMxYcPC5 KD5OTKGLdT6hZI0z9gM0zPEgj969vx/Ri4AgB1D2zGdsSmZWyY6ywUbVxZOuYBVyDaWl doxQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="LokGQ/5F"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g21si17176999ejx.118.2021.05.11.11.56.51; Tue, 11 May 2021 11:57:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="LokGQ/5F"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.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: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232075AbhEKS4t (ORCPT + 99 others); Tue, 11 May 2021 14:56:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53280 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232060AbhEKS4s (ORCPT ); Tue, 11 May 2021 14:56:48 -0400 Received: from mail-pg1-x532.google.com (mail-pg1-x532.google.com [IPv6:2607:f8b0:4864:20::532]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1F53FC061574 for ; Tue, 11 May 2021 11:55:42 -0700 (PDT) Received: by mail-pg1-x532.google.com with SMTP id q15so12173922pgg.12 for ; Tue, 11 May 2021 11:55:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=6CV/Ogv2k+2pDmDGhqvW2m8g2EESP7gyWTlebIXjFfA=; b=LokGQ/5F+E/QlHM7wtqfs3lxNKOPqpwSPZ1fAcNxJtSUTegVrsoke3T5wOEAgFpV8c pljKlJUuyXV/a1iKdeMuO5NGSokbEAEYY1G1AWNDbNF6wBLurD5SWhztTiIM53c0vanl wbJ7Cporb4a5VkZBNI3pRcWSQhRIzFF3lMGAVsBV7ifdvZN200uAGrWx5Fb28nhordUk azaHGbCizKsUe+bmcZd0wyApPKoLfPQJJd9FwxcibnVAsHSNhKQ0Qa57ZiDhw5Km9jE0 jxWRWJuaduVQABk7jSrTmIlbSb3wS+pf5P+gp9thLBaemgJ7pgOyuMf62Og38y1nSHQi S9ZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=6CV/Ogv2k+2pDmDGhqvW2m8g2EESP7gyWTlebIXjFfA=; b=oYEUw40Uz/megt3I/O5ETp7PejIbEpVMrIAOkthZl3XpPSYgoI62ayB4nGvSs8dj7/ MeHozJgKRAORSqjG20X/xSlpGfBPvA6KFekXT8PSYhPVJArT9m3Dxt02qJVYKMVcVyHV 5+UYIlF+uYsKWoUaeV6xmUNAbnyogod66GbIdMvS6VRtSY/Ttvpm/6dOyYh563SrdLwq oVopvqu1fqv49cqXxZTZgidUepkx53T6tDu7nz+zaR2Qie1wNeNDld7mOekb74E2xbDP 4geO1919P5jEyDSaFZNPrs6JjMi3rx5cA26L7g7b3Ttqu3Qtvi92CV1g6KKcResENC+B s5sA== X-Gm-Message-State: AOAM531Kr1Yamo+2p9/vNjlo5Mernb55pGG4SzMRKHO5MNxhxncdXTzu TuFk++6FcZ4XXCzcFODQLeZgtg== X-Received: by 2002:a62:2901:0:b029:28e:ef3d:10d2 with SMTP id p1-20020a6229010000b029028eef3d10d2mr30934510pfp.45.1620759341453; Tue, 11 May 2021 11:55:41 -0700 (PDT) Received: from google.com (240.111.247.35.bc.googleusercontent.com. [35.247.111.240]) by smtp.gmail.com with ESMTPSA id w81sm14021632pfc.106.2021.05.11.11.55.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 May 2021 11:55:40 -0700 (PDT) Date: Tue, 11 May 2021 18:55:37 +0000 From: Sean Christopherson To: Ben Gardon Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org, Paolo Bonzini , Peter Xu , Peter Shier , Yulei Zhang , Wanpeng Li , Xiao Guangrong , Kai Huang , Keqian Zhu , David Hildenbrand Subject: Re: [PATCH v4 4/7] KVM: mmu: Add slots_arch_lock for memslot arch fields Message-ID: References: <20210511171610.170160-1-bgardon@google.com> <20210511171610.170160-5-bgardon@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210511171610.170160-5-bgardon@google.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, May 11, 2021, Ben Gardon wrote: > Add a new lock to protect the arch-specific fields of memslots if they > need to be modified in a kvm->srcu read critical section. A future > commit will use this lock to lazily allocate memslot rmaps for x86. > > Signed-off-by: Ben Gardon > --- > include/linux/kvm_host.h | 9 +++++++++ > virt/kvm/kvm_main.c | 31 ++++++++++++++++++++++++++----- > 2 files changed, 35 insertions(+), 5 deletions(-) > > diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h > index 8895b95b6a22..2d5e797fbb08 100644 > --- a/include/linux/kvm_host.h > +++ b/include/linux/kvm_host.h > @@ -472,6 +472,15 @@ struct kvm { > #endif /* KVM_HAVE_MMU_RWLOCK */ > > struct mutex slots_lock; > + > + /* > + * Protects the arch-specific fields of struct kvm_memory_slots in > + * use by the VM. To be used under the slots_lock (above) or in a > + * kvm->srcu read cirtical section where acquiring the slots_lock ^^^^^^^^ critical > + * would lead to deadlock with the synchronize_srcu in > + * install_new_memslots. > + */ > + struct mutex slots_arch_lock; > struct mm_struct *mm; /* userspace tied to this vm */ > struct kvm_memslots __rcu *memslots[KVM_ADDRESS_SPACE_NUM]; > struct kvm_vcpu *vcpus[KVM_MAX_VCPUS];