From: Paolo Bonzini Date: Thu, 2 Nov 2023 12:01:41 +0100 Subject: [PATCH v13 09/35] KVM: Add KVM_EXIT_MEMORY_FAULT exit to report faults to userspace In-Reply-To: References: <20231027182217.3615211-1-seanjc@google.com> <20231027182217.3615211-10-seanjc@google.com> <482bfea6f54ea1bb7d1ad75e03541d0ba0e5be6f.camel@intel.com> Message-ID: List-Id: To: kvm-riscv@lists.infradead.org MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit On 11/1/23 18:36, Sean Christopherson wrote: > A good example is KVM_RUN with -EINTR; if KVM were to return something other than > -EINTR on a pending signal or vcpu->run->immediate_exit, userspace would fall over. And dually if KVM were to return KVM_EXIT_INTR together with something other than -EINTR. > And purging exit_reason super early is subtly tricky because KVM's > (again, poorly documented) ABI is that *some* exit reasons are preserved > across KVM_RUN with vcpu->run->immediate_exit (or with a pending > signal). https://lore.kernel.org/all/ZFFbwOXZ5uI%2Fgdaf at google.com vcpu->run->immediate_exit preserves all exit reasons, but it's not a good idea that immediate_exit behaves different from a pending signal on entry to KVM_RUN (remember that immediate_exit was meant to be a better performing alternative to KVM_SET_SIGNAL_MASK). In principle, vcpu->run->immediate_exit could return KVM_EXIT_INTR (perhaps even _should_, except that breaks selftests so at this point it is ABI). Paolo