From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pg1-f201.google.com (mail-pg1-f201.google.com [209.85.215.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 41636314B6D for ; Fri, 30 Jan 2026 15:32:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769787172; cv=none; b=Ya4lHkbTpqJuvgeeRyZUgMtRxRVq0ZXr262jN8LE5oxEhDFVbmTo50wLzgjmt8JUEyWuK3fISOwlUvS9fnWVLaOA0udobVH6zxMmKwbLCuGPRYBiNBoucnSMCMBz98rsSwhVzChf47HDlwK7kwR85oMtbS/I3oc8AYeKBljKBjE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769787172; c=relaxed/simple; bh=i8wscdSHr/yETmiNRCOhea7uOvB2cu7M4xeAbqKz3xI=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=RQGks5kpfXez5VGOO0zv4P7dCaegzwxplX3JCFrkMlQv0Xk/GZ07j4DyY1N1D8OclEmlIhNI+fEF6NZGl8zUZYHCvGUH0czrXlLSTFJsMuoNtFteYXpvUvcE7S4f+2ZvfYc/isHxwtasctw61Jc0ji/0NMHUjeHGTqcxnnGI6iM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=JbWRFcMi; arc=none smtp.client-ip=209.85.215.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="JbWRFcMi" Received: by mail-pg1-f201.google.com with SMTP id 41be03b00d2f7-b5edecdf94eso6860546a12.2 for ; Fri, 30 Jan 2026 07:32:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1769787170; x=1770391970; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=BQOWjbxwtcESWSfKrgjbMAEnNEFgcacz0OCrlLF7boI=; b=JbWRFcMiyKV7T6yNYUjjUo+JqyZvjX0UNyKAMgOoxbNcs1lDhLy35s+PbQ/lHmQm2o BFMvKjGZ2QE41iBsqI6dWN+ZFfak//lLQEUZBhgt0ASvUTOc+qFwajvFBhQvDYatakAt GtYh2GQq/XJPP/hMzAV7R3Pi809VmyviUWL7hSrHscKBjbrhxUqmXjES/xw7/ADIF7Xi 7F6MVBb1ptye4UmXfvmYuKprTVC2xwfbShfJVhEYsxfKCo/nTTEehU82zL6B51qHmsLS Ou0o5SqhgENmifw7v9quGCKeypfPZOJTiwKjnycSdUlJFzddyTkwg6r/E8n5zWxofM7L m+1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1769787170; x=1770391970; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=BQOWjbxwtcESWSfKrgjbMAEnNEFgcacz0OCrlLF7boI=; b=j99URu8qEakWijW9j+5BTK1puTE1xcQ//YvgxSyEskxQwpIQ/qbT5FUL2bdjuBQV6b /NCaBaB15syJtYqobi/9kmnHM21HPmIUNmFpDKLgGXAMgDJPloNVLfC2S7g5xtWn9zIT WD7HdFPkiE032XVGtGFzu5iXUd9GaKY/aI66KD/3oKMYCdBgqVnrTcY8BPLqG220IsTx MuQCZjwEkHRxqkTroSJpG8ZRB0yZp9s1Q58hhEFDySRBFy9bOKQBM/NXLLW2nJejF0GM l0krs7d60AlhHFYD75Y0CKMjMqxVpAVCx7fe0IcqveiC/tn0kNF+uu2le80NyCHA42qx 4ndw== X-Forwarded-Encrypted: i=1; AJvYcCVOswR6tqRPuuCUpozVy1xPXnX/srKkrd5oXhPOuh9DlnXAPtahNIQfhZOXYDoH4lOASpmPhSgQ9h9Hyxo=@vger.kernel.org X-Gm-Message-State: AOJu0YxfeNFQDjJVORHrP6BQizkxXWeFeovZnyAenZRthgcPodjNvNZe NzOizoXRNNGbRg85LXYb8/+GKKTHIliBqDK/F3GHoTfWles8KNtYckMyiaoSViSO4PYfrsqERYV HyqCBUw== X-Received: from pjbok5.prod.google.com ([2002:a17:90b:1d45:b0:34e:795d:fe31]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a21:6185:b0:350:3436:68de with SMTP id adf61e73a8af0-392e014ba69mr3010045637.53.1769787170466; Fri, 30 Jan 2026 07:32:50 -0800 (PST) Date: Fri, 30 Jan 2026 07:32:48 -0800 In-Reply-To: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <6184812b4449947395417b07ae3bad2f191d178f.camel@intel.com> Message-ID: Subject: Re: [PATCH v3 00/24] KVM: TDX huge page support for private memory From: Sean Christopherson To: Yan Zhao Cc: Rick P Edgecombe , Fan Du , Xiaoyao Li , Kai Huang , "kvm@vger.kernel.org" , Dave Hansen , "thomas.lendacky@amd.com" , "vbabka@suse.cz" , "tabba@google.com" , "david@kernel.org" , "kas@kernel.org" , "linux-kernel@vger.kernel.org" , Ira Weiny , "francescolavra.fl@gmail.com" , "pbonzini@redhat.com" , "ackerleytng@google.com" , "nik.borisov@suse.com" , "binbin.wu@linux.intel.com" , Isaku Yamahata , Chao P Peng , "michael.roth@amd.com" , Vishal Annapurve , "sagis@google.com" , Chao Gao , Jun Miao , "jgross@suse.com" , "pgonda@google.com" , "x86@kernel.org" Content-Type: text/plain; charset="us-ascii" On Mon, Jan 19, 2026, Yan Zhao wrote: > On Sat, Jan 17, 2026 at 12:58:02AM +0800, Edgecombe, Rick P wrote: > > On Fri, 2026-01-16 at 08:31 -0800, Sean Christopherson wrote: > IIUC, this concern should be gone as Dave has agreed to use "pfn" as the > SEAMCALL parameter [1]? > Then should we invoke "KVM_MMU_WARN_ON(!tdx_is_convertible_pfn(pfn));" in KVM > for every pfn of a huge mapping? Or should we keep the sanity check inside the > SEAMCALL wrappers? I don't have a strong preference. But if it goes in KVM, definitely guard it with KVM_MMU_WARN_ON(). > BTW, I have another question about the SEAMCALL wrapper implementation, as Kai > also pointed out in [2]: since the SEAMCALL wrappers now serve as APIs available > to callers besides KVM, should the SEAMCALL wrappers return TDX_OPERAND_INVALID > or WARN_ON() (or WARN_ON_ONCE()) on sanity check failure? Why not both? But maybe TDX_SW_ERROR instead of TDX_OPERAND_INVALID? If an API has a defined contract and/or set of expectations, and those expectations aren't met by the caller, then a WARN is justified. But the failure still needs to be communicated to the caller. > By returning TDX_OPERAND_INVALID, the caller can check the return code, adjust > the input or trigger WARN_ON() by itself; > By triggering WARN_ON() directly in the SEAMCALL wrapper, we need to document > this requirement for the SEAMCALL wrappers and have the caller invoke the API > correctly. Document what exactly? Most of this should be common sense. E.g. we don't generally document that pointers must be non-NULL, because that goes without saying 99.9% of the time. IMO, that holds true here as well. E.g. trying to map memory into a TDX guest that isn't convertible is obviously a bug, I don't see any value in formally documenting that requirement. > So, it looks that "WARN_ON() directly in the SEAMCALL wrapper" is the preferred > approach, right? > > [1] https://lore.kernel.org/all/d119c824-4770-41d2-a926-4ab5268ea3a6@intel.com/ > [2] https://lore.kernel.org/all/baf6df2cc63d8e897455168c1bf07180fc9c1db8.camel@intel.com