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 75FFD3FFFAD for ; Fri, 10 Jul 2026 14:48:04 +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=1783694885; cv=none; b=HvMHwwxyDtUjstqCwhq0cX3zPtH60Hezp3A9Qb796oRZxQcFtNJf64aweUPdrSJOV5QLzZCkbIQzGGGjoV/vLtCG4mqi2w97Axii+tuASkLmJ77/hgb6rr+JzGTzLnERZ95r4wDqFqSTgywegD5Fxt7Chua4E4PGXjbLc8FJi68= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783694885; c=relaxed/simple; bh=9/BUljy6TNRY9n09ZmVql69eTpV3ZFcHR2xOX8xQaBc=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=GSrLB/Orv47mXG6i0ltuUngiUEf2HyiVeSXLTSBPLUvBtXHKp41I/jINS34xU6NoRcynLog7nu8s9ilww3Iwzvi1PwKndem9zdw6siSelKKqRWEN0yXRrcRvFxpOrXYv2+VdklFsAeGoL6/w0vd3szzYUtEAcoZsAijJCiyoo0Q= 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=ovCh2KPn; 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="ovCh2KPn" Received: by mail-pg1-f201.google.com with SMTP id 41be03b00d2f7-c89704da8c7so1653955a12.0 for ; Fri, 10 Jul 2026 07:48:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1783694884; x=1784299684; darn=vger.kernel.org; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:from:to:cc:subject:date:message-id:reply-to :content-type; bh=BMyY/scxQTo0tXtbyEdWPI4W0NbSwCug6oGYu+Luc9M=; b=ovCh2KPndgoRd6q1k5thvXwHVVvWo9yGJR4Xt+guCSgYoC8Kz36fHaNl6V7Y0rTxm2 FGgLJcnRW482X/0owfXQJWGbP2SzBwUt9d/AQ9CaB2pTzMNVX89tz7Q8+1GOsYlN80uk TPyFye+44xmNC/6Bn+eSPttnNWajp+tmEcKosH2GcCWmvUbfvUKU71MnSOYtuQkzDc/h TBsOe7adZvif/p6L/xfFsGLU5P/FmOmhW80WmdGeKZ7hg3iPPp5ko6lYqM66dELfaZ6I l2Wf1YYvig0c06lZhx8ld2o9c8IYj9B3/muwLTKk2Ygd/qMnZ1GAqw0WGXC96tc/+qM1 aQRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783694884; x=1784299684; h=content-type: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:content-type; bh=BMyY/scxQTo0tXtbyEdWPI4W0NbSwCug6oGYu+Luc9M=; b=J+3SDDP4812yWfZAIr2W5wu34dvw3MQWa7TOLV/C3QcADbcPtO//aZ2wU/OOT9jagj 5XDa5Dof6pzLZZXFlgQqfU9utNNrZmfO1gNOqX/dux8K4G8GE9fArPJzVUy0tavSlbXW vdUbsmLnc5UbmqQEQpVwkIogbYFj3U6zwT/b/yV9llbCy3Npg0Nb0+18Uu3Sthe3zkio eczjPRqJCmP1hkA4BYHywMifBbA90InbPVv/wSoRJRIvdNGdXFako+Cz3G6T0oTzM3ml tCWfiAHiv1qwaD6m3z33G6q+kxF73+sCJ6XAG5pJ4X9E1EYslTxUISC5Fo+v38JjCjjj Vw5A== X-Forwarded-Encrypted: i=1; AHgh+RqG2R1Es1z6Nh+056xOYxSAM2Mh+sfyOqenwnSo3OAZIxdAJ61N3sbGStLOLFpE/cPQHpcvoxaewjeMIBY=@vger.kernel.org X-Gm-Message-State: AOJu0YzkK+/aVkiYOolQktNXJP1Wcmn4oFI38Sjnup1W/jNwYSAwhC/b 9bLn59xWlcrZcvHxcuFnJxZpCUAvaM6GQAgE9UNGEiJ17qiwDm3+3Wl6d0dCVd1XLaX1JUN6LIl jBf/aCA== X-Received: from pghi22.prod.google.com ([2002:a63:e916:0:b0:c99:7baf:126d]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a21:32a2:b0:3bf:a0e5:99a5 with SMTP id adf61e73a8af0-3c0bcea2f0cmr16321169637.47.1783694883588; Fri, 10 Jul 2026 07:48:03 -0700 (PDT) Date: Fri, 10 Jul 2026 07:48:02 -0700 In-Reply-To: <20260710125211.GB2816371@pedri> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260618081355.3253581-1-yilun.xu@linux.intel.com> <20260618081355.3253581-17-yilun.xu@linux.intel.com> <20260710125211.GB2816371@pedri> Message-ID: Subject: Re: [PATCH v2 16/17] KVM: TDX: Add in-kernel Quote generation From: Sean Christopherson To: Peter Fang Cc: Xu Yilun , x86@kernel.org, kvm@vger.kernel.org, linux-coco@lists.linux.dev, linux-kernel@vger.kernel.org, djbw@kernel.org, kas@kernel.org, rick.p.edgecombe@intel.com, yilun.xu@intel.com, xiaoyao.li@intel.com, sohil.mehta@intel.com, adrian.hunter@intel.com, kishen.maloor@intel.com, tony.lindgren@linux.intel.com, baolu.lu@linux.intel.com, zhenzhong.duan@intel.com, dave.hansen@intel.com, dave.hansen@linux.intel.com Content-Type: text/plain; charset="us-ascii" On Fri, Jul 10, 2026, Peter Fang wrote: > On Wed, Jul 08, 2026 at 02:37:55PM -0700, Sean Christopherson wrote: > > On Thu, Jun 18, 2026, Xu Yilun wrote: > > And is keying off tdx_quote_enabled() and only tdx_quote_enabled() backwards > > compatible? How do we know that cutting userspace out of the loop wont' break > > anything? > > Yeah this needs explaining: > > The guest-observable difference between the two paths is that it sees > quotes in different formats (the TDX module uses newer formats of > course). And an old guest must be able to continue using its > TDVMCALL interface for quotes. The guest sends the quote to an > external verifier to authenticate itself. The verifier (part of the > cloud infrastructure) must know how to parse this format. So in other > words, it's the verifier that must maintain backward compatibility if it > wants to continue accepting old quotes. And it needs to be updated to > support newer formats as well. Uh, no, that's not how KVM's guest/host ABI works. Updating the host kernel and breaking existing guest is not acceptable. > > > +{ > > > + gfn_t gfn_start, gfn_end; > > > + u64 end; > > > + > > > + if (!size) > > > + return TDVMCALL_STATUS_INVALID_OPERAND; > > > + > > > + if (!PAGE_ALIGNED(gpa) || !PAGE_ALIGNED(size)) > > > + return TDVMCALL_STATUS_ALIGN_ERROR; > > > + > > > + if (check_add_overflow(gpa, size, &end)) > > > + return TDVMCALL_STATUS_INVALID_OPERAND; > > > + > > > + gfn_start = gpa_to_gfn(gpa); > > > + gfn_end = gpa_to_gfn(end); > > > + > > > + /* > > > + * Reject if the guest didn't explicitly convert its quote pages to > > > + * shared. > > > + */ > > > + if (!kvm_range_has_memory_attributes(vcpu->kvm, gfn_start, gfn_end, > > > + KVM_MEMORY_ATTRIBUTE_PRIVATE, 0)) > > > > TOCTOU? > > I struggled a bit with this actually... I can't just grab > kvm->slots_lock here, and dropping kvm->srcu seems bad because the quote > will be written to guest memory later. I settled on the idea that the > guest should make sure these pages are converted to shared first. If it > tries to convert them back to private after this check, before this > TDVMCALL returns, then it's kind of a self-inflicted race and I don't > see KVM doing any self damage in this case. Not sure if this makes sense > to you? Or maybe I should just drop this check and go straight to > kvm_vcpu_read_guest()? Yes, drop it and rely on uaccess to do the right thing.