16c9f99dfSJanosch Frank /* SPDX-License-Identifier: GPL-2.0-only */ 24da93626SDavid Hildenbrand /* 34da93626SDavid Hildenbrand * Copyright (c) 2017 Red Hat Inc 44da93626SDavid Hildenbrand * 54da93626SDavid Hildenbrand * Authors: 64da93626SDavid Hildenbrand * David Hildenbrand <david@redhat.com> 74da93626SDavid Hildenbrand */ 84da93626SDavid Hildenbrand #ifndef _ASMS390X_IRQ_H_ 94da93626SDavid Hildenbrand #define _ASMS390X_IRQ_H_ 104da93626SDavid Hildenbrand #include <asm/arch_def.h> 114da93626SDavid Hildenbrand 12df121a0cSJanosch Frank #define EXT_IRQ_EMERGENCY_SIG 0x1201 13df121a0cSJanosch Frank #define EXT_IRQ_EXTERNAL_CALL 0x1202 148ead801eSJanosch Frank #define EXT_IRQ_SERVICE_SIG 0x2401 158ead801eSJanosch Frank 162652cb00SClaudio Imbrenda #define TEID_ASCE_PRIMARY 0 172652cb00SClaudio Imbrenda #define TEID_ASCE_AR 1 182652cb00SClaudio Imbrenda #define TEID_ASCE_SECONDARY 2 192652cb00SClaudio Imbrenda #define TEID_ASCE_HOME 3 202652cb00SClaudio Imbrenda 212652cb00SClaudio Imbrenda union teid { 222652cb00SClaudio Imbrenda unsigned long val; 23*c2c1663aSJanis Schoetterl-Glausch union { 24*c2c1663aSJanis Schoetterl-Glausch /* common fields DAT exc & protection exc */ 252652cb00SClaudio Imbrenda struct { 26*c2c1663aSJanis Schoetterl-Glausch uint64_t addr : 52 - 0; 27*c2c1663aSJanis Schoetterl-Glausch uint64_t acc_exc_fetch_store : 54 - 52; 28*c2c1663aSJanis Schoetterl-Glausch uint64_t side_effect_acc : 55 - 54; 29*c2c1663aSJanis Schoetterl-Glausch uint64_t /* reserved */ : 62 - 55; 30*c2c1663aSJanis Schoetterl-Glausch uint64_t asce_id : 64 - 62; 31*c2c1663aSJanis Schoetterl-Glausch }; 32*c2c1663aSJanis Schoetterl-Glausch /* DAT exc */ 33*c2c1663aSJanis Schoetterl-Glausch struct { 34*c2c1663aSJanis Schoetterl-Glausch uint64_t /* pad */ : 61 - 0; 35*c2c1663aSJanis Schoetterl-Glausch uint64_t dat_move_page : 62 - 61; 36*c2c1663aSJanis Schoetterl-Glausch }; 37*c2c1663aSJanis Schoetterl-Glausch /* suppression on protection */ 38*c2c1663aSJanis Schoetterl-Glausch struct { 39*c2c1663aSJanis Schoetterl-Glausch uint64_t /* pad */ : 60 - 0; 40*c2c1663aSJanis Schoetterl-Glausch uint64_t sop_acc_list : 61 - 60; 41*c2c1663aSJanis Schoetterl-Glausch uint64_t sop_teid_predictable : 62 - 61; 42*c2c1663aSJanis Schoetterl-Glausch }; 43*c2c1663aSJanis Schoetterl-Glausch /* enhanced suppression on protection 2 */ 44*c2c1663aSJanis Schoetterl-Glausch struct { 45*c2c1663aSJanis Schoetterl-Glausch uint64_t /* pad */ : 56 - 0; 46*c2c1663aSJanis Schoetterl-Glausch uint64_t esop2_prot_code_0 : 57 - 56; 47*c2c1663aSJanis Schoetterl-Glausch uint64_t /* pad */ : 60 - 57; 48*c2c1663aSJanis Schoetterl-Glausch uint64_t esop2_prot_code_1 : 61 - 60; 49*c2c1663aSJanis Schoetterl-Glausch uint64_t esop2_prot_code_2 : 62 - 61; 502652cb00SClaudio Imbrenda }; 512652cb00SClaudio Imbrenda }; 52*c2c1663aSJanis Schoetterl-Glausch }; 53*c2c1663aSJanis Schoetterl-Glausch 54*c2c1663aSJanis Schoetterl-Glausch enum prot_code { 55*c2c1663aSJanis Schoetterl-Glausch PROT_KEY_OR_LAP, 56*c2c1663aSJanis Schoetterl-Glausch PROT_DAT, 57*c2c1663aSJanis Schoetterl-Glausch PROT_KEY, 58*c2c1663aSJanis Schoetterl-Glausch PROT_ACC_LIST, 59*c2c1663aSJanis Schoetterl-Glausch PROT_LAP, 60*c2c1663aSJanis Schoetterl-Glausch PROT_IEP, 61*c2c1663aSJanis Schoetterl-Glausch PROT_NUM_CODES /* Must always be last */ 62*c2c1663aSJanis Schoetterl-Glausch }; 63*c2c1663aSJanis Schoetterl-Glausch 64*c2c1663aSJanis Schoetterl-Glausch static inline enum prot_code teid_esop2_prot_code(union teid teid) 65*c2c1663aSJanis Schoetterl-Glausch { 66*c2c1663aSJanis Schoetterl-Glausch int code = (teid.esop2_prot_code_0 << 2 | 67*c2c1663aSJanis Schoetterl-Glausch teid.esop2_prot_code_1 << 1 | 68*c2c1663aSJanis Schoetterl-Glausch teid.esop2_prot_code_2); 69*c2c1663aSJanis Schoetterl-Glausch 70*c2c1663aSJanis Schoetterl-Glausch assert(code < PROT_NUM_CODES); 71*c2c1663aSJanis Schoetterl-Glausch return (enum prot_code)code; 72*c2c1663aSJanis Schoetterl-Glausch } 732652cb00SClaudio Imbrenda 74cc7bed1bSJanosch Frank void register_pgm_cleanup_func(void (*f)(void)); 7536cfc0b7SJanosch Frank void handle_pgm_int(struct stack_frame_int *stack); 7636cfc0b7SJanosch Frank void handle_ext_int(struct stack_frame_int *stack); 770f87a91aSJanosch Frank void handle_mcck_int(void); 780f87a91aSJanosch Frank void handle_io_int(void); 790f87a91aSJanosch Frank void handle_svc_int(void); 804da93626SDavid Hildenbrand void expect_pgm_int(void); 81df121a0cSJanosch Frank void expect_ext_int(void); 823db880b6SDavid Hildenbrand uint16_t clear_pgm_int(void); 834da93626SDavid Hildenbrand void check_pgm_int_code(uint16_t code); 844da93626SDavid Hildenbrand 852667b05eSThomas Huth /* Activate low-address protection */ 862667b05eSThomas Huth static inline void low_prot_enable(void) 872667b05eSThomas Huth { 881b2c0437SClaudio Imbrenda ctl_set_bit(0, CTL0_LOW_ADDR_PROT); 892667b05eSThomas Huth } 902667b05eSThomas Huth 912667b05eSThomas Huth /* Disable low-address protection */ 922667b05eSThomas Huth static inline void low_prot_disable(void) 932667b05eSThomas Huth { 941b2c0437SClaudio Imbrenda ctl_clear_bit(0, CTL0_LOW_ADDR_PROT); 952667b05eSThomas Huth } 962667b05eSThomas Huth 974da93626SDavid Hildenbrand #endif 98