kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: [PATCH] kvm/x86 : Remove redundant pic_in_kernel
       [not found] <HKAPR02MB42914E8F73424BCF815DAC6CE0A10@HKAPR02MB4291.apcprd02.prod.outlook.com>
@ 2020-05-11 13:50 ` Paolo Bonzini
  0 siblings, 0 replies; only message in thread
From: Paolo Bonzini @ 2020-05-11 13:50 UTC (permalink / raw)
  To: 彭浩(Richard); +Cc: kvm, linux-kernel

On 11/05/20 13:21, 彭浩(Richard) wrote:
> pic_in_kernel() and irqchip_kernel() have the same implementation.
> 
> Signed-off-by: Peng Hao <richard.peng@oppo.com>

Thanks for the patch, this is interesting!  And there is also
ioapic_in_kernel.  However, the three functions are used in different
cases, for example ioapic_in_kernel before accessing kvm->arch.vioapic.
 So the right thing to do would be to keep the functions, but change
them to just return irqchip_kernel(kvm).

Paolo

> ---
>  arch/x86/kvm/irq.h | 9 ---------
>  arch/x86/kvm/x86.c | 6 +++---
>  2 files changed, 3 insertions(+), 12 deletions(-)
> 
> diff --git a/arch/x86/kvm/irq.h b/arch/x86/kvm/irq.h
> index f173ab6..3ad07ca 100644
> --- a/arch/x86/kvm/irq.h
> +++ b/arch/x86/kvm/irq.h
> @@ -66,15 +66,6 @@ void kvm_pic_destroy(struct kvm *kvm);
>  int kvm_pic_read_irq(struct kvm *kvm);
>  void kvm_pic_update_irq(struct kvm_pic *s);
> 
> -static inline int pic_in_kernel(struct kvm *kvm)
> -{
> -int mode = kvm->arch.irqchip_mode;
> -
> -/* Matches smp_wmb() when setting irqchip_mode */
> -smp_rmb();
> -return mode == KVM_IRQCHIP_KERNEL;
> -}
> -
>  static inline int irqchip_split(struct kvm *kvm)
>  {
>  int mode = kvm->arch.irqchip_mode;
> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> index d786c7d..559053f 100644
> --- a/arch/x86/kvm/x86.c
> +++ b/arch/x86/kvm/x86.c
> @@ -3710,7 +3710,7 @@ static int kvm_vcpu_ioctl_interrupt(struct kvm_vcpu *vcpu,
>   * With in-kernel LAPIC, we only use this to inject EXTINT, so
>   * fail for in-kernel 8259.
>   */
> -if (pic_in_kernel(vcpu->kvm))
> +if (irqchip_kernel(vcpu->kvm))
>  return -ENXIO;
> 
>  if (vcpu->arch.pending_external_vector != -1)
> @@ -7622,7 +7622,7 @@ static int emulator_fix_hypercall(struct x86_emulate_ctxt *ctxt)
>  static int dm_request_for_irq_injection(struct kvm_vcpu *vcpu)
>  {
>  return vcpu->run->request_interrupt_window &&
> -likely(!pic_in_kernel(vcpu->kvm));
> +likely(!irqchip_kernel(vcpu->kvm));
>  }
> 
>  static void post_kvm_run_save(struct kvm_vcpu *vcpu)
> @@ -7634,7 +7634,7 @@ static void post_kvm_run_save(struct kvm_vcpu *vcpu)
>  kvm_run->cr8 = kvm_get_cr8(vcpu);
>  kvm_run->apic_base = kvm_get_apic_base(vcpu);
>  kvm_run->ready_for_interrupt_injection =
> -pic_in_kernel(vcpu->kvm) ||
> +irqchip_kernel(vcpu->kvm) ||
>  kvm_vcpu_ready_for_interrupt_injection(vcpu);
>  }
> 
> --
> 2.7.4


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-05-11 13:50 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <HKAPR02MB42914E8F73424BCF815DAC6CE0A10@HKAPR02MB4291.apcprd02.prod.outlook.com>
2020-05-11 13:50 ` [PATCH] kvm/x86 : Remove redundant pic_in_kernel Paolo Bonzini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).