[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20210523225746.GF1002214@nvidia.com>
Date: Sun, 23 May 2021 19:57:46 -0300
From: Jason Gunthorpe <jgg@...dia.com>
To: Tony Krowiak <akrowiak@...ux.ibm.com>
Cc: linux-s390@...r.kernel.org, linux-kernel@...r.kernel.org,
borntraeger@...ibm.com, cohuck@...hat.com,
pasic@...ux.vnet.ibm.com, jjherne@...ux.ibm.com,
alex.williamson@...hat.com, kwankhede@...dia.com,
frankja@...ux.ibm.com, david@...hat.com, imbrenda@...ux.ibm.com,
hca@...ux.ibm.com
Subject: Re: [PATCH v4 2/2] s390/vfio-ap: control access to PQAP(AQIC)
interception handler
On Fri, May 21, 2021 at 03:36:48PM -0400, Tony Krowiak wrote:
> +static struct kvm_s390_crypto_hook
> +*kvm_arch_crypto_find_hook(enum kvm_s390_crypto_hook_type type)
> +{
> + struct kvm_s390_crypto_hook *crypto_hook;
> +
> + list_for_each_entry(crypto_hook, &crypto_hooks, node) {
> + if (crypto_hook->type == type)
> + return crypto_hook;
> + }
> +
> + return NULL;
> +}
> +
> +int kvm_arch_crypto_register_hook(struct kvm_s390_crypto_hook *hook)
> +{
> + struct kvm_s390_crypto_hook *crypto_hook;
> +
> + mutex_lock(&crypto_hooks_lock);
> + crypto_hook = kvm_arch_crypto_find_hook(hook->type);
> + if (crypto_hook) {
> + if (crypto_hook->owner != hook->owner)
> + return -EACCES;
> + list_replace(&crypto_hook->node, &hook->node);
This is all dead code right? This is only called from a module init
function so it can't be called twice. Just always fail if the hook is
already used and delete the owner stuff.
But this is alot of complicated and unused code to solve a lock
ordering problem..
Jason
Powered by blists - more mailing lists