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 X-Spam-Level: X-Spam-Status: No, score=-2.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0B924C35242 for ; Fri, 7 Feb 2020 18:07:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E36F620726 for ; Fri, 7 Feb 2020 18:07:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727114AbgBGSHW (ORCPT ); Fri, 7 Feb 2020 13:07:22 -0500 Received: from mga14.intel.com ([192.55.52.115]:38121 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726900AbgBGSHV (ORCPT ); Fri, 7 Feb 2020 13:07:21 -0500 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 07 Feb 2020 10:07:20 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,414,1574150400"; d="scan'208";a="432641480" Received: from sjchrist-coffee.jf.intel.com (HELO linux.intel.com) ([10.54.74.202]) by fmsmga006.fm.intel.com with ESMTP; 07 Feb 2020 10:07:20 -0800 Date: Fri, 7 Feb 2020 10:07:20 -0800 From: Sean Christopherson To: Peter Xu Cc: Paolo Bonzini , Paul Mackerras , Christian Borntraeger , Janosch Frank , David Hildenbrand , Cornelia Huck , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , Marc Zyngier , James Morse , Julien Thierry , Suzuki K Poulose , linux-mips@vger.kernel.org, kvm@vger.kernel.org, kvm-ppc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, linux-kernel@vger.kernel.org, Christoffer Dall , Philippe =?iso-8859-1?Q?Mathieu-Daud=E9?= Subject: Re: [PATCH v5 12/19] KVM: Move memslot deletion to helper function Message-ID: <20200207180720.GH2401@linux.intel.com> References: <20200121223157.15263-1-sean.j.christopherson@intel.com> <20200121223157.15263-13-sean.j.christopherson@intel.com> <20200206161415.GA695333@xz-x1> <20200206162818.GD13067@linux.intel.com> <20200206165116.GE695333@xz-x1> <20200207175912.GG2401@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200207175912.GG2401@linux.intel.com> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Feb 07, 2020 at 09:59:12AM -0800, Sean Christopherson wrote: > On Thu, Feb 06, 2020 at 11:51:16AM -0500, Peter Xu wrote: > > /* > > * Make a full copy of the old memslot, the pointer will become stale > > * when the memslots are re-sorted by update_memslots() in > > * kvm_delete_memslot(), while to make the kvm_free_memslot() work as > > * expected later on, we still need the cached memory slot. > > */ > > As above, it's more subtle than just the kvm_delete_memslot() case. > > /* > * Make a full copy of the old memslot, the pointer will become stale > * when the memslots are re-sorted by update_memslots() when deleting > * or moving a memslot, and additional modifications to the old memslot > * need to be made after calling update_memslots(). > */ Actually, that's not quite correct, as the same is true for all memslot updates, and we still query @old after update_memslots() for CREATE and FLAGS. This is better. /* * Make a full copy of the old memslot, the pointer will become stale * when the memslots are re-sorted by update_memslots(), and the old * memslot needs to be referenced after calling update_memslots(), e.g. * to free its resources and for arch specific behavior. */