1ae115bc7Smrj/* 2ae115bc7Smrj * CDDL HEADER START 3ae115bc7Smrj * 4ae115bc7Smrj * The contents of this file are subject to the terms of the 5ae115bc7Smrj * Common Development and Distribution License (the "License"). 6ae115bc7Smrj * You may not use this file except in compliance with the License. 7ae115bc7Smrj * 8ae115bc7Smrj * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9ae115bc7Smrj * or http://www.opensolaris.org/os/licensing. 10ae115bc7Smrj * See the License for the specific language governing permissions 11ae115bc7Smrj * and limitations under the License. 12ae115bc7Smrj * 13ae115bc7Smrj * When distributing Covered Code, include this CDDL HEADER in each 14ae115bc7Smrj * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15ae115bc7Smrj * If applicable, add the following below this CDDL HEADER, with the 16ae115bc7Smrj * fields enclosed by brackets "[]" replaced with your own identifying 17ae115bc7Smrj * information: Portions Copyright [yyyy] [name of copyright owner] 18ae115bc7Smrj * 19ae115bc7Smrj * CDDL HEADER END 20ae115bc7Smrj */ 21ae115bc7Smrj/* 22ae115bc7Smrj * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 23ae115bc7Smrj * Use is subject to license terms. 24ae115bc7Smrj */ 25ae115bc7Smrj 26ae115bc7Smrj#pragma ident "%Z%%M% %I% %E% SMI" 27ae115bc7Smrj 28ae115bc7Smrj/* 29ae115bc7Smrj * Companion to kdi_idt.c - the implementation of the trap and interrupt 30ae115bc7Smrj * handlers. For the most part, these handlers do the same thing - they 31ae115bc7Smrj * push a trap number onto the stack, followed by a jump to kdi_cmnint. 32ae115bc7Smrj * Each trap and interrupt has its own handler because each one pushes a 33ae115bc7Smrj * different number. 34ae115bc7Smrj */ 35ae115bc7Smrj 36ae115bc7Smrj#include <sys/asm_linkage.h> 37ae115bc7Smrj#include <sys/kdi_regs.h> 38ae115bc7Smrj 39ae115bc7Smrj/* Nothing in this file is of interest to lint. */ 40ae115bc7Smrj#if !defined(__lint) 41ae115bc7Smrj 42ae115bc7Smrj/* 43ae115bc7Smrj * The default ASM_ENTRY_ALIGN (16) wastes far too much space. Pay no 44ae115bc7Smrj * attention to the fleet of nop's we're adding to each handler. 45ae115bc7Smrj */ 46ae115bc7Smrj#undef ASM_ENTRY_ALIGN 47ae115bc7Smrj#define ASM_ENTRY_ALIGN 8 48ae115bc7Smrj 49ae115bc7Smrj/* 50ae115bc7Smrj * We need the .align in ENTRY_NP (defined to be ASM_ENTRY_ALIGN) to match our 51ae115bc7Smrj * manual .align (KDI_MSR_PATCHOFF) in order to ensure that the space reserved 52ae115bc7Smrj * at the beginning of the handler for code is exactly KDI_MSR_PATCHOFF bytes 53ae115bc7Smrj * long. Note that the #error below isn't supported by the preprocessor invoked 54ae115bc7Smrj * by as(1), and won't stop the build, but it'll emit a noticeable error message 55ae115bc7Smrj * which won't escape the filters. 56ae115bc7Smrj */ 57ae115bc7Smrj#if ASM_ENTRY_ALIGN != KDI_MSR_PATCHOFF 58ae115bc7Smrj#error "ASM_ENTRY_ALIGN != KDI_MSR_PATCHOFF" 59ae115bc7Smrjthis won't assemble 60ae115bc7Smrj#endif 61ae115bc7Smrj 62ae115bc7Smrj/* 63ae115bc7Smrj * kdi_idt_patch will, on certain processors, replace the patch points below 64ae115bc7Smrj * with MSR-clearing code. kdi_id_patch has intimate knowledge of the size of 65ae115bc7Smrj * the nop hole, as well as the structure of the handlers. Do not change 66ae115bc7Smrj * anything here without also changing kdi_idt_patch. 67ae115bc7Smrj */ 68ae115bc7Smrj 69ae115bc7Smrj/* 70ae115bc7Smrj * Generic trap and interrupt handlers. 71ae115bc7Smrj */ 72ae115bc7Smrj 73*843e1988Sjohnlev#if defined(__xpv) && defined(__amd64) 74*843e1988Sjohnlev 75*843e1988Sjohnlev/* 76*843e1988Sjohnlev * The hypervisor places r11 and rcx on the stack. 77*843e1988Sjohnlev */ 78*843e1988Sjohnlev 79*843e1988Sjohnlev#define TRAP_NOERR(trapno) \ 80*843e1988Sjohnlev popq %rcx; \ 81*843e1988Sjohnlev popq %r11; \ 82*843e1988Sjohnlev pushq $trapno 83*843e1988Sjohnlev 84*843e1988Sjohnlev#define TRAP_ERR(trapno) \ 85*843e1988Sjohnlev popq %rcx; \ 86*843e1988Sjohnlev popq %r11; \ 87*843e1988Sjohnlev pushq $0; \ 88*843e1988Sjohnlev pushq $trapno 89*843e1988Sjohnlev 90*843e1988Sjohnlev#else 91*843e1988Sjohnlev 92ae115bc7Smrj#define TRAP_NOERR(trapno) \ 93ae115bc7Smrj push $trapno 94ae115bc7Smrj 95ae115bc7Smrj#define TRAP_ERR(trapno) \ 96ae115bc7Smrj push $0; \ 97ae115bc7Smrj push $trapno 98ae115bc7Smrj 99*843e1988Sjohnlev#endif /* __xpv && __amd64 */ 100*843e1988Sjohnlev 101*843e1988Sjohnlev 102ae115bc7Smrj#define MKIVCT(n) \ 103ae115bc7Smrj ENTRY_NP(kdi_ivct/**/n/**/); \ 104ae115bc7Smrj TRAP_ERR(n); \ 105ae115bc7Smrj .align KDI_MSR_PATCHOFF; \ 106ae115bc7Smrj KDI_MSR_PATCH; \ 107ae115bc7Smrj jmp kdi_cmnint; \ 108ae115bc7Smrj SET_SIZE(kdi_ivct/**/n/**/) 109ae115bc7Smrj 110ae115bc7Smrj#define MKTRAPHDLR(n) \ 111ae115bc7Smrj ENTRY_NP(kdi_trap/**/n); \ 112ae115bc7Smrj TRAP_ERR(n); \ 113ae115bc7Smrj .align KDI_MSR_PATCHOFF; \ 114ae115bc7Smrj KDI_MSR_PATCH; \ 115ae115bc7Smrj jmp kdi_cmnint; \ 116ae115bc7Smrj SET_SIZE(kdi_trap/**/n/**/) 117ae115bc7Smrj 118ae115bc7Smrj#define MKTRAPERRHDLR(n) \ 119ae115bc7Smrj ENTRY_NP(kdi_traperr/**/n); \ 120ae115bc7Smrj TRAP_NOERR(n); \ 121ae115bc7Smrj .align KDI_MSR_PATCHOFF; \ 122ae115bc7Smrj KDI_MSR_PATCH; \ 123ae115bc7Smrj jmp kdi_cmnint; \ 124ae115bc7Smrj SET_SIZE(kdi_traperr/**/n) 125ae115bc7Smrj 126ae115bc7Smrj#define MKNMIHDLR \ 127ae115bc7Smrj ENTRY_NP(kdi_int2); \ 128ae115bc7Smrj TRAP_NOERR(2); \ 129ae115bc7Smrj .align KDI_MSR_PATCHOFF; \ 130ae115bc7Smrj KDI_MSR_PATCH; \ 131ae115bc7Smrj jmp kdi_nmiint; \ 132ae115bc7Smrj SET_SIZE(kdi_int2) 133ae115bc7Smrj 134ae115bc7Smrj#define MKINVALHDLR \ 135ae115bc7Smrj ENTRY_NP(kdi_invaltrap); \ 136ae115bc7Smrj TRAP_NOERR(255); \ 137ae115bc7Smrj .align KDI_MSR_PATCHOFF; \ 138ae115bc7Smrj KDI_MSR_PATCH; \ 139ae115bc7Smrj jmp kdi_cmnint; \ 140ae115bc7Smrj SET_SIZE(kdi_invaltrap) 141ae115bc7Smrj 142ae115bc7Smrj/* 143ae115bc7Smrj * The handlers themselves 144ae115bc7Smrj */ 145ae115bc7Smrj 146ae115bc7Smrj MKINVALHDLR 147ae115bc7Smrj MKTRAPHDLR(0) 148ae115bc7Smrj MKTRAPHDLR(1) 149ae115bc7Smrj MKNMIHDLR/*2*/ 150ae115bc7Smrj MKTRAPHDLR(3) 151ae115bc7Smrj MKTRAPHDLR(4) 152ae115bc7Smrj MKTRAPHDLR(5) 153ae115bc7Smrj MKTRAPHDLR(6) 154ae115bc7Smrj MKTRAPHDLR(7) 155ae115bc7Smrj MKTRAPHDLR(9) 156ae115bc7Smrj MKTRAPHDLR(15) 157ae115bc7Smrj MKTRAPHDLR(16) 158ae115bc7Smrj MKTRAPHDLR(17) 159ae115bc7Smrj MKTRAPHDLR(18) 160ae115bc7Smrj MKTRAPHDLR(19) 161ae115bc7Smrj MKTRAPHDLR(20) 162ae115bc7Smrj 163ae115bc7Smrj MKTRAPERRHDLR(8) 164ae115bc7Smrj MKTRAPERRHDLR(10) 165ae115bc7Smrj MKTRAPERRHDLR(11) 166ae115bc7Smrj MKTRAPERRHDLR(12) 167ae115bc7Smrj MKTRAPERRHDLR(13) 168ae115bc7Smrj MKTRAPERRHDLR(14) 169ae115bc7Smrj 170ae115bc7Smrj .globl kdi_ivct_size 171ae115bc7Smrjkdi_ivct_size: 172ae115bc7Smrj .NWORD [kdi_ivct33-kdi_ivct32] 173ae115bc7Smrj 174ae115bc7Smrj /* 10 billion and one interrupt handlers */ 175ae115bc7Smrjkdi_ivct_base: 176ae115bc7Smrj MKIVCT(32); MKIVCT(33); MKIVCT(34); MKIVCT(35); 177ae115bc7Smrj MKIVCT(36); MKIVCT(37); MKIVCT(38); MKIVCT(39); 178ae115bc7Smrj MKIVCT(40); MKIVCT(41); MKIVCT(42); MKIVCT(43); 179ae115bc7Smrj MKIVCT(44); MKIVCT(45); MKIVCT(46); MKIVCT(47); 180ae115bc7Smrj MKIVCT(48); MKIVCT(49); MKIVCT(50); MKIVCT(51); 181ae115bc7Smrj MKIVCT(52); MKIVCT(53); MKIVCT(54); MKIVCT(55); 182ae115bc7Smrj MKIVCT(56); MKIVCT(57); MKIVCT(58); MKIVCT(59); 183ae115bc7Smrj MKIVCT(60); MKIVCT(61); MKIVCT(62); MKIVCT(63); 184ae115bc7Smrj MKIVCT(64); MKIVCT(65); MKIVCT(66); MKIVCT(67); 185ae115bc7Smrj MKIVCT(68); MKIVCT(69); MKIVCT(70); MKIVCT(71); 186ae115bc7Smrj MKIVCT(72); MKIVCT(73); MKIVCT(74); MKIVCT(75); 187ae115bc7Smrj MKIVCT(76); MKIVCT(77); MKIVCT(78); MKIVCT(79); 188ae115bc7Smrj MKIVCT(80); MKIVCT(81); MKIVCT(82); MKIVCT(83); 189ae115bc7Smrj MKIVCT(84); MKIVCT(85); MKIVCT(86); MKIVCT(87); 190ae115bc7Smrj MKIVCT(88); MKIVCT(89); MKIVCT(90); MKIVCT(91); 191ae115bc7Smrj MKIVCT(92); MKIVCT(93); MKIVCT(94); MKIVCT(95); 192ae115bc7Smrj MKIVCT(96); MKIVCT(97); MKIVCT(98); MKIVCT(99); 193ae115bc7Smrj MKIVCT(100); MKIVCT(101); MKIVCT(102); MKIVCT(103); 194ae115bc7Smrj MKIVCT(104); MKIVCT(105); MKIVCT(106); MKIVCT(107); 195ae115bc7Smrj MKIVCT(108); MKIVCT(109); MKIVCT(110); MKIVCT(111); 196ae115bc7Smrj MKIVCT(112); MKIVCT(113); MKIVCT(114); MKIVCT(115); 197ae115bc7Smrj MKIVCT(116); MKIVCT(117); MKIVCT(118); MKIVCT(119); 198ae115bc7Smrj MKIVCT(120); MKIVCT(121); MKIVCT(122); MKIVCT(123); 199ae115bc7Smrj MKIVCT(124); MKIVCT(125); MKIVCT(126); MKIVCT(127); 200ae115bc7Smrj MKIVCT(128); MKIVCT(129); MKIVCT(130); MKIVCT(131); 201ae115bc7Smrj MKIVCT(132); MKIVCT(133); MKIVCT(134); MKIVCT(135); 202ae115bc7Smrj MKIVCT(136); MKIVCT(137); MKIVCT(138); MKIVCT(139); 203ae115bc7Smrj MKIVCT(140); MKIVCT(141); MKIVCT(142); MKIVCT(143); 204ae115bc7Smrj MKIVCT(144); MKIVCT(145); MKIVCT(146); MKIVCT(147); 205ae115bc7Smrj MKIVCT(148); MKIVCT(149); MKIVCT(150); MKIVCT(151); 206ae115bc7Smrj MKIVCT(152); MKIVCT(153); MKIVCT(154); MKIVCT(155); 207ae115bc7Smrj MKIVCT(156); MKIVCT(157); MKIVCT(158); MKIVCT(159); 208ae115bc7Smrj MKIVCT(160); MKIVCT(161); MKIVCT(162); MKIVCT(163); 209ae115bc7Smrj MKIVCT(164); MKIVCT(165); MKIVCT(166); MKIVCT(167); 210ae115bc7Smrj MKIVCT(168); MKIVCT(169); MKIVCT(170); MKIVCT(171); 211ae115bc7Smrj MKIVCT(172); MKIVCT(173); MKIVCT(174); MKIVCT(175); 212ae115bc7Smrj MKIVCT(176); MKIVCT(177); MKIVCT(178); MKIVCT(179); 213ae115bc7Smrj MKIVCT(180); MKIVCT(181); MKIVCT(182); MKIVCT(183); 214ae115bc7Smrj MKIVCT(184); MKIVCT(185); MKIVCT(186); MKIVCT(187); 215ae115bc7Smrj MKIVCT(188); MKIVCT(189); MKIVCT(190); MKIVCT(191); 216ae115bc7Smrj MKIVCT(192); MKIVCT(193); MKIVCT(194); MKIVCT(195); 217ae115bc7Smrj MKIVCT(196); MKIVCT(197); MKIVCT(198); MKIVCT(199); 218ae115bc7Smrj MKIVCT(200); MKIVCT(201); MKIVCT(202); MKIVCT(203); 219ae115bc7Smrj MKIVCT(204); MKIVCT(205); MKIVCT(206); MKIVCT(207); 220ae115bc7Smrj MKIVCT(208); MKIVCT(209); MKIVCT(210); MKIVCT(211); 221ae115bc7Smrj MKIVCT(212); MKIVCT(213); MKIVCT(214); MKIVCT(215); 222ae115bc7Smrj MKIVCT(216); MKIVCT(217); MKIVCT(218); MKIVCT(219); 223ae115bc7Smrj MKIVCT(220); MKIVCT(221); MKIVCT(222); MKIVCT(223); 224ae115bc7Smrj MKIVCT(224); MKIVCT(225); MKIVCT(226); MKIVCT(227); 225ae115bc7Smrj MKIVCT(228); MKIVCT(229); MKIVCT(230); MKIVCT(231); 226ae115bc7Smrj MKIVCT(232); MKIVCT(233); MKIVCT(234); MKIVCT(235); 227ae115bc7Smrj MKIVCT(236); MKIVCT(237); MKIVCT(238); MKIVCT(239); 228ae115bc7Smrj MKIVCT(240); MKIVCT(241); MKIVCT(242); MKIVCT(243); 229ae115bc7Smrj MKIVCT(244); MKIVCT(245); MKIVCT(246); MKIVCT(247); 230ae115bc7Smrj MKIVCT(248); MKIVCT(249); MKIVCT(250); MKIVCT(251); 231ae115bc7Smrj MKIVCT(252); MKIVCT(253); MKIVCT(254); MKIVCT(255); 232ae115bc7Smrj 233ae115bc7Smrj#endif 234