On 28.05.26 17:50, Jürgen Groß wrote: > On 28.05.26 15:21, Sean Christopherson wrote: >> On Thu, May 28, 2026, Jürgen Groß wrote: >>> On 28.05.26 15:09, Sean Christopherson wrote: >>>> On Thu, May 28, 2026, Juergen Gross wrote: >>>>> Please disregard this series, there is one complication sashiko made me >>>>> aware of. >>>> >>>> Sashiko beat me to the punch. :-) >>>> >>>> See commit 2368048bf5c2 ("KVM: x86: Signal #GP, not -EPERM, on bad >>>> WRMSR(MCi_CTL/STATUS)") >>>> for a real world example of how things can and will go wrong. >>> >>> Yeah, with Sashiko's pointer it was easy to spot. >>> >>> Question now is whether the already existing cases of -errno passed as return >>> value are wrong or on purpose. >> >> What are the existing cases? >> >>> If the latter, there should be a comment for >>> that, otherwise they need to be fixed.. >>> >>> Disentangling the MSR emulation return values from the "normal" ones ("return >>> to guest"/"return to user mode") will be quite interesting with the overloaded >>> semantics of "1". >> >> LOL, "interesting". > > What do you think about the following idea: > > Lets pass struct msr_info * down to all functions which get their return > value passed up. Then extend msr_info with a bool "return_to_guest" (valid > only if !host_initiated), which should be set instead of passing "1" up to > the caller (probably using an inline helper). Then the return value could > be 0 or -errno, and after MSR emulation the return_to_guest indicator can > be tested if needed. In the end I think it is less error prone to define a struct kvm_msr_ret_t used as return type, consisting of an int and a bool with the same semantics as above. Helpers will still be a good idea IMHO. I'll have a try how it looks like. Juergen