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: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAAhSdy3H8LaDHJq6H0rFirsWhC8tnE+bWwmWFtO8Eag-kcXcSA@mail.gmail.com>
Date: Tue, 13 May 2025 16:48:02 +0530
From: Anup Patel <anup@...infault.org>
To: Maxim Levitsky <mlevitsk@...hat.com>
Cc: kvm@...r.kernel.org, Suzuki K Poulose <suzuki.poulose@....com>, 
	Jing Zhang <jingzhangos@...gle.com>, "H. Peter Anvin" <hpa@...or.com>, 
	Sebastian Ott <sebott@...hat.com>, Shusen Li <lishusen2@...wei.com>, 
	Waiman Long <longman@...hat.com>, Thomas Gleixner <tglx@...utronix.de>, 
	linux-arm-kernel@...ts.infradead.org, Bjorn Helgaas <bhelgaas@...gle.com>, 
	Borislav Petkov <bp@...en8.de>, Will Deacon <will@...nel.org>, Palmer Dabbelt <palmer@...belt.com>, 
	Alexander Potapenko <glider@...gle.com>, kvmarm@...ts.linux.dev, 
	Keisuke Nishimura <keisuke.nishimura@...ia.fr>, Zenghui Yu <yuzenghui@...wei.com>, 
	Peter Zijlstra <peterz@...radead.org>, Atish Patra <atishp@...shpatra.org>, 
	Joey Gouly <joey.gouly@....com>, x86@...nel.org, Marc Zyngier <maz@...nel.org>, 
	Sean Christopherson <seanjc@...gle.com>, Andre Przywara <andre.przywara@....com>, 
	Kunkun Jiang <jiangkunkun@...wei.com>, linux-riscv@...ts.infradead.org, 
	Randy Dunlap <rdunlap@...radead.org>, Paolo Bonzini <pbonzini@...hat.com>, 
	Boqun Feng <boqun.feng@...il.com>, Catalin Marinas <catalin.marinas@....com>, 
	Alexandre Ghiti <alex@...ti.fr>, linux-kernel@...r.kernel.org, 
	Dave Hansen <dave.hansen@...ux.intel.com>, Oliver Upton <oliver.upton@...ux.dev>, 
	kvm-riscv@...ts.infradead.org, Ingo Molnar <mingo@...hat.com>, 
	Paul Walmsley <paul.walmsley@...ive.com>, Albert Ou <aou@...s.berkeley.edu>
Subject: Re: [PATCH v5 6/6] RISC-V: KVM: use kvm_trylock_all_vcpus when
 locking all vCPUs

On Mon, May 12, 2025 at 11:35 PM Maxim Levitsky <mlevitsk@...hat.com> wrote:
>
> Use kvm_trylock_all_vcpus instead of a custom implementation when locking
> all vCPUs of a VM.
>
> Compile tested only.
>
> Suggested-by: Paolo Bonzini <pbonzini@...hat.com>
> Signed-off-by: Maxim Levitsky <mlevitsk@...hat.com>

For KVM RISC-V:
Tested-by: Anup Patel <anup@...infault.org>
Reviewed-by: Anup Patel <anup@...infault.org>

Regards,
Anup

> ---
>  arch/riscv/kvm/aia_device.c | 34 ++--------------------------------
>  1 file changed, 2 insertions(+), 32 deletions(-)
>
> diff --git a/arch/riscv/kvm/aia_device.c b/arch/riscv/kvm/aia_device.c
> index 39cd26af5a69..6315821f0d69 100644
> --- a/arch/riscv/kvm/aia_device.c
> +++ b/arch/riscv/kvm/aia_device.c
> @@ -12,36 +12,6 @@
>  #include <linux/kvm_host.h>
>  #include <linux/uaccess.h>
>
> -static void unlock_vcpus(struct kvm *kvm, int vcpu_lock_idx)
> -{
> -       struct kvm_vcpu *tmp_vcpu;
> -
> -       for (; vcpu_lock_idx >= 0; vcpu_lock_idx--) {
> -               tmp_vcpu = kvm_get_vcpu(kvm, vcpu_lock_idx);
> -               mutex_unlock(&tmp_vcpu->mutex);
> -       }
> -}
> -
> -static void unlock_all_vcpus(struct kvm *kvm)
> -{
> -       unlock_vcpus(kvm, atomic_read(&kvm->online_vcpus) - 1);
> -}
> -
> -static bool lock_all_vcpus(struct kvm *kvm)
> -{
> -       struct kvm_vcpu *tmp_vcpu;
> -       unsigned long c;
> -
> -       kvm_for_each_vcpu(c, tmp_vcpu, kvm) {
> -               if (!mutex_trylock(&tmp_vcpu->mutex)) {
> -                       unlock_vcpus(kvm, c - 1);
> -                       return false;
> -               }
> -       }
> -
> -       return true;
> -}
> -
>  static int aia_create(struct kvm_device *dev, u32 type)
>  {
>         int ret;
> @@ -53,7 +23,7 @@ static int aia_create(struct kvm_device *dev, u32 type)
>                 return -EEXIST;
>
>         ret = -EBUSY;
> -       if (!lock_all_vcpus(kvm))
> +       if (kvm_trylock_all_vcpus(kvm))
>                 return ret;
>
>         kvm_for_each_vcpu(i, vcpu, kvm) {
> @@ -65,7 +35,7 @@ static int aia_create(struct kvm_device *dev, u32 type)
>         kvm->arch.aia.in_kernel = true;
>
>  out_unlock:
> -       unlock_all_vcpus(kvm);
> +       kvm_unlock_all_vcpus(kvm);
>         return ret;
>  }
>
> --
> 2.46.0
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ