Received: by 2002:a05:6358:e9c4:b0:b2:91dc:71ab with SMTP id hc4csp4119953rwb; Sun, 7 Aug 2022 15:37:14 -0700 (PDT) X-Google-Smtp-Source: AA6agR7wswSk7/Jd1dJeVm6iBry6WYaA/L/GPJsr+I/Sk4ivSFiKZzWQfvGuDFW1kf1JX8uVqMhl X-Received: by 2002:a17:902:cec4:b0:16f:8fdc:954d with SMTP id d4-20020a170902cec400b0016f8fdc954dmr12859112plg.37.1659911834557; Sun, 07 Aug 2022 15:37:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659911834; cv=none; d=google.com; s=arc-20160816; b=c0r1jfyxQ0vLevkE/SCrgrn8UKar6rOFUPiVnfrLVusKviGqEXKc4aRkQe2UlClkH0 VIG2GWID7IG0txDYrQPZBaIVCH/mHkj8jzQ+pv/1gKlvGaebw2lvtdywS8J8Woxo5vZm ZtKnxBlzmdp756azbacMM4UT/3D2Ni6mJpAOLsRR7qeyYK6brj1INAjaImj39tqzkeYP VNS9peBV6LWHqBnYe5JY8uaaR+Osd88rgJObBetq3h/b0B+SEk3E6etRbdGI1M/M9b8c NSOnxqDReylJ2MhXFWbXF8qucfA8m0i24TTbKubmbOXf1lrKQ12cS2aTEg/xXQYYIKTq VQfg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=RYDqz7VQfiSZZ40SQ+xFVD8vaOnrEx4mG/AuhNUYBZw=; b=Pi3jYJAwpmJmYfyY6URVRSzBC1e8Daam3ijzBT+WiyZJWJnTmcpUpzqDNr6CWm7BG4 Ng8RSVjS3FUsQxkcXBCSGTeaMtKSvCj9a1RhYLZ3eJJQpMpmxWa57PpAfEaRRVlEghGQ 7A/7JNC3rpiNX4CSN5nY3blBJ7fOG9fsET6kYuNQS8+OCxpShV8HsahYAIvjH/terYmn IybaHdQGetipNXlr7MwP1Iq0ptEMoXy6KNbUqQIEbBPztqkS+Jl5NGXk2jHkxeOgf2xR 5PoO+g9KarJu8ovvqIUrkCNgQO23BwiswQFkiwR1ngU6YC0tSTY2yCYvB6OtmzzNJAJ1 xo9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=YFkXUarf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z12-20020a170903018c00b0016d2b3ddaaasi11564829plg.9.2022.08.07.15.37.00; Sun, 07 Aug 2022 15:37:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=YFkXUarf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242349AbiHGWcH (ORCPT + 99 others); Sun, 7 Aug 2022 18:32:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35668 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242170AbiHGWbh (ORCPT ); Sun, 7 Aug 2022 18:31:37 -0400 Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B851418358; Sun, 7 Aug 2022 15:18:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1659910729; x=1691446729; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=L/qfCpkL6EjBOusAo/hpTfWMeNJV7Hjj/edqAUVoBdg=; b=YFkXUarfKXKWHj3nnQLW8cQV1Jd5TqHao395tT1OM6R6+jIMAUAwHeYl eY/Bol7UcHIcGtpTTclA9KH6aDPjBBCJ3t+LNEb7AL7Uqpr8CJ3l1V2EA QNu87MLuXvtWCqo60QFkjFh3sN46igbh/rMnJ7KenrGgNd0BWDGjc58Cy /QJw7v7udxmItSX88dGB3EbVUBE/uTvIuah9Lx58UQDIR5SVWHxtn1Ct7 1ULHh16FqFPp5G34Tr89J030Fzqh+pN/7t8RiyNrEY4/kVHtPcr76Z1W/ VHtWjt7HISYGiTes17oYf+ohCdwy6/pKUdD2fPPd0C49kVrHQ2JVfScuv w==; X-IronPort-AV: E=McAfee;i="6400,9594,10432"; a="270852830" X-IronPort-AV: E=Sophos;i="5.93,221,1654585200"; d="scan'208";a="270852830" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Aug 2022 15:18:48 -0700 X-IronPort-AV: E=Sophos;i="5.93,221,1654585200"; d="scan'208";a="632642302" Received: from ls.sc.intel.com (HELO localhost) ([143.183.96.54]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Aug 2022 15:18:48 -0700 From: isaku.yamahata@intel.com To: kvm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: isaku.yamahata@intel.com, isaku.yamahata@gmail.com, Paolo Bonzini , erdemaktas@google.com, Sean Christopherson , Sagi Shahar Subject: [RFC PATCH 02/13] KVM: TDP_MMU: Go to next level if smaller private mapping exists Date: Sun, 7 Aug 2022 15:18:35 -0700 Message-Id: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-5.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE 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 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 f2461deba2dc..faf278e0c740 100644 --- a/arch/x86/kvm/mmu/tdp_mmu.c +++ b/arch/x86/kvm/mmu/tdp_mmu.c @@ -1322,7 +1322,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) { - if (fault->nx_huge_page_workaround_enabled) + if (fault->nx_huge_page_workaround_enabled || + kvm_gfn_shared_mask(vcpu->kvm)) disallowed_hugepage_adjust(fault, iter.old_spte, iter.level); if (iter.level == fault->goal_level) -- 2.25.1