Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp398716rwb; Tue, 25 Jul 2023 18:08:11 -0700 (PDT) X-Google-Smtp-Source: APBJJlGzmZtB/sVo/m/PGwVeCmC11tq2tVUqapDUzHTp+Ppx0i51TiLOnJ0/4U0ktSfaHCnSWZfV X-Received: by 2002:a9d:7395:0:b0:6b9:b938:3524 with SMTP id j21-20020a9d7395000000b006b9b9383524mr731200otk.6.1690333691284; Tue, 25 Jul 2023 18:08:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690333691; cv=none; d=google.com; s=arc-20160816; b=wanFA27/FW3OQ8sn0HH4LOfJ4EZHFtboLBxHR78awYkKNQ9x7driTiM45BDwxMuYTk tIwf333fHp1iaVt9zdv+C9Ir9G+PTn8yiU6fDhkxcyWRBeb+36tW5jYo3TrTHOA6mw9y 9AAojBnyzip1saURzU2DohDYBxchpuYspVO2veQReJd4M0ygmN8Y6Fz7oPwvk2UJpGmi RtmIP8XwpEbrTDz8b4JMtESIpF0pHhp4xLWSggeSqiu3Ecle+TkSh9RsZkv8byA73QoX qRcQtZPqzGO0n9hLoZXLaRrAzKJl4Kwmi2OehnjmNdcg2UtzjNi9NAoPcN26D21iKDgP wp5g== 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=004yygNE0NQAEMSKX5yJ32O6DXjBsqBsPXe8v0C8ZxM=; fh=juxwNcA6iKwLISFgUCNwdoIYC0NKLUseq3xZdq25RR4=; b=1G7dGKV08tH5Lict6Qd+FBQTgdkUhcrPnTdveC0ZxfhaHL1kiJPWjKwwZmkj6vsZEH uVzgFcNqdFaKN9+oypWSDk8vMjqotw0uILUcKgGJTLtSW+rgyCO+33d72zNgVCDze+TT onLauv6eR6awhTXtnLJB3zuCQbthG7c8XYA3JVRAa2CYNnRQ8QcjL31MSUF6DKBn18+s uQ/fWmZC/4JJLCpvJW8KwNmLlgvWcGeoycD/VVzxz8vFsMcP938IV6AMz6PeKPxZWv6X vy/vnvjFKjjibJv8nVDTPV4SrSP4nZc/p1k6kRUpWA4mHnEG+Ak+d4Hzz80mWqY9NDM/ c+tw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=FKAsJE67; 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 v22-20020a63f216000000b00550e8b1ebc1si12695084pgh.339.2023.07.25.18.07.57; Tue, 25 Jul 2023 18:08:11 -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=FKAsJE67; 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 S233173AbjGYWga (ORCPT + 99 others); Tue, 25 Jul 2023 18:36:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52164 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231386AbjGYWf4 (ORCPT ); Tue, 25 Jul 2023 18:35:56 -0400 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1CC1D83CB; Tue, 25 Jul 2023 15:29:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1690324162; x=1721860162; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=0/rdZv+daTbP9cxzhTYyVNie8gfjPaewsgxVuIU0ZhY=; b=FKAsJE67rODgNliTZwAOLt51/Y61zHuILGyVCw3C0pG2A/hibJ7kN0pu M5132RomoegkXrix513Gcbr63u6AYRZpnEArGpllJgwRZ+7Ko1j+gyjnn 7qDrowqHS2+6LBLJFehgJRKEiAcXQkL4BgyxD96/JJZlgrEio7IO7aw58 wnU/mCaLHKsPwtphmqQ5Z0rebILSrG6m9miv7K8QhBIrpQ6BbuEAJjeTU XEGOnKv/GiE2dIN9GXc8HdtaR9ReyN8Q2hqXp5HUxVQq3rAHnkoOOgKBs W+XPv+D7lFvvHTp2vtaseWVsAgPVYVtN0bB7/SkfvJer6BESsUW0Besdg Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10782"; a="371467143" X-IronPort-AV: E=Sophos;i="6.01,231,1684825200"; d="scan'208";a="371467143" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Jul 2023 15:24:12 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10782"; a="972855825" X-IronPort-AV: E=Sophos;i="6.01,231,1684825200"; d="scan'208";a="972855825" Received: from ls.sc.intel.com (HELO localhost) ([172.25.112.31]) by fmsmga006-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Jul 2023 15:24:12 -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 , David Matlack , Kai Huang , Zhi Wang , chen.bo@intel.com, hang.yuan@intel.com, tina.zhang@intel.com Subject: [RFC PATCH v4 10/16] KVM: x86/tdp_mmu: Allocate private page table for large page split Date: Tue, 25 Jul 2023 15:23:56 -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=-4.4 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,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 From: Isaku Yamahata Make tdp_mmu_alloc_sp_split() aware of private page table. Signed-off-by: Isaku Yamahata --- arch/x86/kvm/mmu/mmu_internal.h | 14 ++++++++++++++ arch/x86/kvm/mmu/tdp_mmu.c | 8 ++++++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/arch/x86/kvm/mmu/mmu_internal.h b/arch/x86/kvm/mmu/mmu_internal.h index d65324d87a17..2dc733b15c39 100644 --- a/arch/x86/kvm/mmu/mmu_internal.h +++ b/arch/x86/kvm/mmu/mmu_internal.h @@ -201,6 +201,15 @@ static inline void kvm_mmu_alloc_private_spt(struct kvm_vcpu *vcpu, struct kvm_m } } +static inline int kvm_alloc_private_spt_for_split(struct kvm_mmu_page *sp, gfp_t gfp) +{ + gfp &= ~__GFP_ZERO; + sp->private_spt = (void *)__get_free_page(gfp); + if (!sp->private_spt) + return -ENOMEM; + return 0; +} + static inline void kvm_mmu_free_private_spt(struct kvm_mmu_page *sp) { if (sp->private_spt) @@ -229,6 +238,11 @@ static inline void kvm_mmu_alloc_private_spt(struct kvm_vcpu *vcpu, struct kvm_m { } +static inline int kvm_alloc_private_spt_for_split(struct kvm_mmu_page *sp, gfp_t gfp) +{ + return -ENOMEM; +} + static inline void kvm_mmu_free_private_spt(struct kvm_mmu_page *sp) { } diff --git a/arch/x86/kvm/mmu/tdp_mmu.c b/arch/x86/kvm/mmu/tdp_mmu.c index a9f0f4ade2d0..548b559280d7 100644 --- a/arch/x86/kvm/mmu/tdp_mmu.c +++ b/arch/x86/kvm/mmu/tdp_mmu.c @@ -1585,8 +1585,12 @@ static struct kvm_mmu_page *__tdp_mmu_alloc_sp_for_split(gfp_t gfp, union kvm_mm sp->role = role; sp->spt = (void *)__get_free_page(gfp); - /* TODO: large page support for private GPA. */ - WARN_ON_ONCE(kvm_mmu_page_role_is_private(role)); + if (kvm_mmu_page_role_is_private(role)) { + if (kvm_alloc_private_spt_for_split(sp, gfp)) { + free_page((unsigned long)sp->spt); + sp->spt = NULL; + } + } if (!sp->spt) { kmem_cache_free(mmu_page_header_cache, sp); return NULL; -- 2.25.1