linux-s390.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [GIT PULL 0/4] KVM: s390: Fixes for 6.0 take 2
@ 2022-09-23 12:04 Janosch Frank
  2022-09-23 12:04 ` [GIT PULL 1/4] KVM: s390: pci: fix plain integer as NULL pointer warnings Janosch Frank
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Janosch Frank @ 2022-09-23 12:04 UTC (permalink / raw)
  To: pbonzini; +Cc: kvm, frankja, david, borntraeger, cohuck, linux-s390, imbrenda

Paolo,

vfio-pci has kept us busy for a bit so here are three additional pci fixes.
Additionally there's a smatch fix by Janis.

It might be a bit late for rc7 but we wanted to have the coverage.
Enjoy the weekend!

The following changes since commit 521a547ced6477c54b4b0cc206000406c221b4d6:

  Linux 6.0-rc6 (2022-09-18 13:44:14 -0700)

are available in the Git repository at:

  https://git.kernel.org/pub/scm/linux/kernel/git/kvms390/linux.git tags/kvm-s390-master-6.0-2

for you to fetch changes up to 189e7d876e48d7c791fe1c9c01516f70f5621a9f:

  KVM: s390: pci: register pci hooks without interpretation (2022-09-21 16:18:38 +0200)

----------------------------------------------------------------
More pci fixes
Fix for a code analyser warning
----------------------------------------------------------------

Janis Schoetterl-Glausch (1):
  KVM: s390: Pass initialized arg even if unused

Matthew Rosato (3):
  KVM: s390: pci: fix plain integer as NULL pointer warnings
  KVM: s390: pci: fix GAIT physical vs virtual pointers usage
  KVM: s390: pci: register pci hooks without interpretation

 arch/s390/kvm/gaccess.c   | 16 +++++++++++++---
 arch/s390/kvm/interrupt.c |  2 +-
 arch/s390/kvm/kvm-s390.c  |  4 ++--
 arch/s390/kvm/pci.c       | 20 ++++++++++++++------
 arch/s390/kvm/pci.h       |  6 +++---
 5 files changed, 33 insertions(+), 15 deletions(-)

-- 
2.37.3


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [GIT PULL 1/4] KVM: s390: pci: fix plain integer as NULL pointer warnings
  2022-09-23 12:04 [GIT PULL 0/4] KVM: s390: Fixes for 6.0 take 2 Janosch Frank
@ 2022-09-23 12:04 ` Janosch Frank
  2022-09-23 12:04 ` [GIT PULL 2/4] KVM: s390: Pass initialized arg even if unused Janosch Frank
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Janosch Frank @ 2022-09-23 12:04 UTC (permalink / raw)
  To: pbonzini; +Cc: kvm, frankja, david, borntraeger, cohuck, linux-s390, imbrenda

From: Matthew Rosato <mjrosato@linux.ibm.com>

Fix some sparse warnings that a plain integer 0 is being used instead of
NULL.

Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Matthew Rosato <mjrosato@linux.ibm.com>
Link: https://lore.kernel.org/r/20220915175514.167899-1-mjrosato@linux.ibm.com
Signed-off-by: Christian Borntraeger <borntraeger@linux.ibm.com>
Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
---
 arch/s390/kvm/pci.c | 4 ++--
 arch/s390/kvm/pci.h | 6 +++---
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/arch/s390/kvm/pci.c b/arch/s390/kvm/pci.c
index bb8c335d17b9..3c12637ce08c 100644
--- a/arch/s390/kvm/pci.c
+++ b/arch/s390/kvm/pci.c
@@ -58,7 +58,7 @@ static int zpci_setup_aipb(u8 nisc)
 	if (!zpci_aipb)
 		return -ENOMEM;
 
-	aift->sbv = airq_iv_create(ZPCI_NR_DEVICES, AIRQ_IV_ALLOC, 0);
+	aift->sbv = airq_iv_create(ZPCI_NR_DEVICES, AIRQ_IV_ALLOC, NULL);
 	if (!aift->sbv) {
 		rc = -ENOMEM;
 		goto free_aipb;
@@ -373,7 +373,7 @@ static int kvm_s390_pci_aif_disable(struct zpci_dev *zdev, bool force)
 		gaite->gisc = 0;
 		gaite->aisbo = 0;
 		gaite->gisa = 0;
-		aift->kzdev[zdev->aisb] = 0;
+		aift->kzdev[zdev->aisb] = NULL;
 		/* Clear zdev info */
 		airq_iv_free_bit(aift->sbv, zdev->aisb);
 		airq_iv_release(zdev->aibv);
diff --git a/arch/s390/kvm/pci.h b/arch/s390/kvm/pci.h
index 3a3606c3a0fe..486d06ef563f 100644
--- a/arch/s390/kvm/pci.h
+++ b/arch/s390/kvm/pci.h
@@ -46,9 +46,9 @@ extern struct zpci_aift *aift;
 static inline struct kvm *kvm_s390_pci_si_to_kvm(struct zpci_aift *aift,
 						 unsigned long si)
 {
-	if (!IS_ENABLED(CONFIG_VFIO_PCI_ZDEV_KVM) || aift->kzdev == 0 ||
-	    aift->kzdev[si] == 0)
-		return 0;
+	if (!IS_ENABLED(CONFIG_VFIO_PCI_ZDEV_KVM) || !aift->kzdev ||
+	    !aift->kzdev[si])
+		return NULL;
 	return aift->kzdev[si]->kvm;
 };
 
-- 
2.37.3


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [GIT PULL 2/4] KVM: s390: Pass initialized arg even if unused
  2022-09-23 12:04 [GIT PULL 0/4] KVM: s390: Fixes for 6.0 take 2 Janosch Frank
  2022-09-23 12:04 ` [GIT PULL 1/4] KVM: s390: pci: fix plain integer as NULL pointer warnings Janosch Frank
@ 2022-09-23 12:04 ` Janosch Frank
  2022-09-23 12:04 ` [GIT PULL 3/4] KVM: s390: pci: fix GAIT physical vs virtual pointers usage Janosch Frank
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Janosch Frank @ 2022-09-23 12:04 UTC (permalink / raw)
  To: pbonzini; +Cc: kvm, frankja, david, borntraeger, cohuck, linux-s390, imbrenda

From: Janis Schoetterl-Glausch <scgl@linux.ibm.com>

This silences smatch warnings reported by kbuild bot:
arch/s390/kvm/gaccess.c:859 guest_range_to_gpas() error: uninitialized symbol 'prot'.
arch/s390/kvm/gaccess.c:1064 access_guest_with_key() error: uninitialized symbol 'prot'.

This is because it cannot tell that the value is not used in this case.
The trans_exc* only examine prot if code is PGM_PROTECTION.
Pass a dummy value for other codes.

Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Janis Schoetterl-Glausch <scgl@linux.ibm.com>
Reviewed-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
Link: https://lore.kernel.org/r/20220825192540.1560559-1-scgl@linux.ibm.com
Signed-off-by: Christian Borntraeger <borntraeger@linux.ibm.com>
Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
---
 arch/s390/kvm/gaccess.c | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/arch/s390/kvm/gaccess.c b/arch/s390/kvm/gaccess.c
index 082ec5f2c3a5..0243b6e38d36 100644
--- a/arch/s390/kvm/gaccess.c
+++ b/arch/s390/kvm/gaccess.c
@@ -489,6 +489,8 @@ enum prot_type {
 	PROT_TYPE_ALC  = 2,
 	PROT_TYPE_DAT  = 3,
 	PROT_TYPE_IEP  = 4,
+	/* Dummy value for passing an initialized value when code != PGM_PROTECTION */
+	PROT_NONE,
 };
 
 static int trans_exc_ending(struct kvm_vcpu *vcpu, int code, unsigned long gva, u8 ar,
@@ -504,6 +506,10 @@ static int trans_exc_ending(struct kvm_vcpu *vcpu, int code, unsigned long gva,
 	switch (code) {
 	case PGM_PROTECTION:
 		switch (prot) {
+		case PROT_NONE:
+			/* We should never get here, acts like termination */
+			WARN_ON_ONCE(1);
+			break;
 		case PROT_TYPE_IEP:
 			tec->b61 = 1;
 			fallthrough;
@@ -968,8 +974,10 @@ static int guest_range_to_gpas(struct kvm_vcpu *vcpu, unsigned long ga, u8 ar,
 				return rc;
 		} else {
 			gpa = kvm_s390_real_to_abs(vcpu, ga);
-			if (kvm_is_error_gpa(vcpu->kvm, gpa))
+			if (kvm_is_error_gpa(vcpu->kvm, gpa)) {
 				rc = PGM_ADDRESSING;
+				prot = PROT_NONE;
+			}
 		}
 		if (rc)
 			return trans_exc(vcpu, rc, ga, ar, mode, prot);
@@ -1112,8 +1120,6 @@ int access_guest_with_key(struct kvm_vcpu *vcpu, unsigned long ga, u8 ar,
 		if (rc == PGM_PROTECTION && try_storage_prot_override)
 			rc = access_guest_page_with_key(vcpu->kvm, mode, gpas[idx],
 							data, fragment_len, PAGE_SPO_ACC);
-		if (rc == PGM_PROTECTION)
-			prot = PROT_TYPE_KEYC;
 		if (rc)
 			break;
 		len -= fragment_len;
@@ -1123,6 +1129,10 @@ int access_guest_with_key(struct kvm_vcpu *vcpu, unsigned long ga, u8 ar,
 	if (rc > 0) {
 		bool terminate = (mode == GACC_STORE) && (idx > 0);
 
+		if (rc == PGM_PROTECTION)
+			prot = PROT_TYPE_KEYC;
+		else
+			prot = PROT_NONE;
 		rc = trans_exc_ending(vcpu, rc, ga, ar, mode, prot, terminate);
 	}
 out_unlock:
-- 
2.37.3


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [GIT PULL 3/4] KVM: s390: pci: fix GAIT physical vs virtual pointers usage
  2022-09-23 12:04 [GIT PULL 0/4] KVM: s390: Fixes for 6.0 take 2 Janosch Frank
  2022-09-23 12:04 ` [GIT PULL 1/4] KVM: s390: pci: fix plain integer as NULL pointer warnings Janosch Frank
  2022-09-23 12:04 ` [GIT PULL 2/4] KVM: s390: Pass initialized arg even if unused Janosch Frank
@ 2022-09-23 12:04 ` Janosch Frank
  2022-09-23 12:04 ` [GIT PULL 4/4] KVM: s390: pci: register pci hooks without interpretation Janosch Frank
  2022-09-23 14:10 ` [GIT PULL 0/4] KVM: s390: Fixes for 6.0 take 2 Paolo Bonzini
  4 siblings, 0 replies; 6+ messages in thread
From: Janosch Frank @ 2022-09-23 12:04 UTC (permalink / raw)
  To: pbonzini; +Cc: kvm, frankja, david, borntraeger, cohuck, linux-s390, imbrenda

From: Matthew Rosato <mjrosato@linux.ibm.com>

The GAIT and all of its entries must be represented by physical
addresses as this structure is shared with underlying firmware.
We can keep a virtual address of the GAIT origin in order to
handle processing in the kernel, but when traversing the entries
we must again convert the physical AISB stored in that GAIT entry
into a virtual address in order to process it.

Note: this currently doesn't fix a real bug, since virtual addresses
are indentical to physical ones.

Reviewed-by: Pierre Morel <pmorel@linux.ibm.com>
Acked-by: Nico Boehr <nrb@linux.ibm.com>
Signed-off-by: Matthew Rosato <mjrosato@linux.ibm.com>
Reviewed-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
Link: https://lore.kernel.org/r/20220907155952.87356-1-mjrosato@linux.ibm.com
Message-Id: <20220907155952.87356-1-mjrosato@linux.ibm.com>
Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
---
 arch/s390/kvm/interrupt.c | 2 +-
 arch/s390/kvm/pci.c       | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/s390/kvm/interrupt.c b/arch/s390/kvm/interrupt.c
index b9c944b262c7..ab569faf0df2 100644
--- a/arch/s390/kvm/interrupt.c
+++ b/arch/s390/kvm/interrupt.c
@@ -3324,7 +3324,7 @@ static void aen_host_forward(unsigned long si)
 	if (gaite->count == 0)
 		return;
 	if (gaite->aisb != 0)
-		set_bit_inv(gaite->aisbo, (unsigned long *)gaite->aisb);
+		set_bit_inv(gaite->aisbo, phys_to_virt(gaite->aisb));
 
 	kvm = kvm_s390_pci_si_to_kvm(aift, si);
 	if (!kvm)
diff --git a/arch/s390/kvm/pci.c b/arch/s390/kvm/pci.c
index 3c12637ce08c..90aaba80696a 100644
--- a/arch/s390/kvm/pci.c
+++ b/arch/s390/kvm/pci.c
@@ -71,7 +71,7 @@ static int zpci_setup_aipb(u8 nisc)
 		rc = -ENOMEM;
 		goto free_sbv;
 	}
-	aift->gait = (struct zpci_gaite *)page_to_phys(page);
+	aift->gait = (struct zpci_gaite *)page_to_virt(page);
 
 	zpci_aipb->aipb.faisb = virt_to_phys(aift->sbv->vector);
 	zpci_aipb->aipb.gait = virt_to_phys(aift->gait);
-- 
2.37.3


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [GIT PULL 4/4] KVM: s390: pci: register pci hooks without interpretation
  2022-09-23 12:04 [GIT PULL 0/4] KVM: s390: Fixes for 6.0 take 2 Janosch Frank
                   ` (2 preceding siblings ...)
  2022-09-23 12:04 ` [GIT PULL 3/4] KVM: s390: pci: fix GAIT physical vs virtual pointers usage Janosch Frank
@ 2022-09-23 12:04 ` Janosch Frank
  2022-09-23 14:10 ` [GIT PULL 0/4] KVM: s390: Fixes for 6.0 take 2 Paolo Bonzini
  4 siblings, 0 replies; 6+ messages in thread
From: Janosch Frank @ 2022-09-23 12:04 UTC (permalink / raw)
  To: pbonzini; +Cc: kvm, frankja, david, borntraeger, cohuck, linux-s390, imbrenda

From: Matthew Rosato <mjrosato@linux.ibm.com>

The kvm registration hooks must be registered even if the facilities
necessary for zPCI interpretation are unavailable, as vfio-pci-zdev will
expect to use the hooks regardless.
This fixes an issue where vfio-pci-zdev will fail its open function
because of a missing kvm_register when running on hardware that does not
support zPCI interpretation.

Fixes: ca922fecda6c ("KVM: s390: pci: Hook to access KVM lowlevel from VFIO")
Signed-off-by: Matthew Rosato <mjrosato@linux.ibm.com>
Reviewed-by: Pierre Morel <pmorel@linux.ibm.com>
Link: https://lore.kernel.org/r/20220920193025.135655-1-mjrosato@linux.ibm.com
Message-Id: <20220920193025.135655-1-mjrosato@linux.ibm.com>
Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
---
 arch/s390/kvm/kvm-s390.c |  4 ++--
 arch/s390/kvm/pci.c      | 14 +++++++++++---
 2 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
index edfd4bbd0cba..b7ef0b71014d 100644
--- a/arch/s390/kvm/kvm-s390.c
+++ b/arch/s390/kvm/kvm-s390.c
@@ -505,7 +505,7 @@ int kvm_arch_init(void *opaque)
 		goto out;
 	}
 
-	if (kvm_s390_pci_interp_allowed()) {
+	if (IS_ENABLED(CONFIG_VFIO_PCI_ZDEV_KVM)) {
 		rc = kvm_s390_pci_init();
 		if (rc) {
 			pr_err("Unable to allocate AIFT for PCI\n");
@@ -527,7 +527,7 @@ int kvm_arch_init(void *opaque)
 void kvm_arch_exit(void)
 {
 	kvm_s390_gib_destroy();
-	if (kvm_s390_pci_interp_allowed())
+	if (IS_ENABLED(CONFIG_VFIO_PCI_ZDEV_KVM))
 		kvm_s390_pci_exit();
 	debug_unregister(kvm_s390_dbf);
 	debug_unregister(kvm_s390_dbf_uv);
diff --git a/arch/s390/kvm/pci.c b/arch/s390/kvm/pci.c
index 90aaba80696a..c50c1645c0ae 100644
--- a/arch/s390/kvm/pci.c
+++ b/arch/s390/kvm/pci.c
@@ -672,23 +672,31 @@ int kvm_s390_pci_zpci_op(struct kvm *kvm, struct kvm_s390_zpci_op *args)
 
 int kvm_s390_pci_init(void)
 {
+	zpci_kvm_hook.kvm_register = kvm_s390_pci_register_kvm;
+	zpci_kvm_hook.kvm_unregister = kvm_s390_pci_unregister_kvm;
+
+	if (!kvm_s390_pci_interp_allowed())
+		return 0;
+
 	aift = kzalloc(sizeof(struct zpci_aift), GFP_KERNEL);
 	if (!aift)
 		return -ENOMEM;
 
 	spin_lock_init(&aift->gait_lock);
 	mutex_init(&aift->aift_lock);
-	zpci_kvm_hook.kvm_register = kvm_s390_pci_register_kvm;
-	zpci_kvm_hook.kvm_unregister = kvm_s390_pci_unregister_kvm;
 
 	return 0;
 }
 
 void kvm_s390_pci_exit(void)
 {
-	mutex_destroy(&aift->aift_lock);
 	zpci_kvm_hook.kvm_register = NULL;
 	zpci_kvm_hook.kvm_unregister = NULL;
 
+	if (!kvm_s390_pci_interp_allowed())
+		return;
+
+	mutex_destroy(&aift->aift_lock);
+
 	kfree(aift);
 }
-- 
2.37.3


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [GIT PULL 0/4] KVM: s390: Fixes for 6.0 take 2
  2022-09-23 12:04 [GIT PULL 0/4] KVM: s390: Fixes for 6.0 take 2 Janosch Frank
                   ` (3 preceding siblings ...)
  2022-09-23 12:04 ` [GIT PULL 4/4] KVM: s390: pci: register pci hooks without interpretation Janosch Frank
@ 2022-09-23 14:10 ` Paolo Bonzini
  4 siblings, 0 replies; 6+ messages in thread
From: Paolo Bonzini @ 2022-09-23 14:10 UTC (permalink / raw)
  To: Janosch Frank; +Cc: kvm, david, borntraeger, cohuck, linux-s390, imbrenda

On 9/23/22 14:04, Janosch Frank wrote:
> Paolo,
> 
> vfio-pci has kept us busy for a bit so here are three additional pci fixes.
> Additionally there's a smatch fix by Janis.
> 
> It might be a bit late for rc7 but we wanted to have the coverage.

They're in today's linux-next even, and everybody was busy with other 
stuff last week, so it's fine.  Pulled, thanks!

Paolo

> Enjoy the weekend!
> 
> The following changes since commit 521a547ced6477c54b4b0cc206000406c221b4d6:
> 
>    Linux 6.0-rc6 (2022-09-18 13:44:14 -0700)
> 
> are available in the Git repository at:
> 
>    https://git.kernel.org/pub/scm/linux/kernel/git/kvms390/linux.git tags/kvm-s390-master-6.0-2
> 
> for you to fetch changes up to 189e7d876e48d7c791fe1c9c01516f70f5621a9f:
> 
>    KVM: s390: pci: register pci hooks without interpretation (2022-09-21 16:18:38 +0200)
> 
> ----------------------------------------------------------------
> More pci fixes
> Fix for a code analyser warning
> ----------------------------------------------------------------
> 
> Janis Schoetterl-Glausch (1):
>    KVM: s390: Pass initialized arg even if unused
> 
> Matthew Rosato (3):
>    KVM: s390: pci: fix plain integer as NULL pointer warnings
>    KVM: s390: pci: fix GAIT physical vs virtual pointers usage
>    KVM: s390: pci: register pci hooks without interpretation
> 
>   arch/s390/kvm/gaccess.c   | 16 +++++++++++++---
>   arch/s390/kvm/interrupt.c |  2 +-
>   arch/s390/kvm/kvm-s390.c  |  4 ++--
>   arch/s390/kvm/pci.c       | 20 ++++++++++++++------
>   arch/s390/kvm/pci.h       |  6 +++---
>   5 files changed, 33 insertions(+), 15 deletions(-)
> 


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-09-23 14:11 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-23 12:04 [GIT PULL 0/4] KVM: s390: Fixes for 6.0 take 2 Janosch Frank
2022-09-23 12:04 ` [GIT PULL 1/4] KVM: s390: pci: fix plain integer as NULL pointer warnings Janosch Frank
2022-09-23 12:04 ` [GIT PULL 2/4] KVM: s390: Pass initialized arg even if unused Janosch Frank
2022-09-23 12:04 ` [GIT PULL 3/4] KVM: s390: pci: fix GAIT physical vs virtual pointers usage Janosch Frank
2022-09-23 12:04 ` [GIT PULL 4/4] KVM: s390: pci: register pci hooks without interpretation Janosch Frank
2022-09-23 14:10 ` [GIT PULL 0/4] KVM: s390: Fixes for 6.0 take 2 Paolo Bonzini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).