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 59C7A26AAAB for ; Mon, 20 Oct 2025 15:25:29 +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=1760973932; cv=none; b=I9ZofcN6uba+4irSOTd/f8jB2UAY4Na1v6yQ/raIkF4h8FhDJUhdQuvYKJSUuSbxQTr2vzGZOSIlQ3T2zr64Dn0r9E/Q9mpwjVVGQC2M+PJINRZj3RB94CRxj7OkbN2dcv8vb5AinUQu16MdiHCEbeT/y2fjtIAugL+m+17LckY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760973932; c=relaxed/simple; bh=X2cNT2jodYHE9VXEpV2Jc+n9s/IGEDlBeAa8Q4UPTyw=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=dIQeBo4w8mGLE7/lNUGjvTmB0fGPBL7YkaF3WUEret6B7e0h16pPdY4mNiHYictReZT3OT7jxK49mvJiVljViiXO/DKDEi/tlPQxNHy0l0ZJqaLH9WjXZD7kXinNhig4f8ThMGE6EOxCf01gqtVDeMA4qIqdbeAXG7/BsHi2rK0= 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=OZQ3MC10; 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="OZQ3MC10" Received: by mail-pg1-f201.google.com with SMTP id 41be03b00d2f7-b557abaad02so7508703a12.3 for ; Mon, 20 Oct 2025 08:25:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1760973929; x=1761578729; 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=8duMiPUW3Ov9cGPKQdSL4cotcPZI8856r/Bae2VnHbg=; b=OZQ3MC102imDjjy7y7+21WZgroY+0QHEwH2ceetvgvGjk0KWlWJ0pQqWiGE+etRcx/ Js8ys2eFoTwW0j6EJasNYn4DvXQiZZn9vMuZ9BfGcdm1Aj8jFnmT7Ir9jBSZi/4T2A4X D9KSTMI4EKjBKMBm6N2w/ffq8ySX8y+U0FNIHsQ5Vks7NvSuB617s64ZQtjE5+K35/IB DBdQDln17mlL/YCH501RQYHbsAU4dca2scg7VX/CUzpJc3JKIWoLZmKGGtJUytSUFT4l wQawmRhYJoc1nJAvrMZrvyJm2ZNg/WNPdFoiRoR0ykTkhrGeJm0OYjI39jA8TdaUYtXE d4eQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760973929; x=1761578729; 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=8duMiPUW3Ov9cGPKQdSL4cotcPZI8856r/Bae2VnHbg=; b=bK41JPyiSl16Tv4JAUS+M9PgZxBVnsO8/51Kx7mvXcV3cfxU0BedaN+uXzq2P11+hE hCSsSOGRYZNrsI2Q2K9QC8vau0wREsyiNP+oe78yCfp60GzpYYsy3r6kxf4ib+kfnzR9 A3xpZFn+FgB152C4B634qrtkOXYxB60e9kRhVwjgtIxHmZo1E0ekNzGZRHtt8cwE8NfU QLbXJuZSW9SETBBSQTao1FOpwyLHSKy+X85f4jk2kpIX82a29+Rkaqp1yUVeOYKGfbsd s1CiqXoB1lUBQtQixoQTKjXP73Uvgdf65N0faa+MZYwI6fPmK5F6tiW4Krzwe6FYmScx VUiA== X-Forwarded-Encrypted: i=1; AJvYcCXCe6PzfPkalM0XZV9d1hEmU3e5DxB66gC2x+BMKqAyENcUpeXE+LxURRLj5glupBYYrzJy7IrWCZX9/Ko=@vger.kernel.org X-Gm-Message-State: AOJu0YyWU+S8R+MxSXJmOl2bS5FEpPs6vqk38nZWnOX03xGu9enzKiMe B23/pp5wikB74niVjMI3w/1GJhj7PeYdlIownth7l291JMBZbbvMbQpiBh05AJJvxTFV7mXvv/g U0nd7Aw== X-Google-Smtp-Source: AGHT+IFqW3qIYEVTbpVnhf/SO53CXDCgtTQdekIynQUGkmgpYGTVsnP6gv23UN57ly+8fm7EenYdxfMTkTw= X-Received: from pjsc19.prod.google.com ([2002:a17:90a:bf13:b0:33b:ab21:aff7]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a17:90b:3c0e:b0:330:a228:d32 with SMTP id 98e67ed59e1d1-33bcf86b401mr19164126a91.10.1760973929211; Mon, 20 Oct 2025 08:25:29 -0700 (PDT) Date: Mon, 20 Oct 2025 08:25:23 -0700 In-Reply-To: <033f56f9-fb66-4bf5-b25a-f2f8b964cd4e@intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20250910144453.1389652-1-dave.hansen@linux.intel.com> <872c17f3-9ded-46b2-a036-65fc2abaf2e6@intel.com> <033f56f9-fb66-4bf5-b25a-f2f8b964cd4e@intel.com> Message-ID: Subject: Re: [PATCH] x86/virt/tdx: Use precalculated TDVPR page physical address From: Sean Christopherson To: Dave Hansen Cc: Dave Hansen , linux-kernel@vger.kernel.org, Thomas Gleixner , Ingo Molnar , Borislav Petkov , x86@kernel.org, "H. Peter Anvin" , "Kirill A. Shutemov" , Rick Edgecombe , Paolo Bonzini , Kai Huang , Isaku Yamahata , Vishal Annapurve , Thomas Huth , Adrian Hunter , linux-coco@lists.linux.dev, kvm@vger.kernel.org, Farrah Chen Content-Type: text/plain; charset="us-ascii" On Mon, Oct 20, 2025, Dave Hansen wrote: > On 10/20/25 07:42, Sean Christopherson wrote: > >> In a perfect world, we'd have sparse annotations for the vaddr, paddr, > >> pfn, dma_addr_t and all the other address spaces. Until then, I like > >> passing struct page around. > > But that clearly doesn't work since now the raw paddr is being passed in many > > places, and we end up with goofy code like this where one param takes a raw paddr, > > and another uses page_to_phys(). > > > > @@ -1583,7 +1578,7 @@ u64 tdh_vp_addcx(struct tdx_vp *vp, struct page *tdcx_page) > > { > > struct tdx_module_args args = { > > .rcx = page_to_phys(tdcx_page), > > - .rdx = tdx_tdvpr_pa(vp), > > + .rdx = vp->tdvpr_pa, > > }; > > I'm kinda dense normally and my coffee hasn't kicked in yet. What > clearly does not work there? Relying on struct page to provide type safety. > Yeah, vp->tdvpr_pa is storing a physical address as a raw u64 and not a > 'struct page'. That's not ideal. But it's also for a pretty good reason. Right, but my point is that regradless of the justification, every exception to passing a struct page diminishes the benefits of using struct page in the first place. > The "use 'struct page *' instead of u64 for physical addresses" thingy > is a good pattern, not an absolute rule. Use it when you can, but > abandon it for the greater good when necessary. > > I don't hate the idea of a tdx_page_t. I'm just not sure it's worth the > trouble. I'd certainly take a good look at the patches if someone hacked > it together.