Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp1172225rbb; Mon, 26 Feb 2024 00:31:27 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVXcv9toTGJAzOwNQvFiZa+SY4qql/24vEbCApiFDgJHuwT3wCb6Zyp40iGlECcjXH6xCiOx7M7lRTnSjOvJms4pZgOwTfnqcEfNYl8Kw== X-Google-Smtp-Source: AGHT+IE2ZOWfhxXEx204w+aBTGr4915lxCEoQYGbV63rKhj6KaVBOuglhz6yvO0FIoIOodrk3gHa X-Received: by 2002:a17:906:5f97:b0:a40:75e8:a84e with SMTP id a23-20020a1709065f9700b00a4075e8a84emr3756207eju.5.1708936287735; Mon, 26 Feb 2024 00:31:27 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708936287; cv=pass; d=google.com; s=arc-20160816; b=pmPwFLKhIA5T7xATOg9RxAWzRAJJCs3fxpRbsdxxpuaE7i1H6HxNr78HDTanyYNaSm 9+PlxIHhOvVsImw97BEtcvIqjpUa3EM8SfSJM5szQFwDPQo/AYOjD+T/fRhEY57S8YPq EV1V3fwNiQ3HK3OfWndMGSYpBAEtiGoI7cpBnsdTHt9W4edaZz5Qmh1fXo2wiykPq+Od phRsfJo9bZd80yE+QBG2rbu/MkPNnW8f6wi5k5npY3TmqTXIwwLKe0Cqq5dIaHWFsX+d WSUFzebIpk6qimoyGR5/liPs8gscQAcL/X+FjfnfJ0pESNFJY9HzPYr2/x7z3IaVx3s2 GOpQ== 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=R4wvlLPZa5XKdkGbXF4b9FWclkUFgwi20c7GME28QHk=; fh=Itbyk7CEvizIrzGEESCqq3I2tZgG1kc/GkVOa3S7Hsg=; b=Sz58ZikAoe4jwaYhSDYMC4ZG9XFWE5t6RXwN/0HVxK9ycx9iDVi02Q9o4bezPjyuuj Jq4Swh3TDh4RQ2DwJ4Q4k51LRCA9P7A/D9yIg1IHO2el/gWTeRMgwtxr4t/Qo7SWSxB9 yx+7dBJsjnh+lRtNqS2DuEPk3qdnrAD03cwtzHWRlHDRmyWIibKgWetXb5E4VYFbJu1s 03RKAjqpTfOogoVRRc7TsnzD1DXuEjkTOt9LNQ2A7FYYDjNjMmBU/p2l9umXtUure3Wc Emy4cMpbZhV4N+ldj7r3l67jneOoIThc15HzLc+Aj89ZWIIxI+qkGihM5RxweFEqPMXG ntHg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=V2gLD7oE; 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-80771-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-80771-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id r17-20020a170906551100b00a3e7b8a8347si1870846ejp.1053.2024.02.26.00.31.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 00:31:27 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-80771-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=V2gLD7oE; 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-80771-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-80771-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 7C60F1F24289 for ; Mon, 26 Feb 2024 08:31:27 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 220DB4EB49; Mon, 26 Feb 2024 08:27:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="V2gLD7oE" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.7]) (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 6971B38397; Mon, 26 Feb 2024 08:27:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.7 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708936064; cv=none; b=pF5J3HEbuQPP9h7Z1CVwgogwrkdjufFplX5oDUtJPirTYnki3/iwu8F5X+Ug9mq2drsFoEL0HH3VlDwNUmLUWwF85/PsqD7Tv2KgyVmN3KJc9SEbu8qw/SPyHrrqKPztaU57QosBZpU+QVfHJno96ZpTfs69J85lTehxhJQp+Dc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708936064; c=relaxed/simple; bh=Fyink57/ejQGrZ8tQRVicXDKz0HYEbCM9W9KphhTHVI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=r+DAekreflbmQuWO8yoyLk1OGY6bXHq6LZU+FLepVVTXet2AuGjK7AzJFkiXUJw/dq2pbukz43+6HHRPHFynT24qUNoIYMOJsZmT+nXLuyxa26e9MqNYwEnBrV16UhHkjkMr07KNsVjS3oA0nycPVouZLLKEZ6ZtiuHfWmZu7lI= 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=V2gLD7oE; arc=none smtp.client-ip=192.198.163.7 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=1708936062; x=1740472062; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Fyink57/ejQGrZ8tQRVicXDKz0HYEbCM9W9KphhTHVI=; b=V2gLD7oE5oysIguiRSLUZOD6qMydjEB0hYWDSop+WMEMQdy66UUyj3Og Ddvy+dJpwOQfb1TPxHWE9G+HL+SJPqsvlvD5eFYnvJnNCFIPtALV663wF 6+pgklIv5Cbu6/TEo1e6OLGIT2rGzyr5yu6OZYwE/cU5V5Pwkjre8tpoC u1BmttzhJkmVGgP7524WF1N0LN4n2qtaZdDX39VLgZfd0OwKzZKnxI3zP crLkVGhKhHysOYXYjriP37u8j8KW6aAzy/GsVMXkVb0GTAL3YnZLZmwhu TSl7E/CYjvN8lrYWjVT8QGKOwrzZYH+J4U4IM8c+DTzxoxKBCDF9OOQay Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10995"; a="28631466" X-IronPort-AV: E=Sophos;i="6.06,185,1705392000"; d="scan'208";a="28631466" Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by fmvoesa101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Feb 2024 00:27:40 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,185,1705392000"; d="scan'208";a="6474321" Received: from ls.sc.intel.com (HELO localhost) ([172.25.112.31]) by fmviesa007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Feb 2024 00:27:40 -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 v19 010/130] KVM: x86: Pass is_private to gmem hook of gmem_max_level Date: Mon, 26 Feb 2024 00:25:12 -0800 Message-Id: <8108cc2b8ff01ec22de68f0d0758ef0671db43fc.1708933498.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: Isaku Yamahata TDX wants to know the faulting address is shared or private so that the max level is limited by Secure-EPT or not. Because fault->gfn doesn't include shared bit, gfn doesn't tell if the faulting address is shared or not. Pass is_private for TDX case. TDX logic will be if (!is_private) return 0; else return PG_LEVEL_4K. Signed-off-by: Isaku Yamahata --- arch/x86/include/asm/kvm_host.h | 3 ++- arch/x86/kvm/mmu/mmu.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h index d15f5b4b1656..57ce89fc2740 100644 --- a/arch/x86/include/asm/kvm_host.h +++ b/arch/x86/include/asm/kvm_host.h @@ -1797,7 +1797,8 @@ struct kvm_x86_ops { gva_t (*get_untagged_addr)(struct kvm_vcpu *vcpu, gva_t gva, unsigned int flags); - int (*gmem_max_level)(struct kvm *kvm, kvm_pfn_t pfn, gfn_t gfn, u8 *max_level); + int (*gmem_max_level)(struct kvm *kvm, kvm_pfn_t pfn, gfn_t gfn, + bool is_private, u8 *max_level); }; struct kvm_x86_nested_ops { diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c index 1e5e12d2707d..22db1a9f528a 100644 --- a/arch/x86/kvm/mmu/mmu.c +++ b/arch/x86/kvm/mmu/mmu.c @@ -4324,7 +4324,8 @@ static int kvm_faultin_pfn_private(struct kvm_vcpu *vcpu, max_level = kvm_max_level_for_order(max_order); r = static_call(kvm_x86_gmem_max_level)(vcpu->kvm, fault->pfn, - fault->gfn, &max_level); + fault->gfn, fault->is_private, + &max_level); if (r) { kvm_release_pfn_clean(fault->pfn); return r; -- 2.25.1