1b2441318SGreg Kroah-Hartman // SPDX-License-Identifier: GPL-2.0 29844ab11SCyrill Gorcunov /* 39844ab11SCyrill Gorcunov * NOOP APIC driver. 49844ab11SCyrill Gorcunov * 59844ab11SCyrill Gorcunov * Does almost nothing and should be substituted by a real apic driver via 69844ab11SCyrill Gorcunov * probe routine. 79844ab11SCyrill Gorcunov * 89844ab11SCyrill Gorcunov * Though in case if apic is disabled (for some reason) we try 99844ab11SCyrill Gorcunov * to not uglify the caller's code and allow to call (some) apic routines 10f88f2b4fSCyrill Gorcunov * like self-ipi, etc... 119844ab11SCyrill Gorcunov */ 129844ab11SCyrill Gorcunov #include <linux/cpumask.h> 13521b82feSThomas Gleixner 149844ab11SCyrill Gorcunov #include <asm/apic.h> 159844ab11SCyrill Gorcunov 16f88f2b4fSCyrill Gorcunov static void noop_init_apic_ldr(void) { } 174727da2eSThomas Gleixner static void noop_send_IPI(int cpu, int vector) { } 18f88f2b4fSCyrill Gorcunov static void noop_send_IPI_mask(const struct cpumask *cpumask, int vector) { } 19f88f2b4fSCyrill Gorcunov static void noop_send_IPI_mask_allbutself(const struct cpumask *cpumask, int vector) { } 20f88f2b4fSCyrill Gorcunov static void noop_send_IPI_allbutself(int vector) { } 21f88f2b4fSCyrill Gorcunov static void noop_send_IPI_all(int vector) { } 22f88f2b4fSCyrill Gorcunov static void noop_send_IPI_self(int vector) { } 23f88f2b4fSCyrill Gorcunov static void noop_apic_wait_icr_idle(void) { } 24f88f2b4fSCyrill Gorcunov static void noop_apic_icr_write(u32 low, u32 id) { } 25f88f2b4fSCyrill Gorcunov 26f88f2b4fSCyrill Gorcunov static int noop_wakeup_secondary_cpu(int apicid, unsigned long start_eip) 279844ab11SCyrill Gorcunov { 28f88f2b4fSCyrill Gorcunov return -1; 299844ab11SCyrill Gorcunov } 309844ab11SCyrill Gorcunov 31f88f2b4fSCyrill Gorcunov static u32 noop_safe_apic_wait_icr_idle(void) 32f88f2b4fSCyrill Gorcunov { 33f88f2b4fSCyrill Gorcunov return 0; 34f88f2b4fSCyrill Gorcunov } 359844ab11SCyrill Gorcunov 36f88f2b4fSCyrill Gorcunov static u64 noop_apic_icr_read(void) 37f88f2b4fSCyrill Gorcunov { 38f88f2b4fSCyrill Gorcunov return 0; 39f88f2b4fSCyrill Gorcunov } 40f88f2b4fSCyrill Gorcunov 41f88f2b4fSCyrill Gorcunov static int noop_phys_pkg_id(int cpuid_apic, int index_msb) 42f88f2b4fSCyrill Gorcunov { 43f88f2b4fSCyrill Gorcunov return 0; 44f88f2b4fSCyrill Gorcunov } 45f88f2b4fSCyrill Gorcunov 46f88f2b4fSCyrill Gorcunov static unsigned int noop_get_apic_id(unsigned long x) 47f88f2b4fSCyrill Gorcunov { 48f88f2b4fSCyrill Gorcunov return 0; 49f88f2b4fSCyrill Gorcunov } 509844ab11SCyrill Gorcunov 519844ab11SCyrill Gorcunov static int noop_probe(void) 529844ab11SCyrill Gorcunov { 53f88f2b4fSCyrill Gorcunov /* 54f88f2b4fSCyrill Gorcunov * NOOP apic should not ever be 55f88f2b4fSCyrill Gorcunov * enabled via probe routine 56f88f2b4fSCyrill Gorcunov */ 579844ab11SCyrill Gorcunov return 0; 589844ab11SCyrill Gorcunov } 599844ab11SCyrill Gorcunov 609844ab11SCyrill Gorcunov static int noop_apic_id_registered(void) 619844ab11SCyrill Gorcunov { 62f88f2b4fSCyrill Gorcunov /* 63f88f2b4fSCyrill Gorcunov * if we would be really "pedantic" 64f88f2b4fSCyrill Gorcunov * we should pass read_apic_id() here 65f88f2b4fSCyrill Gorcunov * but since NOOP suppose APIC ID = 0 66f88f2b4fSCyrill Gorcunov * lets save a few cycles 67f88f2b4fSCyrill Gorcunov */ 68f88f2b4fSCyrill Gorcunov return physid_isset(0, phys_cpu_present_map); 699844ab11SCyrill Gorcunov } 709844ab11SCyrill Gorcunov 719844ab11SCyrill Gorcunov static u32 noop_apic_read(u32 reg) 729844ab11SCyrill Gorcunov { 7393984fbdSBorislav Petkov WARN_ON_ONCE(boot_cpu_has(X86_FEATURE_APIC) && !disable_apic); 749844ab11SCyrill Gorcunov return 0; 759844ab11SCyrill Gorcunov } 769844ab11SCyrill Gorcunov 77f88f2b4fSCyrill Gorcunov static void noop_apic_write(u32 reg, u32 v) 78f88f2b4fSCyrill Gorcunov { 7993984fbdSBorislav Petkov WARN_ON_ONCE(boot_cpu_has(X86_FEATURE_APIC) && !disable_apic); 80f88f2b4fSCyrill Gorcunov } 81f88f2b4fSCyrill Gorcunov 821da91779SThomas Gleixner #ifdef CONFIG_X86_32 831da91779SThomas Gleixner static int noop_x86_32_early_logical_apicid(int cpu) 841da91779SThomas Gleixner { 851da91779SThomas Gleixner return BAD_APICID; 861da91779SThomas Gleixner } 871da91779SThomas Gleixner #endif 881da91779SThomas Gleixner 89404f6aacSKees Cook struct apic apic_noop __ro_after_init = { 909844ab11SCyrill Gorcunov .name = "noop", 919844ab11SCyrill Gorcunov .probe = noop_probe, 929844ab11SCyrill Gorcunov .acpi_madt_oem_check = NULL, 939844ab11SCyrill Gorcunov 94fa63030eSDaniel J Blueman .apic_id_valid = default_apic_id_valid, 959844ab11SCyrill Gorcunov .apic_id_registered = noop_apic_id_registered, 969844ab11SCyrill Gorcunov 97a31e58e1SThomas Gleixner .irq_delivery_mode = dest_Fixed, 989844ab11SCyrill Gorcunov /* logical delivery broadcast to all CPUs: */ 999844ab11SCyrill Gorcunov .irq_dest_mode = 1, 1009844ab11SCyrill Gorcunov 1019844ab11SCyrill Gorcunov .disable_esr = 0, 1029844ab11SCyrill Gorcunov .dest_logical = APIC_DEST_LOGICAL, 1034c59f3e6SDavid Rientjes .check_apicid_used = default_check_apicid_used, 1049844ab11SCyrill Gorcunov 1059844ab11SCyrill Gorcunov .init_apic_ldr = noop_init_apic_ldr, 1069844ab11SCyrill Gorcunov 1077abc0753SCyrill Gorcunov .ioapic_phys_id_map = default_ioapic_phys_id_map, 1089844ab11SCyrill Gorcunov .setup_apic_routing = NULL, 1099844ab11SCyrill Gorcunov 1109844ab11SCyrill Gorcunov .cpu_present_to_apicid = default_cpu_present_to_apicid, 1117abc0753SCyrill Gorcunov .apicid_to_cpu_present = physid_set_mask_of_physid, 1129844ab11SCyrill Gorcunov 1139844ab11SCyrill Gorcunov .check_phys_apicid_present = default_check_phys_apicid_present, 1149844ab11SCyrill Gorcunov 115f88f2b4fSCyrill Gorcunov .phys_pkg_id = noop_phys_pkg_id, 1169844ab11SCyrill Gorcunov 1179844ab11SCyrill Gorcunov .get_apic_id = noop_get_apic_id, 1189844ab11SCyrill Gorcunov .set_apic_id = NULL, 1199844ab11SCyrill Gorcunov 1209f9e3bb1SThomas Gleixner .calc_dest_apicid = apic_flat_calc_apicid, 1219844ab11SCyrill Gorcunov 1224727da2eSThomas Gleixner .send_IPI = noop_send_IPI, 1239844ab11SCyrill Gorcunov .send_IPI_mask = noop_send_IPI_mask, 1249844ab11SCyrill Gorcunov .send_IPI_mask_allbutself = noop_send_IPI_mask_allbutself, 1259844ab11SCyrill Gorcunov .send_IPI_allbutself = noop_send_IPI_allbutself, 1269844ab11SCyrill Gorcunov .send_IPI_all = noop_send_IPI_all, 1279844ab11SCyrill Gorcunov .send_IPI_self = noop_send_IPI_self, 1289844ab11SCyrill Gorcunov 1299844ab11SCyrill Gorcunov .wakeup_secondary_cpu = noop_wakeup_secondary_cpu, 1309844ab11SCyrill Gorcunov 1319844ab11SCyrill Gorcunov .inquire_remote_apic = NULL, 1329844ab11SCyrill Gorcunov 1339844ab11SCyrill Gorcunov .read = noop_apic_read, 1349844ab11SCyrill Gorcunov .write = noop_apic_write, 1352a43195dSMichael S. Tsirkin .eoi_write = noop_apic_write, 1369844ab11SCyrill Gorcunov .icr_read = noop_apic_icr_read, 1379844ab11SCyrill Gorcunov .icr_write = noop_apic_icr_write, 1389844ab11SCyrill Gorcunov .wait_icr_idle = noop_apic_wait_icr_idle, 1399844ab11SCyrill Gorcunov .safe_wait_icr_idle = noop_safe_apic_wait_icr_idle, 140acb8bc09STejun Heo 141acb8bc09STejun Heo #ifdef CONFIG_X86_32 142acb8bc09STejun Heo .x86_32_early_logical_apicid = noop_x86_32_early_logical_apicid, 143acb8bc09STejun Heo #endif 1449844ab11SCyrill Gorcunov }; 145