Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp1188790rbb; Mon, 26 Feb 2024 01:15:39 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVaaYbM+QXnybTnRFpdGUAgHY/CgyW813NA5S304CtW5frj7D4xOPUp7zYQu1lWjkAzb0kYAezjQT4BmdVB3tWHesJCDGCYkEGbAplzhA== X-Google-Smtp-Source: AGHT+IG5Gxz4BiGTpBqc0hHkP3A+DoF4FRaKmV9srxbiVn4MLUfJLU2lKnlXahGPj/BrvNyXJ2O2 X-Received: by 2002:a05:6358:e483:b0:17b:b13e:5b31 with SMTP id by3-20020a056358e48300b0017bb13e5b31mr588895rwb.6.1708938939164; Mon, 26 Feb 2024 01:15:39 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708938939; cv=pass; d=google.com; s=arc-20160816; b=JmOhd2Tkz4Wa8D6ApKqekQKnzXpGs1W4tk8nTyk8zQhsFpA14wD1oBnhqQht+vaUW5 2B9bovPf9FiFTrctX9Wkp9pHRVnSlVjphoGL8akjIaF9IQKI/EDfvE8AaU3SEK2y55X+ KZfMxBPgOQF07Z4DAhV8eeT+RPRpon12r24WK59gJ4ikraHKnQqP1ZyKkQbV7KW+d3O1 cMHccAw3eaoKiYjXfT2EbW6gzK8bfan6VvgkvYlDfv4DMsJVM+W+FSPNLRtqEp7zrIhf DWzb8HS5Ny/3t7qlcqxUAOBB23V4XRpXh+MXjjAmto5jtvmaUqpp77M6HwmyEUCtOpHx AJAg== 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=U6bo0ajjw2ita2FTVfiiUeveUPhpHKCraOxUXa+xufQ=; fh=sMdP/xP2j0mAr7mmqXKi/DmIqVqVXObmf3aqGFg9BJU=; b=HyPIzZ4CTr2usSIITzRapnOqo0CfN7WVYEtRYz/rhjiyPQ1lCyFNmVZAjyx5FDPH5v W8WkA6mALeHjBIIhIP6GJjguuvliq7sg2jM3DAGQ+jUICLMLnzGeh0wUr5Bm2p/da+yL mLvqDtcSM+Y5tStutlaAqE8y2DKovzBQGSOujGpiiTB6tDZ9uHJsVvQWs+phOZjzBtGC LXvJOIJb3gv0c9CYiNNf6h/ms0R5qp5z1B7fikJEl9NZKWAlqIZH21Gcluq7cWu8mqhu nc1FkV61NfCqZKAZHg7baLFLIJESZsvTyesWMxsxtqIxgJ5Xv2gilWUSWaAHpmAV8OBu jf9g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=m91SWsCt; 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-80908-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-80908-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id ay10-20020a056a00300a00b006e5343da718si826956pfb.102.2024.02.26.01.15.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 01:15:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-80908-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=m91SWsCt; 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-80908-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-80908-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id C3C1D28357C for ; Mon, 26 Feb 2024 09:15:14 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4901A136648; Mon, 26 Feb 2024 08:29:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="m91SWsCt" 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 BAC9B1353EE; Mon, 26 Feb 2024 08:29:55 +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=1708936197; cv=none; b=nG6C/Pg9ZyF3+QF7ukdDWfEDyiOAi2T+VjGTAPbKMP5mgnk9oY4fF9pqnC64We1L6hk4eQywwRdxn1P4WrDVllitXjHQ5cijA0B9GJwoPmWEuJONDFZ4e0FIMemwkqHWQqAQoYbTQY+GUNvpVYBjcQns9hLmM/eVRkfXQSBYYXk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708936197; c=relaxed/simple; bh=dO1PBJiymwhAoqOQlpC9i+z46NWUa5VVHxrGTwyy1RQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=fHhgBQ9ljtmcxfg9iC5SZTw7CBHbJ2GBkYKjK3onTyHJYJqDOLv9xavo7uHYEEPraD0p3ETV0XxC5DXvWjmp+vikHd8n1ri+WAMjw17gq3zGTAl4f6NPapGPmBC/qNxra9SxBXc5OwDFAqc9YuwpOIJuyOIiO4ZIFlvYb1IitA0= 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=m91SWsCt; 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=1708936196; x=1740472196; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=dO1PBJiymwhAoqOQlpC9i+z46NWUa5VVHxrGTwyy1RQ=; b=m91SWsCtSnzLOtQWK2fkYgMAG6TOnLUc/4mvOZgtc/9I8gU+bEtPdm1m tFCDORSARgcdQ6ADMtcpzwRYBVtNyGfksoVKTul71VP9AkRXkVIGGGv5A DKRVmwkKujlzFbmpkrhAp8egZIxNFym5ZJ1z8rlScx0dAguvF9kqMSHtf +eS+M0fg7Cy9nHpJy9b19nkNDDyRgWZ6n3WCkBNTxhnm2bkWF8zkNxouV XqCBOoy54Q01omCvYJXn24dPVlSoFkhs4xqc6cG7gyyU/9NZJghvNbTeB BP5KOlrSFZD87f6JxxIIyuimEB3S0KDQPFwdiNeBpXzHp735MWk7HLbM0 w==; X-IronPort-AV: E=McAfee;i="6600,9927,10995"; a="14623341" X-IronPort-AV: E=Sophos;i="6.06,185,1705392000"; d="scan'208";a="14623341" 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:37 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,185,1705392000"; d="scan'208";a="6519439" 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:37 -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, Xiaoyao Li Subject: [PATCH v8 14/14] KVM: TDX: Allow 2MB large page for TD GUEST Date: Mon, 26 Feb 2024 00:29:28 -0800 Message-Id: <2f5ea6d9ae5ce86c7eebd52de4a061ffb05eb420.1708933625.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: Xiaoyao Li Now that everything is there to support 2MB page for TD guest. Because TDX module TDH.MEM.PAGE.AUG supports 4KB page and 2MB page, set struct kvm_arch.tdp_max_page_level to 2MB page level. Signed-off-by: Xiaoyao Li Signed-off-by: Isaku Yamahata --- arch/x86/kvm/mmu/tdp_mmu.c | 9 ++------- arch/x86/kvm/vmx/tdx.c | 7 +++++-- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/arch/x86/kvm/mmu/tdp_mmu.c b/arch/x86/kvm/mmu/tdp_mmu.c index d6ce8496803f..8663e163427c 100644 --- a/arch/x86/kvm/mmu/tdp_mmu.c +++ b/arch/x86/kvm/mmu/tdp_mmu.c @@ -1544,14 +1544,9 @@ int kvm_tdp_mmu_map(struct kvm_vcpu *vcpu, struct kvm_page_fault *fault) sp->nx_huge_page_disallowed = fault->huge_page_disallowed; - if (is_shadow_present_pte(iter.old_spte)) { - /* - * TODO: large page support. - * Doesn't support large page for TDX now - */ - KVM_BUG_ON(is_private_sptep(iter.sptep), vcpu->kvm); + if (is_shadow_present_pte(iter.old_spte)) r = tdp_mmu_split_huge_page(kvm, &iter, sp, true); - } else + else r = tdp_mmu_link_sp(kvm, &iter, sp, true); /* diff --git a/arch/x86/kvm/vmx/tdx.c b/arch/x86/kvm/vmx/tdx.c index 5b4d94a6c6e2..1a94b1072068 100644 --- a/arch/x86/kvm/vmx/tdx.c +++ b/arch/x86/kvm/vmx/tdx.c @@ -3109,8 +3109,11 @@ int tdx_gmem_max_level(struct kvm *kvm, kvm_pfn_t pfn, gfn_t gfn, if (!is_private) return 0; - /* TODO: Enable 2mb and 1gb large page support. */ - *max_level = min(*max_level, PG_LEVEL_4K); + /* + * TDH.MEM.PAGE.AUG supports up to 2MB page. + * TODO: Enable 1gb large page support. + */ + *max_level = min(*max_level, PG_LEVEL_2M); return 0; } -- 2.25.1