Re: [PATCH 6/6] x86/kvm/vmx: Defer TR reload after VM exit

From: Paolo Bonzini
Date: Mon Feb 20 2017 - 12:52:07 EST




On 20/02/2017 17:56, Andy Lutomirski wrote:
> +{
> + DEBUG_LOCKS_WARN_ON(preemptible());
> +
> + if (unlikely(this_cpu_read(need_tr_refresh))) {
> + force_reload_TR();
> + this_cpu_write(need_tr_refresh, false);
> + }
> +}
> +
> +/*
> + * If you do something evil that corrupts the cached TSS limit (I'm looking
> + * at you, VMX exits), call this function.
> + *
> + * The optimization here is that the TSS limit only matters for Linux if the
> + * IO bitmap is in use. If the TSS limit gets forced to its minimum value,
> + * everything works except that IO bitmap will be ignored and all CPL 3 IO
> + * instructions will #GP, which is exactly what we want for normal tasks.
> + */
> +static inline void invalidate_tss_limit(void)
> +{
> + DEBUG_LOCKS_WARN_ON(preemptible());
> +
> + if (unlikely(test_thread_flag(TIF_IO_BITMAP)))
> + refresh_TR();

This must be force_reload_TR, not refresh_TR.

Paolo

> + else
> + this_cpu_write(need_tr_refresh, true);