19.06.2021 00:07, Jim Mattson пишет:
I believe DS is illegal. Per the SDM, Checks on Guest Segment Registers:
OK, so this indeed have solved the biggest part of the problem, thanks again. Now back to the original problem, where I was getting a page fault on some CPUs sometimes. I digged a bit more. It seems I am getting a race of this kind: exception in guest happens at the same time when the host's SIGALRM arrives. KVM returns to host with the exception somehow "pending", but its still on ring3, not switched to the ring0 handler. Then from host I inject the interrupt (which is what SIGALRM asks for), and when I enter the guest, it throws the pending exception instead of executing the interrupt handler. I suspect the bug is again on my side, but I am not sure how to handle that kind of race. I suppose I need to look at some interruptibility state to find out that the interrupt cannot be injected at that time. But I can't find if KVM exports the interruptibility state, other than guest's IF/VIF flag, which is not enough in this case. Also I am a bit puzzled why I can't see such race on an I7 CPU even after disabling the unrestricted_guest. Any ideas? :)