Received: by 2002:a05:6a10:a841:0:0:0:0 with SMTP id d1csp810105pxy; Wed, 28 Apr 2021 14:48:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxFMxsgWye4R0Lk7aI8zRH1+Q78eOTOF1+j5pAamtFi69A8tOSMZHfmkAtaxKIw85k2AZ9h X-Received: by 2002:a17:90a:8906:: with SMTP id u6mr35276479pjn.162.1619646486650; Wed, 28 Apr 2021 14:48:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619646486; cv=none; d=google.com; s=arc-20160816; b=MCo9MmkH+7NNauY82YsY4a+7kathKqrx+Sw568SM3ohDWSsAPJEsj6BNTmm8m9OhOQ 4bCeZRZKche216PPpELveXybUOp72o6+VTMnb13FCM4NzkCRXGiJ2ISq5p+5vryyFFZ7 g/1BjY8hsijn9PLu0wsE9ncx+YYi2YecveT7cP6C/K9g6FHVRg4C04FlvZm3Iz5dnnsF CMbwfz+SurqrqeUN/ZopFozZllwuT+QRDqeljdPBgfeT004WqrU3pmntOR+nSItpVlTO c23V/ac3HRG6RQrj4Px0TQJ72BfeU71TO8SZMtrIMoJ0XXra8dPeggjc1DWCLTfIAVcg YYhQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=jE1E10cGmiSxQu3rQMfcH0+7CTwQjkmgUeVjmmNpp6c=; b=UjagDh5jdqomK6q73q7c2I81stsFm3NVN3VbBDvoBSM7hQQGljX47p4Yw6SY2rzPPy 2GDbmBVVxw7Z/pVtqij+Bl/mNukvF7704SZItYMeqzkgVwvG47Ej8e0+XaV4pvIco8Fk XvYWz8m9Y9moQevnCqY56lAuuphi/XG3SAvSs8eJk8lOZ/xweFEz72DJO9A7syY7vsjJ 4XEkMFuTreTRp36KsfQuTHXw4O0hClPdzzXj1DMUEc3O/ObTyDZoEuB3uxkpud2q+5LJ zBJzMYhH8n4zLFVKhltiklwR3MXkTR0jYOqiI6W6txMoHC4XZrEsiiGWtS+zIK28L7Zl 6d6Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="l/8Tzlss"; 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 x21si937522plm.142.2021.04.28.14.47.53; Wed, 28 Apr 2021 14:48:06 -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="l/8Tzlss"; 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 S231400AbhD1Vre (ORCPT + 99 others); Wed, 28 Apr 2021 17:47:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46280 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229890AbhD1Vrd (ORCPT ); Wed, 28 Apr 2021 17:47:33 -0400 Received: from mail-ot1-x32e.google.com (mail-ot1-x32e.google.com [IPv6:2607:f8b0:4864:20::32e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F0F65C06138B for ; Wed, 28 Apr 2021 14:46:46 -0700 (PDT) Received: by mail-ot1-x32e.google.com with SMTP id v23-20020a9d60570000b02902a53bac99a3so4949091otj.5 for ; Wed, 28 Apr 2021 14:46:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=jE1E10cGmiSxQu3rQMfcH0+7CTwQjkmgUeVjmmNpp6c=; b=l/8TzlssY3PiJZtW54q7AoA6lZZauP2ipudz7fax18/n36l3wFP+NFeJKcr0NQGpzs LttGshZngyDW4v/9Fp6Nx+O43NfXC86dgxGG7lHkn/23tMgWxXL4f6M4Q2nshTc/tiB+ YKzGBqlbYPPhYjSaFEI0M+5FEjwt86AcDMfbzGBhcAk2yOyLOTswO6BnywhSQnCz7CXG 8kyU/OYuzsaybobtl2O71BpVIJip5teIk80KgZG8JDT471+CGpMr3Qzq94WiE4YfqWt0 E5G+2HIw95CualvAqUfzl1+FzNnPTozfKWGaolIp+edUiwtcyBs3hZQWScbh3GEDX2J0 dt6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=jE1E10cGmiSxQu3rQMfcH0+7CTwQjkmgUeVjmmNpp6c=; b=RPnWxjHyNGgiI+Kt8B/ETNb28NpCtnnuF5Gwued9O6z769UmJ9mh/UacS69FIFP0fD 5p1r+CMWstvRBl7xJHP5T2BXyr19EYscjaS/Wv7G5ikWL92NsaQSbeEXWFoukUfaFQuR 2n+rjawEcrfW0i3kyjxzEy8au1PtC8X7o0uavMKehDRCphZD0u3Bgg5PFXPxv2CqZZXh BCkUmL02r3VApBSJO/VW7IWOD8kFgVCCJ2by74UkeNPdZKjsGfPZt9jFUP2p+p2zLzAO gEmFGCMQykZCAac1sl1xs2UnZc/A5l/U0se67HYeeVNdATcuS5K9AmxgIc/Po0jir5nv wqyg== X-Gm-Message-State: AOAM53239WxFudkHn9hClQJ8BFf38wOsSXSQzueLpmI30AkTfehK+Tl1 Pjfr2ert7vMUGkqdq+mC4FbPmXMMP9DUW0526taZ8avO4ac= X-Received: by 2002:a05:6830:2159:: with SMTP id r25mr25458409otd.313.1619646406176; Wed, 28 Apr 2021 14:46:46 -0700 (PDT) MIME-Version: 1.0 References: <20210427223635.2711774-1-bgardon@google.com> <20210427223635.2711774-6-bgardon@google.com> <997f9fe3-847b-8216-c629-1ad5fdd2ffae@redhat.com> <5b4a0c30-118c-da1f-281c-130438a1c833@redhat.com> In-Reply-To: <5b4a0c30-118c-da1f-281c-130438a1c833@redhat.com> From: Ben Gardon Date: Wed, 28 Apr 2021 14:46:35 -0700 Message-ID: Subject: Re: [PATCH 5/6] KVM: x86/mmu: Protect kvm->memslots with a mutex To: Paolo Bonzini Cc: LKML , kvm , Peter Xu , Sean Christopherson , Peter Shier , Junaid Shahid , Jim Mattson , Yulei Zhang , Wanpeng Li , Vitaly Kuznetsov , Xiao Guangrong Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Apr 28, 2021 at 2:41 PM Paolo Bonzini wrote: > > On 28/04/21 22:40, Ben Gardon wrote: > > ... However with the locking you propose below, we might still run > > into issues on a move or delete, which would mean we'd still need the > > separate memory allocation for the rmaps array. Or we do some > > shenanigans where we try to copy the rmap pointers from the other set > > of memslots. > > If that's (almost) as easy as passing old to > kvm_arch_prepare_memory_region, that would be totally okay. Unfortunately it's not quite that easy because it's all the slots _besides_ the one being modified where we'd need to copy the rmaps. > > > My only worry is the latency this could add to a nested VM launch, but > > it seems pretty unlikely that that would be frequently coinciding with > > a memslot change in practice. > > Right, memslot changes in practice occur only at boot and on hotplug. > If that was a problem we could always make the allocation state > off/in-progress/on, allowing to check the allocation state out of the > lock. This would only potentially slow down the first nested VM launch. > > Paolo >