1 
  2 
  3 
  4 
  5 
  6 
  7 
  8 
  9 
 10 
 11 
 12 
 13 
 14 seg_fault: proc (a_mcptr);
 15 
 16 
 17 
 18 
 19 
 20 
 21 
 22 
 23 
 24 
 25 
 26 
 27 
 28 
 29 
 30 
 31 
 32 
 33 
 34 
 35 
 36 
 37 
 38 
 39 
 40 
 41 
 42 
 43 
 44 
 45 
 46 
 47 
 48 
 49 
 50 
 51 
 52 
 53 
 54 
 55 
 56 
 57 
 58 
 59 
 60 
 61 
 62 
 63 
 64 
 65 
 66 
 67 
 68 
 69 
 70 
 71 
 72 
 73 
 74 
 75 
 76 
 77 
 78 
 79 
 80 
 81 
 82 
 83 
 84 
 85 
 86 
 87 
 88 
 89 
 90 
 91 
 92 
 93 
 94 
 95 
 96 
 97 dcl  a_code                             fixed bin (35) parameter;
 98 dcl  a_kstep                            pointer parameter;
 99 dcl  a_mcptr                            pointer parameter;
100 
101 
102 
103 dcl  activated_sw                       bit (1) aligned;
104 dcl  audit_eventflags                   bit (36) aligned;
105 dcl  branch_entrypt_bound               bit (14);
106 dcl  branch_entrypt_sw                  bit (1);
107 dcl  code                               fixed bin (35);
108 dcl  esw                                fixed bin;
109 dcl  lsw                                bit (1) aligned;
110 dcl  lvx                                fixed bin (8);
111 dcl  mode                               bit (36) aligned;
112 dcl  offset                             fixed bin (18);
113 dcl  1 orig_sdwi                        aligned like sdw_info automatic;
114 dcl  pts                                fixed bin;
115 dcl  pw1                                fixed bin (17);
116 dcl  pw2                                fixed bin (17);
117 dcl  ringno                             fixed bin;
118 dcl  sdw_address                        fixed bin (26);
119 dcl  sdw_valid                          bit (1) aligned;
120 dcl  1 sdwi                             aligned like sdw_info automatic;
121 dcl  segno                              fixed bin (17);
122 dcl  segptr                             pointer;
123 dcl  time1                              fixed bin (71);
124 dcl  time2                              fixed bin (71);
125 dcl  tsdw                               fixed bin (71);
126 
127 
128 
129 dcl  access_operations_$log_vol_full    bit (36) aligned external static;
130 dcl  active_all_rings_data$stack_base_segno fixed bin (18) external static;
131 dcl  dseg$                              (0:4095) fixed bin (71) external static;
132 dcl  error_table_$big_seg               fixed bin (35) external static;
133 dcl  error_table_$boundviol             fixed bin (35) external static;
134 dcl  error_table_$log_vol_full          fixed bin (35) external static;
135 dcl  error_table_$mylock                fixed bin (35) external static;
136 dcl  error_table_$oosw                  fixed bin (35) external static;
137 dcl  error_table_$seg_busted            fixed bin (35) external static;
138 dcl  error_table_$seg_deleted           fixed bin (35) external static;
139 dcl  pds$access_authorization           bit (72) aligned ext;
140 dcl  pds$dstep                          bit (18) external static;
141 dcl  pds$segment_faults                 fixed bin (35) external static;
142 dcl  pds$stacks                         (0:7) ptr external static;
143 dcl  pvt$root_lvid                      bit (36) aligned external static;
144 dcl  sst$cpu_sf_time                    fixed bin (71) external static;
145 dcl  sst$makeknown_activations          fixed bin (35) external static;
146 dcl  sst$pts                            (0:3) fixed bin external static;
147 dcl  sst$root_astep                     pointer external static;
148 dcl  sst$tfreep                         pointer external static;
149 dcl  sst$total_sf_pf                    fixed bin (35) external static;
150 dcl  sst$total_sf                       fixed bin (35) external static;
151 dcl  sst$seg_fault_calls                fixed bin (35) external static;
152 dcl  sys_info$seg_size_256K             fixed bin (19) external static;
153 
154 
155 
156 dcl  access_audit_$log_general          entry (char (*), fixed bin, bit (36) aligned, bit (36) aligned, char (*), fixed bin (35), ptr, fixed bin (18), char (*));
157 dcl  activate$activate_long             entry (ptr, bit (1) aligned, fixed bin (35)) returns (ptr);
158 dcl  get_kstep                          entry (fixed bin (17), ptr, fixed bin (35));
159 dcl  get_ptrs_$given_astep              entry (pointer) returns (fixed bin (71));
160 dcl  level$get                          entry () returns (fixed bin);
161 dcl  lock$dir_unlock                    entry (pointer);
162 dcl  lock$lock_ast                      entry;
163 dcl  lock$unlock_ast                    entry;
164 dcl  logical_volume_manager$lvtep       entry (bit (36) aligned, ptr, fixed bin (35));
165 dcl  makestack                          entry (fixed bin);
166 dcl  page$enter_data                    entry (fixed bin (17), fixed bin);
167 dcl  private_logical_volume$lvx         entry (bit (36) aligned, fixed bin (8), fixed bin (35));
168 dcl  sdw_util_$construct                entry (pointer, pointer);
169 dcl  sdw_util_$dissect                  entry (pointer, pointer);
170 dcl  sdw_util_$get_address              entry (pointer, fixed bin (26));
171 dcl  sdw_util_$get_valid                entry (pointer, bit (1) aligned);
172 dcl  segment_mover                      entry (fixed bin (18), ptr, ptr, fixed bin, fixed bin (35));
173 dcl  setfaults$cache                    entry (pointer, bit (1) aligned);
174 dcl  sum$getbranch_root_my              entry (pointer, bit (36) aligned, pointer, fixed bin (35));
175 dcl  syserr                             entry options (variable);
176 dcl  thread$lin                         entry (pointer, bit (18)); 
177 dcl  usage_values                       entry (fixed bin (17), fixed bin (71));
178 
179 
180 
181 dcl  FAULT                              fixed bin static internal options (constant) init (0);
182 dcl  MAKEKNOWN                          fixed bin static internal options (constant) init (1);
183 
184 
185 
186 dcl  (addr, baseptr, bin, binary, bit, min, null, ptr, rel, string, substr) builtin;
187 %page;
188 
189 
190 
191           call usage_values (pw1, time1);                   
192           esw = FAULT;
193           code = 0;
194           kstp = pds$kstp;
195           mcp = a_mcptr;
196           scup = addr (mc.scu (0));
197           mc.errcode = 0;
198           ringno = bin (scu.ppr.prr, 3);
199 
200 
201 
202 
203 
204 
205           if scu.cu.if then segno = bin (scu.ppr.psr, 15);
206           else segno = bin (scu.tpr.tsr, 15);
207 
208           call sdw_util_$get_valid (addr (dseg$ (segno)), sdw_valid);
209           if sdw_valid then do;                             
210                call syserr (0, "seg_fault: illegal segfault on cpu ^a",
211                     substr ("ABCDEFGH", bin (scu.cpu_no, 3) + 1, 1)); 
212                return;                                      
213           end;
214 
215           call page$enter_data (segno, (seg_fault_start));  
216 
217           offset = bin (scu.ca, 18);                        
218 
219 
220 
221 
222           if segno >= active_all_rings_data$stack_base_segno then
223                if segno <= active_all_rings_data$stack_base_segno + 7 then
224                     if pds$stacks (segno - active_all_rings_data$stack_base_segno) = null then do;
225                          call makestack (segno - active_all_rings_data$stack_base_segno); 
226                          go to finish;
227                     end;
228 
229 
230 
231 
232           segptr = baseptr (segno);                         
233           call get_kstep (segno, kstep, code);
234           if code ^= 0 then go to err;
235 
236 
237 
238 
239 
240 
241 COMMON:
242           if kste.uid = (36)"1"b then do;                   
243 
244 
245 
246                lsw = "0"b;                                  
247                call lock$lock_ast;
248                if code ^= 0 then go to err;
249                astep = sst$root_astep;                      
250           end;
251 
252 
253 
254           else do;
255                if esw = MAKEKNOWN then lsw = "0"b;          
256 
257                else do;                                     
258 
259 
260 
261 
262 
263                     lsw = "0"b;
264                     call sum$getbranch_root_my (segptr, "0"b, ep, code);
265                     if code = 0 then lsw = "1"b;
266                     else if code = error_table_$mylock then code = 0;
267                     else if code = error_table_$seg_deleted then do;
268                          dp, ep = null;
269                          go to seg_audit;
270                     end;
271                     else go to err;
272                     dp = ptr (ep, 0);
273 
274 
275 
276 
277                     if entry.security_oosw then
278                          if ^addr (pds$access_authorization) -> aim_template.privileges.soos then do;
279                               code = error_table_$oosw;
280                               go to err1;
281                          end;
282 
283                     if ^entry.dirsw then do;                
284 seg_audit:               call dc_find$seg_fault (kstep, ep, code);
285                          if code ^= 0 then go to err1;
286                     end;
287                end;
288 
289                if ^kste.dirsw then do;
290 
291 
292 
293 
294                     branch_entrypt_bound = entry.entrypt_bound;
295                     branch_entrypt_sw = entry.entrypt_sw;
296 
297                end;
298 
299 
300 
301 
302                if ^kste.dirsw then                          
303                     if kste.infcount = 0 then               
304                          if (entry.sons_lvid ^= pvt$root_lvid) |
305                               entry.master_dir then do;     
306                                                             
307                               call logical_volume_manager$lvtep (dir.sons_lvid, lvtep, code);
308                               if code ^= 0 then goto err1;  
309                               if ^lvte.public then do;      
310                                    call private_logical_volume$lvx (dir.sons_lvid, lvx, code);
311                                    if code ^= 0 then goto err1; 
312                                    kste.infcount = lvx;     
313                               end;
314                          end;
315 
316                astep = activate$activate_long (ep, activated_sw, code); 
317                if code ^= 0 then go to err1;
318 
319                if esw = MAKEKNOWN then                      
320                     if activated_sw then
321                          sst$makeknown_activations = sst$makeknown_activations + 1;
322           end;
323 
324 
325 
326           if aste.damaged & ^kste.dirsw then do;
327                code = error_table_$seg_busted;
328                go to err0;
329           end;
330 
331 
332 
333           if ^kst.allow_256K_connect & ^kste.dirsw then     
334                if bin (aste.msl, 9) * 1024 >= sys_info$seg_size_256K then do;
335                     code = error_table_$big_seg;
336                     go to err0;
337                end;
338 
339 
340 
341           if offset >= bin (aste.msl, 9) * 1024 then do;    
342                code = error_table_$boundviol;
343                mc.resignal = "1"b;                          
344                mc.fcode = bit (bin (out_of_bounds_sct_index, 17), 17);
345                go to err0;
346           end;
347 
348 
349 
350 
351 
352 
353           if aste.pack_ovfl then do;                        
354                call segment_mover (offset, astep, ep, segno, code);
355                if code = error_table_$log_vol_full then do;
356                     audit_eventflags = "0"b;
357                     addr (audit_eventflags) -> audit_event_flags.cc_1_10 = "1"b;
358                     call access_audit_$log_general ("seg_fault", level$get (), audit_eventflags, access_operations_$log_vol_full, "", code, null, 0, "");
359                end;
360                go to err1;                                  
361                                                             
362           end;
363 
364 
365 
366 
367 
368 MAKE_TRAILER:
369           pts = sst$pts (bin (aste.ptsi, 3));               
370 
371           call sdw_util_$get_address (addr (dseg$ (segno)), sdw_address);
372           if sdw_address = 0 then do;                       
373                if rel (sst$tfreep) = ""b then
374                     call syserr (1, "seg_fault: trailer storage area exhausted");
375 
376                strp = sst$tfreep;                           
377                if str.fp = "0"b then call syserr (1, "seg_fault: trailer list trap"); 
378                sst$tfreep = ptr (strp, str.fp);             
379                str.segno = bit (bin (segno, 18), 18);       
380                str.dstep = pds$dstep;                       
381                str.fp, str.bp = "0"b;                       
382                call thread$lin (strp, aste.strp);           
383 
384                aste.gtus = aste.gtus & kste.tus;
385                aste.gtms = aste.gtms & kste.tms;
386                aste.explicit_deact_ok = aste.explicit_deact_ok & kste.explicit_deact_ok;
387           end;
388 
389 
390 
391 
392           tsdw = get_ptrs_$given_astep (astep);             
393           call sdw_util_$dissect (addr (tsdw), addr (sdwi));
394 
395           if kste.dirsw then do;
396 
397 
398 
399                string (sdwi.access) = "1010"b;              
400                sdwi.cache = "0"b;                           
401 
402           end;
403 
404 
405 
406           else do;
407                call sdw_util_$dissect (addr (dseg$ (segno)), addr (orig_sdwi)); 
408                                                             
409 
410 
411 
412                string (sdwi.access) = string (orig_sdwi.access);
413                mode = substr (string (orig_sdwi.access), 1, 3);
414                string (sdwi.rings) = string (orig_sdwi.rings);
415                if branch_entrypt_sw then                    
416                     sdwi.gate_entry_bound = binary (branch_entrypt_bound) + 1;
417                                                             
418 
419 
420 
421                sdwi.cache = "1"b;                           
422                                                             
423                if aste.any_access_on then                   
424 
425                     if substr (mode, 3, 1) |                
426                          aste.write_access_on then do;      
427                                                             
428                          call setfaults$cache (astep, "0"b);
429                          sdwi.cache = "0"b;                 
430                          aste.any_access_on = "0"b;         
431                     end;
432                     else ;                                  
433                                                             
434 
435                else if aste.write_access_on then            
436                     sdwi.cache = "0"b;
437                else aste.any_access_on = "1"b;
438 
439                aste.write_access_on = aste.write_access_on | substr (mode, 3, 1);
440                                                             
441           end;
442 
443           sdwi.size = min (pts, bin (aste.msl, 9)) * 1024;  
444 
445 
446 
447           call sdw_util_$construct (addr (dseg$ (segno)), addr (sdwi)); 
448 
449 err0:     call lock$unlock_ast;
450 
451 err1:     if lsw then call lock$dir_unlock (dp);            
452 
453 err:
454 
455           call usage_values (pw2, time2);                   
456           sst$cpu_sf_time = sst$cpu_sf_time + time2 - time1;
457           sst$total_sf_pf = sst$total_sf_pf + pw2 - pw1;
458           sst$total_sf = sst$total_sf + 1;
459           pds$segment_faults = pds$segment_faults + 1;
460           if esw = MAKEKNOWN then do;
461                sst$seg_fault_calls = sst$seg_fault_calls + 1;
462                a_code = code;
463                return;
464           end;
465 
466           mc.errcode = code;
467 
468 finish:   call page$enter_data (segno, (seg_fault_end));    
469           return;
470 %page;
471 makeknown_activate: entry (a_kstep, a_code);
472 
473           call usage_values (pw1, time1);
474           esw = MAKEKNOWN;                                  
475           kstp = pds$kstp;
476           code = 0;
477           mcp = null;                                       
478           scup = null;                                      
479           ringno = 0;                                       
480           offset = -1;                                      
481           kstep = a_kstep;                                  
482           ep = kste.entryp;
483           dp = ptr (ep, 0);
484           segno = kste.segno;
485           segptr = baseptr (segno);
486           go to COMMON;
487 %page; %include access_audit_eventflags;
488 %page; %include aim_template;
489 %page; %include aste;
490 %page; %include dc_find_dcls;
491 %page; %include dir_entry;
492 %page; %include dir_header;
493 %page; %include kst;
494 %page; %include lvt;
495 %page; %include mc;
496 %page; %include sdw_info;
497 %page; %include static_handlers;
498 %page; %include str;
499 %page; %include trace_types;
500 %page;
501 
502 
503 
504 
505 
506 
507 
508 
509 
510 
511 
512 
513 
514 
515 
516 
517 
518 
519 
520 
521 
522 
523 
524 
525 
526 
527 
528 
529 
530 
531 
532 
533 
534 
535 
536 
537 
538 
539 
540 
541 
542 
543 
544 
545 
546 
547 
548 
549 
550 
551 
552 
553 
554 
555 
556 
557 
558 
559 
560 
561 
562 
563 
564 
565 
566 
567 
568 
569      end seg_fault;