@@ -50,6 +50,24 @@ static void kvmppc_xive_native_cleanup_queue(struct kvm_vcpu *vcpu, int prio)
50
50
}
51
51
}
52
52
53
+ static int kvmppc_xive_native_configure_queue (u32 vp_id , struct xive_q * q ,
54
+ u8 prio , __be32 * qpage ,
55
+ u32 order , bool can_escalate )
56
+ {
57
+ int rc ;
58
+ __be32 * qpage_prev = q -> qpage ;
59
+
60
+ rc = xive_native_configure_queue (vp_id , q , prio , qpage , order ,
61
+ can_escalate );
62
+ if (rc )
63
+ return rc ;
64
+
65
+ if (qpage_prev )
66
+ put_page (virt_to_page (qpage_prev ));
67
+
68
+ return rc ;
69
+ }
70
+
53
71
void kvmppc_xive_native_cleanup_vcpu (struct kvm_vcpu * vcpu )
54
72
{
55
73
struct kvmppc_xive_vcpu * xc = vcpu -> arch .xive_vcpu ;
@@ -575,19 +593,14 @@ static int kvmppc_xive_native_set_queue_config(struct kvmppc_xive *xive,
575
593
q -> guest_qaddr = 0 ;
576
594
q -> guest_qshift = 0 ;
577
595
578
- rc = xive_native_configure_queue (xc -> vp_id , q , priority ,
579
- NULL , 0 , true);
596
+ rc = kvmppc_xive_native_configure_queue (xc -> vp_id , q , priority ,
597
+ NULL , 0 , true);
580
598
if (rc ) {
581
599
pr_err ("Failed to reset queue %d for VCPU %d: %d\n" ,
582
600
priority , xc -> server_num , rc );
583
601
return rc ;
584
602
}
585
603
586
- if (q -> qpage ) {
587
- put_page (virt_to_page (q -> qpage ));
588
- q -> qpage = NULL ;
589
- }
590
-
591
604
return 0 ;
592
605
}
593
606
@@ -617,12 +630,6 @@ static int kvmppc_xive_native_set_queue_config(struct kvmppc_xive *xive,
617
630
618
631
srcu_idx = srcu_read_lock (& kvm -> srcu );
619
632
gfn = gpa_to_gfn (kvm_eq .qaddr );
620
- page = gfn_to_page (kvm , gfn );
621
- if (is_error_page (page )) {
622
- srcu_read_unlock (& kvm -> srcu , srcu_idx );
623
- pr_err ("Couldn't get queue page %llx!\n" , kvm_eq .qaddr );
624
- return - EINVAL ;
625
- }
626
633
627
634
page_size = kvm_host_page_size (kvm , gfn );
628
635
if (1ull << kvm_eq .qshift > page_size ) {
@@ -631,6 +638,13 @@ static int kvmppc_xive_native_set_queue_config(struct kvmppc_xive *xive,
631
638
return - EINVAL ;
632
639
}
633
640
641
+ page = gfn_to_page (kvm , gfn );
642
+ if (is_error_page (page )) {
643
+ srcu_read_unlock (& kvm -> srcu , srcu_idx );
644
+ pr_err ("Couldn't get queue page %llx!\n" , kvm_eq .qaddr );
645
+ return - EINVAL ;
646
+ }
647
+
634
648
qaddr = page_to_virt (page ) + (kvm_eq .qaddr & ~PAGE_MASK );
635
649
srcu_read_unlock (& kvm -> srcu , srcu_idx );
636
650
@@ -646,8 +660,8 @@ static int kvmppc_xive_native_set_queue_config(struct kvmppc_xive *xive,
646
660
* OPAL level because the use of END ESBs is not supported by
647
661
* Linux.
648
662
*/
649
- rc = xive_native_configure_queue (xc -> vp_id , q , priority ,
650
- (__be32 * ) qaddr , kvm_eq .qshift , true);
663
+ rc = kvmppc_xive_native_configure_queue (xc -> vp_id , q , priority ,
664
+ (__be32 * ) qaddr , kvm_eq .qshift , true);
651
665
if (rc ) {
652
666
pr_err ("Failed to configure queue %d for VCPU %d: %d\n" ,
653
667
priority , xc -> server_num , rc );
0 commit comments