Re: [PATCH 4/6] x86/entry: Optimize local_db_save() for virt

From: Sean Christopherson
Date: Fri May 29 2020 - 13:35:00 EST


On Thu, May 28, 2020 at 10:19:41PM +0200, Peter Zijlstra wrote:
> static int arch_bp_generic_len(int x86_len)
> --- a/arch/x86/kvm/vmx/nested.c
> +++ b/arch/x86/kvm/vmx/nested.c
> @@ -3027,6 +3027,8 @@ static int nested_vmx_check_vmentry_hw(s
>
> /*
> * VMExit clears RFLAGS.IF and DR7, even on a consistency check.
> + * XXX how is this not broken? access to cpu_dr7 ought to be with
> + * IRQs disabled.

Ah, it's simply broken. This code is conditional on a module param that's
off by default, i.e. it's not run widely, and odds are intersection with
debugging is rare.

Moving local_irq_enable() below the DR7 restoration is not an issue.

Maybe also add lockdep_assert_irqs_disabled() to hw_breakpoint_restore() or
hw_breakpoint_active()?

> */
> local_irq_enable();
> if (hw_breakpoint_active())
>
>