From patchwork Mon Feb 26 08:29:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Isaku Yamahata X-Patchwork-Id: 206469 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp1953920dyb; Mon, 26 Feb 2024 01:14:39 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVO05mDnqwxdgawH+e49bycIVkBbXdZztb46pVDUA7RLoluB5GOFv0lkkbanJ/MMgLUKvjiZKsdkPZl6m0umP1e2WFUmA== X-Google-Smtp-Source: AGHT+IHW0LxdnrbUPNbA0zVsez/5dorBGuN5lkrqyqMYnvEZrEOhOhlfkGzOtGwz6ZTg4QYSMcfJ X-Received: by 2002:a25:94c:0:b0:dcc:9d30:58a0 with SMTP id u12-20020a25094c000000b00dcc9d3058a0mr3431004ybm.64.1708938879627; Mon, 26 Feb 2024 01:14:39 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708938879; cv=pass; d=google.com; s=arc-20160816; b=iZezCiDGMHKAktZ1q21j2+ZlDnV82601hwFW1SutOL2uGfFQG2X6hHTr+OD8LSJb5k Fn6kmbQLmrHXbv1x/HBuOg1ZvcqsE4lzaz48bnhUXbo/nQuwdsfG+SDP1y79fdVqmNL9 ZlVi1+tGVnsvj3aRLk3DEbhHZvjBs+vahYXrhQNHwZQB3AAayxuXvKLM7fGI/T7T1UN7 K8RyqjBs4OunTax5np4Gm/5nm+UBhXFpDw9etTkf+rwRWzCXJeR3ToudDhhQLoykDCzb kIoq8F5VQL7H60MNHrEYxg6EnKjTk6/hhO0f+vASJUBaRsQjNd/ks9ffscd8PIeYM5Fn ROMA== 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=TP3ITd0rLWpIi8dhZMFlcYfNKQehhQ2xUWuofknK8eY=; fh=Itbyk7CEvizIrzGEESCqq3I2tZgG1kc/GkVOa3S7Hsg=; b=rkZeUbGDPdQX3RhqimVHtfMyl/9q0Eqgoj5PfgMNTtH58hirrZfuWs+wTMgxExCNQ2 Njvl6SnakF1O4IQS+w9nUxgecGFClhP6KZ1GukWdrPCRIM678pvnUj7kxNyj1MjbibRV KcgCghcaLVCnLiDoqaiWtEtMNBVxvUdflMHcezIIP/LETLCAIkGP7idXXzBczP9dDRWY YPMI2GdS4SIcRRGvZmc0ev+rk5skdzlYP2uvDTniFviNcykF9U/uISuSlohTIOQyg4VG VWOTBc1ypilV6lP/eRj06PpPLL68ipFRT7ypbCHRVCEQurRC6VX79pZFcP+SmId8WmoN VpZg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=OzFZCYjp; 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-80903-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-80903-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id e13-20020ac8490d000000b0042e4c1029fesi4552619qtq.539.2024.02.26.01.14.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 01:14:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-80903-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=OzFZCYjp; 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-80903-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-80903-ouuuleilei=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 6C7551C23B09 for ; Mon, 26 Feb 2024 09:14:39 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 703E213540E; Mon, 26 Feb 2024 08:29:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="OzFZCYjp" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.10]) (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 5966A1DDF2; Mon, 26 Feb 2024 08:29:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.10 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708936192; cv=none; b=osA+uYsGnX6yOZ5hOhGr03LlXbmnIEEtHbbtI5Kn3nWT+hrmAsNxXZJlH89uKIxbakhl4UEAR9eFOCjiv0nIpRHSGsZMYekQvw30ETavHfpd+0v4GrNlGXxWngAt7a5lVhDtbs9YB193CnYyCCP+mMl/Z479SYQRYnY4xxhYtYg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708936192; c=relaxed/simple; bh=AX82JcILUa46R1G0PfPXFjiVx0GFJf+AzOhgtIqj4R8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=TLzuW94I5f+r7CjxiG6WdcFw+Ttz0ipUzMzpi2FAYmysFE39ePR3yeAt+KGcAcEgJIDnhqH4L3fcNr2JRhtUYoMMzcjWikEa1DX4JOEPN3KO1vu8tM6THUq5VCNjIW3zGhGG26XVU5aneDGGG8B+l6fF4l66DnwstBQ8Wq3BaQc= 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=OzFZCYjp; arc=none smtp.client-ip=192.198.163.10 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=1708936190; x=1740472190; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=AX82JcILUa46R1G0PfPXFjiVx0GFJf+AzOhgtIqj4R8=; b=OzFZCYjp7MydseztlfNJWt+31fupV8S4VOh5t2Q+7eMogLtfz+kXIe1l XfwYugpG17bSyno6Ot0yG36xlaSWxv3OKShEJ1l4j8c0hf5Yef3a5FmbC nY2IGmNcgHho8b7Wu2CgJGwrq38S6e1Rg2RxkM3voT1PXzYX2/b/ptQJn Q7LbW8hA6pdL3xJL1bFeAYc7pXdU1/LJg0SS5PzVHmrSZDnQoDta51W1i /vKTdRdnn2ltowBpbuwVVwfP+prVIUjWviKGiaCChPkQLczEg35gsfLaL 5CFdQfMlv/DbOoXdhqgUfEyVf7QSSB0ZkliqdM3M4x/tetn6FS0inCuqE Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10995"; a="14623311" X-IronPort-AV: E=Sophos;i="6.06,185,1705392000"; d="scan'208";a="14623311" Received: from fmviesa009.fm.intel.com ([10.60.135.149]) by fmvoesa104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Feb 2024 00:29:34 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,185,1705392000"; d="scan'208";a="6519410" Received: from ls.sc.intel.com (HELO localhost) ([172.25.112.31]) by fmviesa009-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Feb 2024 00:29:33 -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 v8 08/14] KVM: x86/tdp_mmu: Allocate private page table for large page split Date: Mon, 26 Feb 2024 00:29:22 -0800 Message-Id: <657c4a403e63f2c7e1742b4cdb09ca94c6d5d9b8.1708933624.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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791952294566638928 X-GMAIL-MSGID: 1791952294566638928 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 | 9 +++++++++ arch/x86/kvm/mmu/tdp_mmu.c | 8 ++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/arch/x86/kvm/mmu/mmu_internal.h b/arch/x86/kvm/mmu/mmu_internal.h index 9e2c7c6d85bf..9aa4c6ffa207 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) diff --git a/arch/x86/kvm/mmu/tdp_mmu.c b/arch/x86/kvm/mmu/tdp_mmu.c index 1a0e4baa8311..66de875d3de1 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;