forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-11 04dd17822334871b23ea2862f7798fb0e0007777
kernel/arch/powerpc/kvm/book3s_xive.h
....@@ -1,9 +1,6 @@
1
+/* SPDX-License-Identifier: GPL-2.0-only */
12 /*
23 * Copyright 2017 Benjamin Herrenschmidt, IBM Corporation
3
- *
4
- * This program is free software; you can redistribute it and/or modify
5
- * it under the terms of the GNU General Public License, version 2, as
6
- * published by the Free Software Foundation.
74 */
85
96 #ifndef _KVM_PPC_BOOK3S_XIVE_H
....@@ -11,6 +8,13 @@
118
129 #ifdef CONFIG_KVM_XICS
1310 #include "book3s_xics.h"
11
+
12
+/*
13
+ * The XIVE Interrupt source numbers are within the range 0 to
14
+ * KVMPPC_XICS_NR_IRQS.
15
+ */
16
+#define KVMPPC_XIVE_FIRST_IRQ 0
17
+#define KVMPPC_XIVE_NR_IRQS KVMPPC_XICS_NR_IRQS
1418
1519 /*
1620 * State for one guest irq source.
....@@ -54,6 +58,9 @@
5458 bool saved_p;
5559 bool saved_q;
5660 u8 saved_scan_prio;
61
+
62
+ /* Xive native */
63
+ u32 eisn; /* Guest Effective IRQ number */
5764 };
5865
5966 /* Select the "right" interrupt (IPI vs. passthrough) */
....@@ -84,6 +91,11 @@
8491 struct kvmppc_xive_irq_state irq_state[KVMPPC_XICS_IRQ_PER_ICS];
8592 };
8693
94
+struct kvmppc_xive;
95
+
96
+struct kvmppc_xive_ops {
97
+ int (*reset_mapped)(struct kvm *kvm, unsigned long guest_irq);
98
+};
8799
88100 struct kvmppc_xive {
89101 struct kvm *kvm;
....@@ -122,6 +134,14 @@
122134
123135 /* Flags */
124136 u8 single_escalation;
137
+
138
+ /* Number of entries in the VP block */
139
+ u32 nr_servers;
140
+
141
+ struct kvmppc_xive_ops *ops;
142
+ struct address_space *mapping;
143
+ struct mutex mapping_lock;
144
+ struct mutex lock;
125145 };
126146
127147 #define KVMPPC_XIVE_Q_COUNT 8
....@@ -198,6 +218,23 @@
198218 return xive->src_blocks[bid];
199219 }
200220
221
+static inline u32 kvmppc_xive_vp(struct kvmppc_xive *xive, u32 server)
222
+{
223
+ return xive->vp_base + kvmppc_pack_vcpu_id(xive->kvm, server);
224
+}
225
+
226
+static inline bool kvmppc_xive_vp_in_use(struct kvm *kvm, u32 vp_id)
227
+{
228
+ struct kvm_vcpu *vcpu = NULL;
229
+ int i;
230
+
231
+ kvm_for_each_vcpu(i, vcpu, kvm) {
232
+ if (vcpu->arch.xive_vcpu && vp_id == vcpu->arch.xive_vcpu->vp_id)
233
+ return true;
234
+ }
235
+ return false;
236
+}
237
+
201238 /*
202239 * Mapping between guest priorities and host priorities
203240 * is as follow.
....@@ -248,5 +285,22 @@
248285 extern int (*__xive_vm_h_cppr)(struct kvm_vcpu *vcpu, unsigned long cppr);
249286 extern int (*__xive_vm_h_eoi)(struct kvm_vcpu *vcpu, unsigned long xirr);
250287
288
+/*
289
+ * Common Xive routines for XICS-over-XIVE and XIVE native
290
+ */
291
+void kvmppc_xive_disable_vcpu_interrupts(struct kvm_vcpu *vcpu);
292
+int kvmppc_xive_debug_show_queues(struct seq_file *m, struct kvm_vcpu *vcpu);
293
+struct kvmppc_xive_src_block *kvmppc_xive_create_src_block(
294
+ struct kvmppc_xive *xive, int irq);
295
+void kvmppc_xive_free_sources(struct kvmppc_xive_src_block *sb);
296
+int kvmppc_xive_select_target(struct kvm *kvm, u32 *server, u8 prio);
297
+int kvmppc_xive_attach_escalation(struct kvm_vcpu *vcpu, u8 prio,
298
+ bool single_escalation);
299
+struct kvmppc_xive *kvmppc_xive_get_device(struct kvm *kvm, u32 type);
300
+void xive_cleanup_single_escalation(struct kvm_vcpu *vcpu,
301
+ struct kvmppc_xive_vcpu *xc, int irq);
302
+int kvmppc_xive_compute_vp_id(struct kvmppc_xive *xive, u32 cpu, u32 *vp);
303
+int kvmppc_xive_set_nr_servers(struct kvmppc_xive *xive, u64 addr);
304
+
251305 #endif /* CONFIG_KVM_XICS */
252306 #endif /* _KVM_PPC_BOOK3S_XICS_H */