Re: [PATCH v7 15/22] KVM: s390: interfaces to clear CRYCB masks

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 30/07/2018 11:24, David Hildenbrand wrote:
On 26.07.2018 21:54, Christian Borntraeger wrote:
From: Tony Krowiak <akrowiak@xxxxxxxxxxxxx>

Introduces two new KVM interface to lear the APM, AQM and ADM masks in
the guest's CRYCB.  The VCPUs are taken out of SIE to ensure the VCPUs do
not get out of synch.
s/synch/sync/

When will this be called and why?

If I read correctly, this can happen while other VCPUs are running
(currently in the SIE). Please note that
kvm_s390_vcpu_block_all/kvm_s390_vcpu_unblock_all will not care about
vSIE. So a CPU inside the vSIE loop will not be hindered of executing
the SIE. (because so far, all VCPU requests we handle don't rely on that)

So it could happen here, that after this call a vSIE CPU still can
access some adapters if we allowed to forward some of them to the nested
guest.

You are right for the principle.

However this function is only called when the mediated device is release
which is, as we do not support hotplug, when the vfio-device is closed
and the guest already disappeared.

So I do not think it is useful the way it is currently used.

What about just letting this call and function fall and take more
time on this problem when we introduce hotplug?

Regards,

Pierre

Signed-off-by: Tony Krowiak <akrowiak@xxxxxxxxxxxxx>
Acked-by: Halil Pasic <pasic@xxxxxxxxxxxxx>
Tested-by: Michael Mueller <mimu@xxxxxxxxxxxxx>
Tested-by: Farhan Ali <alifm@xxxxxxxxxxxxx>
Tested-by: Pierre Morel <pmorel@xxxxxxxxxxxxx>
Signed-off-by: Christian Borntraeger <borntraeger@xxxxxxxxxx>
---
  arch/s390/include/asm/kvm_host.h |  3 +++
  arch/s390/kvm/kvm-s390.c         | 15 +++++++++++++++
  2 files changed, 18 insertions(+)

diff --git a/arch/s390/include/asm/kvm_host.h b/arch/s390/include/asm/kvm_host.h
index d44e0d57e96a..88b8e18356dd 100644
--- a/arch/s390/include/asm/kvm_host.h
+++ b/arch/s390/include/asm/kvm_host.h
@@ -257,6 +257,7 @@ struct kvm_s390_sie_block {
  	__u64	tecmc;			/* 0x00e8 */
  	__u8	reservedf0[12];		/* 0x00f0 */
  #define CRYCB_FORMAT_MASK 0x00000003
+#define CRYCB_FORMAT0 0x00000000
  #define CRYCB_FORMAT1 0x00000001
  #define CRYCB_FORMAT2 0x00000003
  	__u32	crycbd;			/* 0x00fc */
@@ -861,6 +862,8 @@ void kvm_arch_async_page_not_present(struct kvm_vcpu *vcpu,
  void kvm_arch_async_page_present(struct kvm_vcpu *vcpu,
  				 struct kvm_async_pf *work);
+void kvm_arch_crypto_clear_masks(struct kvm *kvm);
+
  extern int sie64a(struct kvm_s390_sie_block *, u64 *);
  extern char sie_exit;
diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
index ef0db58f5ca8..738b090fcf54 100644
--- a/arch/s390/kvm/kvm-s390.c
+++ b/arch/s390/kvm/kvm-s390.c
@@ -1916,6 +1916,21 @@ static void kvm_s390_set_crycb_format(struct kvm *kvm)
  		kvm->arch.crypto.crycbd |= CRYCB_FORMAT1;
  }
+void kvm_arch_crypto_clear_masks(struct kvm *kvm)
+{
+	mutex_lock(&kvm->lock);
+	kvm_s390_vcpu_block_all(kvm);
+
+	memset(&kvm->arch.crypto.crycb->apcb0, 0,
+	       sizeof(kvm->arch.crypto.crycb->apcb0));
+	memset(&kvm->arch.crypto.crycb->apcb1, 0,
+	       sizeof(kvm->arch.crypto.crycb->apcb1));
+
+	kvm_s390_vcpu_unblock_all(kvm);
+	mutex_unlock(&kvm->lock);
+}
+EXPORT_SYMBOL(kvm_arch_crypto_clear_masks);
+
  static u64 kvm_s390_get_initial_cpuid(void)
  {
  	struct cpuid cpuid;



--
Pierre Morel
Linux/KVM/QEMU in Böblingen - Germany




[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux