@@ -981,40 +981,6 @@ do_sigbus(struct pt_regs *regs, unsigned long error_code, unsigned long address,
981
981
force_sig_fault (SIGBUS , BUS_ADRERR , (void __user * )address );
982
982
}
983
983
984
- static noinline void
985
- mm_fault_error (struct pt_regs * regs , unsigned long error_code ,
986
- unsigned long address , vm_fault_t fault )
987
- {
988
- if (fatal_signal_pending (current ) && !(error_code & X86_PF_USER )) {
989
- no_context (regs , error_code , address , 0 , 0 );
990
- return ;
991
- }
992
-
993
- if (fault & VM_FAULT_OOM ) {
994
- /* Kernel mode? Handle exceptions or die: */
995
- if (!(error_code & X86_PF_USER )) {
996
- no_context (regs , error_code , address ,
997
- SIGSEGV , SEGV_MAPERR );
998
- return ;
999
- }
1000
-
1001
- /*
1002
- * We ran out of memory, call the OOM killer, and return the
1003
- * userspace (which will retry the fault, or kill us if we got
1004
- * oom-killed):
1005
- */
1006
- pagefault_out_of_memory ();
1007
- } else {
1008
- if (fault & (VM_FAULT_SIGBUS |VM_FAULT_HWPOISON |
1009
- VM_FAULT_HWPOISON_LARGE ))
1010
- do_sigbus (regs , error_code , address , fault );
1011
- else if (fault & VM_FAULT_SIGSEGV )
1012
- bad_area_nosemaphore (regs , error_code , address );
1013
- else
1014
- BUG ();
1015
- }
1016
- }
1017
-
1018
984
static int spurious_kernel_fault_check (unsigned long error_code , pte_t * pte )
1019
985
{
1020
986
if ((error_code & X86_PF_WRITE ) && !pte_write (* pte ))
@@ -1252,7 +1218,7 @@ NOKPROBE_SYMBOL(do_kern_addr_fault);
1252
1218
/* Handle faults in the user portion of the address space */
1253
1219
static inline
1254
1220
void do_user_addr_fault (struct pt_regs * regs ,
1255
- unsigned long hw_error_code ,
1221
+ unsigned long error_code ,
1256
1222
unsigned long address )
1257
1223
{
1258
1224
struct vm_area_struct * vma ;
@@ -1272,8 +1238,8 @@ void do_user_addr_fault(struct pt_regs *regs,
1272
1238
* Reserved bits are never expected to be set on
1273
1239
* entries in the user portion of the page tables.
1274
1240
*/
1275
- if (unlikely (hw_error_code & X86_PF_RSVD ))
1276
- pgtable_bad (regs , hw_error_code , address );
1241
+ if (unlikely (error_code & X86_PF_RSVD ))
1242
+ pgtable_bad (regs , error_code , address );
1277
1243
1278
1244
/*
1279
1245
* If SMAP is on, check for invalid kernel (supervisor) access to user
@@ -1283,10 +1249,10 @@ void do_user_addr_fault(struct pt_regs *regs,
1283
1249
* enforcement appears to be consistent with the USER bit.
1284
1250
*/
1285
1251
if (unlikely (cpu_feature_enabled (X86_FEATURE_SMAP ) &&
1286
- !(hw_error_code & X86_PF_USER ) &&
1252
+ !(error_code & X86_PF_USER ) &&
1287
1253
!(regs -> flags & X86_EFLAGS_AC )))
1288
1254
{
1289
- bad_area_nosemaphore (regs , hw_error_code , address );
1255
+ bad_area_nosemaphore (regs , error_code , address );
1290
1256
return ;
1291
1257
}
1292
1258
@@ -1295,7 +1261,7 @@ void do_user_addr_fault(struct pt_regs *regs,
1295
1261
* in a region with pagefaults disabled then we must not take the fault
1296
1262
*/
1297
1263
if (unlikely (faulthandler_disabled () || !mm )) {
1298
- bad_area_nosemaphore (regs , hw_error_code , address );
1264
+ bad_area_nosemaphore (regs , error_code , address );
1299
1265
return ;
1300
1266
}
1301
1267
@@ -1316,9 +1282,9 @@ void do_user_addr_fault(struct pt_regs *regs,
1316
1282
1317
1283
perf_sw_event (PERF_COUNT_SW_PAGE_FAULTS , 1 , regs , address );
1318
1284
1319
- if (hw_error_code & X86_PF_WRITE )
1285
+ if (error_code & X86_PF_WRITE )
1320
1286
flags |= FAULT_FLAG_WRITE ;
1321
- if (hw_error_code & X86_PF_INSTR )
1287
+ if (error_code & X86_PF_INSTR )
1322
1288
flags |= FAULT_FLAG_INSTRUCTION ;
1323
1289
1324
1290
#ifdef CONFIG_X86_64
@@ -1334,7 +1300,7 @@ void do_user_addr_fault(struct pt_regs *regs,
1334
1300
* to consider the PF_PK bit.
1335
1301
*/
1336
1302
if (is_vsyscall_vaddr (address )) {
1337
- if (emulate_vsyscall (hw_error_code , regs , address ))
1303
+ if (emulate_vsyscall (error_code , regs , address ))
1338
1304
return ;
1339
1305
}
1340
1306
#endif
@@ -1357,7 +1323,7 @@ void do_user_addr_fault(struct pt_regs *regs,
1357
1323
* Fault from code in kernel from
1358
1324
* which we do not expect faults.
1359
1325
*/
1360
- bad_area_nosemaphore (regs , hw_error_code , address );
1326
+ bad_area_nosemaphore (regs , error_code , address );
1361
1327
return ;
1362
1328
}
1363
1329
retry :
@@ -1373,17 +1339,17 @@ void do_user_addr_fault(struct pt_regs *regs,
1373
1339
1374
1340
vma = find_vma (mm , address );
1375
1341
if (unlikely (!vma )) {
1376
- bad_area (regs , hw_error_code , address );
1342
+ bad_area (regs , error_code , address );
1377
1343
return ;
1378
1344
}
1379
1345
if (likely (vma -> vm_start <= address ))
1380
1346
goto good_area ;
1381
1347
if (unlikely (!(vma -> vm_flags & VM_GROWSDOWN ))) {
1382
- bad_area (regs , hw_error_code , address );
1348
+ bad_area (regs , error_code , address );
1383
1349
return ;
1384
1350
}
1385
1351
if (unlikely (expand_stack (vma , address ))) {
1386
- bad_area (regs , hw_error_code , address );
1352
+ bad_area (regs , error_code , address );
1387
1353
return ;
1388
1354
}
1389
1355
@@ -1392,8 +1358,8 @@ void do_user_addr_fault(struct pt_regs *regs,
1392
1358
* we can handle it..
1393
1359
*/
1394
1360
good_area :
1395
- if (unlikely (access_error (hw_error_code , vma ))) {
1396
- bad_area_access_error (regs , hw_error_code , address , vma );
1361
+ if (unlikely (access_error (error_code , vma ))) {
1362
+ bad_area_access_error (regs , error_code , address , vma );
1397
1363
return ;
1398
1364
}
1399
1365
@@ -1415,7 +1381,7 @@ void do_user_addr_fault(struct pt_regs *regs,
1415
1381
/* Quick path to respond to signals */
1416
1382
if (fault_signal_pending (fault , regs )) {
1417
1383
if (!user_mode (regs ))
1418
- no_context (regs , hw_error_code , address , SIGBUS ,
1384
+ no_context (regs , error_code , address , SIGBUS ,
1419
1385
BUS_ADRERR );
1420
1386
return ;
1421
1387
}
@@ -1432,11 +1398,38 @@ void do_user_addr_fault(struct pt_regs *regs,
1432
1398
}
1433
1399
1434
1400
mmap_read_unlock (mm );
1435
- if (unlikely (fault & VM_FAULT_ERROR )) {
1436
- mm_fault_error (regs , hw_error_code , address , fault );
1401
+ if (likely (!(fault & VM_FAULT_ERROR )))
1402
+ return ;
1403
+
1404
+ if (fatal_signal_pending (current ) && !(error_code & X86_PF_USER )) {
1405
+ no_context (regs , error_code , address , 0 , 0 );
1437
1406
return ;
1438
1407
}
1439
1408
1409
+ if (fault & VM_FAULT_OOM ) {
1410
+ /* Kernel mode? Handle exceptions or die: */
1411
+ if (!(error_code & X86_PF_USER )) {
1412
+ no_context (regs , error_code , address ,
1413
+ SIGSEGV , SEGV_MAPERR );
1414
+ return ;
1415
+ }
1416
+
1417
+ /*
1418
+ * We ran out of memory, call the OOM killer, and return the
1419
+ * userspace (which will retry the fault, or kill us if we got
1420
+ * oom-killed):
1421
+ */
1422
+ pagefault_out_of_memory ();
1423
+ } else {
1424
+ if (fault & (VM_FAULT_SIGBUS |VM_FAULT_HWPOISON |
1425
+ VM_FAULT_HWPOISON_LARGE ))
1426
+ do_sigbus (regs , error_code , address , fault );
1427
+ else if (fault & VM_FAULT_SIGSEGV )
1428
+ bad_area_nosemaphore (regs , error_code , address );
1429
+ else
1430
+ BUG ();
1431
+ }
1432
+
1440
1433
check_v8086_mode (regs , address , tsk );
1441
1434
}
1442
1435
NOKPROBE_SYMBOL (do_user_addr_fault );
0 commit comments