From patchwork Mon Feb 26 08:29:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Isaku Yamahata X-Patchwork-Id: 206475 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp1954623dyb; Mon, 26 Feb 2024 01:16:06 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCU0CH2BzlelAqQWoGmkh8M3CZr6/zUS2uSw240g8ym07KdgB0NKEMYM1DQ1YlMRoUy3dJ29usfyxiVq5aeEcC7y6nU5DA== X-Google-Smtp-Source: AGHT+IElvAJ+pXlwyfx2O3NZW5C1H87qm50yxTbuB04YB2rd2eGY5eWcIfweuzkieCemyNMswEuo X-Received: by 2002:aa7:85ce:0:b0:6e4:9ba7:a622 with SMTP id z14-20020aa785ce000000b006e49ba7a622mr5651333pfn.19.1708938965869; Mon, 26 Feb 2024 01:16:05 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708938965; cv=pass; d=google.com; s=arc-20160816; b=HiFhS6bhZ3s/t7dE94tDWizefHVokLs7Ud2X2ffa/ww+DqY53bbh2fvHQ3UmJcymIV x8aVRDLqttirtAHfZUm2owdJyhexTtMAYYH2GKMf5riden769XrKAxK6bmTdbAIzhlQE 6lQWrVlOFKC+DShuKZDsTeiplPE36P2l3aA1HJGXwOQAceJQLcxsTGgXL2DCCqcF2h3O Sp47f4rh/zMuBZw2+rO+ZSJ0rqLMhOrDU77bACUjPwQMoMiogi+INUi9o1/SI/2bMosl scdfG9xwD9m2gZ98vUaiUQsicICLne5t9o9hA8Hh4iwoXsTXP27c2yeAQphvLJ0R8Zrk feIw== 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-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-80908-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id e6-20020a056a001a8600b006e0f4907ebasi3386321pfv.113.2024.02.26.01.16.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 01:16:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-80908-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; 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-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-80908-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id A9214284CD0 for ; Mon, 26 Feb 2024 09:15:48 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5CA8B1369A4; Mon, 26 Feb 2024 08:30:00 +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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791952385046162272 X-GMAIL-MSGID: 1791952385046162272 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; }