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>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <82c4d5da-2a28-558c-5e17-d837005b8d76@redhat.com>
Date:   Thu, 21 Jan 2021 21:17:31 +0100
From:   Paolo Bonzini <pbonzini@...hat.com>
To:     Sean Christopherson <seanjc@...gle.com>,
        Ben Gardon <bgardon@...gle.com>,
        Marc Zyngier <Marc.Zyngier@....com>,
        Will Deacon <will@...nel.org>,
        Paul Mackerras <paulus@...abs.org>
Cc:     linux-kernel@...r.kernel.org, kvm@...r.kernel.org,
        Peter Xu <peterx@...hat.com>, Peter Shier <pshier@...gle.com>,
        Peter Feiner <pfeiner@...gle.com>,
        Junaid Shahid <junaids@...gle.com>,
        Jim Mattson <jmattson@...gle.com>,
        Yulei Zhang <yulei.kernel@...il.com>,
        Wanpeng Li <kernellwp@...il.com>,
        Vitaly Kuznetsov <vkuznets@...hat.com>
Subject: Re: [PATCH 15/24] kvm: mmu: Wrap mmu_lock cond_resched and needbreak

On 21/01/21 01:19, Sean Christopherson wrote:
> IMO, moving the lock to arch-specific code is bad for KVM. The 
> architectures' MMUs already diverge pretty horribly, and once things 
> diverge it's really hard to go the other direction. And this change, 
> along with all of the wrappers, thrash a lot of code and add a fair 
> amount of indirection without any real benefit to the other 
> architectures. What if we simply make the common mmu_lock a union? The 
> rwlock_t is probably a bit bigger, but that's a few bytes for an entire 
> VM. And maybe this would entice/inspire other architectures to move to a 
> similar MMU model.
I agree.  Most architectures don't do the lockless tricks that x86 do, 
and being able to lock for read would be better than nothing.  For 
example, I took a look at ARM and stage2_update_leaf_attrs could be 
changed to operate in cmpxchg-like style while holding the rwlock for read.

Paolo

> 
> diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
> index f3b1013fb22c..bbc8efd4af62 100644
> --- a/include/linux/kvm_host.h
> +++ b/include/linux/kvm_host.h
> @@ -451,7 +451,10 @@ struct kvm_memslots {
>  };
> 
>  struct kvm {
> -       spinlock_t mmu_lock;
> +       union {
> +               rwlock_t mmu_rwlock;
> +               spinlock_t mmu_lock;
> +       };
>         struct mutex slots_lock;
>         struct mm_struct *mm; /* userspace tied to this vm */
>         struct kvm_memslots __rcu *memslots[KVM_ADDRESS_SPACE_NUM];

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ