|
Lines 35-40
Link Here
|
| 35 |
#include <machine/asmacros.h> |
35 |
#include <machine/asmacros.h> |
| 36 |
#include <machine/intr_machdep.h> |
36 |
#include <machine/intr_machdep.h> |
| 37 |
#include <machine/pmap.h> |
37 |
#include <machine/pmap.h> |
|
|
38 |
#include <machine/smap_instr.h> |
| 38 |
|
39 |
|
| 39 |
#include "assym.s" |
40 |
#include "assym.s" |
| 40 |
|
41 |
|
|
Lines 244-255
ENTRY(copyout)
Link Here
|
| 244 |
|
245 |
|
| 245 |
shrq $3,%rcx |
246 |
shrq $3,%rcx |
| 246 |
cld |
247 |
cld |
|
|
248 |
STAC |
| 247 |
rep |
249 |
rep |
| 248 |
movsq |
250 |
movsq |
|
|
251 |
CLAC |
| 249 |
movb %dl,%cl |
252 |
movb %dl,%cl |
| 250 |
andb $7,%cl |
253 |
andb $7,%cl |
|
|
254 |
STAC |
| 251 |
rep |
255 |
rep |
| 252 |
movsb |
256 |
movsb |
|
|
257 |
CLAC |
| 253 |
|
258 |
|
| 254 |
done_copyout: |
259 |
done_copyout: |
| 255 |
xorl %eax,%eax |
260 |
xorl %eax,%eax |
|
Lines 258-263
done_copyout:
Link Here
|
| 258 |
ret |
263 |
ret |
| 259 |
|
264 |
|
| 260 |
ALIGN_TEXT |
265 |
ALIGN_TEXT |
|
|
266 |
/* |
| 267 |
* note: |
| 268 |
* When SMAP enabled, the EFLAGS.AC bit gets cleared before control reaches |
| 269 |
* the fault handler. |
| 270 |
*/ |
| 261 |
copyout_fault: |
271 |
copyout_fault: |
| 262 |
movq PCPU(CURPCB),%rdx |
272 |
movq PCPU(CURPCB),%rdx |
| 263 |
movq $0,PCB_ONFAULT(%rdx) |
273 |
movq $0,PCB_ONFAULT(%rdx) |
|
Lines 290-301
ENTRY(copyin)
Link Here
|
| 290 |
movb %cl,%al |
300 |
movb %cl,%al |
| 291 |
shrq $3,%rcx /* copy longword-wise */ |
301 |
shrq $3,%rcx /* copy longword-wise */ |
| 292 |
cld |
302 |
cld |
|
|
303 |
STAC |
| 293 |
rep |
304 |
rep |
| 294 |
movsq |
305 |
movsq |
|
|
306 |
CLAC |
| 295 |
movb %al,%cl |
307 |
movb %al,%cl |
| 296 |
andb $7,%cl /* copy remaining bytes */ |
308 |
andb $7,%cl /* copy remaining bytes */ |
|
|
309 |
STAC |
| 297 |
rep |
310 |
rep |
| 298 |
movsb |
311 |
movsb |
|
|
312 |
CLAC |
| 299 |
|
313 |
|
| 300 |
done_copyin: |
314 |
done_copyin: |
| 301 |
xorl %eax,%eax |
315 |
xorl %eax,%eax |
|
Lines 304-309
done_copyin:
Link Here
|
| 304 |
ret |
318 |
ret |
| 305 |
|
319 |
|
| 306 |
ALIGN_TEXT |
320 |
ALIGN_TEXT |
|
|
321 |
/* |
| 322 |
* note: |
| 323 |
* When SMAP enabled, the EFLAGS.AC bit gets cleared before control reaches |
| 324 |
* the fault handler. |
| 325 |
*/ |
| 307 |
copyin_fault: |
326 |
copyin_fault: |
| 308 |
movq PCPU(CURPCB),%rdx |
327 |
movq PCPU(CURPCB),%rdx |
| 309 |
movq $0,PCB_ONFAULT(%rdx) |
328 |
movq $0,PCB_ONFAULT(%rdx) |
|
Lines 324-333
ENTRY(casuword32)
Link Here
|
| 324 |
ja fusufault |
343 |
ja fusufault |
| 325 |
|
344 |
|
| 326 |
movl %esi,%eax /* old */ |
345 |
movl %esi,%eax /* old */ |
|
|
346 |
STAC |
| 327 |
#ifdef SMP |
347 |
#ifdef SMP |
| 328 |
lock |
348 |
lock |
| 329 |
#endif |
349 |
#endif |
| 330 |
cmpxchgl %edx,(%rdi) /* new = %edx */ |
350 |
cmpxchgl %edx,(%rdi) /* new = %edx */ |
|
|
351 |
CLAC |
| 331 |
|
352 |
|
| 332 |
/* |
353 |
/* |
| 333 |
* The old value is in %eax. If the store succeeded it will be the |
354 |
* The old value is in %eax. If the store succeeded it will be the |
|
Lines 353-362
ENTRY(casuword)
Link Here
|
| 353 |
ja fusufault |
374 |
ja fusufault |
| 354 |
|
375 |
|
| 355 |
movq %rsi,%rax /* old */ |
376 |
movq %rsi,%rax /* old */ |
|
|
377 |
STAC |
| 356 |
#ifdef SMP |
378 |
#ifdef SMP |
| 357 |
lock |
379 |
lock |
| 358 |
#endif |
380 |
#endif |
| 359 |
cmpxchgq %rdx,(%rdi) /* new = %rdx */ |
381 |
cmpxchgq %rdx,(%rdi) /* new = %rdx */ |
|
|
382 |
CLAC |
| 360 |
|
383 |
|
| 361 |
/* |
384 |
/* |
| 362 |
* The old value is in %eax. If the store succeeded it will be the |
385 |
* The old value is in %eax. If the store succeeded it will be the |
|
Lines 385-391
ENTRY(fuword)
Link Here
|
| 385 |
cmpq %rax,%rdi /* verify address is valid */ |
408 |
cmpq %rax,%rdi /* verify address is valid */ |
| 386 |
ja fusufault |
409 |
ja fusufault |
| 387 |
|
410 |
|
|
|
411 |
STAC |
| 388 |
movq (%rdi),%rax |
412 |
movq (%rdi),%rax |
|
|
413 |
CLAC |
| 389 |
movq $0,PCB_ONFAULT(%rcx) |
414 |
movq $0,PCB_ONFAULT(%rcx) |
| 390 |
ret |
415 |
ret |
| 391 |
END(fuword64) |
416 |
END(fuword64) |
|
Lines 399-405
ENTRY(fuword32)
Link Here
|
| 399 |
cmpq %rax,%rdi /* verify address is valid */ |
424 |
cmpq %rax,%rdi /* verify address is valid */ |
| 400 |
ja fusufault |
425 |
ja fusufault |
| 401 |
|
426 |
|
|
|
427 |
STAC |
| 402 |
movl (%rdi),%eax |
428 |
movl (%rdi),%eax |
|
|
429 |
CLAC |
| 403 |
movq $0,PCB_ONFAULT(%rcx) |
430 |
movq $0,PCB_ONFAULT(%rcx) |
| 404 |
ret |
431 |
ret |
| 405 |
END(fuword32) |
432 |
END(fuword32) |
|
Lines 426-432
ENTRY(fuword16)
Link Here
|
| 426 |
cmpq %rax,%rdi |
453 |
cmpq %rax,%rdi |
| 427 |
ja fusufault |
454 |
ja fusufault |
| 428 |
|
455 |
|
|
|
456 |
STAC |
| 429 |
movzwl (%rdi),%eax |
457 |
movzwl (%rdi),%eax |
|
|
458 |
CLAC |
| 430 |
movq $0,PCB_ONFAULT(%rcx) |
459 |
movq $0,PCB_ONFAULT(%rcx) |
| 431 |
ret |
460 |
ret |
| 432 |
END(fuword16) |
461 |
END(fuword16) |
|
Lines 439-450
ENTRY(fubyte)
Link Here
|
| 439 |
cmpq %rax,%rdi |
468 |
cmpq %rax,%rdi |
| 440 |
ja fusufault |
469 |
ja fusufault |
| 441 |
|
470 |
|
|
|
471 |
STAC |
| 442 |
movzbl (%rdi),%eax |
472 |
movzbl (%rdi),%eax |
|
|
473 |
CLAC |
| 443 |
movq $0,PCB_ONFAULT(%rcx) |
474 |
movq $0,PCB_ONFAULT(%rcx) |
| 444 |
ret |
475 |
ret |
| 445 |
END(fubyte) |
476 |
END(fubyte) |
| 446 |
|
477 |
|
| 447 |
ALIGN_TEXT |
478 |
ALIGN_TEXT |
|
|
479 |
/* |
| 480 |
* note: |
| 481 |
* When SMAP enabled, the EFLAGS.AC bit gets cleared before control reaches |
| 482 |
* the fault handler. |
| 483 |
*/ |
| 448 |
fusufault: |
484 |
fusufault: |
| 449 |
movq PCPU(CURPCB),%rcx |
485 |
movq PCPU(CURPCB),%rcx |
| 450 |
xorl %eax,%eax |
486 |
xorl %eax,%eax |
|
Lines 466-472
ENTRY(suword)
Link Here
|
| 466 |
cmpq %rax,%rdi /* verify address validity */ |
502 |
cmpq %rax,%rdi /* verify address validity */ |
| 467 |
ja fusufault |
503 |
ja fusufault |
| 468 |
|
504 |
|
|
|
505 |
STAC |
| 469 |
movq %rsi,(%rdi) |
506 |
movq %rsi,(%rdi) |
|
|
507 |
CLAC |
| 470 |
xorl %eax,%eax |
508 |
xorl %eax,%eax |
| 471 |
movq PCPU(CURPCB),%rcx |
509 |
movq PCPU(CURPCB),%rcx |
| 472 |
movq %rax,PCB_ONFAULT(%rcx) |
510 |
movq %rax,PCB_ONFAULT(%rcx) |
|
Lines 482-488
ENTRY(suword32)
Link Here
|
| 482 |
cmpq %rax,%rdi /* verify address validity */ |
520 |
cmpq %rax,%rdi /* verify address validity */ |
| 483 |
ja fusufault |
521 |
ja fusufault |
| 484 |
|
522 |
|
|
|
523 |
STAC |
| 485 |
movl %esi,(%rdi) |
524 |
movl %esi,(%rdi) |
|
|
525 |
CLAC |
| 486 |
xorl %eax,%eax |
526 |
xorl %eax,%eax |
| 487 |
movq PCPU(CURPCB),%rcx |
527 |
movq PCPU(CURPCB),%rcx |
| 488 |
movq %rax,PCB_ONFAULT(%rcx) |
528 |
movq %rax,PCB_ONFAULT(%rcx) |
|
Lines 497-503
ENTRY(suword16)
Link Here
|
| 497 |
cmpq %rax,%rdi /* verify address validity */ |
537 |
cmpq %rax,%rdi /* verify address validity */ |
| 498 |
ja fusufault |
538 |
ja fusufault |
| 499 |
|
539 |
|
|
|
540 |
STAC |
| 500 |
movw %si,(%rdi) |
541 |
movw %si,(%rdi) |
|
|
542 |
CLAC |
| 501 |
xorl %eax,%eax |
543 |
xorl %eax,%eax |
| 502 |
movq PCPU(CURPCB),%rcx /* restore trashed register */ |
544 |
movq PCPU(CURPCB),%rcx /* restore trashed register */ |
| 503 |
movq %rax,PCB_ONFAULT(%rcx) |
545 |
movq %rax,PCB_ONFAULT(%rcx) |
|
Lines 513-519
ENTRY(subyte)
Link Here
|
| 513 |
ja fusufault |
555 |
ja fusufault |
| 514 |
|
556 |
|
| 515 |
movl %esi,%eax |
557 |
movl %esi,%eax |
|
|
558 |
STAC |
| 516 |
movb %al,(%rdi) |
559 |
movb %al,(%rdi) |
|
|
560 |
CLAC |
| 517 |
xorl %eax,%eax |
561 |
xorl %eax,%eax |
| 518 |
movq PCPU(CURPCB),%rcx /* restore trashed register */ |
562 |
movq PCPU(CURPCB),%rcx /* restore trashed register */ |
| 519 |
movq %rax,PCB_ONFAULT(%rcx) |
563 |
movq %rax,PCB_ONFAULT(%rcx) |
|
Lines 555-561
ENTRY(copyinstr)
Link Here
|
| 555 |
decq %rdx |
599 |
decq %rdx |
| 556 |
jz 3f |
600 |
jz 3f |
| 557 |
|
601 |
|
|
|
602 |
STAC |
| 558 |
lodsb |
603 |
lodsb |
|
|
604 |
CLAC |
| 559 |
stosb |
605 |
stosb |
| 560 |
orb %al,%al |
606 |
orb %al,%al |
| 561 |
jnz 2b |
607 |
jnz 2b |
|
Lines 584-590
cpystrflt_x:
Link Here
|
| 584 |
testq %r9,%r9 |
630 |
testq %r9,%r9 |
| 585 |
jz 1f |
631 |
jz 1f |
| 586 |
subq %rdx,%r8 |
632 |
subq %rdx,%r8 |
|
|
633 |
STAC |
| 587 |
movq %r8,(%r9) |
634 |
movq %r8,(%r9) |
|
|
635 |
CLAC |
| 588 |
1: |
636 |
1: |
| 589 |
ret |
637 |
ret |
| 590 |
END(copyinstr) |
638 |
END(copyinstr) |