Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp564356rwb; Thu, 12 Jan 2023 09:22:07 -0800 (PST) X-Google-Smtp-Source: AMrXdXv6cbQJpddtNugo89jdNrxY/Y1CCNjC8mBJiOL3UBZT0IeWzSpSVA0xBwfYt3/IuIQZN7e+ X-Received: by 2002:aa7:d599:0:b0:496:b479:e437 with SMTP id r25-20020aa7d599000000b00496b479e437mr20667910edq.27.1673544127114; Thu, 12 Jan 2023 09:22:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673544127; cv=none; d=google.com; s=arc-20160816; b=0f/yT5NWiMuQbNPDrIdDWUhRUhE/P3mz/uxhqigwu5kR8hQ5zcipK8SwQl8yBKre8s 4sKiEJGwBNtogR0y95RqvgV86iJQk73Pp94Z5OGi6fEIsH/lI67RcpSX8SBUUryOAs17 lQBajVvMbCPj41NSTypMq9TdYTWDSXZHCCbBjXBpDFJGbuuZ1PxGEo0l8cQcymwWnLy4 khHj56O1nvwi4YawOtzBgkiQGLlnPYj3ITslDW2QDp3xmLNLAxoZ8+Az4ftbA3MyaVs3 Q/qGYYnb1Ou/TtB6HytMW8ALr+q4UMGRefiXuUz98jkJiyPmmm6rbqCmFgDl3PZgBjP4 MrdQ== 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=EzlF8R7RaWnRbP2A1yUSDXribPDSsgcHODMHLSxHtrI=; b=gzX6h+nRvHwtW4HlWn/jT6glkgmr8tmf9gxNcMqBHzQNvxwBK2lPFrIXHk6g35JNXR 0khDOvSJ0XjXd30zp0v4yIKW0viYnKdJISjQcni9mkVWW/8dHcqwj8EP34qZLusa+afb mlBarvT9FPkbFZHFo+9tLMSo4yDBrkzH15uM7jFSoeOH9mxiMWmlsnVwbHi+QAArj6EI apTkLgjxAUuuTeMaXSQ1VplfPUXfz/l8XR4Kc40U8Z0Z7wEWePHfjkG4CIeq0xu6jyqM R07uJkXkkrcGKoT66zvQqBvfUqvfNIDfv6qIHouDZyHCHS22tfk7qoa04GbMEbz/Ssko ma1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=PuJTMjAF; 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 sd6-20020a1709076e0600b007c0bf7f6845si20892158ejc.619.2023.01.12.09.21.55; Thu, 12 Jan 2023 09:22:07 -0800 (PST) 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=PuJTMjAF; 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 S240408AbjALROt (ORCPT + 50 others); Thu, 12 Jan 2023 12:14:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44078 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231814AbjALRNv (ORCPT ); Thu, 12 Jan 2023 12:13:51 -0500 Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F093C7FEC7; Thu, 12 Jan 2023 08:49:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1673542157; x=1705078157; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=KZYRVGkJd5m7mGfOiF9U3xQlytIMIV5s9yI1a8jwmE4=; b=PuJTMjAFSLr3sep2HZsu5qk3rk4rq0lqga7EIqWzGZD3/bP97wppw/rK 0rabTQsvRxkE4aFvOMs1U1o+Hm8/3tKPWP2+qUK6fc+VtMMqkyvN7XvDi zLFTI1ZN1wKytJ7npgHI7Mqu7pMKUoMZH5xOojPcEGvTuBWTKzDM441TB 0Fbtf8AbkgysuK/5Gwt+DUQ3DpFity6kXbkrLCC5D4SC5J1NUqiGX3gXp 73LaqRlsKjUBMsJ2TpcCUZ5dBh98hotlCLWvxtDrd2o1xjfhw8XyI5M39 pXEhrSQBeDZGCFYwbsMlK5iPeldJSNzL+TtO+gVTKGg92on69Ky1lYK6Q w==; X-IronPort-AV: E=McAfee;i="6500,9779,10588"; a="323816322" X-IronPort-AV: E=Sophos;i="5.97,211,1669104000"; d="scan'208";a="323816322" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Jan 2023 08:44:17 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10588"; a="986658352" X-IronPort-AV: E=Sophos;i="5.97,211,1669104000"; d="scan'208";a="986658352" Received: from ls.sc.intel.com (HELO localhost) ([143.183.96.54]) by fmsmga005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Jan 2023 08:44:17 -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 , David Matlack Subject: [RFC PATCH v3 10/16] KVM: x86/tdp_mmu: Allocate private page table for large page split Date: Thu, 12 Jan 2023 08:44:02 -0800 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 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 0ed802dc8627..e51fc5a5cabc 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 5c2c7e8ea62e..1a71aad62bd3 100644 --- a/arch/x86/kvm/mmu/tdp_mmu.c +++ b/arch/x86/kvm/mmu/tdp_mmu.c @@ -1690,8 +1690,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