Received: by 2002:ab2:788f:0:b0:1ee:8f2e:70ae with SMTP id b15csp275424lqi; Wed, 6 Mar 2024 17:35:05 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXjCjRq3qGOGPxq/xkG+aAlVGJhZAvIwOKky053d6XX7fIfZ2/46Y+9IkvemxjGvx026aoX/U0/h8tlbWMf2BNxFeyxjNV6Jsyoibc38w== X-Google-Smtp-Source: AGHT+IFZttotQNbmiMJGCi6sbP8BGjaeMh39iIzAbFKxMt2nfiwrePVdDa9kIOramLjoYEH+d7tF X-Received: by 2002:a17:902:c081:b0:1dc:7923:a9e5 with SMTP id j1-20020a170902c08100b001dc7923a9e5mr5803102pld.39.1709775305092; Wed, 06 Mar 2024 17:35:05 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709775305; cv=pass; d=google.com; s=arc-20160816; b=FKSXdhfFvvkxbxDowNtueFwwyLsVMNyiueHbwxbGY6lmhU/2coNsM8eg905KjC4ZFL Lve/8AZncJ+LEFGXrAh18Jai4BqcOTg6LJVF2baeSN09aDetTVubDwwvyHGqULRZ2f1v RqRtkcMLP2vqxeTTSa822kYO1BuLNq7bCMLVz+AxuSVBRZCVlPlCsr6lmUmDV60sg2E0 fbINBES/RGQOS/Kq+RS6kd/vDboy950jSYqTUy5S/pJIITtJVxIigNzQFvGQGPAO6130 VVgpahdH+SpWPoPuekhWONteQzRnVQpQET+dvUm3VW7h5MjFPcxNfzANCdSTqNz/LwCm KljA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=Nh0zyKtOZaD3brFgB0SNfqHjTVBWiT9GBveEFxrLgSU=; fh=UgqpCNH9WwmosEfqySsUNEa2pBAicm1yju45jT3AJTg=; b=rpIM5tU4VusAZr4mGRzG+ro8TDyirnZQcHyfJf+FMAo3B6VpbQ9ak+cPVnLfWr8fE9 C1rAEq9LFgwnFENyR6JgN5Oebmm2+GqYFBFkePt79WPai5+thS0Nb7UEvfA84OltRfjo oKEZXVci3LwPoYGYRgZ0h0ekq/WBa+BcFDTzsxIcEm/Ffh4tXGXMUVLgBUziwRMdHV5U kKSg88STWJFpvfm/bYfyqIydxEPjtdQRZ0YDa0gYa2/WaFISpOFrynoRbpL45Bgfatxb Y+b2dvU8sx7tG62s01zOvtf3qK3xI0LpLWzLV7ca4whsXVARJGCR1eeck7qS1/s5grGh qpMg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=YkjcK10B; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-94827-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-94827-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id b8-20020a170903228800b001dc75ea0f70si13294758plh.341.2024.03.06.17.35.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Mar 2024 17:35:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-94827-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=YkjcK10B; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-94827-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-94827-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id BBDE1286C55 for ; Thu, 7 Mar 2024 01:35:04 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 058F25221; Thu, 7 Mar 2024 01:34:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="YkjcK10B" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.16]) (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 6E93C4689; Thu, 7 Mar 2024 01:34:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.16 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709775295; cv=none; b=lrtoUB5zfg2S8EO8R3h2xU23s2Jiq+ffxAYVTSF02Gf5/MZrcXkEIu0r635EXwOBPehYSJpQxeRzmKEyIKJg9JZxl06MeLesPhPXe1Fa4wPhlkvzwrUcwZJZtMIjco57xxEe2CA7A3fLGgIkuhIs7qQbyecGhqn/UsIw8XeaaXA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709775295; c=relaxed/simple; bh=FxSafHmZOK92FTSBXrwz0pUq3BM0aeLdXeQdbuUUjS8=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=cHDlFG8X4jEU92aKRKF4u+Zp6QaeGbRgjlVZf1vR5hcuR4WYwcbq8Dr5/cmUW+w38P8hgKBWP/MBcCAfUUIgoz6bvlzVk5vF9SIQvJUhOlnriTfuahmJ+uY0jLfdCkeA8GplBiNwY2flpCPLlY80Hn9v3xuzDCCDTivDwTeLWXk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=YkjcK10B; arc=none smtp.client-ip=198.175.65.16 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.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=1709775294; x=1741311294; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=FxSafHmZOK92FTSBXrwz0pUq3BM0aeLdXeQdbuUUjS8=; b=YkjcK10BrElQnTzXnXMFfLxoL+lUkKioYDPjlRla+2vI9zMJtAJ3djoC uz4B+TuoUWK09DqisTnHiUPRce6tub6z0U1lX6NPo8b3MkqbNgz3bamFS HufMzS6q9azIbhbYAiST17MwbKjfKhZRFTERO7mOOiVHmx8pXay9PWw6r +LM8UiJisdhk7r0I9kqmejKGhGq5MKq6kSUuLuas2z2oMsonqb7VI3qZC XpMWEAvznNeFvFEFefgoVvCUw2dehmjjx77Y5XOnEH2V+hMEpUNscGKev tCZ3pN6qTeMebiAwKra8Pq5AIf2tIJXrW8/T8f536tscZw1NgpG5WSZRy A==; X-IronPort-AV: E=McAfee;i="6600,9927,11005"; a="4549168" X-IronPort-AV: E=Sophos;i="6.06,209,1705392000"; d="scan'208";a="4549168" Received: from orviesa010.jf.intel.com ([10.64.159.150]) by orvoesa108.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Mar 2024 17:34:51 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,209,1705392000"; d="scan'208";a="9929621" Received: from ls.sc.intel.com (HELO localhost) ([172.25.112.31]) by orviesa010-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Mar 2024 17:34:51 -0800 Date: Wed, 6 Mar 2024 17:34:50 -0800 From: Isaku Yamahata To: David Matlack Cc: isaku.yamahata@intel.com, kvm@vger.kernel.org, isaku.yamahata@gmail.com, linux-kernel@vger.kernel.org, Sean Christopherson , Paolo Bonzini , Michael Roth , Federico Parola , isaku.yamahata@linux.intel.com Subject: Re: [RFC PATCH 6/8] KVM: x86: Implement kvm_arch_{, pre_}vcpu_map_memory() Message-ID: <20240307013450.GE368614@ls.amr.corp.intel.com> References: <66a957f4ec4a8591d2ff2550686e361ec648b308.1709288671.git.isaku.yamahata@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 In-Reply-To: On Wed, Mar 06, 2024 at 04:30:58PM -0800, David Matlack wrote: > On 2024-03-01 09:28 AM, isaku.yamahata@intel.com wrote: > > From: Isaku Yamahata > > > > Wire KVM_MAP_MEMORY ioctl to kvm_mmu_map_tdp_page() to populate guest > > memory. > > > > Signed-off-by: Isaku Yamahata > > --- > > arch/x86/kvm/x86.c | 49 ++++++++++++++++++++++++++++++++++++++++++++++ > > 1 file changed, 49 insertions(+) > > > > diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c > > index 3b8cb69b04fa..6025c0e12d89 100644 > > --- a/arch/x86/kvm/x86.c > > +++ b/arch/x86/kvm/x86.c > > @@ -4660,6 +4660,7 @@ int kvm_vm_ioctl_check_extension(struct kvm *kvm, long ext) > > case KVM_CAP_VM_DISABLE_NX_HUGE_PAGES: > > case KVM_CAP_IRQFD_RESAMPLE: > > case KVM_CAP_MEMORY_FAULT_INFO: > > + case KVM_CAP_MAP_MEMORY: > > r = 1; > > break; > > case KVM_CAP_EXIT_HYPERCALL: > > @@ -5805,6 +5806,54 @@ static int kvm_vcpu_ioctl_enable_cap(struct kvm_vcpu *vcpu, > > } > > } > > > > +int kvm_arch_vcpu_pre_map_memory(struct kvm_vcpu *vcpu) > > +{ > > + return kvm_mmu_reload(vcpu); > > +} > > Why is the here and not kvm_arch_vcpu_map_memory()? We can push down kvm_mmu_relaod into kvm_arch_vcpu_map_memory() under gpa loop. Probably the inefficiency won't matter. kvm_mmu_realod() loop on gpa kvm_arch_vcpu_map_memory() => loop on gpa kvm_arch_vcpu_map_memory() kvm_mmu_reload() -- Isaku Yamahata