public inbox for linux-s390@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1] KVM: s390: GISA: sort out physical vs virtual pointers usage
@ 2022-11-07  8:57 Nico Boehr
  2022-11-08 12:50 ` Claudio Imbrenda
  2022-11-24 11:48 ` Michael Mueller
  0 siblings, 2 replies; 3+ messages in thread
From: Nico Boehr @ 2022-11-07  8:57 UTC (permalink / raw)
  To: borntraeger, frankja, imbrenda
  Cc: kvm, linux-s390, pasic, akrowiak, jjherne, mimu, vneethv, oberpar

Fix virtual vs physical address confusion (which currently are the same).

In chsc_sgib(), do the virtual-physical conversion in the caller since
the caller needs to make sure it is a 31-bit address and zero has a
special meaning (disassociating the GIB).

Signed-off-by: Nico Boehr <nrb@linux.ibm.com>
---
 arch/s390/kvm/interrupt.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/arch/s390/kvm/interrupt.c b/arch/s390/kvm/interrupt.c
index ab569faf0df2..ae018217eac8 100644
--- a/arch/s390/kvm/interrupt.c
+++ b/arch/s390/kvm/interrupt.c
@@ -3104,9 +3104,9 @@ static enum hrtimer_restart gisa_vcpu_kicker(struct hrtimer *timer)
 static void process_gib_alert_list(void)
 {
 	struct kvm_s390_gisa_interrupt *gi;
+	u32 final, gisa_phys, origin = 0UL;
 	struct kvm_s390_gisa *gisa;
 	struct kvm *kvm;
-	u32 final, origin = 0UL;
 
 	do {
 		/*
@@ -3132,9 +3132,10 @@ static void process_gib_alert_list(void)
 		 * interruptions asap.
 		 */
 		while (origin & GISA_ADDR_MASK) {
-			gisa = (struct kvm_s390_gisa *)(u64)origin;
+			gisa_phys = origin;
+			gisa = phys_to_virt(gisa_phys);
 			origin = gisa->next_alert;
-			gisa->next_alert = (u32)(u64)gisa;
+			gisa->next_alert = gisa_phys;
 			kvm = container_of(gisa, struct sie_page2, gisa)->kvm;
 			gi = &kvm->arch.gisa_int;
 			if (hrtimer_active(&gi->timer))
@@ -3418,6 +3419,7 @@ void kvm_s390_gib_destroy(void)
 
 int kvm_s390_gib_init(u8 nisc)
 {
+	u32 gib_origin;
 	int rc = 0;
 
 	if (!css_general_characteristics.aiv) {
@@ -3439,7 +3441,8 @@ int kvm_s390_gib_init(u8 nisc)
 	}
 
 	gib->nisc = nisc;
-	if (chsc_sgib((u32)(u64)gib)) {
+	gib_origin = virt_to_phys(gib);
+	if (chsc_sgib(gib_origin)) {
 		pr_err("Associating the GIB with the AIV facility failed\n");
 		free_page((unsigned long)gib);
 		gib = NULL;
-- 
2.37.3


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

* Re: [PATCH v1] KVM: s390: GISA: sort out physical vs virtual pointers usage
  2022-11-07  8:57 [PATCH v1] KVM: s390: GISA: sort out physical vs virtual pointers usage Nico Boehr
@ 2022-11-08 12:50 ` Claudio Imbrenda
  2022-11-24 11:48 ` Michael Mueller
  1 sibling, 0 replies; 3+ messages in thread
From: Claudio Imbrenda @ 2022-11-08 12:50 UTC (permalink / raw)
  To: Nico Boehr
  Cc: borntraeger, frankja, kvm, linux-s390, pasic, akrowiak, jjherne,
	mimu, vneethv, oberpar

On Mon,  7 Nov 2022 09:57:27 +0100
Nico Boehr <nrb@linux.ibm.com> wrote:

> Fix virtual vs physical address confusion (which currently are the same).
> 
> In chsc_sgib(), do the virtual-physical conversion in the caller since
> the caller needs to make sure it is a 31-bit address and zero has a
> special meaning (disassociating the GIB).
> 
> Signed-off-by: Nico Boehr <nrb@linux.ibm.com>

Reviewed-by: Claudio Imbrenda <imbrenda@linux.ibm.com>

> ---
>  arch/s390/kvm/interrupt.c | 11 +++++++----
>  1 file changed, 7 insertions(+), 4 deletions(-)
> 
> diff --git a/arch/s390/kvm/interrupt.c b/arch/s390/kvm/interrupt.c
> index ab569faf0df2..ae018217eac8 100644
> --- a/arch/s390/kvm/interrupt.c
> +++ b/arch/s390/kvm/interrupt.c
> @@ -3104,9 +3104,9 @@ static enum hrtimer_restart gisa_vcpu_kicker(struct hrtimer *timer)
>  static void process_gib_alert_list(void)
>  {
>  	struct kvm_s390_gisa_interrupt *gi;
> +	u32 final, gisa_phys, origin = 0UL;
>  	struct kvm_s390_gisa *gisa;
>  	struct kvm *kvm;
> -	u32 final, origin = 0UL;
>  
>  	do {
>  		/*
> @@ -3132,9 +3132,10 @@ static void process_gib_alert_list(void)
>  		 * interruptions asap.
>  		 */
>  		while (origin & GISA_ADDR_MASK) {
> -			gisa = (struct kvm_s390_gisa *)(u64)origin;
> +			gisa_phys = origin;
> +			gisa = phys_to_virt(gisa_phys);
>  			origin = gisa->next_alert;
> -			gisa->next_alert = (u32)(u64)gisa;
> +			gisa->next_alert = gisa_phys;
>  			kvm = container_of(gisa, struct sie_page2, gisa)->kvm;
>  			gi = &kvm->arch.gisa_int;
>  			if (hrtimer_active(&gi->timer))
> @@ -3418,6 +3419,7 @@ void kvm_s390_gib_destroy(void)
>  
>  int kvm_s390_gib_init(u8 nisc)
>  {
> +	u32 gib_origin;
>  	int rc = 0;
>  
>  	if (!css_general_characteristics.aiv) {
> @@ -3439,7 +3441,8 @@ int kvm_s390_gib_init(u8 nisc)
>  	}
>  
>  	gib->nisc = nisc;
> -	if (chsc_sgib((u32)(u64)gib)) {
> +	gib_origin = virt_to_phys(gib);
> +	if (chsc_sgib(gib_origin)) {
>  		pr_err("Associating the GIB with the AIV facility failed\n");
>  		free_page((unsigned long)gib);
>  		gib = NULL;


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

* Re: [PATCH v1] KVM: s390: GISA: sort out physical vs virtual pointers usage
  2022-11-07  8:57 [PATCH v1] KVM: s390: GISA: sort out physical vs virtual pointers usage Nico Boehr
  2022-11-08 12:50 ` Claudio Imbrenda
@ 2022-11-24 11:48 ` Michael Mueller
  1 sibling, 0 replies; 3+ messages in thread
From: Michael Mueller @ 2022-11-24 11:48 UTC (permalink / raw)
  To: Nico Boehr, borntraeger, frankja, imbrenda
  Cc: kvm, linux-s390, pasic, akrowiak, jjherne, vneethv, oberpar



Am 07.11.22 um 09:57 schrieb Nico Boehr:
> Fix virtual vs physical address confusion (which currently are the same).
> 
> In chsc_sgib(), do the virtual-physical conversion in the caller since
> the caller needs to make sure it is a 31-bit address and zero has a
> special meaning (disassociating the GIB).
> 
> Signed-off-by: Nico Boehr <nrb@linux.ibm.com>


Looks good to me!

Reviewed-by: Michael Mueller <mimu@linux.ibm.com>

> ---
>   arch/s390/kvm/interrupt.c | 11 +++++++----
>   1 file changed, 7 insertions(+), 4 deletions(-)
> 
> diff --git a/arch/s390/kvm/interrupt.c b/arch/s390/kvm/interrupt.c
> index ab569faf0df2..ae018217eac8 100644
> --- a/arch/s390/kvm/interrupt.c
> +++ b/arch/s390/kvm/interrupt.c
> @@ -3104,9 +3104,9 @@ static enum hrtimer_restart gisa_vcpu_kicker(struct hrtimer *timer)
>   static void process_gib_alert_list(void)
>   {
>   	struct kvm_s390_gisa_interrupt *gi;
> +	u32 final, gisa_phys, origin = 0UL;
>   	struct kvm_s390_gisa *gisa;
>   	struct kvm *kvm;
> -	u32 final, origin = 0UL;
>   
>   	do {
>   		/*
> @@ -3132,9 +3132,10 @@ static void process_gib_alert_list(void)
>   		 * interruptions asap.
>   		 */
>   		while (origin & GISA_ADDR_MASK) {
> -			gisa = (struct kvm_s390_gisa *)(u64)origin;
> +			gisa_phys = origin;
> +			gisa = phys_to_virt(gisa_phys);
>   			origin = gisa->next_alert;
> -			gisa->next_alert = (u32)(u64)gisa;
> +			gisa->next_alert = gisa_phys;
>   			kvm = container_of(gisa, struct sie_page2, gisa)->kvm;
>   			gi = &kvm->arch.gisa_int;
>   			if (hrtimer_active(&gi->timer))
> @@ -3418,6 +3419,7 @@ void kvm_s390_gib_destroy(void)
>   
>   int kvm_s390_gib_init(u8 nisc)
>   {
> +	u32 gib_origin;
>   	int rc = 0;
>   
>   	if (!css_general_characteristics.aiv) {
> @@ -3439,7 +3441,8 @@ int kvm_s390_gib_init(u8 nisc)
>   	}
>   
>   	gib->nisc = nisc;
> -	if (chsc_sgib((u32)(u64)gib)) {
> +	gib_origin = virt_to_phys(gib);
> +	if (chsc_sgib(gib_origin)) {
>   		pr_err("Associating the GIB with the AIV facility failed\n");
>   		free_page((unsigned long)gib);
>   		gib = NULL;

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

end of thread, other threads:[~2022-11-24 11:48 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-11-07  8:57 [PATCH v1] KVM: s390: GISA: sort out physical vs virtual pointers usage Nico Boehr
2022-11-08 12:50 ` Claudio Imbrenda
2022-11-24 11:48 ` Michael Mueller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox