On Thu, 2025-06-26 at 09:59 -0700, Dave Hansen wrote: > On 6/26/25 08:51, Sean Christopherson wrote: > > No, I was thinking: > > > > if (IS_TDX_ERR_OPERAND_BUSY(err)) > > > > e.g. to so that it looks like IS_ERR(), which is a familiar pattern. > > That would be a more more compelling if IS_ERR() worked on integers. It > works on pointers, so I'm not sure it's a pattern we want to apply to > integers here. > > I kind of hate all of this. I'd kinda prefer that we just shove the TDX > error codes as far up into the helpers as possible rather than making > them easier to deal with in random code. Hi, Picking this up from Kirill. At a high level Dave seems to want to encapsulate the TDX error code stuff more, and Sean wants something more lightweight. This seems to be partly a style difference between arch/x86 and KVM, but also a tension between how much TDX interface to wrap (i.e. the SEAMCALL wrapper layer). But at a code level, the helpers have basically identical logic. The difference between IS_TDX_ERR_OPERAND_BUSY() and tdx_operand_busy() seems more about whether they look more raw. Since KVM side has many more users of error code parsing, I'll lean towards Sean's preference of the all caps macro-like signature. Since Dave points out IS_ERR() operates on pointers, I'll go with something else. TDX docs call these "Completion Status Codes", so maybe: STATUS_OPERAND_BUSY()? As far as leaking TDX bits out of the SEAMCALL wrappers. I did consider trying to convert the error codes into errno codes at the wrapper level, which arch/x86 side already does internally. I think we could mostly do that for the wrappers that KVM uses, but there would be few cases (VCPU_NOT_ASSOCIATED) where you would have to look at the code to see which errno matches to which TDX concept. The other problem with translating it to errno would be that we print out the TDX error codes in a lot of warning cases (KVM_BUG_ON(), etc). We already went through this somewhat with the TDX extended error codes. The bits of the normal error code could be very useful for debugging too, and only the KVM callers knows whether to print them out or not. So we would need to return the TDX format error code anyway, and at that point the TDX->errno conversion would seem like superfluous complexity. So STATUS_OPERAND_BUSY() seems like an ok thing to try next for v3 of this series at least. Unless anyone has any strong objections ahead of time. Thanks, Rick