forked from ~ljy/RK356X_SDK_RELEASE

hc
2023-12-08 01573e231f18eb2d99162747186f59511f56b64d
kernel/arch/x86/xen/smp_pv.c
....@@ -22,11 +22,14 @@
2222 #include <linux/tick.h>
2323 #include <linux/nmi.h>
2424 #include <linux/cpuhotplug.h>
25
+#include <linux/stackprotector.h>
26
+#include <linux/pgtable.h>
2527
2628 #include <asm/paravirt.h>
29
+#include <asm/idtentry.h>
2730 #include <asm/desc.h>
28
-#include <asm/pgtable.h>
2931 #include <asm/cpu.h>
32
+#include <asm/io_apic.h>
3033
3134 #include <xen/interface/xen.h>
3235 #include <xen/interface/vcpu.h>
....@@ -52,11 +55,13 @@
5255 static DEFINE_PER_CPU(struct xen_common_irq, xen_pmu_irq) = { .irq = -1 };
5356
5457 static irqreturn_t xen_irq_work_interrupt(int irq, void *dev_id);
58
+void asm_cpu_bringup_and_idle(void);
5559
5660 static void cpu_bringup(void)
5761 {
5862 int cpu;
5963
64
+ cr4_init();
6065 cpu_init();
6166 touch_softlockup_watchdog();
6267 preempt_disable();
....@@ -89,7 +94,6 @@
8994 {
9095 cpu_bringup();
9196 cpu_startup_entry(CPUHP_AP_ONLINE_IDLE);
92
- prevent_tail_call_optimization();
9397 }
9498
9599 void xen_smp_intr_free_pv(unsigned int cpu)
....@@ -126,7 +130,7 @@
126130 per_cpu(xen_irq_work, cpu).irq = rc;
127131 per_cpu(xen_irq_work, cpu).name = callfunc_name;
128132
129
- if (is_xen_pmu(cpu)) {
133
+ if (is_xen_pmu) {
130134 pmu_name = kasprintf(GFP_KERNEL, "pmu%d", cpu);
131135 rc = bind_virq_to_irqhandler(VIRQ_XENPMU, cpu,
132136 xen_pmu_irq_handler,
....@@ -145,28 +149,12 @@
145149 return rc;
146150 }
147151
148
-static void __init xen_fill_possible_map(void)
149
-{
150
- int i, rc;
151
-
152
- if (xen_initial_domain())
153
- return;
154
-
155
- for (i = 0; i < nr_cpu_ids; i++) {
156
- rc = HYPERVISOR_vcpu_op(VCPUOP_is_up, i, NULL);
157
- if (rc >= 0) {
158
- num_processors++;
159
- set_cpu_possible(i, true);
160
- }
161
- }
162
-}
163
-
164
-static void __init xen_filter_cpu_maps(void)
152
+static void __init _get_smp_config(unsigned int early)
165153 {
166154 int i, rc;
167155 unsigned int subtract = 0;
168156
169
- if (!xen_initial_domain())
157
+ if (early)
170158 return;
171159
172160 num_processors = 0;
....@@ -207,16 +195,6 @@
207195 * sure the old memory can be recycled. */
208196 make_lowmem_page_readwrite(xen_initial_gdt);
209197
210
-#ifdef CONFIG_X86_32
211
- /*
212
- * Xen starts us with XEN_FLAT_RING1_DS, but linux code
213
- * expects __USER_DS
214
- */
215
- loadsegment(ds, __USER_DS);
216
- loadsegment(es, __USER_DS);
217
-#endif
218
-
219
- xen_filter_cpu_maps();
220198 xen_setup_vcpu_info_placement();
221199
222200 /*
....@@ -250,6 +228,7 @@
250228 for_each_possible_cpu(i) {
251229 zalloc_cpumask_var(&per_cpu(cpu_sibling_map, i), GFP_KERNEL);
252230 zalloc_cpumask_var(&per_cpu(cpu_core_map, i), GFP_KERNEL);
231
+ zalloc_cpumask_var(&per_cpu(cpu_die_map, i), GFP_KERNEL);
253232 zalloc_cpumask_var(&per_cpu(cpu_llc_shared_map, i), GFP_KERNEL);
254233 }
255234 set_cpu_sibling_map(0);
....@@ -295,10 +274,6 @@
295274
296275 gdt = get_cpu_gdt_rw(cpu);
297276
298
-#ifdef CONFIG_X86_32
299
- ctxt->user_regs.fs = __KERNEL_PERCPU;
300
- ctxt->user_regs.gs = __KERNEL_STACK_CANARY;
301
-#endif
302277 memset(&ctxt->fpu_ctxt, 0, sizeof(ctxt->fpu_ctxt));
303278
304279 /*
....@@ -306,7 +281,7 @@
306281 * pointing just below where pt_regs would be if it were a normal
307282 * kernel entry.
308283 */
309
- ctxt->user_regs.eip = (unsigned long)cpu_bringup_and_idle;
284
+ ctxt->user_regs.eip = (unsigned long)asm_cpu_bringup_and_idle;
310285 ctxt->flags = VGCF_IN_KERNEL;
311286 ctxt->user_regs.eflags = 0x1000; /* IOPL_RING1 */
312287 ctxt->user_regs.ds = __USER_DS;
....@@ -336,14 +311,9 @@
336311 ctxt->kernel_ss = __KERNEL_DS;
337312 ctxt->kernel_sp = task_top_of_stack(idle);
338313
339
-#ifdef CONFIG_X86_32
340
- ctxt->event_callback_cs = __KERNEL_CS;
341
- ctxt->failsafe_callback_cs = __KERNEL_CS;
342
-#else
343314 ctxt->gs_base_kernel = per_cpu_offset(cpu);
344
-#endif
345315 ctxt->event_callback_eip =
346
- (unsigned long)xen_hypervisor_callback;
316
+ (unsigned long)xen_asm_exc_xen_hypervisor_callback;
347317 ctxt->failsafe_callback_eip =
348318 (unsigned long)xen_failsafe_callback;
349319 per_cpu(xen_cr3, cpu) = __pa(swapper_pg_dir);
....@@ -360,7 +330,9 @@
360330 {
361331 int rc;
362332
363
- common_cpu_up(cpu, idle);
333
+ rc = common_cpu_up(cpu, idle);
334
+ if (rc)
335
+ return rc;
364336
365337 xen_setup_runstate_info(cpu);
366338
....@@ -502,5 +474,8 @@
502474 void __init xen_smp_init(void)
503475 {
504476 smp_ops = xen_smp_ops;
505
- xen_fill_possible_map();
477
+
478
+ /* Avoid searching for BIOS MP tables */
479
+ x86_init.mpparse.find_smp_config = x86_init_noop;
480
+ x86_init.mpparse.get_smp_config = _get_smp_config;
506481 }