From mboxrd@z Thu Jan 1 00:00:00 1970 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 084CE3EA98; Wed, 11 Jun 2025 16:00:24 +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=1749657626; cv=none; b=YtPKoztf0r5+guGC6G1dlPrOSbty8eaM4XgHvqfhh3sPR++7wLgsBqsog2XxZ7NHqr6fTD1bnftXMAxBVHwyeQCXSQhoHhk9++QC8W1SgpFFG45UkpzAjoQGWtn3fyUj/n0E8dj28Fkmp7m4+HkkZI1YpxXn6uPFNmeDl3bKn1w= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749657626; c=relaxed/simple; bh=BkD1XYR/BuytZqUUGnqZ6ZVXug4e1DergqtOvJL28Bk=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=ogH9/UphMPlanBBKAeri2x1qvwZFB9vCPoem7HU536mp8xogubKUVP8OPIKByqhs5cd/ztINKsxorJ0iAJnEUKf/zWV400MO079XrsdYBa2OqR5sZMgT0wTH78h5Sg8QdVZ41bqVo3sLi9QrGzOdx5aInYLIkihQQ+DDTly7UQU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=TKT6TUOK; arc=none smtp.client-ip=192.198.163.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="TKT6TUOK" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1749657625; x=1781193625; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=BkD1XYR/BuytZqUUGnqZ6ZVXug4e1DergqtOvJL28Bk=; b=TKT6TUOKZiMp0IMM0gL+0TemQP2HiVtXKnhubZMFBGGKbsM3cGQ+sdyG aERtyMojM6wmC1BhOpgC6kEk/VR5/lxVAuCY8CLWcpg6ShKE8YhfF9het VGNmvqwmez4OLmJdbI0k9hXD1Bmy/akM73RqL65VxLwZ8TV6lbWYggEUe dbuCPSjikq827OIZ0A30OiPgbivRRqR3KBMebWbjT5oYAwp5qmKuZPG15 uiKxlLPW9IWhQ0wtRGQKAg7XWakG6DUwpGFCx4R64vT+3mpz6aL/NVcXL FLEE2XrZY3aj9ifBmvKOOqehidhs+vw232nqi21VGJCTdoBatxT3/48+y w==; X-CSE-ConnectionGUID: eB0IuQFiTSuvYfvyGhZZsQ== X-CSE-MsgGUID: A55jczP9TCSNzJn+J++YlA== X-IronPort-AV: E=McAfee;i="6800,10657,11461"; a="63153323" X-IronPort-AV: E=Sophos;i="6.16,228,1744095600"; d="scan'208";a="63153323" Received: from fmviesa004.fm.intel.com ([10.60.135.144]) by fmvoesa104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Jun 2025 09:00:24 -0700 X-CSE-ConnectionGUID: QWv6GWAKTraeOQzbQHaQYw== X-CSE-MsgGUID: HLeiHM0TTYapsxHFcJgbnA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.16,228,1744095600"; d="scan'208";a="152392947" Received: from binbinwu-mobl.ccr.corp.intel.com (HELO [10.124.241.118]) ([10.124.241.118]) by fmviesa004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Jun 2025 09:00:21 -0700 Message-ID: Date: Thu, 12 Jun 2025 00:00:18 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [RFC PATCH 4/4] KVM: TDX: Check KVM exit on KVM_HC_MAP_GPA_RANGE when TD finalize To: Xiaoyao Li , "Edgecombe, Rick P" , "seanjc@google.com" Cc: "mikko.ylinen@linux.intel.com" , "Huang, Kai" , "Yao, Jiewen" , "Chatre, Reinette" , "Lindgren, Tony" , "Hunter, Adrian" , "Zhao, Yan Y" , "kvm@vger.kernel.org" , "pbonzini@redhat.com" , "Yamahata, Isaku" , "linux-kernel@vger.kernel.org" , "Shutemov, Kirill" References: <20250610021422.1214715-1-binbin.wu@linux.intel.com> <20250610021422.1214715-5-binbin.wu@linux.intel.com> <936ccea77b474fbad1bde799ee92139356f91c5f.camel@intel.com> <31c4ab96-55bf-4f80-a6fd-3478cc1d1117@linux.intel.com> Content-Language: en-US From: Binbin Wu In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 6/11/2025 10:26 PM, Xiaoyao Li wrote: > On 6/11/2025 10:04 PM, Edgecombe, Rick P wrote: >> On Wed, 2025-06-11 at 22:01 +0800, Xiaoyao Li wrote: >>>>> So, when the TDX guest calls MapGPA and KVM finds userspace doesn't opt-in >>>>> KVM_HC_MAP_GPA_RANGE, just return error to userspace? >>>> >>>> Why can't KVM just do what it already does, and return an error to the >>>> guest? >>> >>> Because GHCI requires it must be supported. No matter with the old GHCI >>> that only allows to succeed and the success of >>> means all the TDVMCALL leafs are support, or the >>> proposed updated GHCI that defines as one of the base API/leaf, >>> and the base API must be supported by VMM. >>> >>> Binbin wants to honor it. >> >> But KVM doesn't need to support all ways that userspace could meet the GHCI >> spec. If userspace opts-in to the exit, they will meet the spec. If they >> configure KVM differently then they wont, but this is their decision. > > I agree with you and Sean. And I'm trying to answer Sean's question on behalf of Binbin. Yes, it was my thought. > > Strictly speaking, KVM can be blamed for some reason. Because it is KVM that returns success for unconditionally when r12 == 0  to report that all the (base) leafs are supported. > > But I totally agree with KVM cannot guarantee userspace will behave correctly. Even with this patch that KVM mandates the userspace to enable user exit of KVM_HC_MAP_GPA_RANGE, it's still possible for a misbehaved userspace to error to TD guest on KVM_HC_MAP_GPA_RANGE and breaks the semantics of successful . > > So I'm with you and Sean. > Also see my reply https://lore.kernel.org/kvm/ba611f52-9817-46ff-b16b-a9ef7404a51d@linux.intel.com/ In the next version, how about combining this patch to patch 1 to use TDVMCALL_STATUS_SUBFUNC_UNSUPPORTED if userspace doesn't opt-in KVM_HC_MAP_GPA_RANGE?