Received: by 2002:ab2:710b:0:b0:1ef:a325:1205 with SMTP id z11csp1911255lql; Wed, 13 Mar 2024 11:34:09 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUJA8UJ9gdAZIM1HAHVjeNwG6jdWm2zzJNmt9MhDuApxsQDT/oePhC7axoXFUHYt2zuNkeb/rar0jwmJlsQ9zsCr2lyCIaOsfpc3TwCxg== X-Google-Smtp-Source: AGHT+IGiGcmesr2bZIIqxyXsOO20UIG1nTSs8Ex3hacbif88KbeftTa/FA+jdKKXGEejSnyuorVi X-Received: by 2002:a50:d6de:0:b0:566:777:af4f with SMTP id l30-20020a50d6de000000b005660777af4fmr9116921edj.1.1710354849039; Wed, 13 Mar 2024 11:34:09 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710354849; cv=pass; d=google.com; s=arc-20160816; b=pW60e5BOvnYr9WpGK4/aaazZicW7oRko4bujeyoYTR6ruHxdGFJWKSaGMrrIsuFvm0 UZmw1clI1Di9N5aegAZBwpuOobAp7BP2vO/zZcY2I7jLXUBny5hK7t7GnR2qN4eOvKNW eIkuVuYuo5A1okDId6tkdTDQOIJ4F/cy3qoTKwYh687SHyOUSyMHPsDSjQ5M4i8GjC37 Ls+Nnpv0gd2LYXDH0klJNI3aXo70ZCegOeoCRNi7PvZ5IlZFwcaaYitahOg2g76ocYKy x795Rcay8pcrcZhg/R/jELbObQo4l2Wi7YYl8DG7RT5IkzxuLqEf8qaiHeepPqdJ7l8l iZ5w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:subject:cc:to:from:date:dkim-signature; bh=eGD3iktv/oY6U7I/Dry8fNr4wjsZ2aJhxA6rXwOjceQ=; fh=P/quV/w7uXmndbL78FtEpLTNkJRPx4LJS51PzREvtL8=; b=RZjYTz6Gkd+GuMdtLRLKdKFQCgytc2+/ByQ4ym6T2g4e5knfZVuljWg/h/8WIKugeU bQJ4eWC8euPjC6b/qvz1JUU1GLM47RYIyzEnHcstEKnTQXbo+WF0yCWEDGb1Mp6/47hb EiVft6yaOcU5+MpJ2SCVZlyJlU3WfTQFJYLcG/N15b9iZwasmjtbr6/x/HM54Ai6bdej 1MoqTY4WGrVtIB+j4OclwPTmtMMeurLU9bXmmAJyjzA9CVthOsUGEvh7yWGxZyZdEK9m qxf6+x74aR8uQHcQ3uKZoSGpEqqfXcqFXn0nE27flPg0TdonqNeM5HFsDQm1CtkUtHav GxlQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=FShHlpCc; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-102244-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-102244-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id ij24-20020a056402159800b0056833760684si4922697edb.272.2024.03.13.11.34.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Mar 2024 11:34:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-102244-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=FShHlpCc; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-102244-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-102244-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id C0FE61F2D7D6 for ; Wed, 13 Mar 2024 18:34:08 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9718A7CF37; Wed, 13 Mar 2024 17:14:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="FShHlpCc" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6E9A77CF17; Wed, 13 Mar 2024 17:14:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.11 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710350076; cv=none; b=lNOPSS2uzQB5uERJJ4tro4R/mDvjSlcSkxu7jk/XBvWu/Rd09+AVJDJUlbZU9O/I5jk1002sIfGTVYgRELKOqrwxVF89yZo0fx983hhoypF3iYbJnDZduHyS+98MnAB1zugfobR+82vq4eQAtbnZLsxg1/6OPK97dMpqDyxkO9Y= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710350076; c=relaxed/simple; bh=yd+LQyIBKkRzDjOGx/9XTYnW/gs4JXp/mmcKcMds5kM=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=YZFKcF0nq1W4GSbYwUFMFdm1G0NZnBO1wEqEGTpz04F8nPH2TUIUEOXFZ3zGtXZyP7zNi31pGjXvV2xhW6lfp7CmtAc3jXQANH+9t0sVvFweJJJvWptEXlzz3E7HVUpfQutrPgqdsr8o8JHt9MoCri3JuKjdIpvFNqQLwP81Xkc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=FShHlpCc; arc=none smtp.client-ip=198.175.65.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1710350074; x=1741886074; h=date:from:to:cc:subject:message-id:references: mime-version:content-transfer-encoding:in-reply-to; bh=yd+LQyIBKkRzDjOGx/9XTYnW/gs4JXp/mmcKcMds5kM=; b=FShHlpCc2LBXvcjsIaDEedOUdp5/hqnEATFKicMEbUgRpQseBkfoNFO7 2JGU7neGkH0n6F+DspAwyKX+QuqooXFf0s0yHHJcBwLJHRzydarts+ef9 GIt+1czhtOeCrfhgNEgOTjc497PuEjHXLo+5AQ4L/jmyyZZhUs3/L81va Mgqx1Y91cYTsl9v8aPyqeYCmYzXapoxAqPSId8AgLCOJIh177aG2nI0Nj 59FvtsjUzLepvCDmKIf/OdooPplkZb7hFDrZBgJOh6DE1QLulV8BKkASz IgdGhwwhNwucTvH4KGwK4XaU2SLhrptjGCmv9SkKjfutha2/zW9pahOFf A==; X-IronPort-AV: E=McAfee;i="6600,9927,11012"; a="15688327" X-IronPort-AV: E=Sophos;i="6.07,123,1708416000"; d="scan'208";a="15688327" Received: from fmviesa004.fm.intel.com ([10.60.135.144]) by orvoesa103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Mar 2024 10:14:33 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,123,1708416000"; d="scan'208";a="16581412" Received: from ls.sc.intel.com (HELO localhost) ([172.25.112.31]) by fmviesa004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Mar 2024 10:14:33 -0700 Date: Wed, 13 Mar 2024 10:14:28 -0700 From: Isaku Yamahata To: Binbin Wu Cc: isaku.yamahata@intel.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, isaku.yamahata@gmail.com, Paolo Bonzini , erdemaktas@google.com, Sean Christopherson , Sagi Shahar , Kai Huang , chen.bo@intel.com, hang.yuan@intel.com, tina.zhang@intel.com, isaku.yamahata@linux.intel.com Subject: Re: [PATCH v19 011/130] KVM: Add new members to struct kvm_gfn_range to operate on Message-ID: <20240313171428.GK935089@ls.amr.corp.intel.com> References: <2daf03ae-6b5a-44ae-806e-76d09fb5273b@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <2daf03ae-6b5a-44ae-806e-76d09fb5273b@linux.intel.com> On Tue, Mar 12, 2024 at 09:33:31PM +0800, Binbin Wu wrote: > > > On 2/26/2024 4:25 PM, isaku.yamahata@intel.com wrote: > > From: Isaku Yamahata > > > > Add new members to strut kvm_gfn_range to indicate which mapping > > (private-vs-shared) to operate on. only_private and only_shared. Update > > mmu notifier, set memory attributes ioctl or KVM gmem callback to > > initialize them. > > > > It was premature for set_memory_attributes ioctl to call > > kvm_unmap_gfn_range(). Instead, let kvm_arch_ste_memory_attributes() > "kvm_arch_ste_memory_attributes()" -> "kvm_vm_set_mem_attributes()" ? Yes, will fix it. > > handle it and add a new x86 vendor callback to react to memory attribute > > change. [1] > Which new x86 vendor callback? Now we don't have it. Will drop this sentnse. > > diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h > > index 7e7fd25b09b3..0520cd8d03cc 100644 > > --- a/include/linux/kvm_host.h > > +++ b/include/linux/kvm_host.h > > @@ -264,6 +264,8 @@ struct kvm_gfn_range { > > gfn_t start; > > gfn_t end; > > union kvm_mmu_notifier_arg arg; > > + bool only_private; > > + bool only_shared; > > IMO, an enum will be clearer than the two flags. > >     enum { >         PROCESS_PRIVATE_AND_SHARED, >         PROCESS_ONLY_PRIVATE, >         PROCESS_ONLY_SHARED, >     }; The code will be ugly like "if (== PRIVATE || == PRIVATE_AND_SHARED)" or "if (== SHARED || == PRIVATE_AND_SHARED)" two boolean (or two flags) is less error-prone. Thanks, -- Isaku Yamahata