lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <65b8f660-1d78-10f5-fe61-54de94cd5017@redhat.com>
Date:   Mon, 11 May 2020 15:50:26 +0200
From:   Paolo Bonzini <pbonzini@...hat.com>
To:     彭浩(Richard) <richard.peng@...o.com>
Cc:     "kvm@...r.kernel.org" <kvm@...r.kernel.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] kvm/x86 : Remove redundant pic_in_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@...o.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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ