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 9F5681B4231 for ; Wed, 25 Jun 2025 21:27:23 +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=1750886845; cv=none; b=iQQ0RUw6rdXZeY3DMkU93tWDmFUtOVDO+SwODnAKsbspOq/A0c4Mgos6NRsusJBmpVHXUZkS0/gTvmhOQw6wg8phqW/SLtguZXMytXK4KnO3OMMy3J136xLyutb9u2/oh49IiKY4xPXQjL2IjC/plnpN6e4PwnDXEDdv6Nbg/QM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750886845; c=relaxed/simple; bh=5/AIDMzcp9aAn9GVVD2wKIiPIrXAOBeyMNI9k6+uBv8=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=GMWWV6LLF7/cVS2Hkt7gVwBPQShZnrUd3H0617ahH5+dnjkfrexREBBUVCTUyNuEYqxXaQotym5H3ZL+FLTkAG5iiMXFR3wXLoUUn1Ls+9frRvfARgx076lNRxqPzrfDv8kuYAepWT13yF6mKcsLOXzcHvF3Tw4CsfBu5WKO0DI= 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=0dIQQcEk; 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="0dIQQcEk" Received: by mail-pg1-f201.google.com with SMTP id 41be03b00d2f7-b31ff607527so215129a12.0 for ; Wed, 25 Jun 2025 14:27:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1750886843; x=1751491643; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:from:to:cc:subject:date:message-id :reply-to; bh=KDkUH/8hPd96nHKcCj5ct66aFf82AL3mnAQ30uxk9O8=; b=0dIQQcEkGzL0OK3+cvDkHl9CLorXFtyko7Y8nVVUS/Jt5isX5qz7F0UEHT5LWZfglY Y4Ck02d4WAMJ7kYxxX22yKj+IvnUOD9JsWqrYLZPfMX3G56Agj0nmNebwWah1+ch3kmU SnACsnf5VC3eaghI/9QbNGszQiyQKq/OS/8s851Ik922GUrDODtIuE+Dxbq4R7oB2VYS 9hvS6pRL9JnapON8va4ueR4EGQMbW/j+LrryuaYng+cQaMZFv4sD2W4euCfcbNu+PKuN gU7+fyZEm8LR9tTYqJPNkUVTrO8ITh2kqj5L72JcBIW2J68bkcJnGjdVm59apz456OY8 jKhQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1750886843; x=1751491643; h=content-transfer-encoding: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=KDkUH/8hPd96nHKcCj5ct66aFf82AL3mnAQ30uxk9O8=; b=qn6MMHHS9/l9KcEvgqK5ycgwQmCG3obwwI55vThLAmtlHYc4On1Ck87bg7en7t0bdC M+6OvlBWeH5J/MyHQBc4OImk6HWbU4qampgDTr6R79bzqkW45wSk39eRFyGoXBnfZf8c v8D4IcI46OnApA2QkWU28e/TId7zJrRJyvOdakdzHbeZr0V3ZAxgxUrmEd4WAGLSZGcv jlLi7qFKQ1OKqA1sbaDiG5jzuElBiCKW7o8XYEg1fPYvJGyK1CiQz0t0jlGCfP58iIDO 4kXYph694Cvm7i6dg/UzBtapAF83vxd7YkbhPhuFAzDmLft2WY2jA1l0gs3vL66LQWFp jnRA== X-Forwarded-Encrypted: i=1; AJvYcCXMsA5pp5CRArOer9k6kqxNNNoT1OiTC/IP9oyDlktdNYVLlScdHXzEHxhMIEraIOhZxqtGowEm2//1JS4=@vger.kernel.org X-Gm-Message-State: AOJu0Yw4dkRKti81j9wJLLq39Eu4xBU8daLoeIsqKc/fkP+FlPFf3s89 lTakZ0Uy1BYqK0gVY0iGhUL+E8dgaQdH9Y7kBeHaC+MzgVeW+mmf/owFOooYOAnG1oZmdKQ7g5R Zs1ZRkw== X-Google-Smtp-Source: AGHT+IHnNSiQClR98Tu2DIjJN0yUuPOY+tZ7wsPVNu+SogPTpvB/xoqOJtGyrrKUyaCs7hclUXM8so0Z7ms= X-Received: from pjboi14.prod.google.com ([2002:a17:90b:3a0e:b0:2ff:6132:8710]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a17:903:1aab:b0:235:eefe:68ec with SMTP id d9443c01a7336-23823fe1d8dmr78782915ad.19.1750886843038; Wed, 25 Jun 2025 14:27:23 -0700 (PDT) Date: Wed, 25 Jun 2025 14:27:21 -0700 In-Reply-To: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20250609191340.2051741-1-kirill.shutemov@linux.intel.com> <20250609191340.2051741-2-kirill.shutemov@linux.intel.com> <5cfb2e09-7ecb-4144-9122-c11152b18b5e@intel.com> Message-ID: Subject: Re: [PATCHv2 01/12] x86/tdx: Consolidate TDX error handling From: Sean Christopherson To: Rick P Edgecombe Cc: "kirill.shutemov@linux.intel.com" , "pbonzini@redhat.com" , Dave Hansen , "dave.hansen@linux.intel.com" , Chao Gao , "bp@alien8.de" , Kai Huang , "x86@kernel.org" , "mingo@redhat.com" , Yan Y Zhao , "tglx@linutronix.de" , "kvm@vger.kernel.org" , "linux-coco@lists.linux.dev" , Isaku Yamahata , "linux-kernel@vger.kernel.org" Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable On Wed, Jun 25, 2025, Rick P Edgecombe wrote: > On Wed, 2025-06-25 at 10:58 -0700, Dave Hansen wrote: > > > --- a/arch/x86/kvm/vmx/tdx.c > > > +++ b/arch/x86/kvm/vmx/tdx.c > > > @@ -202,12 +202,6 @@ static DEFINE_MUTEX(tdx_lock); > > > =C2=A0=20 > > > =C2=A0 static atomic_t nr_configured_hkid; > > > =C2=A0=20 > > > -static bool tdx_operand_busy(u64 err) > > > -{ > > > - return (err & TDX_SEAMCALL_STATUS_MASK) =3D=3D TDX_OPERAND_BUSY; > > > -} > > > - > > > - > >=20 > > Isaku, this one was yours (along with the whitespace damage). What do > > you think of this patch? >=20 > I think this actually got added by Paolo, suggested by Binbin. I like the= se > added helpers a lot. KVM code is often open coded for bitwise stuff, but = since > Paolo added tdx_operand_busy(), I like the idea of following the pattern = more > broadly. I'm on the fence about tdx_status() though. Can we turn them into macros that make it super obvious they are checking i= f the error code *is* xyz? E.g. #define IS_TDX_ERR_OPERAND_BUSY #define IS_TDX_ERR_OPERAND_INVALID #define IS_TDX_ERR_NO_ENTROPY #define IS_TDX_ERR_SW_ERROR As is, it's not at all clear that things like tdx_success() are simply chec= ks, as opposed to commands.