Re: [PATCH v2 2/8] KVM: x86: Rename interrupt.pending to interrupt.injected

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This makes sense to me, though as we've discussed elsewhere, the
existing uses in x86.h are questionable.

Reviewed-by: Jim Mattson <jmattson@xxxxxxxxxx>

On Tue, Nov 21, 2017 at 7:30 AM, Liran Alon <liran.alon@xxxxxxxxxx> wrote:
> For exceptions & NMIs events, KVM code use the following
> coding convention:
> *) "pending" represents an event that should be injected to guest at
> some point but it's side-effects have not yet occurred.
> *) "injected" represents an event that it's side-effects have already
> occurred.
>
> However, interrupts don't confirm to this coding convention.
> All current code flows mark interrupt.pending when it's side-effects
> have already taken place (For example, bit moved from LAPIC IRR to
> ISR). Therefore, it makes sense to just rename
> interrupt.pending to interrupt.injected.
>
> This change follows logic of previous commit 664f8e26b00c ("KVM: X86:
> Fix loss of exception which has not yet been injected") which changed
> exception to follow this coding convention as well.
>
> Signed-off-by: Liran Alon <liran.alon@xxxxxxxxxx>
> Reviewed-by: Nikita Leshenko <nikita.leshchenko@xxxxxxxxxx>
> Reviewed-by: Krish Sadhukhan <krish.sadhukhan@xxxxxxxxxx>
> Signed-off-by: Krish Sadhukhan <krish.sadhukhan@xxxxxxxxxx>
> ---
>  arch/x86/include/asm/kvm_host.h | 2 +-
>  arch/x86/kvm/irq.c              | 4 ++--
>  arch/x86/kvm/vmx.c              | 2 +-
>  arch/x86/kvm/x86.c              | 8 ++++----
>  arch/x86/kvm/x86.h              | 6 +++---
>  5 files changed, 11 insertions(+), 11 deletions(-)
>
> diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
> index 1bfb99770c34..f8ad3ca11a3a 100644
> --- a/arch/x86/include/asm/kvm_host.h
> +++ b/arch/x86/include/asm/kvm_host.h
> @@ -556,7 +556,7 @@ struct kvm_vcpu_arch {
>         } exception;
>
>         struct kvm_queued_interrupt {
> -               bool pending;
> +               bool injected;
>                 bool soft;
>                 u8 nr;
>         } interrupt;
> diff --git a/arch/x86/kvm/irq.c b/arch/x86/kvm/irq.c
> index 5c24811e8b0b..1f7f37d1c8b9 100644
> --- a/arch/x86/kvm/irq.c
> +++ b/arch/x86/kvm/irq.c
> @@ -74,7 +74,7 @@ static int kvm_cpu_has_extint(struct kvm_vcpu *v)
>  int kvm_cpu_has_injectable_intr(struct kvm_vcpu *v)
>  {
>         if (!lapic_in_kernel(v))
> -               return v->arch.interrupt.pending;
> +               return v->arch.interrupt.injected;
>
>         if (kvm_cpu_has_extint(v))
>                 return 1;
> @@ -92,7 +92,7 @@ int kvm_cpu_has_injectable_intr(struct kvm_vcpu *v)
>  int kvm_cpu_has_interrupt(struct kvm_vcpu *v)
>  {
>         if (!lapic_in_kernel(v))
> -               return v->arch.interrupt.pending;
> +               return v->arch.interrupt.injected;
>
>         if (kvm_cpu_has_extint(v))
>                 return 1;
> diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
> index c8a7bcc1bbd4..d939ed84f136 100644
> --- a/arch/x86/kvm/vmx.c
> +++ b/arch/x86/kvm/vmx.c
> @@ -11007,7 +11007,7 @@ static void vmcs12_save_pending_event(struct kvm_vcpu *vcpu,
>         } else if (vcpu->arch.nmi_injected) {
>                 vmcs12->idt_vectoring_info_field =
>                         INTR_TYPE_NMI_INTR | INTR_INFO_VALID_MASK | NMI_VECTOR;
> -       } else if (vcpu->arch.interrupt.pending) {
> +       } else if (vcpu->arch.interrupt.injected) {
>                 nr = vcpu->arch.interrupt.nr;
>                 idt_vectoring = nr | VECTORING_INFO_VALID_MASK;
>
> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> index c85fc4406a7d..45baba8bc02e 100644
> --- a/arch/x86/kvm/x86.c
> +++ b/arch/x86/kvm/x86.c
> @@ -3111,7 +3111,7 @@ static void kvm_vcpu_ioctl_x86_get_vcpu_events(struct kvm_vcpu *vcpu,
>         events->exception.error_code = vcpu->arch.exception.error_code;
>
>         events->interrupt.injected =
> -               vcpu->arch.interrupt.pending && !vcpu->arch.interrupt.soft;
> +               vcpu->arch.interrupt.injected && !vcpu->arch.interrupt.soft;
>         events->interrupt.nr = vcpu->arch.interrupt.nr;
>         events->interrupt.soft = 0;
>         events->interrupt.shadow = kvm_x86_ops->get_interrupt_shadow(vcpu);
> @@ -3164,7 +3164,7 @@ static int kvm_vcpu_ioctl_x86_set_vcpu_events(struct kvm_vcpu *vcpu,
>         vcpu->arch.exception.has_error_code = events->exception.has_error_code;
>         vcpu->arch.exception.error_code = events->exception.error_code;
>
> -       vcpu->arch.interrupt.pending = events->interrupt.injected;
> +       vcpu->arch.interrupt.injected = events->interrupt.injected;
>         vcpu->arch.interrupt.nr = events->interrupt.nr;
>         vcpu->arch.interrupt.soft = events->interrupt.soft;
>         if (events->flags & KVM_VCPUEVENT_VALID_SHADOW)
> @@ -6406,7 +6406,7 @@ static int inject_pending_event(struct kvm_vcpu *vcpu, bool req_int_win)
>                         return 0;
>                 }
>
> -               if (vcpu->arch.interrupt.pending) {
> +               if (vcpu->arch.interrupt.injected) {
>                         kvm_x86_ops->set_irq(vcpu);
>                         return 0;
>                 }
> @@ -7413,7 +7413,7 @@ int kvm_arch_vcpu_ioctl_get_sregs(struct kvm_vcpu *vcpu,
>
>         memset(sregs->interrupt_bitmap, 0, sizeof sregs->interrupt_bitmap);
>
> -       if (vcpu->arch.interrupt.pending && !vcpu->arch.interrupt.soft)
> +       if (vcpu->arch.interrupt.injected && !vcpu->arch.interrupt.soft)
>                 set_bit(vcpu->arch.interrupt.nr,
>                         (unsigned long *)sregs->interrupt_bitmap);
>
> diff --git a/arch/x86/kvm/x86.h b/arch/x86/kvm/x86.h
> index 6d112d8f799c..4eab2bae5937 100644
> --- a/arch/x86/kvm/x86.h
> +++ b/arch/x86/kvm/x86.h
> @@ -19,19 +19,19 @@ static inline void kvm_clear_exception_queue(struct kvm_vcpu *vcpu)
>  static inline void kvm_queue_interrupt(struct kvm_vcpu *vcpu, u8 vector,
>         bool soft)
>  {
> -       vcpu->arch.interrupt.pending = true;
> +       vcpu->arch.interrupt.injected = true;
>         vcpu->arch.interrupt.soft = soft;
>         vcpu->arch.interrupt.nr = vector;
>  }
>
>  static inline void kvm_clear_interrupt_queue(struct kvm_vcpu *vcpu)
>  {
> -       vcpu->arch.interrupt.pending = false;
> +       vcpu->arch.interrupt.injected = false;
>  }
>
>  static inline bool kvm_event_needs_reinjection(struct kvm_vcpu *vcpu)
>  {
> -       return vcpu->arch.exception.injected || vcpu->arch.interrupt.pending ||
> +       return vcpu->arch.exception.injected || vcpu->arch.interrupt.injected ||
>                 vcpu->arch.nmi_injected;
>  }
>
> --
> 1.9.1
>



[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux