forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-11 04dd17822334871b23ea2862f7798fb0e0007777
kernel/arch/powerpc/kvm/book3s_hv_rm_xics.c
....@@ -1,16 +1,14 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Copyright 2012 Michael Ellerman, IBM Corporation.
34 * Copyright 2012 Benjamin Herrenschmidt, IBM Corporation
4
- *
5
- * This program is free software; you can redistribute it and/or modify
6
- * it under the terms of the GNU General Public License, version 2, as
7
- * published by the Free Software Foundation.
85 */
96
107 #include <linux/kernel.h>
118 #include <linux/kvm_host.h>
129 #include <linux/err.h>
1310 #include <linux/kernel_stat.h>
11
+#include <linux/pgtable.h>
1412
1513 #include <asm/kvm_book3s.h>
1614 #include <asm/kvm_ppc.h>
....@@ -18,7 +16,6 @@
1816 #include <asm/xics.h>
1917 #include <asm/synch.h>
2018 #include <asm/cputhreads.h>
21
-#include <asm/pgtable.h>
2219 #include <asm/ppc-opcode.h>
2320 #include <asm/pnv-pci.h>
2421 #include <asm/opal.h>
....@@ -136,11 +133,18 @@
136133
137134 /* Mark the target VCPU as having an interrupt pending */
138135 vcpu->stat.queue_intr++;
139
- set_bit(BOOK3S_IRQPRIO_EXTERNAL_LEVEL, &vcpu->arch.pending_exceptions);
136
+ set_bit(BOOK3S_IRQPRIO_EXTERNAL, &vcpu->arch.pending_exceptions);
140137
141138 /* Kick self ? Just set MER and return */
142139 if (vcpu == this_vcpu) {
143140 mtspr(SPRN_LPCR, mfspr(SPRN_LPCR) | LPCR_MER);
141
+ return;
142
+ }
143
+
144
+ if (xive_enabled() && kvmhv_on_pseries()) {
145
+ /* No XICS access or hypercalls available, too hard */
146
+ this_icp->rm_action |= XICS_RM_KICK_VCPU;
147
+ this_icp->rm_kick_target = vcpu;
144148 return;
145149 }
146150
....@@ -170,8 +174,7 @@
170174 static void icp_rm_clr_vcpu_irq(struct kvm_vcpu *vcpu)
171175 {
172176 /* Note: Only called on self ! */
173
- clear_bit(BOOK3S_IRQPRIO_EXTERNAL_LEVEL,
174
- &vcpu->arch.pending_exceptions);
177
+ clear_bit(BOOK3S_IRQPRIO_EXTERNAL, &vcpu->arch.pending_exceptions);
175178 mtspr(SPRN_LPCR, mfspr(SPRN_LPCR) & ~LPCR_MER);
176179 }
177180
....@@ -761,12 +764,20 @@
761764 return ics_rm_eoi(vcpu, irq);
762765 }
763766
764
-unsigned long eoi_rc;
767
+static unsigned long eoi_rc;
765768
766769 static void icp_eoi(struct irq_chip *c, u32 hwirq, __be32 xirr, bool *again)
767770 {
768771 void __iomem *xics_phys;
769772 int64_t rc;
773
+
774
+ if (kvmhv_on_pseries()) {
775
+ unsigned long retbuf[PLPAR_HCALL_BUFSIZE];
776
+
777
+ iosync();
778
+ plpar_hcall_raw(H_EOI, retbuf, hwirq);
779
+ return;
780
+ }
770781
771782 rc = pnv_opal_pci_msi_eoi(c, hwirq);
772783
....@@ -808,7 +819,7 @@
808819 raddr = per_cpu_ptr(addr, cpu);
809820 l = (unsigned long)raddr;
810821
811
- if (REGION_ID(l) == VMALLOC_REGION_ID) {
822
+ if (get_region_id(l) == VMALLOC_REGION_ID) {
812823 l = vmalloc_to_phys(raddr);
813824 raddr = (unsigned int *)l;
814825 }