mirror of
https://github.com/xen-project/xen.git
synced 2026-10-28 18:21:39 +01:00
Under certain conditions guests can get the CPU stuck in an unbounded loop without the possibility of an interrupt window to occur on instruction boundary. This was the case with the scenarios described in XSA-156. Make use of the Notify VM Exit mechanism, that will trigger a VM Exit if no interrupt window occurs for a specified amount of time. Note that using the Notify VM Exit avoids having to trap #AC and #DB exceptions, as Xen is guaranteed to get a VM Exit even if the guest puts the CPU in a loop without an interrupt window, as such disable the intercepts if the feature is available and enabled. Setting the notify VM exit window to 0 is safe because there's a threshold added by the hardware in order to have a sane window value. Note the handling of EXIT_REASON_NOTIFY in the nested virtualization case is passed to L0, and hence a nested guest being able to trigger a notify VM exit with an invalid context would be able to crash the L1 hypervisor (by L0 destroying the domain). Since we don't expose VM Notify support to L1 it should already enable the required protections in order to prevent VM Notify from triggering in the first place. Suggested-by: Andrew Cooper <andrew.cooper3@citrix.com> Signed-off-by: Roger Pau Monné <roger.pau@citrix.com> Reviewed-by: Kevin Tian <kevin.tian@intel.com> x86/vmx: Partially revert "x86/vmx: implement Notify VM Exit" The original patch tried to do two things - implement VMNotify, and re-optimise VT-x to not intercept #DB/#AC by default. The second part is buggy in multiple ways. Both GDBSX and Introspection need to conditionally intercept #DB, which was not accounted for. Also, #DB interception has nothing at all to do with cpu_has_monitor_trap_flag. Revert the second half, leaving #DB/#AC intercepted unilaterally, but with VMNotify active by default when available. Fixes:573279cde1("x86/vmx: implement Notify VM Exit") Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com> Reviewed-by: Kevin Tian <kevin.tian@intel.com> master commit:573279cde1master date: 2022-12-19 11:24:14 +0100 master commit:5f08bc9404master date: 2023-01-20 19:39:32 +0000