Received: by 2002:a05:7412:5112:b0:fa:6e18:a558 with SMTP id fm18csp189637rdb; Mon, 22 Jan 2024 17:04:03 -0800 (PST) X-Google-Smtp-Source: AGHT+IF6X4JhwnL96zDcXhcLnS6pykZjAhJCM+W5dnW6tnpTaRshVORMGMoPtkkRl+BNvNqVENMu X-Received: by 2002:a05:620a:998:b0:783:55af:9d5c with SMTP id x24-20020a05620a099800b0078355af9d5cmr5430435qkx.55.1705971843582; Mon, 22 Jan 2024 17:04:03 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705971843; cv=pass; d=google.com; s=arc-20160816; b=TtMPBI7Jf9bSyxKvd3twqPImdvvURfy3DpFV+I2vgGhC07WSBorrFABjHBT/YcCHwQ Qrqp+IOiIaGbOPOOsiv8DbxZ7BuU8SgcJcgtIz2dncOD9BlzXM8Z3vS4KRfoq0bC5IPI tC0e/qMlSTpMWqnfAM8uRFYhQbzm95pVHMj3rjrZopRUZ9WV0rJUtMLKE4qhmK95bDFi 5hoexP96PFB2Tlgy2FF4WcQ8tgP6dKPUclNfgEmlJO5PNfhW8y34RMMxOdBnHEEQzhjJ vTQ/LqBhrw2J51uyUloSJiVDh+I0tQI7PDXm0Bz6WUUpQKSkbq/zRxQddCIAzCSZ3LH6 SAWg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=vOY0+9wXYXsEKKw97npMck/Pth30Fxvldc64Jv2ude0=; fh=Itbyk7CEvizIrzGEESCqq3I2tZgG1kc/GkVOa3S7Hsg=; b=UkkIjD/+RI2674Ppk0fuD9e/DXvo62ZstmWSP5RuqZ60nuQcoo+XBrxDqP2ApaEP6f v/ADw071MoWfJNzRqpPhNGNsgShZS/SPYgXGR3+2gEqbC+9NWctW3hjSYWsb3UAB0110 ZlEmro5yd1uNC1hbn1I+qJjV7/YfU7J7mX5bh5o29jAqVtDrzi99fobO+hsv8A4CsiX5 PgUGUTifRMtlNepck84bZgLJGjATD4vJiSvfGJ1NmegvxN9EvLm6vM/+Y2saSZR5YNKf I/KjmlJEnxFy05KtYe9JfuFBPWL4fX5E/VaKDSpXDQuauezKZfbwN+09vDAtvBStvDZk QG7g== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=bqtzD1ZM; 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-34454-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-34454-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id f9-20020a05620a20c900b0078398c46c8asi512350qka.703.2024.01.22.17.04.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jan 2024 17:04:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-34454-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=bqtzD1ZM; 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-34454-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-34454-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 59EA71C274C0 for ; Tue, 23 Jan 2024 01:04:03 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A043A150981; Tue, 23 Jan 2024 00:22:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="bqtzD1ZM" Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.65]) (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 DC5DF14E2DE; Tue, 23 Jan 2024 00:22:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=134.134.136.65 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705969363; cv=none; b=lg83S+OYP03sAGti2HbK5V+dyZG9WQ3Mon68JHzg5mv1MzSQqExxqhthZNfZLHSv4pM0veXkzI5IwuMy2d03QcoU8bgHmyrovhz0cGgglzNZVfizvLiJ521NeGesLZnR6qNqwArGraGfkit6znerMQLCOoZm/F9XbOZPdiwv4SI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705969363; c=relaxed/simple; bh=D8ucLB5R3WU1RLu3fuizNfiGPSEyK3aQUihpWV4tz0k=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=YD//OtF/rQm7nicCaLUXMvTORLFVj5YRCVQUkCD2/IebJN2+6fmS0QNfJv83AP51GHS2ZLhaDk9aj7eEkCEk9KY5tyA1nAMOQy4dW50hipC8cWU0GObYbaObvqIhcZserLWcNcUfay8ShqPZVfpHOHPEwx9lSs/dXRcAk0y25L8= 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=bqtzD1ZM; arc=none smtp.client-ip=134.134.136.65 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=1705969361; x=1737505361; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=D8ucLB5R3WU1RLu3fuizNfiGPSEyK3aQUihpWV4tz0k=; b=bqtzD1ZMQfzQtLpeY+iU+kCQW6TjpFXWeaN87YfHYtxGVpJTYxaJ+fVH LMAW6T7bLe8oXmoeyRLu3n5TuOUrWSBaln/23Fo6hnkMJciShaJgMGRP5 M9TGXKI/di4Rc3te1+7Nw3d2FN3f5A8hCozVwwKh1M/A1KIIM0o00jiSX dtY/fWWImyL+4Lpbj8S1DaFKzSt8mnc8iCGB+yfLGUFRGk7zotXHTxVRi X9i2gla7xvKw/cBy+vY5dqltM3KmFeUAL58VPAjp0tCb4qN7tJ8nyDqy+ k/fHC5Oo0dkHzGCbFmm5ztXTdJGhTPR318zH/u1sCI5polY5DHKtwIA7g w==; X-IronPort-AV: E=McAfee;i="6600,9927,10961"; a="405125675" X-IronPort-AV: E=Sophos;i="6.05,212,1701158400"; d="scan'208";a="405125675" Received: from fmviesa001.fm.intel.com ([10.60.135.141]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Jan 2024 16:22:39 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.05,212,1701158400"; d="scan'208";a="27825650" Received: from ls.sc.intel.com (HELO localhost) ([172.25.112.31]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Jan 2024 16:22:39 -0800 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 , Kai Huang , chen.bo@intel.com, hang.yuan@intel.com, tina.zhang@intel.com Subject: [PATCH v7 07/13] KVM: x86/tdp_mmu: Allocate private page table for large page split Date: Mon, 22 Jan 2024 16:22:22 -0800 Message-Id: <2e0999bc6c5d1ebdf07d195f5e99e6c8b2141378.1705965958.git.isaku.yamahata@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 e9eafc2f7885..9888ea0046ea 100644 --- a/arch/x86/kvm/mmu/mmu_internal.h +++ b/arch/x86/kvm/mmu/mmu_internal.h @@ -203,6 +203,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) @@ -231,6 +240,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 25c201686d1f..7991934b3f37 100644 --- a/arch/x86/kvm/mmu/tdp_mmu.c +++ b/arch/x86/kvm/mmu/tdp_mmu.c @@ -1593,8 +1593,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