Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp2624808rdg; Mon, 16 Oct 2023 09:43:19 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG1UtdgLx5DAShyhr3LBq8Ft5ai6maSDpd/37sbzZuP39hdQnRC+8P4keZLqi0dlH4Je5mf X-Received: by 2002:a17:902:c94f:b0:1c3:8464:cabd with SMTP id i15-20020a170902c94f00b001c38464cabdmr37694547pla.12.1697474599444; Mon, 16 Oct 2023 09:43:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697474599; cv=none; d=google.com; s=arc-20160816; b=Xb/lQkTUwbSImLyMxR/+T6Er5dDn7qs2EvBIKxqshjUjLzG4F1NjG2G65n7I/HZAD7 kz+S2nOaRourOtUo7MxDaYpH6n4ZHVfmDXJMoZbW5iwrIkb3N1na4dTOQY1SNRad7PYo GWcKOcqKFdBNcyEyg7ofaWo7WGY9BXZQLGjEo8v50teYnhE5JeKjBT9VTnvsnHcSmb/V joqmR63IhwRHsDGPbPt99ASZUJ9pxEiBxJkI9LLquthaQGq+wZIO8lY1CAHDKIjvvV2z s2btEeND8uf4Agw3XYqfw5eFoV4d6G1F8UKkuKRWPRLSehn7x1CK/7HGIBT5G/fv8Lbe iQ5Q== 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=d0jMQ56rfqM0WsFxT3hOpBYt6nEkwZUcyQ6ujjPDmJo=; fh=lRdU2Q/1zx5DcPdZuWBjshA5VT5Oc9cEhB1tCFiV0Nw=; b=0qP3GBOXGZ2aPoN//XgqjYl1XU5KHWNRb4gud97VjBIAAYY/ZcwnVW+VUu0H2ntRXu 1DdAU50LfztgBsbvbcCfXtMOwlN7o+edPAj8gMO5dmlcr2T1ms2AwV9fFvuIdK2D9DwO 69Kp20O8F0QWAp3D9EJjfZcIrdoVe4CDyxcWJtxy3kHHR/v5ZE+/hVmvQwsXilSxIK3V V/N6hV+vJLG+k9BFXkopNH/R6FTM02b2hJVLE9X6TKig7HwWjPcEGmojrvmUGs+mLR/f M+mHIo8bQ0Vaa5F9dffrUOSiV9tRP5H61O9CmyZRcx4S0xZfx4+yO1IQcdPdW6riikVe e2JQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=f1fO1Ivo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 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 agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id z20-20020a1709028f9400b001c9d96cbd97si10451948plo.66.2023.10.16.09.43.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Oct 2023 09:43:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=f1fO1Ivo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 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 agentk.vger.email (Postfix) with ESMTP id 45B6E80AD9AA; Mon, 16 Oct 2023 09:43:09 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234185AbjJPQk3 (ORCPT + 99 others); Mon, 16 Oct 2023 12:40:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52998 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343574AbjJPQjP (ORCPT ); Mon, 16 Oct 2023 12:39:15 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EE7A88267; Mon, 16 Oct 2023 09:23:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1697473397; x=1729009397; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=wxBtarhP8Ri01XIHFhb3x0YgU9de0ypsG7SgSLsDpf4=; b=f1fO1IvobXcHTrbv3B32/7QNYXamf5OOiHODeVIdsnOiEZpohlcr7AOr 1zJTXd7px2EoCtV1IPLPepLPFD/I/1v/X72iPb94lVc4b9BRVZxohJGpk r9QzEP9tfFvt9qPUrpMO9EIJoLbCXAqQMdvXt6wudO9N60dkArFVQcU42 JbIFwyDBIQ/v/f/D6Vpj5DUbA6ZBkISauGWE0RAjuNFTWocMUAYTU66yJ YRERwPfYbbwo6W8r2HUBJvN2OS5Lu/h3Dt+U35gLjl/STafBt5ukq8dlR xV+8tP9Qii1TVhlNRAKIkwRkR+vqf01sC14Bjse3v1K4wBBZxLXJmtZHh w==; X-IronPort-AV: E=McAfee;i="6600,9927,10865"; a="471793176" X-IronPort-AV: E=Sophos;i="6.03,229,1694761200"; d="scan'208";a="471793176" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Oct 2023 09:21:15 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10865"; a="899569245" X-IronPort-AV: E=Sophos;i="6.03,229,1694761200"; d="scan'208";a="899569245" Received: from ls.sc.intel.com (HELO localhost) ([172.25.112.31]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Oct 2023 09:19:15 -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 v5 10/16] KVM: x86/tdp_mmu: Allocate private page table for large page split Date: Mon, 16 Oct 2023 09:21:01 -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=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email 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 (agentk.vger.email [0.0.0.0]); Mon, 16 Oct 2023 09:43:09 -0700 (PDT) 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 908504bcc2cd..641d4e777b73 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 012f270cfb6f..75a2fec7a3fa 100644 --- a/arch/x86/kvm/mmu/tdp_mmu.c +++ b/arch/x86/kvm/mmu/tdp_mmu.c @@ -1706,8 +1706,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