18aa34ab8SBenjamin Herrenschmidt #ifndef _ASM_POWERPC_EXCEPTION_H 28aa34ab8SBenjamin Herrenschmidt #define _ASM_POWERPC_EXCEPTION_H 38aa34ab8SBenjamin Herrenschmidt /* 48aa34ab8SBenjamin Herrenschmidt * Extracted from head_64.S 58aa34ab8SBenjamin Herrenschmidt * 68aa34ab8SBenjamin Herrenschmidt * PowerPC version 78aa34ab8SBenjamin Herrenschmidt * Copyright (C) 1995-1996 Gary Thomas (gdt@linuxppc.org) 88aa34ab8SBenjamin Herrenschmidt * 98aa34ab8SBenjamin Herrenschmidt * Rewritten by Cort Dougan (cort@cs.nmt.edu) for PReP 108aa34ab8SBenjamin Herrenschmidt * Copyright (C) 1996 Cort Dougan <cort@cs.nmt.edu> 118aa34ab8SBenjamin Herrenschmidt * Adapted for Power Macintosh by Paul Mackerras. 128aa34ab8SBenjamin Herrenschmidt * Low-level exception handlers and MMU support 138aa34ab8SBenjamin Herrenschmidt * rewritten by Paul Mackerras. 148aa34ab8SBenjamin Herrenschmidt * Copyright (C) 1996 Paul Mackerras. 158aa34ab8SBenjamin Herrenschmidt * 168aa34ab8SBenjamin Herrenschmidt * Adapted for 64bit PowerPC by Dave Engebretsen, Peter Bergner, and 178aa34ab8SBenjamin Herrenschmidt * Mike Corrigan {engebret|bergner|mikejc}@us.ibm.com 188aa34ab8SBenjamin Herrenschmidt * 198aa34ab8SBenjamin Herrenschmidt * This file contains the low-level support and setup for the 208aa34ab8SBenjamin Herrenschmidt * PowerPC-64 platform, including trap and interrupt dispatch. 218aa34ab8SBenjamin Herrenschmidt * 228aa34ab8SBenjamin Herrenschmidt * This program is free software; you can redistribute it and/or 238aa34ab8SBenjamin Herrenschmidt * modify it under the terms of the GNU General Public License 248aa34ab8SBenjamin Herrenschmidt * as published by the Free Software Foundation; either version 258aa34ab8SBenjamin Herrenschmidt * 2 of the License, or (at your option) any later version. 268aa34ab8SBenjamin Herrenschmidt */ 278aa34ab8SBenjamin Herrenschmidt /* 288aa34ab8SBenjamin Herrenschmidt * The following macros define the code that appears as 298aa34ab8SBenjamin Herrenschmidt * the prologue to each of the exception handlers. They 308aa34ab8SBenjamin Herrenschmidt * are split into two parts to allow a single kernel binary 318aa34ab8SBenjamin Herrenschmidt * to be used for pSeries and iSeries. 328aa34ab8SBenjamin Herrenschmidt * 338aa34ab8SBenjamin Herrenschmidt * We make as much of the exception code common between native 348aa34ab8SBenjamin Herrenschmidt * exception handlers (including pSeries LPAR) and iSeries LPAR 358aa34ab8SBenjamin Herrenschmidt * implementations as possible. 368aa34ab8SBenjamin Herrenschmidt */ 37da2bc464SMichael Ellerman #include <asm/head-64.h> 388aa34ab8SBenjamin Herrenschmidt 398aa34ab8SBenjamin Herrenschmidt #define EX_R9 0 408aa34ab8SBenjamin Herrenschmidt #define EX_R10 8 418aa34ab8SBenjamin Herrenschmidt #define EX_R11 16 428aa34ab8SBenjamin Herrenschmidt #define EX_R12 24 438aa34ab8SBenjamin Herrenschmidt #define EX_R13 32 448aa34ab8SBenjamin Herrenschmidt #define EX_SRR0 40 458aa34ab8SBenjamin Herrenschmidt #define EX_DAR 48 468aa34ab8SBenjamin Herrenschmidt #define EX_DSISR 56 478aa34ab8SBenjamin Herrenschmidt #define EX_CCR 60 488aa34ab8SBenjamin Herrenschmidt #define EX_R3 64 498aa34ab8SBenjamin Herrenschmidt #define EX_LR 72 5048404f2eSPaul Mackerras #define EX_CFAR 80 51a09688cdSHaren Myneni #define EX_PPR 88 /* SMT thread status register (priority) */ 52bc2e6c6aSMichael Neuling #define EX_CTR 96 538aa34ab8SBenjamin Herrenschmidt 544700dfafSMichael Neuling #ifdef CONFIG_RELOCATABLE 551707dd16SPaul Mackerras #define __EXCEPTION_RELON_PROLOG_PSERIES_1(label, h) \ 564700dfafSMichael Neuling mfspr r11,SPRN_##h##SRR0; /* save SRR0 */ \ 574700dfafSMichael Neuling LOAD_HANDLER(r12,label); \ 58bc2e6c6aSMichael Neuling mtctr r12; \ 594700dfafSMichael Neuling mfspr r12,SPRN_##h##SRR1; /* and SRR1 */ \ 604700dfafSMichael Neuling li r10,MSR_RI; \ 614700dfafSMichael Neuling mtmsrd r10,1; /* Set RI (EE=0) */ \ 62bc2e6c6aSMichael Neuling bctr; 634700dfafSMichael Neuling #else 644700dfafSMichael Neuling /* If not relocatable, we can jump directly -- and save messing with LR */ 651707dd16SPaul Mackerras #define __EXCEPTION_RELON_PROLOG_PSERIES_1(label, h) \ 664700dfafSMichael Neuling mfspr r11,SPRN_##h##SRR0; /* save SRR0 */ \ 674700dfafSMichael Neuling mfspr r12,SPRN_##h##SRR1; /* and SRR1 */ \ 684700dfafSMichael Neuling li r10,MSR_RI; \ 694700dfafSMichael Neuling mtmsrd r10,1; /* Set RI (EE=0) */ \ 704700dfafSMichael Neuling b label; 714700dfafSMichael Neuling #endif 721707dd16SPaul Mackerras #define EXCEPTION_RELON_PROLOG_PSERIES_1(label, h) \ 731707dd16SPaul Mackerras __EXCEPTION_RELON_PROLOG_PSERIES_1(label, h) \ 744700dfafSMichael Neuling 754700dfafSMichael Neuling /* 764700dfafSMichael Neuling * As EXCEPTION_PROLOG_PSERIES(), except we've already got relocation on 774700dfafSMichael Neuling * so no need to rfid. Save lr in case we're CONFIG_RELOCATABLE, in which 784700dfafSMichael Neuling * case EXCEPTION_RELON_PROLOG_PSERIES_1 will be using lr. 794700dfafSMichael Neuling */ 804700dfafSMichael Neuling #define EXCEPTION_RELON_PROLOG_PSERIES(area, label, h, extra, vec) \ 811707dd16SPaul Mackerras EXCEPTION_PROLOG_0(area); \ 824700dfafSMichael Neuling EXCEPTION_PROLOG_1(area, extra, vec); \ 834700dfafSMichael Neuling EXCEPTION_RELON_PROLOG_PSERIES_1(label, h) 844700dfafSMichael Neuling 858aa34ab8SBenjamin Herrenschmidt /* 868aa34ab8SBenjamin Herrenschmidt * We're short on space and time in the exception prolog, so we can't 8727510235SMichael Ellerman * use the normal LOAD_REG_IMMEDIATE macro to load the address of label. 8827510235SMichael Ellerman * Instead we get the base of the kernel from paca->kernelbase and or in the low 8927510235SMichael Ellerman * part of label. This requires that the label be within 64KB of kernelbase, and 9027510235SMichael Ellerman * that kernelbase be 64K aligned. 918aa34ab8SBenjamin Herrenschmidt */ 928aa34ab8SBenjamin Herrenschmidt #define LOAD_HANDLER(reg, label) \ 93d8d42b05SMichael Ellerman ld reg,PACAKBASE(r13); /* get high part of &label */ \ 94e6740ae6SHugh Dickins ori reg,reg,FIXED_SYMBOL_ABS_ADDR(label); 958aa34ab8SBenjamin Herrenschmidt 96fb479e44SNicholas Piggin #define __LOAD_HANDLER(reg, label) \ 97fb479e44SNicholas Piggin ld reg,PACAKBASE(r13); \ 98fb479e44SNicholas Piggin ori reg,reg,(ABS_ADDR(label))@l; 99fb479e44SNicholas Piggin 100a97a65d5SNicholas Piggin /* 101a97a65d5SNicholas Piggin * Branches from unrelocated code (e.g., interrupts) to labels outside 102a97a65d5SNicholas Piggin * head-y require >64K offsets. 103a97a65d5SNicholas Piggin */ 104a97a65d5SNicholas Piggin #define __LOAD_FAR_HANDLER(reg, label) \ 105a97a65d5SNicholas Piggin ld reg,PACAKBASE(r13); \ 106a97a65d5SNicholas Piggin ori reg,reg,(ABS_ADDR(label))@l; \ 107a97a65d5SNicholas Piggin addis reg,reg,(ABS_ADDR(label))@h; 108a97a65d5SNicholas Piggin 109a5d4f3adSBenjamin Herrenschmidt /* Exception register prefixes */ 110a5d4f3adSBenjamin Herrenschmidt #define EXC_HV H 111a5d4f3adSBenjamin Herrenschmidt #define EXC_STD 112a5d4f3adSBenjamin Herrenschmidt 1134700dfafSMichael Neuling #if defined(CONFIG_RELOCATABLE) 1144700dfafSMichael Neuling /* 115bc2e6c6aSMichael Neuling * If we support interrupts with relocation on AND we're a relocatable kernel, 116bc2e6c6aSMichael Neuling * we need to use CTR to get to the 2nd level handler. So, save/restore it 117bc2e6c6aSMichael Neuling * when required. 1184700dfafSMichael Neuling */ 119bc2e6c6aSMichael Neuling #define SAVE_CTR(reg, area) mfctr reg ; std reg,area+EX_CTR(r13) 120bc2e6c6aSMichael Neuling #define GET_CTR(reg, area) ld reg,area+EX_CTR(r13) 121bc2e6c6aSMichael Neuling #define RESTORE_CTR(reg, area) ld reg,area+EX_CTR(r13) ; mtctr reg 1224700dfafSMichael Neuling #else 123bc2e6c6aSMichael Neuling /* ...else CTR is unused and in register. */ 124bc2e6c6aSMichael Neuling #define SAVE_CTR(reg, area) 125bc2e6c6aSMichael Neuling #define GET_CTR(reg, area) mfctr reg 126bc2e6c6aSMichael Neuling #define RESTORE_CTR(reg, area) 1274700dfafSMichael Neuling #endif 1284700dfafSMichael Neuling 12913e7a8e8SHaren Myneni /* 13013e7a8e8SHaren Myneni * PPR save/restore macros used in exceptions_64s.S 13113e7a8e8SHaren Myneni * Used for P7 or later processors 13213e7a8e8SHaren Myneni */ 13313e7a8e8SHaren Myneni #define SAVE_PPR(area, ra, rb) \ 13413e7a8e8SHaren Myneni BEGIN_FTR_SECTION_NESTED(940) \ 13513e7a8e8SHaren Myneni ld ra,PACACURRENT(r13); \ 13613e7a8e8SHaren Myneni ld rb,area+EX_PPR(r13); /* Read PPR from paca */ \ 13713e7a8e8SHaren Myneni std rb,TASKTHREADPPR(ra); \ 13813e7a8e8SHaren Myneni END_FTR_SECTION_NESTED(CPU_FTR_HAS_PPR,CPU_FTR_HAS_PPR,940) 13913e7a8e8SHaren Myneni 14013e7a8e8SHaren Myneni #define RESTORE_PPR_PACA(area, ra) \ 14113e7a8e8SHaren Myneni BEGIN_FTR_SECTION_NESTED(941) \ 14213e7a8e8SHaren Myneni ld ra,area+EX_PPR(r13); \ 14313e7a8e8SHaren Myneni mtspr SPRN_PPR,ra; \ 14413e7a8e8SHaren Myneni END_FTR_SECTION_NESTED(CPU_FTR_HAS_PPR,CPU_FTR_HAS_PPR,941) 14513e7a8e8SHaren Myneni 14613e7a8e8SHaren Myneni /* 1471707dd16SPaul Mackerras * Get an SPR into a register if the CPU has the given feature 14813e7a8e8SHaren Myneni */ 1491707dd16SPaul Mackerras #define OPT_GET_SPR(ra, spr, ftr) \ 15013e7a8e8SHaren Myneni BEGIN_FTR_SECTION_NESTED(943) \ 1511707dd16SPaul Mackerras mfspr ra,spr; \ 1521707dd16SPaul Mackerras END_FTR_SECTION_NESTED(ftr,ftr,943) 15313e7a8e8SHaren Myneni 1541707dd16SPaul Mackerras /* 155d410ae21SMahesh Salgaonkar * Set an SPR from a register if the CPU has the given feature 156d410ae21SMahesh Salgaonkar */ 157d410ae21SMahesh Salgaonkar #define OPT_SET_SPR(ra, spr, ftr) \ 158d410ae21SMahesh Salgaonkar BEGIN_FTR_SECTION_NESTED(943) \ 159d410ae21SMahesh Salgaonkar mtspr spr,ra; \ 160d410ae21SMahesh Salgaonkar END_FTR_SECTION_NESTED(ftr,ftr,943) 161d410ae21SMahesh Salgaonkar 162d410ae21SMahesh Salgaonkar /* 1631707dd16SPaul Mackerras * Save a register to the PACA if the CPU has the given feature 1641707dd16SPaul Mackerras */ 1651707dd16SPaul Mackerras #define OPT_SAVE_REG_TO_PACA(offset, ra, ftr) \ 1661707dd16SPaul Mackerras BEGIN_FTR_SECTION_NESTED(943) \ 1671707dd16SPaul Mackerras std ra,offset(r13); \ 1681707dd16SPaul Mackerras END_FTR_SECTION_NESTED(ftr,ftr,943) 1691707dd16SPaul Mackerras 170544686caSNicholas Piggin #define EXCEPTION_PROLOG_0(area) \ 171544686caSNicholas Piggin GET_PACA(r13); \ 17244e9309fSHaren Myneni std r9,area+EX_R9(r13); /* save r9 */ \ 1731707dd16SPaul Mackerras OPT_GET_SPR(r9, SPRN_PPR, CPU_FTR_HAS_PPR); \ 1741707dd16SPaul Mackerras HMT_MEDIUM; \ 17544e9309fSHaren Myneni std r10,area+EX_R10(r13); /* save r10 - r12 */ \ 1761707dd16SPaul Mackerras OPT_GET_SPR(r10, SPRN_CFAR, CPU_FTR_CFAR) 1771707dd16SPaul Mackerras 1781707dd16SPaul Mackerras #define __EXCEPTION_PROLOG_1(area, extra, vec) \ 1791707dd16SPaul Mackerras OPT_SAVE_REG_TO_PACA(area+EX_PPR, r9, CPU_FTR_HAS_PPR); \ 1801707dd16SPaul Mackerras OPT_SAVE_REG_TO_PACA(area+EX_CFAR, r10, CPU_FTR_CFAR); \ 181bc2e6c6aSMichael Neuling SAVE_CTR(r10, area); \ 182b01c8b54SPaul Mackerras mfcr r9; \ 183b01c8b54SPaul Mackerras extra(vec); \ 184b01c8b54SPaul Mackerras std r11,area+EX_R11(r13); \ 185b01c8b54SPaul Mackerras std r12,area+EX_R12(r13); \ 186b01c8b54SPaul Mackerras GET_SCRATCH0(r10); \ 187b01c8b54SPaul Mackerras std r10,area+EX_R13(r13) 188b01c8b54SPaul Mackerras #define EXCEPTION_PROLOG_1(area, extra, vec) \ 189b01c8b54SPaul Mackerras __EXCEPTION_PROLOG_1(area, extra, vec) 1908aa34ab8SBenjamin Herrenschmidt 191a5d4f3adSBenjamin Herrenschmidt #define __EXCEPTION_PROLOG_PSERIES_1(label, h) \ 1928aa34ab8SBenjamin Herrenschmidt ld r10,PACAKMSR(r13); /* get MSR value for kernel */ \ 193a5d4f3adSBenjamin Herrenschmidt mfspr r11,SPRN_##h##SRR0; /* save SRR0 */ \ 1948aa34ab8SBenjamin Herrenschmidt LOAD_HANDLER(r12,label) \ 195a5d4f3adSBenjamin Herrenschmidt mtspr SPRN_##h##SRR0,r12; \ 196a5d4f3adSBenjamin Herrenschmidt mfspr r12,SPRN_##h##SRR1; /* and SRR1 */ \ 197a5d4f3adSBenjamin Herrenschmidt mtspr SPRN_##h##SRR1,r10; \ 198a5d4f3adSBenjamin Herrenschmidt h##rfid; \ 1998aa34ab8SBenjamin Herrenschmidt b . /* prevent speculative execution */ 200a5d4f3adSBenjamin Herrenschmidt #define EXCEPTION_PROLOG_PSERIES_1(label, h) \ 201a5d4f3adSBenjamin Herrenschmidt __EXCEPTION_PROLOG_PSERIES_1(label, h) 2028aa34ab8SBenjamin Herrenschmidt 20383a980f7SNicholas Piggin /* _NORI variant keeps MSR_RI clear */ 20483a980f7SNicholas Piggin #define __EXCEPTION_PROLOG_PSERIES_1_NORI(label, h) \ 20583a980f7SNicholas Piggin ld r10,PACAKMSR(r13); /* get MSR value for kernel */ \ 20683a980f7SNicholas Piggin xori r10,r10,MSR_RI; /* Clear MSR_RI */ \ 20783a980f7SNicholas Piggin mfspr r11,SPRN_##h##SRR0; /* save SRR0 */ \ 20883a980f7SNicholas Piggin LOAD_HANDLER(r12,label) \ 20983a980f7SNicholas Piggin mtspr SPRN_##h##SRR0,r12; \ 21083a980f7SNicholas Piggin mfspr r12,SPRN_##h##SRR1; /* and SRR1 */ \ 21183a980f7SNicholas Piggin mtspr SPRN_##h##SRR1,r10; \ 21283a980f7SNicholas Piggin h##rfid; \ 21383a980f7SNicholas Piggin b . /* prevent speculative execution */ 21483a980f7SNicholas Piggin 21583a980f7SNicholas Piggin #define EXCEPTION_PROLOG_PSERIES_1_NORI(label, h) \ 21683a980f7SNicholas Piggin __EXCEPTION_PROLOG_PSERIES_1_NORI(label, h) 21783a980f7SNicholas Piggin 218b01c8b54SPaul Mackerras #define EXCEPTION_PROLOG_PSERIES(area, label, h, extra, vec) \ 2191707dd16SPaul Mackerras EXCEPTION_PROLOG_0(area); \ 220b01c8b54SPaul Mackerras EXCEPTION_PROLOG_1(area, extra, vec); \ 221a5d4f3adSBenjamin Herrenschmidt EXCEPTION_PROLOG_PSERIES_1(label, h); 222c5a8c0c9SBenjamin Herrenschmidt 223da2bc464SMichael Ellerman #define __KVMTEST(h, n) \ 2243c42bf8aSPaul Mackerras lbz r10,HSTATE_IN_GUEST(r13); \ 225b01c8b54SPaul Mackerras cmpwi r10,0; \ 226da2bc464SMichael Ellerman bne do_kvm_##h##n 227b01c8b54SPaul Mackerras 228dd96b2c2SAneesh Kumar K.V #ifdef CONFIG_KVM_BOOK3S_HV_POSSIBLE 229dd96b2c2SAneesh Kumar K.V /* 230dd96b2c2SAneesh Kumar K.V * If hv is possible, interrupts come into to the hv version 231dd96b2c2SAneesh Kumar K.V * of the kvmppc_interrupt code, which then jumps to the PR handler, 232dd96b2c2SAneesh Kumar K.V * kvmppc_interrupt_pr, if the guest is a PR guest. 233dd96b2c2SAneesh Kumar K.V */ 234dd96b2c2SAneesh Kumar K.V #define kvmppc_interrupt kvmppc_interrupt_hv 235dd96b2c2SAneesh Kumar K.V #else 236dd96b2c2SAneesh Kumar K.V #define kvmppc_interrupt kvmppc_interrupt_pr 237dd96b2c2SAneesh Kumar K.V #endif 238dd96b2c2SAneesh Kumar K.V 239fb479e44SNicholas Piggin #ifdef CONFIG_RELOCATABLE 240fb479e44SNicholas Piggin #define BRANCH_TO_COMMON(reg, label) \ 241fb479e44SNicholas Piggin __LOAD_HANDLER(reg, label); \ 242fb479e44SNicholas Piggin mtctr reg; \ 243fb479e44SNicholas Piggin bctr 244fb479e44SNicholas Piggin 2452337d207SNicholas Piggin #define BRANCH_LINK_TO_FAR(reg, label) \ 2462337d207SNicholas Piggin __LOAD_FAR_HANDLER(reg, label); \ 2472337d207SNicholas Piggin mtctr reg; \ 2482337d207SNicholas Piggin bctrl 2492337d207SNicholas Piggin 250a97a65d5SNicholas Piggin /* 251a97a65d5SNicholas Piggin * KVM requires __LOAD_FAR_HANDLER. 252a97a65d5SNicholas Piggin * 253a97a65d5SNicholas Piggin * __BRANCH_TO_KVM_EXIT branches are also a special case because they 254a97a65d5SNicholas Piggin * explicitly use r9 then reload it from PACA before branching. Hence 255a97a65d5SNicholas Piggin * the double-underscore. 256a97a65d5SNicholas Piggin */ 257a97a65d5SNicholas Piggin #define __BRANCH_TO_KVM_EXIT(area, label) \ 258a97a65d5SNicholas Piggin mfctr r9; \ 259a97a65d5SNicholas Piggin std r9,HSTATE_SCRATCH1(r13); \ 260a97a65d5SNicholas Piggin __LOAD_FAR_HANDLER(r9, label); \ 261a97a65d5SNicholas Piggin mtctr r9; \ 262a97a65d5SNicholas Piggin ld r9,area+EX_R9(r13); \ 263a97a65d5SNicholas Piggin bctr 264a97a65d5SNicholas Piggin 265fb479e44SNicholas Piggin #else 266fb479e44SNicholas Piggin #define BRANCH_TO_COMMON(reg, label) \ 267fb479e44SNicholas Piggin b label 268fb479e44SNicholas Piggin 2692337d207SNicholas Piggin #define BRANCH_LINK_TO_FAR(reg, label) \ 2702337d207SNicholas Piggin bl label 2712337d207SNicholas Piggin 272a97a65d5SNicholas Piggin #define __BRANCH_TO_KVM_EXIT(area, label) \ 273a97a65d5SNicholas Piggin ld r9,area+EX_R9(r13); \ 274a97a65d5SNicholas Piggin b label 275a97a65d5SNicholas Piggin 276fb479e44SNicholas Piggin #endif 277fb479e44SNicholas Piggin 278c4f3b52cSNicholas Piggin /* Do not enable RI */ 279c4f3b52cSNicholas Piggin #define EXCEPTION_PROLOG_PSERIES_NORI(area, label, h, extra, vec) \ 280c4f3b52cSNicholas Piggin EXCEPTION_PROLOG_0(area); \ 281c4f3b52cSNicholas Piggin EXCEPTION_PROLOG_1(area, extra, vec); \ 282c4f3b52cSNicholas Piggin EXCEPTION_PROLOG_PSERIES_1_NORI(label, h); 283c4f3b52cSNicholas Piggin 284a97a65d5SNicholas Piggin 285d3918e7fSNicholas Piggin #define __KVM_HANDLER(area, h, n) \ 2860acb9111SPaul Mackerras BEGIN_FTR_SECTION_NESTED(947) \ 2870acb9111SPaul Mackerras ld r10,area+EX_CFAR(r13); \ 2880acb9111SPaul Mackerras std r10,HSTATE_CFAR(r13); \ 2890acb9111SPaul Mackerras END_FTR_SECTION_NESTED(CPU_FTR_CFAR,CPU_FTR_CFAR,947); \ 2904b8473c9SPaul Mackerras BEGIN_FTR_SECTION_NESTED(948) \ 2914b8473c9SPaul Mackerras ld r10,area+EX_PPR(r13); \ 2924b8473c9SPaul Mackerras std r10,HSTATE_PPR(r13); \ 2934b8473c9SPaul Mackerras END_FTR_SECTION_NESTED(CPU_FTR_HAS_PPR,CPU_FTR_HAS_PPR,948); \ 294b01c8b54SPaul Mackerras ld r10,area+EX_R10(r13); \ 2953c42bf8aSPaul Mackerras std r12,HSTATE_SCRATCH0(r13); \ 296d3918e7fSNicholas Piggin sldi r12,r9,32; \ 297d3918e7fSNicholas Piggin ori r12,r12,(n); \ 298a97a65d5SNicholas Piggin /* This reloads r9 before branching to kvmppc_interrupt */ \ 299a97a65d5SNicholas Piggin __BRANCH_TO_KVM_EXIT(area, kvmppc_interrupt) 300b01c8b54SPaul Mackerras 301b01c8b54SPaul Mackerras #define __KVM_HANDLER_SKIP(area, h, n) \ 302b01c8b54SPaul Mackerras cmpwi r10,KVM_GUEST_MODE_SKIP; \ 303b01c8b54SPaul Mackerras beq 89f; \ 3044b8473c9SPaul Mackerras BEGIN_FTR_SECTION_NESTED(948) \ 305d3918e7fSNicholas Piggin ld r10,area+EX_PPR(r13); \ 306d3918e7fSNicholas Piggin std r10,HSTATE_PPR(r13); \ 3074b8473c9SPaul Mackerras END_FTR_SECTION_NESTED(CPU_FTR_HAS_PPR,CPU_FTR_HAS_PPR,948); \ 308d3918e7fSNicholas Piggin ld r10,area+EX_R10(r13); \ 3093c42bf8aSPaul Mackerras std r12,HSTATE_SCRATCH0(r13); \ 310d3918e7fSNicholas Piggin sldi r12,r9,32; \ 311d3918e7fSNicholas Piggin ori r12,r12,(n); \ 312a97a65d5SNicholas Piggin /* This reloads r9 before branching to kvmppc_interrupt */ \ 313a97a65d5SNicholas Piggin __BRANCH_TO_KVM_EXIT(area, kvmppc_interrupt); \ 314b01c8b54SPaul Mackerras 89: mtocrf 0x80,r9; \ 315b01c8b54SPaul Mackerras ld r9,area+EX_R9(r13); \ 316d3918e7fSNicholas Piggin ld r10,area+EX_R10(r13); \ 317b01c8b54SPaul Mackerras b kvmppc_skip_##h##interrupt 318b01c8b54SPaul Mackerras 319b01c8b54SPaul Mackerras #ifdef CONFIG_KVM_BOOK3S_64_HANDLER 320da2bc464SMichael Ellerman #define KVMTEST(h, n) __KVMTEST(h, n) 321b01c8b54SPaul Mackerras #define KVM_HANDLER(area, h, n) __KVM_HANDLER(area, h, n) 322b01c8b54SPaul Mackerras #define KVM_HANDLER_SKIP(area, h, n) __KVM_HANDLER_SKIP(area, h, n) 323b01c8b54SPaul Mackerras 324b01c8b54SPaul Mackerras #else 325da2bc464SMichael Ellerman #define KVMTEST(h, n) 326b01c8b54SPaul Mackerras #define KVM_HANDLER(area, h, n) 327b01c8b54SPaul Mackerras #define KVM_HANDLER_SKIP(area, h, n) 328b01c8b54SPaul Mackerras #endif 329b01c8b54SPaul Mackerras 330b01c8b54SPaul Mackerras #define NOTEST(n) 331b01c8b54SPaul Mackerras 332a4087a4dSNicholas Piggin #define EXCEPTION_PROLOG_COMMON_1() \ 333a4087a4dSNicholas Piggin std r9,_CCR(r1); /* save CR in stackframe */ \ 334a4087a4dSNicholas Piggin std r11,_NIP(r1); /* save SRR0 in stackframe */ \ 335a4087a4dSNicholas Piggin std r12,_MSR(r1); /* save SRR1 in stackframe */ \ 336a4087a4dSNicholas Piggin std r10,0(r1); /* make stack chain pointer */ \ 337a4087a4dSNicholas Piggin std r0,GPR0(r1); /* save r0 in stackframe */ \ 338a4087a4dSNicholas Piggin std r10,GPR1(r1); /* save r1 in stackframe */ \ 339a4087a4dSNicholas Piggin 340a4087a4dSNicholas Piggin 3418aa34ab8SBenjamin Herrenschmidt /* 3428aa34ab8SBenjamin Herrenschmidt * The common exception prolog is used for all except a few exceptions 3438aa34ab8SBenjamin Herrenschmidt * such as a segment miss on a kernel address. We have to be prepared 3448aa34ab8SBenjamin Herrenschmidt * to take another exception from the point where we first touch the 3458aa34ab8SBenjamin Herrenschmidt * kernel stack onwards. 3468aa34ab8SBenjamin Herrenschmidt * 3478aa34ab8SBenjamin Herrenschmidt * On entry r13 points to the paca, r9-r13 are saved in the paca, 3488aa34ab8SBenjamin Herrenschmidt * r9 contains the saved CR, r11 and r12 contain the saved SRR0 and 3498aa34ab8SBenjamin Herrenschmidt * SRR1, and relocation is on. 3508aa34ab8SBenjamin Herrenschmidt */ 3518aa34ab8SBenjamin Herrenschmidt #define EXCEPTION_PROLOG_COMMON(n, area) \ 3528aa34ab8SBenjamin Herrenschmidt andi. r10,r12,MSR_PR; /* See if coming from user */ \ 3538aa34ab8SBenjamin Herrenschmidt mr r10,r1; /* Save r1 */ \ 3548aa34ab8SBenjamin Herrenschmidt subi r1,r1,INT_FRAME_SIZE; /* alloc frame on kernel stack */ \ 3558aa34ab8SBenjamin Herrenschmidt beq- 1f; \ 3568aa34ab8SBenjamin Herrenschmidt ld r1,PACAKSAVE(r13); /* kernel stack to use */ \ 35790ff5d68SMichael Neuling 1: cmpdi cr1,r1,-INT_FRAME_SIZE; /* check if r1 is in userspace */ \ 3581977b502SPaul Mackerras blt+ cr1,3f; /* abort if it is */ \ 3591977b502SPaul Mackerras li r1,(n); /* will be reloaded later */ \ 3608aa34ab8SBenjamin Herrenschmidt sth r1,PACA_TRAP_SAVE(r13); \ 3611977b502SPaul Mackerras std r3,area+EX_R3(r13); \ 3621977b502SPaul Mackerras addi r3,r13,area; /* r3 -> where regs are saved*/ \ 363bc2e6c6aSMichael Neuling RESTORE_CTR(r1, area); \ 3648aa34ab8SBenjamin Herrenschmidt b bad_stack; \ 365a4087a4dSNicholas Piggin 3: EXCEPTION_PROLOG_COMMON_1(); \ 3665d75b264SHaren Myneni beq 4f; /* if from kernel mode */ \ 367c223c903SChristophe Leroy ACCOUNT_CPU_USER_ENTRY(r13, r9, r10); \ 36844e9309fSHaren Myneni SAVE_PPR(area, r9, r10); \ 369b14a7253SMahesh Salgaonkar 4: EXCEPTION_PROLOG_COMMON_2(area) \ 370b14a7253SMahesh Salgaonkar EXCEPTION_PROLOG_COMMON_3(n) \ 371b14a7253SMahesh Salgaonkar ACCOUNT_STOLEN_TIME 372b14a7253SMahesh Salgaonkar 373b14a7253SMahesh Salgaonkar /* Save original regs values from save area to stack frame. */ 374b14a7253SMahesh Salgaonkar #define EXCEPTION_PROLOG_COMMON_2(area) \ 3758aa34ab8SBenjamin Herrenschmidt ld r9,area+EX_R9(r13); /* move r9, r10 to stackframe */ \ 3768aa34ab8SBenjamin Herrenschmidt ld r10,area+EX_R10(r13); \ 3778aa34ab8SBenjamin Herrenschmidt std r9,GPR9(r1); \ 3788aa34ab8SBenjamin Herrenschmidt std r10,GPR10(r1); \ 3798aa34ab8SBenjamin Herrenschmidt ld r9,area+EX_R11(r13); /* move r11 - r13 to stackframe */ \ 3808aa34ab8SBenjamin Herrenschmidt ld r10,area+EX_R12(r13); \ 3818aa34ab8SBenjamin Herrenschmidt ld r11,area+EX_R13(r13); \ 3828aa34ab8SBenjamin Herrenschmidt std r9,GPR11(r1); \ 3838aa34ab8SBenjamin Herrenschmidt std r10,GPR12(r1); \ 3848aa34ab8SBenjamin Herrenschmidt std r11,GPR13(r1); \ 38548404f2eSPaul Mackerras BEGIN_FTR_SECTION_NESTED(66); \ 38648404f2eSPaul Mackerras ld r10,area+EX_CFAR(r13); \ 38748404f2eSPaul Mackerras std r10,ORIG_GPR3(r1); \ 38848404f2eSPaul Mackerras END_FTR_SECTION_NESTED(CPU_FTR_CFAR, CPU_FTR_CFAR, 66); \ 389b14a7253SMahesh Salgaonkar GET_CTR(r10, area); \ 390b14a7253SMahesh Salgaonkar std r10,_CTR(r1); 391b14a7253SMahesh Salgaonkar 392b14a7253SMahesh Salgaonkar #define EXCEPTION_PROLOG_COMMON_3(n) \ 393b14a7253SMahesh Salgaonkar std r2,GPR2(r1); /* save r2 in stackframe */ \ 394b14a7253SMahesh Salgaonkar SAVE_4GPRS(3, r1); /* save r3 - r6 in stackframe */ \ 395b14a7253SMahesh Salgaonkar SAVE_2GPRS(7, r1); /* save r7, r8 in stackframe */ \ 396bc2e6c6aSMichael Neuling mflr r9; /* Get LR, later save to stack */ \ 3978aa34ab8SBenjamin Herrenschmidt ld r2,PACATOC(r13); /* get kernel TOC into r2 */ \ 3988aa34ab8SBenjamin Herrenschmidt std r9,_LINK(r1); \ 3998aa34ab8SBenjamin Herrenschmidt lbz r10,PACASOFTIRQEN(r13); \ 4008aa34ab8SBenjamin Herrenschmidt mfspr r11,SPRN_XER; /* save XER in stackframe */ \ 4018aa34ab8SBenjamin Herrenschmidt std r10,SOFTE(r1); \ 4028aa34ab8SBenjamin Herrenschmidt std r11,_XER(r1); \ 4038aa34ab8SBenjamin Herrenschmidt li r9,(n)+1; \ 4048aa34ab8SBenjamin Herrenschmidt std r9,_TRAP(r1); /* set trap number */ \ 4058aa34ab8SBenjamin Herrenschmidt li r10,0; \ 4068aa34ab8SBenjamin Herrenschmidt ld r11,exception_marker@toc(r2); \ 4078aa34ab8SBenjamin Herrenschmidt std r10,RESULT(r1); /* clear regs->result */ \ 408b14a7253SMahesh Salgaonkar std r11,STACK_FRAME_OVERHEAD-16(r1); /* mark the frame */ 4098aa34ab8SBenjamin Herrenschmidt 4108aa34ab8SBenjamin Herrenschmidt /* 4118aa34ab8SBenjamin Herrenschmidt * Exception vectors. 4128aa34ab8SBenjamin Herrenschmidt */ 4132613265cSMichael Ellerman #define STD_EXCEPTION_PSERIES(vec, label) \ 414673b189aSPaul Mackerras SET_SCRATCH0(r13); /* save r13 */ \ 415da2bc464SMichael Ellerman EXCEPTION_PROLOG_PSERIES(PACA_EXGEN, label, \ 416da2bc464SMichael Ellerman EXC_STD, KVMTEST_PR, vec); \ 4178aa34ab8SBenjamin Herrenschmidt 4181707dd16SPaul Mackerras /* Version of above for when we have to branch out-of-line */ 419da2bc464SMichael Ellerman #define __OOL_EXCEPTION(vec, label, hdlr) \ 420da2bc464SMichael Ellerman SET_SCRATCH0(r13) \ 421da2bc464SMichael Ellerman EXCEPTION_PROLOG_0(PACA_EXGEN) \ 422da2bc464SMichael Ellerman b hdlr; 423da2bc464SMichael Ellerman 4241707dd16SPaul Mackerras #define STD_EXCEPTION_PSERIES_OOL(vec, label) \ 425da2bc464SMichael Ellerman EXCEPTION_PROLOG_1(PACA_EXGEN, KVMTEST_PR, vec); \ 426da2bc464SMichael Ellerman EXCEPTION_PROLOG_PSERIES_1(label, EXC_STD) 4271707dd16SPaul Mackerras 428b3e6b5dfSBenjamin Herrenschmidt #define STD_EXCEPTION_HV(loc, vec, label) \ 429673b189aSPaul Mackerras SET_SCRATCH0(r13); /* save r13 */ \ 430da2bc464SMichael Ellerman EXCEPTION_PROLOG_PSERIES(PACA_EXGEN, label, \ 431da2bc464SMichael Ellerman EXC_HV, KVMTEST_HV, vec); 4328aa34ab8SBenjamin Herrenschmidt 4331707dd16SPaul Mackerras #define STD_EXCEPTION_HV_OOL(vec, label) \ 434da2bc464SMichael Ellerman EXCEPTION_PROLOG_1(PACA_EXGEN, KVMTEST_HV, vec); \ 435da2bc464SMichael Ellerman EXCEPTION_PROLOG_PSERIES_1(label, EXC_HV) 4361707dd16SPaul Mackerras 4374700dfafSMichael Neuling #define STD_RELON_EXCEPTION_PSERIES(loc, vec, label) \ 4384700dfafSMichael Neuling /* No guest interrupts come through here */ \ 4394700dfafSMichael Neuling SET_SCRATCH0(r13); /* save r13 */ \ 440da2bc464SMichael Ellerman EXCEPTION_RELON_PROLOG_PSERIES(PACA_EXGEN, label, EXC_STD, NOTEST, vec); 4414700dfafSMichael Neuling 4421707dd16SPaul Mackerras #define STD_RELON_EXCEPTION_PSERIES_OOL(vec, label) \ 443c9f69518SMichael Ellerman EXCEPTION_PROLOG_1(PACA_EXGEN, NOTEST, vec); \ 444da2bc464SMichael Ellerman EXCEPTION_RELON_PROLOG_PSERIES_1(label, EXC_STD) 4451707dd16SPaul Mackerras 4464700dfafSMichael Neuling #define STD_RELON_EXCEPTION_HV(loc, vec, label) \ 4474700dfafSMichael Neuling SET_SCRATCH0(r13); /* save r13 */ \ 448bc355125SPaul Mackerras EXCEPTION_RELON_PROLOG_PSERIES(PACA_EXGEN, label, \ 449bc355125SPaul Mackerras EXC_HV, KVMTEST_HV, vec); 4504700dfafSMichael Neuling 4511707dd16SPaul Mackerras #define STD_RELON_EXCEPTION_HV_OOL(vec, label) \ 452bc355125SPaul Mackerras EXCEPTION_PROLOG_1(PACA_EXGEN, KVMTEST_HV, vec); \ 453da2bc464SMichael Ellerman EXCEPTION_RELON_PROLOG_PSERIES_1(label, EXC_HV) 4541707dd16SPaul Mackerras 4557230c564SBenjamin Herrenschmidt /* This associate vector numbers with bits in paca->irq_happened */ 4567230c564SBenjamin Herrenschmidt #define SOFTEN_VALUE_0x500 PACA_IRQ_EE 4577230c564SBenjamin Herrenschmidt #define SOFTEN_VALUE_0x900 PACA_IRQ_DEC 458da2bc464SMichael Ellerman #define SOFTEN_VALUE_0x980 PACA_IRQ_DEC 4591dbdafecSIan Munsie #define SOFTEN_VALUE_0xa00 PACA_IRQ_DBELL 460655bb3f4SIan Munsie #define SOFTEN_VALUE_0xe80 PACA_IRQ_DBELL 4610869b6fdSMahesh Salgaonkar #define SOFTEN_VALUE_0xe60 PACA_IRQ_HMI 4629baaef0aSBenjamin Herrenschmidt #define SOFTEN_VALUE_0xea0 PACA_IRQ_EE 4637230c564SBenjamin Herrenschmidt 4647230c564SBenjamin Herrenschmidt #define __SOFTEN_TEST(h, vec) \ 4658aa34ab8SBenjamin Herrenschmidt lbz r10,PACASOFTIRQEN(r13); \ 4668aa34ab8SBenjamin Herrenschmidt cmpwi r10,0; \ 4677230c564SBenjamin Herrenschmidt li r10,SOFTEN_VALUE_##vec; \ 468b01c8b54SPaul Mackerras beq masked_##h##interrupt 469da2bc464SMichael Ellerman 4707230c564SBenjamin Herrenschmidt #define _SOFTEN_TEST(h, vec) __SOFTEN_TEST(h, vec) 471b01c8b54SPaul Mackerras 472de56a948SPaul Mackerras #define SOFTEN_TEST_PR(vec) \ 473da2bc464SMichael Ellerman KVMTEST(EXC_STD, vec); \ 4747230c564SBenjamin Herrenschmidt _SOFTEN_TEST(EXC_STD, vec) 475b01c8b54SPaul Mackerras 476b01c8b54SPaul Mackerras #define SOFTEN_TEST_HV(vec) \ 477da2bc464SMichael Ellerman KVMTEST(EXC_HV, vec); \ 4787230c564SBenjamin Herrenschmidt _SOFTEN_TEST(EXC_HV, vec) 479b01c8b54SPaul Mackerras 480da2bc464SMichael Ellerman #define KVMTEST_PR(vec) \ 481da2bc464SMichael Ellerman KVMTEST(EXC_STD, vec) 482da2bc464SMichael Ellerman 483da2bc464SMichael Ellerman #define KVMTEST_HV(vec) \ 484da2bc464SMichael Ellerman KVMTEST(EXC_HV, vec) 485da2bc464SMichael Ellerman 4864700dfafSMichael Neuling #define SOFTEN_NOTEST_PR(vec) _SOFTEN_TEST(EXC_STD, vec) 4874700dfafSMichael Neuling #define SOFTEN_NOTEST_HV(vec) _SOFTEN_TEST(EXC_HV, vec) 4884700dfafSMichael Neuling 489b01c8b54SPaul Mackerras #define __MASKABLE_EXCEPTION_PSERIES(vec, label, h, extra) \ 490b01c8b54SPaul Mackerras SET_SCRATCH0(r13); /* save r13 */ \ 4911707dd16SPaul Mackerras EXCEPTION_PROLOG_0(PACA_EXGEN); \ 492b01c8b54SPaul Mackerras __EXCEPTION_PROLOG_1(PACA_EXGEN, extra, vec); \ 493da2bc464SMichael Ellerman EXCEPTION_PROLOG_PSERIES_1(label, h); 4941707dd16SPaul Mackerras 495b01c8b54SPaul Mackerras #define _MASKABLE_EXCEPTION_PSERIES(vec, label, h, extra) \ 496b01c8b54SPaul Mackerras __MASKABLE_EXCEPTION_PSERIES(vec, label, h, extra) 497b3e6b5dfSBenjamin Herrenschmidt 498b3e6b5dfSBenjamin Herrenschmidt #define MASKABLE_EXCEPTION_PSERIES(loc, vec, label) \ 499b01c8b54SPaul Mackerras _MASKABLE_EXCEPTION_PSERIES(vec, label, \ 500de56a948SPaul Mackerras EXC_STD, SOFTEN_TEST_PR) 501b3e6b5dfSBenjamin Herrenschmidt 502da2bc464SMichael Ellerman #define MASKABLE_EXCEPTION_PSERIES_OOL(vec, label) \ 503da2bc464SMichael Ellerman EXCEPTION_PROLOG_1(PACA_EXGEN, SOFTEN_TEST_PR, vec); \ 504da2bc464SMichael Ellerman EXCEPTION_PROLOG_PSERIES_1(label, EXC_STD) 505da2bc464SMichael Ellerman 506b3e6b5dfSBenjamin Herrenschmidt #define MASKABLE_EXCEPTION_HV(loc, vec, label) \ 507b01c8b54SPaul Mackerras _MASKABLE_EXCEPTION_PSERIES(vec, label, \ 508b01c8b54SPaul Mackerras EXC_HV, SOFTEN_TEST_HV) 5098aa34ab8SBenjamin Herrenschmidt 5101707dd16SPaul Mackerras #define MASKABLE_EXCEPTION_HV_OOL(vec, label) \ 5111707dd16SPaul Mackerras EXCEPTION_PROLOG_1(PACA_EXGEN, SOFTEN_TEST_HV, vec); \ 512da2bc464SMichael Ellerman EXCEPTION_PROLOG_PSERIES_1(label, EXC_HV) 5131707dd16SPaul Mackerras 5144700dfafSMichael Neuling #define __MASKABLE_RELON_EXCEPTION_PSERIES(vec, label, h, extra) \ 5154700dfafSMichael Neuling SET_SCRATCH0(r13); /* save r13 */ \ 5161707dd16SPaul Mackerras EXCEPTION_PROLOG_0(PACA_EXGEN); \ 5174700dfafSMichael Neuling __EXCEPTION_PROLOG_1(PACA_EXGEN, extra, vec); \ 518da2bc464SMichael Ellerman EXCEPTION_RELON_PROLOG_PSERIES_1(label, h) 519da2bc464SMichael Ellerman 5204700dfafSMichael Neuling #define _MASKABLE_RELON_EXCEPTION_PSERIES(vec, label, h, extra) \ 5214700dfafSMichael Neuling __MASKABLE_RELON_EXCEPTION_PSERIES(vec, label, h, extra) 5224700dfafSMichael Neuling 5234700dfafSMichael Neuling #define MASKABLE_RELON_EXCEPTION_PSERIES(loc, vec, label) \ 5244700dfafSMichael Neuling _MASKABLE_RELON_EXCEPTION_PSERIES(vec, label, \ 5254700dfafSMichael Neuling EXC_STD, SOFTEN_NOTEST_PR) 5264700dfafSMichael Neuling 5274700dfafSMichael Neuling #define MASKABLE_RELON_EXCEPTION_HV(loc, vec, label) \ 5284700dfafSMichael Neuling _MASKABLE_RELON_EXCEPTION_PSERIES(vec, label, \ 529bc355125SPaul Mackerras EXC_HV, SOFTEN_TEST_HV) 5304700dfafSMichael Neuling 5311707dd16SPaul Mackerras #define MASKABLE_RELON_EXCEPTION_HV_OOL(vec, label) \ 532bc355125SPaul Mackerras EXCEPTION_PROLOG_1(PACA_EXGEN, SOFTEN_TEST_HV, vec); \ 533a050d20dSNicholas Piggin EXCEPTION_RELON_PROLOG_PSERIES_1(label, EXC_HV) 5341707dd16SPaul Mackerras 5351b701179SBenjamin Herrenschmidt /* 5361b701179SBenjamin Herrenschmidt * Our exception common code can be passed various "additions" 5371b701179SBenjamin Herrenschmidt * to specify the behaviour of interrupts, whether to kick the 5381b701179SBenjamin Herrenschmidt * runlatch, etc... 5391b701179SBenjamin Herrenschmidt */ 5401b701179SBenjamin Herrenschmidt 5419daf112bSMichael Ellerman /* 5429daf112bSMichael Ellerman * This addition reconciles our actual IRQ state with the various software 5439daf112bSMichael Ellerman * flags that track it. This may call C code. 5449daf112bSMichael Ellerman */ 5459daf112bSMichael Ellerman #define ADD_RECONCILE RECONCILE_IRQ_STATE(r10,r11) 5468aa34ab8SBenjamin Herrenschmidt 547fe1952fcSBenjamin Herrenschmidt #define ADD_NVGPRS \ 548b1576fecSAnton Blanchard bl save_nvgprs 549fe1952fcSBenjamin Herrenschmidt 550fe1952fcSBenjamin Herrenschmidt #define RUNLATCH_ON \ 551fe1952fcSBenjamin Herrenschmidt BEGIN_FTR_SECTION \ 5529778b696SStuart Yoder CURRENT_THREAD_INFO(r3, r1); \ 553fe1952fcSBenjamin Herrenschmidt ld r4,TI_LOCAL_FLAGS(r3); \ 554fe1952fcSBenjamin Herrenschmidt andi. r0,r4,_TLF_RUNLATCH; \ 555fe1952fcSBenjamin Herrenschmidt beql ppc64_runlatch_on_trampoline; \ 556fe1952fcSBenjamin Herrenschmidt END_FTR_SECTION_IFSET(CPU_FTR_CTRL) 557fe1952fcSBenjamin Herrenschmidt 558a3d96f70SNicholas Piggin #define EXCEPTION_COMMON(area, trap, label, hdlr, ret, additions) \ 559a3d96f70SNicholas Piggin EXCEPTION_PROLOG_COMMON(trap, area); \ 560a1d711c5SMichael Ellerman /* Volatile regs are potentially clobbered here */ \ 561fe1952fcSBenjamin Herrenschmidt additions; \ 5628aa34ab8SBenjamin Herrenschmidt addi r3,r1,STACK_FRAME_OVERHEAD; \ 5638aa34ab8SBenjamin Herrenschmidt bl hdlr; \ 564fe1952fcSBenjamin Herrenschmidt b ret 565fe1952fcSBenjamin Herrenschmidt 566fe1952fcSBenjamin Herrenschmidt #define STD_EXCEPTION_COMMON(trap, label, hdlr) \ 567a3d96f70SNicholas Piggin EXCEPTION_COMMON(PACA_EXGEN, trap, label, hdlr, \ 568a3d96f70SNicholas Piggin ret_from_except, ADD_NVGPRS;ADD_RECONCILE) 5698aa34ab8SBenjamin Herrenschmidt 5708aa34ab8SBenjamin Herrenschmidt /* 5718aa34ab8SBenjamin Herrenschmidt * Like STD_EXCEPTION_COMMON, but for exceptions that can occur 5727450f6f0SBenjamin Herrenschmidt * in the idle task and therefore need the special idle handling 5737450f6f0SBenjamin Herrenschmidt * (finish nap and runlatch) 5748aa34ab8SBenjamin Herrenschmidt */ 5757450f6f0SBenjamin Herrenschmidt #define STD_EXCEPTION_COMMON_ASYNC(trap, label, hdlr) \ 576a3d96f70SNicholas Piggin EXCEPTION_COMMON(PACA_EXGEN, trap, label, hdlr, \ 577a3d96f70SNicholas Piggin ret_from_except_lite, FINISH_NAP;ADD_RECONCILE;RUNLATCH_ON) 5788aa34ab8SBenjamin Herrenschmidt 5798aa34ab8SBenjamin Herrenschmidt /* 5808aa34ab8SBenjamin Herrenschmidt * When the idle code in power4_idle puts the CPU into NAP mode, 5818aa34ab8SBenjamin Herrenschmidt * it has to do so in a loop, and relies on the external interrupt 5828aa34ab8SBenjamin Herrenschmidt * and decrementer interrupt entry code to get it out of the loop. 5838aa34ab8SBenjamin Herrenschmidt * It sets the _TLF_NAPPING bit in current_thread_info()->local_flags 5848aa34ab8SBenjamin Herrenschmidt * to signal that it is in the loop and needs help to get out. 5858aa34ab8SBenjamin Herrenschmidt */ 5868aa34ab8SBenjamin Herrenschmidt #ifdef CONFIG_PPC_970_NAP 5878aa34ab8SBenjamin Herrenschmidt #define FINISH_NAP \ 5888aa34ab8SBenjamin Herrenschmidt BEGIN_FTR_SECTION \ 5899778b696SStuart Yoder CURRENT_THREAD_INFO(r11, r1); \ 5908aa34ab8SBenjamin Herrenschmidt ld r9,TI_LOCAL_FLAGS(r11); \ 5918aa34ab8SBenjamin Herrenschmidt andi. r10,r9,_TLF_NAPPING; \ 5928aa34ab8SBenjamin Herrenschmidt bnel power4_fixup_nap; \ 5938aa34ab8SBenjamin Herrenschmidt END_FTR_SECTION_IFSET(CPU_FTR_CAN_NAP) 5948aa34ab8SBenjamin Herrenschmidt #else 5958aa34ab8SBenjamin Herrenschmidt #define FINISH_NAP 5968aa34ab8SBenjamin Herrenschmidt #endif 5978aa34ab8SBenjamin Herrenschmidt 5988aa34ab8SBenjamin Herrenschmidt #endif /* _ASM_POWERPC_EXCEPTION_H */ 599