Re: [PATCH 3/3] s390/vfio-ap: r/w lock for PQAP interception handler function pointer

Jason Gunthorpe
2021-06-11T17:06:14Z

On Wed, Jun 09, 2021 at 06:46:34PM -0400, Tony Krowiak wrote:
> The function pointer to the interception handler for the PQAP instruction
> can get changed during the interception process. Let's add a
> semaphore to struct kvm_s390_crypto to control read/write access to the
> function pointer contained therein.
>
> The semaphore must be locked for write access by the vfio_ap device driver
> when notified that the KVM pointer has been set or cleared. It must be
> locked for read access by the interception framework when the PQAP
> instruction is intercepted.
>
> Signed-off-by: Tony Krowiak <akrowiak@linux.ibm.com>
> ---
> arch/s390/include/asm/kvm_host.h | 6 +++---
> arch/s390/kvm/kvm-s390.c | 1 +
> arch/s390/kvm/priv.c | 6 +++---
> drivers/s390/crypto/vfio_ap_ops.c | 14 ++++++++++----
> drivers/s390/crypto/vfio_ap_private.h | 2 +-
> 5 files changed, 18 insertions(+), 11 deletions(-)

This is alot better than the try_module_get!

Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>

Jason