+ write_fault = kvm_is_write_fault(vcpu);
+ exec_fault = kvm_vcpu_trap_is_exec_fault(vcpu);
+
+ if (write_fault && exec_fault) {
+ kvm_err("Simultaneous write and execution fault\n");
+ return -EFAULT;
+ }
+
+ if (is_perm && !write_fault && !exec_fault) {
+ kvm_err("Unexpected L2 read permission error\n");
+ return -EFAULT;
+ }
I think, ideally, these above checks should be put into a separate
function and shared with user_mem_abort(). (The VM_BUG_ON(write_fault
&& exec_fault) that user_mem_abort() does seems fine to me, I don't see a
real need to change it to -EFAULT.)
I would like to do that, however, I didn't want to change
user_mem_abort(), and regarding the VM_BUG_ON, see David's feedback to
V10:
https://lore.kernel.org/all/ed1928ce-fc6f-4aaa-9f54-126a8af12240@xxxxxxxxxx/
Worth reading Linus' reply in [1], that contains a bit more history on
BUG_ON() and how it should not be used. (VM_BUG_ON we'll now likely get
rid of completely)
[1] https://lkml.kernel.org/r/20250604140544.688711-1-david@xxxxxxxxxx
--
Cheers,
David / dhildenb