6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21
22 /*
23 * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
24 */
25 /*
26 * Copyright 2018 Joyent, Inc.
27 * Copyright (c) 2016, 2017 by Delphix. All rights reserved.
28 */
29
30 /*
31 * PSMI 1.1 extensions are supported only in 2.6 and later versions.
32 * PSMI 1.2 extensions are supported only in 2.7 and later versions.
33 * PSMI 1.3 and 1.4 extensions are supported in Solaris 10.
34 * PSMI 1.5 extensions are supported in Solaris Nevada.
35 * PSMI 1.6 extensions are supported in Solaris Nevada.
36 * PSMI 1.7 extensions are supported in Solaris Nevada.
37 */
38 #define PSMI_1_7
39
40 #include <sys/processor.h>
41 #include <sys/time.h>
42 #include <sys/psm.h>
43 #include <sys/smp_impldefs.h>
44 #include <sys/cram.h>
45 #include <sys/acpi/acpi.h>
46 #include <sys/acpica.h>
791
792 if (temp < apic_last_hrtime) {
793 /* return last hrtime if error occurs */
794 apic_hrtime_error++;
795 temp = apic_last_hrtime;
796 }
797 else
798 apic_last_hrtime = temp;
799
800 lock_clear(&apic_gethrtime_lock);
801 intr_restore(oflags);
802
803 return (temp);
804 }
805
806 /* apic NMI handler */
807 /*ARGSUSED*/
808 void
809 apic_nmi_intr(caddr_t arg, struct regs *rp)
810 {
811 if (apic_shutdown_processors) {
812 apic_disable_local_apic();
813 return;
814 }
815
816 apic_error |= APIC_ERR_NMI;
817
818 if (!lock_try(&apic_nmi_lock))
819 return;
820 apic_num_nmis++;
821
822 if (apic_kmdb_on_nmi && psm_debugger()) {
823 debug_enter("NMI received: entering kmdb\n");
824 } else if (apic_panic_on_nmi) {
825 /* Keep panic from entering kmdb. */
826 nopanicdebug = 1;
827 panic("NMI received\n");
828 } else {
829 /*
830 * prom_printf is the best shot we have of something which is
831 * problem free from high level/NMI type of interrupts
832 */
833 prom_printf("NMI received\n");
834 }
835
836 lock_clear(&apic_nmi_lock);
837 }
838
839 processorid_t
840 apic_get_next_processorid(processorid_t cpu_id)
841 {
842
843 int i;
844
845 if (cpu_id == -1)
846 return ((processorid_t)0);
847
848 for (i = cpu_id + 1; i < NCPU; i++) {
849 if (apic_cpu_in_range(i))
850 return (i);
851 }
852
853 return ((processorid_t)-1);
|
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21
22 /*
23 * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
24 */
25 /*
26 * Copyright 2019, Joyent, Inc.
27 * Copyright (c) 2016, 2017 by Delphix. All rights reserved.
28 */
29
30 /*
31 * PSMI 1.1 extensions are supported only in 2.6 and later versions.
32 * PSMI 1.2 extensions are supported only in 2.7 and later versions.
33 * PSMI 1.3 and 1.4 extensions are supported in Solaris 10.
34 * PSMI 1.5 extensions are supported in Solaris Nevada.
35 * PSMI 1.6 extensions are supported in Solaris Nevada.
36 * PSMI 1.7 extensions are supported in Solaris Nevada.
37 */
38 #define PSMI_1_7
39
40 #include <sys/processor.h>
41 #include <sys/time.h>
42 #include <sys/psm.h>
43 #include <sys/smp_impldefs.h>
44 #include <sys/cram.h>
45 #include <sys/acpi/acpi.h>
46 #include <sys/acpica.h>
791
792 if (temp < apic_last_hrtime) {
793 /* return last hrtime if error occurs */
794 apic_hrtime_error++;
795 temp = apic_last_hrtime;
796 }
797 else
798 apic_last_hrtime = temp;
799
800 lock_clear(&apic_gethrtime_lock);
801 intr_restore(oflags);
802
803 return (temp);
804 }
805
806 /* apic NMI handler */
807 /*ARGSUSED*/
808 void
809 apic_nmi_intr(caddr_t arg, struct regs *rp)
810 {
811 nmi_action_t action = nmi_action;
812
813 if (apic_shutdown_processors) {
814 apic_disable_local_apic();
815 return;
816 }
817
818 apic_error |= APIC_ERR_NMI;
819
820 if (!lock_try(&apic_nmi_lock))
821 return;
822 apic_num_nmis++;
823
824 /*
825 * "nmi_action" always over-rides the older way of doing this, unless we
826 * can't actually drop into kmdb when requested.
827 */
828 if (action == NMI_ACTION_KMDB && !psm_debugger())
829 action = NMI_ACTION_UNSET;
830
831 if (action == NMI_ACTION_UNSET) {
832 if (apic_kmdb_on_nmi && psm_debugger())
833 action = NMI_ACTION_KMDB;
834 else if (apic_panic_on_nmi)
835 action = NMI_ACTION_PANIC;
836 else
837 action = NMI_ACTION_IGNORE;
838 }
839
840 switch (action) {
841 case NMI_ACTION_IGNORE:
842 /*
843 * prom_printf is the best shot we have of something which is
844 * problem free from high level/NMI type of interrupts
845 */
846 prom_printf("NMI received\n");
847 break;
848
849 case NMI_ACTION_PANIC:
850 /* Keep panic from entering kmdb. */
851 nopanicdebug = 1;
852 panic("NMI received\n");
853 break;
854
855 case NMI_ACTION_KMDB:
856 default:
857 debug_enter("NMI received: entering kmdb\n");
858 break;
859 }
860
861 lock_clear(&apic_nmi_lock);
862 }
863
864 processorid_t
865 apic_get_next_processorid(processorid_t cpu_id)
866 {
867
868 int i;
869
870 if (cpu_id == -1)
871 return ((processorid_t)0);
872
873 for (i = cpu_id + 1; i < NCPU; i++) {
874 if (apic_cpu_in_range(i))
875 return (i);
876 }
877
878 return ((processorid_t)-1);
|