Re: [PATCH 1/2] KVM: provide irq_unsafe kvm_guest_{enter|exit}

Paolo Bonzini
2015-04-30T11:50:04Z

On 30/04/2015 13:43, Christian Borntraeger wrote:
> +/* must be called with irqs disabled */
> +static inline void __kvm_guest_enter(void)
> {
> - unsigned long flags;
> -
> - BUG_ON(preemptible());

Please keep the BUG_ON() in kvm_guest_enter. Otherwise looks good, thanks!

Paolo

> - local_irq_save(flags);
> guest_enter();
> - local_irq_restore(flags);
> -
> /* KVM does not hold any references to rcu protected data when it
> * switches CPU into a guest mode. In fact switching to a guest mode
> * is very similar to exiting to userspace from rcu point of view. In
> @@ -769,12 +763,27 @@ static inline void kvm_guest_enter(void)
> rcu_virt_note_context_switch(smp_processor_id());
> }
>
> +/* must be called with irqs disabled */
> +static inline void __kvm_guest_exit(void)
> +{
> + guest_exit();
> +}
> +
> +static inline void kvm_guest_enter(void)
> +{
> + unsigned long flags;
> +
> + local_irq_save(flags);
> + __kvm_guest_enter();
> + local_irq_restore(flags);
> +}
> +