Received: by 2002:a05:7412:b101:b0:e2:908c:2ebd with SMTP id az1csp2985945rdb; Wed, 15 Nov 2023 17:32:35 -0800 (PST) X-Google-Smtp-Source: AGHT+IHyw+YJPKdKOAQ2izIvCuyWmJlMwgUxkCikiXyc4yVK8tkFRUJB0Ow+efmFmFQ6V4KA7XgA X-Received: by 2002:a05:6a21:3384:b0:181:a38c:8106 with SMTP id yy4-20020a056a21338400b00181a38c8106mr378140pzb.20.1700098354738; Wed, 15 Nov 2023 17:32:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700098354; cv=none; d=google.com; s=arc-20160816; b=XV09g7CX2Hj7Js24W9Vxc65wYzDcz8OkMRZoLQncO6vAjdGrefanxUzlpK1fG7mmRZ 9D4xE97UbK5XBp0DICbM8/sPAmfnLU4vZaHsuKN0wsvUi/M/3CFaU0O9Wg13ekp8Y9hU zSlGgPDhD1HJ6mgVkENATBe6aIQBdtcEiYH2geqJfXTc8WyGfYfr9ShnjnSUNHSri/7B chMlJdQmlJGSfy3EGKZ2WGFgENoN4R7/pf3PNa0GyBaR6rfJItQLyJ4FOpZWH0fMA8Q9 W7iPMRXayRO6ny8uKwUZI00rgCM5W23ng6dUFdCLFM7b4eGTlLtwBPFYs/GewpQcuunZ zEjg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:subject:user-agent:mime-version:date:message-id :dkim-signature; bh=EyRh8j2mMOKzRrYx1+Zu5jqBmbvSGgYeQGl/rglt+WM=; fh=SSl64FBK0Lhy77ytVxLm3gRT6oITPT9jTW5tmAf+4Dk=; b=eizjnMrVRsXvjiWjfAQ88a/FzkHuGNec7WD7d3PlbK/N8kzZOyS2t+/+bmx/psyfzd EfnCRy68Ik/7fDZbaXL1Y++Ln1YK3xYgO3kLTm0Yb5b8xNvqg82Si46bco4PUI3rJIJ5 CVYcar+yOhMmzPcJm+BPDQZhVWtv0V8LQwfSuGmB5EAJ+Ggw3MTpevlLlO5l0U5kQIb9 FnEy6IJJyaT7WvMI7Sgo2HKB7bAJDcqgSO3l3mXhW7XkN/WP95cEEqjXzblWWpmHyeBA gq+B8RfrhoxBH/9uq5VwaeML2BKR0asifChtU/uO2X3dUIjrXeqCjP8SqtPp9QQmU2/h Wndg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=dVDBt8wm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id y127-20020a62ce85000000b006c34eaa73e0si10914334pfg.333.2023.11.15.17.32.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Nov 2023 17:32:34 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=dVDBt8wm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 9CCB180755C4; Wed, 15 Nov 2023 17:32:33 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344286AbjKPBcd (ORCPT + 99 others); Wed, 15 Nov 2023 20:32:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46196 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229996AbjKPBcc (ORCPT ); Wed, 15 Nov 2023 20:32:32 -0500 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9517298; Wed, 15 Nov 2023 17:32:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1700098349; x=1731634349; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=ztb1OMvgUbABuanoDYwKGsqiwumi8JvW3rZjOdH8eyY=; b=dVDBt8wmbGuUTRvF3IzMZk6sVPJO/Q/KY72hHSntr2W/5sXy1XLkbAF4 C4qdhYJgGfpXmU310wgDSJVIE+1YQ5ZfH1lQ2CfP3qCpkEdEQ1tH2Xhxm ZiUu/p5l8QkYx4I5b1OvPrPA9gr6QqVz2daILmyOsF5/8sDDFyziF76/H bEj6EFQfoIEnjTV2gXxJFIO6ahXGCUyMBnMQ1XgiM/EfBMVBa3THo+qGG EAOr9MidRrM/Q86tbMaR2mynSck9cBrZuuuAUIh2i9mOYaAfaNnI11+So WEat7EuUjrMPPQP8UigLRrYWlVcCG4K4ebpawtvjn767qMuzpJ1e4T94U A==; X-IronPort-AV: E=McAfee;i="6600,9927,10895"; a="388156216" X-IronPort-AV: E=Sophos;i="6.03,306,1694761200"; d="scan'208";a="388156216" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Nov 2023 17:32:29 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10895"; a="794331762" X-IronPort-AV: E=Sophos;i="6.03,306,1694761200"; d="scan'208";a="794331762" Received: from binbinwu-mobl.ccr.corp.intel.com (HELO [10.238.10.126]) ([10.238.10.126]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Nov 2023 17:32:24 -0800 Message-ID: <52b01c03-15eb-4151-b94b-2433a117cf3d@linux.intel.com> Date: Thu, 16 Nov 2023 09:32:22 +0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v6 01/16] KVM: TDP_MMU: Go to next level if smaller private mapping exists To: isaku.yamahata@intel.com Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, isaku.yamahata@gmail.com, Paolo Bonzini , erdemaktas@google.com, Sean Christopherson , Sagi Shahar , David Matlack , Kai Huang , Zhi Wang , chen.bo@intel.com, hang.yuan@intel.com, tina.zhang@intel.com, Xiaoyao Li References: <439c7be59c35a03bced88a44567431e721fab3da.1699368363.git.isaku.yamahata@intel.com> From: Binbin Wu In-Reply-To: <439c7be59c35a03bced88a44567431e721fab3da.1699368363.git.isaku.yamahata@intel.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Wed, 15 Nov 2023 17:32:33 -0800 (PST) On 11/7/2023 11:00 PM, isaku.yamahata@intel.com wrote: > From: Xiaoyao Li > > Cannot map a private page as large page if any smaller mapping exists. > > It has to wait for all the not-mapped smaller page to be mapped and > promote it to larger mapping. > > Signed-off-by: Xiaoyao Li > --- > arch/x86/kvm/mmu/tdp_mmu.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/arch/x86/kvm/mmu/tdp_mmu.c b/arch/x86/kvm/mmu/tdp_mmu.c > index 2c5257628881..d806574f7f2d 100644 > --- a/arch/x86/kvm/mmu/tdp_mmu.c > +++ b/arch/x86/kvm/mmu/tdp_mmu.c > @@ -1287,7 +1287,8 @@ int kvm_tdp_mmu_map(struct kvm_vcpu *vcpu, struct kvm_page_fault *fault) > tdp_mmu_for_each_pte(iter, mmu, is_private, raw_gfn, raw_gfn + 1) { > int r; > > - if (fault->nx_huge_page_workaround_enabled) > + if (fault->nx_huge_page_workaround_enabled || > + kvm_gfn_shared_mask(vcpu->kvm)) As I mentioned in https://lore.kernel.org/kvm/fef75d54-e319-5170-5f76-f5abc4856315@linux.intel.com/, The change of this patch will not take effect. If "fault->nx_huge_page_workaround_enabled" is false, the condition "spte_to_child_sp(spte)->nx_huge_page_disallowed" will not be true. IIUC, the function disallowed_hugepage_adjust() currently is only to handle nx_huge_page_workaround, it seems no special handling needed for TD. > disallowed_hugepage_adjust(fault, iter.old_spte, iter.level); > > /*