Revert "rename amd64 architecture to x86_64"
[dragonfly.git] / sys / platform / pc64 / amd64 / support.s
1 /*-
2  * Copyright (c) 1993 The Regents of the University of California.
3  * Copyright (c) 2003 Peter Wemm.
4  * Copyright (c) 2008 The DragonFly Project.
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice, this list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  * 4. Neither the name of the University nor the names of its contributors
16  *    may be used to endorse or promote products derived from this software
17  *    without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29  * SUCH DAMAGE.
30  *
31  * $FreeBSD: src/sys/amd64/amd64/support.S,v 1.127 2007/05/23 08:33:04 kib Exp $
32  * $DragonFly: src/sys/platform/pc64/amd64/support.s,v 1.2 2008/08/29 17:07:10 dillon Exp $
33  */
34
35 #include "opt_ddb.h"
36
37 #include <machine/asmacros.h>
38 #include <machine_base/isa/intr_machdep.h>
39 #include <machine/pmap.h>
40
41 #include "assym.s"
42
43         ALIGN_DATA
44
45         .text
46
47 /*
48  * bcopy family
49  * void bzero(void *buf, u_int len)
50  */
51
52 /* done */
53 ENTRY(bzero)
54         movq    %rsi,%rcx
55         xorl    %eax,%eax
56         shrq    $3,%rcx
57         cld
58         rep
59         stosq
60         movq    %rsi,%rcx
61         andq    $7,%rcx
62         rep
63         stosb
64         ret
65
66 /* Address: %rdi */
67 ENTRY(pagezero)
68         movq    $-PAGE_SIZE,%rdx
69         subq    %rdx,%rdi
70         xorl    %eax,%eax
71 1:
72         movnti  %rax,(%rdi,%rdx)
73         movnti  %rax,8(%rdi,%rdx)
74         movnti  %rax,16(%rdi,%rdx)
75         movnti  %rax,24(%rdi,%rdx)
76         addq    $32,%rdx
77         jne     1b
78         sfence
79         ret
80
81 ENTRY(bcmp)
82         movq    %rdx,%rcx
83         shrq    $3,%rcx
84         cld                                     /* compare forwards */
85         repe
86         cmpsq
87         jne     1f
88
89         movq    %rdx,%rcx
90         andq    $7,%rcx
91         repe
92         cmpsb
93 1:
94         setne   %al
95         movsbl  %al,%eax
96         ret
97
98 /*
99  * bcopy(src, dst, cnt)
100  *       rdi, rsi, rdx
101  *  ws@tools.de     (Wolfgang Solfrank, TooLs GmbH) +49-228-985800
102  */
103 ENTRY(generic_bcopy)    /* generic_bcopy is bcopy without FPU */
104 ENTRY(ovbcopy) /* our bcopy doesn't use the FPU, so ovbcopy is the same */
105 ENTRY(bcopy)
106         xchgq   %rsi,%rdi
107         movq    %rdx,%rcx
108
109         movq    %rdi,%rax
110         subq    %rsi,%rax
111         cmpq    %rcx,%rax                       /* overlapping && src < dst? */
112         jb      1f
113
114         shrq    $3,%rcx                         /* copy by 64-bit words */
115         cld                                     /* nope, copy forwards */
116         rep
117         movsq
118         movq    %rdx,%rcx
119         andq    $7,%rcx                         /* any bytes left? */
120         rep
121         movsb
122         ret
123
124         /* ALIGN_TEXT */
125 1:
126         addq    %rcx,%rdi                       /* copy backwards */
127         addq    %rcx,%rsi
128         decq    %rdi
129         decq    %rsi
130         andq    $7,%rcx                         /* any fractional bytes? */
131         std
132         rep
133         movsb
134         movq    %rdx,%rcx                       /* copy remainder by 32-bit words */
135         shrq    $3,%rcx
136         subq    $7,%rsi
137         subq    $7,%rdi
138         rep
139         movsq
140         cld
141         ret
142 ENTRY(reset_dbregs)
143         movq    $0x200,%rax   /* the manual says that bit 10 must be set to 1 */
144         movq    %rax,%dr7     /* disable all breapoints first */
145         movq    $0,%rax
146         movq    %rax,%dr0
147         movq    %rax,%dr1
148         movq    %rax,%dr2
149         movq    %rax,%dr3
150         movq    %rax,%dr6
151         ret
152
153 /*
154  * Note: memcpy does not support overlapping copies
155  */
156 ENTRY(memcpy)
157         movq    %rdx,%rcx
158         shrq    $3,%rcx                         /* copy by 64-bit words */
159         cld                                     /* copy forwards */
160         rep
161         movsq
162         movq    %rdx,%rcx
163         andq    $7,%rcx                         /* any bytes left? */
164         rep
165         movsb
166         ret
167
168 /*
169  * pagecopy(%rdi=from, %rsi=to)
170  */
171 ENTRY(pagecopy)
172         movq    $-PAGE_SIZE,%rax
173         movq    %rax,%rdx
174         subq    %rax,%rdi
175         subq    %rax,%rsi
176 1:
177         prefetchnta (%rdi,%rax)
178         addq    $64,%rax
179         jne     1b
180 2:
181         movq    (%rdi,%rdx),%rax
182         movnti  %rax,(%rsi,%rdx)
183         movq    8(%rdi,%rdx),%rax
184         movnti  %rax,8(%rsi,%rdx)
185         movq    16(%rdi,%rdx),%rax
186         movnti  %rax,16(%rsi,%rdx)
187         movq    24(%rdi,%rdx),%rax
188         movnti  %rax,24(%rsi,%rdx)
189         addq    $32,%rdx
190         jne     2b
191         sfence
192         ret
193
194 /* fillw(pat, base, cnt) */  
195 /*       %rdi,%rsi, %rdx */
196 ENTRY(fillw)
197         movq    %rdi,%rax   
198         movq    %rsi,%rdi
199         movq    %rdx,%rcx
200         cld
201         rep
202         stosw
203         ret
204
205 /*****************************************************************************/
206 /* copyout and fubyte family                                                 */
207 /*****************************************************************************/
208 /*
209  * Access user memory from inside the kernel. These routines should be
210  * the only places that do this.
211  *
212  * These routines set curpcb->onfault for the time they execute. When a
213  * protection violation occurs inside the functions, the trap handler
214  * returns to *curpcb->onfault instead of the function.
215  */
216
217 /*
218  * copyout(from_kernel, to_user, len)  - MP SAFE
219  *         %rdi,        %rsi,    %rdx
220  */
221 ENTRY(copyout)
222         movq    PCPU(curthread),%rax
223         movq    TD_PCB(%rax), %rax
224         movq    $copyout_fault,PCB_ONFAULT(%rax)
225         testq   %rdx,%rdx                       /* anything to do? */
226         jz      done_copyout
227
228         /*
229          * Check explicitly for non-user addresses.  If 486 write protection
230          * is being used, this check is essential because we are in kernel
231          * mode so the h/w does not provide any protection against writing
232          * kernel addresses.
233          */
234
235         /*
236          * First, prevent address wrapping.
237          */
238         movq    %rsi,%rax
239         addq    %rdx,%rax
240         jc      copyout_fault
241 /*
242  * XXX STOP USING VM_MAX_USER_ADDRESS.
243  * It is an end address, not a max, so every time it is used correctly it
244  * looks like there is an off by one error, and of course it caused an off
245  * by one error in several places.
246  */
247         movq    $VM_MAX_USER_ADDRESS,%rcx
248         cmpq    %rcx,%rax
249         ja      copyout_fault
250
251         xchgq   %rdi,%rsi
252         /* bcopy(%rsi, %rdi, %rdx) */
253         movq    %rdx,%rcx
254
255         shrq    $3,%rcx
256         cld
257         rep
258         movsq
259         movb    %dl,%cl
260         andb    $7,%cl
261         rep
262         movsb
263
264 done_copyout:
265         xorl    %eax,%eax
266         movq    PCPU(curthread),%rdx
267         movq    TD_PCB(%rdx), %rdx
268         movq    %rax,PCB_ONFAULT(%rdx)
269         ret
270
271         ALIGN_TEXT
272 copyout_fault:
273         movq    PCPU(curthread),%rdx
274         movq    TD_PCB(%rdx), %rdx
275         movq    $0,PCB_ONFAULT(%rdx)
276         movq    $EFAULT,%rax
277         ret
278
279 /*
280  * copyin(from_user, to_kernel, len) - MP SAFE
281  *        %rdi,      %rsi,      %rdx
282  */
283 ENTRY(copyin)
284         movq    PCPU(curthread),%rax
285         movq    TD_PCB(%rax), %rax
286         movq    $copyin_fault,PCB_ONFAULT(%rax)
287         testq   %rdx,%rdx                       /* anything to do? */
288         jz      done_copyin
289
290         /*
291          * make sure address is valid
292          */
293         movq    %rdi,%rax
294         addq    %rdx,%rax
295         jc      copyin_fault
296         movq    $VM_MAX_USER_ADDRESS,%rcx
297         cmpq    %rcx,%rax
298         ja      copyin_fault
299
300         xchgq   %rdi,%rsi
301         movq    %rdx,%rcx
302         movb    %cl,%al
303         shrq    $3,%rcx                         /* copy longword-wise */
304         cld
305         rep
306         movsq
307         movb    %al,%cl
308         andb    $7,%cl                          /* copy remaining bytes */
309         rep
310         movsb
311
312 done_copyin:
313         xorl    %eax,%eax
314         movq    PCPU(curthread),%rdx
315         movq    TD_PCB(%rdx), %rdx
316         movq    %rax,PCB_ONFAULT(%rdx)
317         ret
318
319         ALIGN_TEXT
320 copyin_fault:
321         movq    PCPU(curthread),%rdx
322         movq    TD_PCB(%rdx), %rdx
323         movq    $0,PCB_ONFAULT(%rdx)
324         movq    $EFAULT,%rax
325         ret
326
327 /*
328  * casuword32.  Compare and set user integer.  Returns -1 or the current value.
329  *        dst = %rdi, old = %rsi, new = %rdx
330  */
331 ENTRY(casuword32)
332         movq    PCPU(curthread),%rcx
333         movq    TD_PCB(%rcx), %rcx
334         movq    $fusufault,PCB_ONFAULT(%rcx)
335
336         movq    $VM_MAX_USER_ADDRESS-4,%rax
337         cmpq    %rax,%rdi                       /* verify address is valid */
338         ja      fusufault
339
340         movl    %esi,%eax                       /* old */
341 #ifdef SMP
342         lock
343 #endif
344         cmpxchgl %edx,(%rdi)                    /* new = %edx */
345
346         /*
347          * The old value is in %eax.  If the store succeeded it will be the
348          * value we expected (old) from before the store, otherwise it will
349          * be the current value.
350          */
351
352         movq    PCPU(curthread),%rcx
353         movq    TD_PCB(%rcx), %rcx
354         movq    $0,PCB_ONFAULT(%rcx)
355         ret
356
357 /*
358  * casuword.  Compare and set user word.  Returns -1 or the current value.
359  *        dst = %rdi, old = %rsi, new = %rdx
360  */
361 ENTRY(casuword)
362         movq    PCPU(curthread),%rcx
363         movq    TD_PCB(%rcx), %rcx
364         movq    $fusufault,PCB_ONFAULT(%rcx)
365
366         movq    $VM_MAX_USER_ADDRESS-4,%rax
367         cmpq    %rax,%rdi                       /* verify address is valid */
368         ja      fusufault
369
370         movq    %rsi,%rax                       /* old */
371 #ifdef SMP
372         lock
373 #endif
374         cmpxchgq %rdx,(%rdi)                    /* new = %rdx */
375
376         /*
377          * The old value is in %eax.  If the store succeeded it will be the
378          * value we expected (old) from before the store, otherwise it will
379          * be the current value.
380          */
381
382         movq    PCPU(curthread),%rcx
383         movq    TD_PCB(%rcx), %rcx
384         movq    $fusufault,PCB_ONFAULT(%rcx)
385         movq    $0,PCB_ONFAULT(%rcx)
386         ret
387
388 /*
389  * Fetch (load) a 64-bit word, a 32-bit word, a 16-bit word, or an 8-bit
390  * byte from user memory.  All these functions are MPSAFE.
391  * addr = %rdi
392  */
393
394 ALTENTRY(fuword64)
395 ENTRY(fuword)
396         movq    PCPU(curthread),%rcx
397         movq    TD_PCB(%rcx), %rcx
398         movq    $fusufault,PCB_ONFAULT(%rcx)
399
400         movq    $VM_MAX_USER_ADDRESS-8,%rax
401         cmpq    %rax,%rdi                       /* verify address is valid */
402         ja      fusufault
403
404         movq    (%rdi),%rax
405         movq    $0,PCB_ONFAULT(%rcx)
406         ret
407
408 ENTRY(fuword32)
409         movq    PCPU(curthread),%rcx
410         movq    TD_PCB(%rcx), %rcx
411         movq    $fusufault,PCB_ONFAULT(%rcx)
412
413         movq    $VM_MAX_USER_ADDRESS-4,%rax
414         cmpq    %rax,%rdi                       /* verify address is valid */
415         ja      fusufault
416
417         movl    (%rdi),%eax
418         movq    $0,PCB_ONFAULT(%rcx)
419         ret
420
421 /*
422  * fuswintr() and suswintr() are specialized variants of fuword16() and
423  * suword16(), respectively.  They are called from the profiling code,
424  * potentially at interrupt time.  If they fail, that's okay; good things
425  * will happen later.  They always fail for now, until the trap code is
426  * able to deal with this.
427  */
428 ALTENTRY(suswintr)
429 ENTRY(fuswintr)
430         movq    $-1,%rax
431         ret
432
433 ENTRY(fuword16)
434         movq    PCPU(curthread),%rcx
435         movq    TD_PCB(%rcx), %rcx
436         movq    $fusufault,PCB_ONFAULT(%rcx)
437
438         movq    $VM_MAX_USER_ADDRESS-2,%rax
439         cmpq    %rax,%rdi
440         ja      fusufault
441
442         movzwl  (%rdi),%eax
443         movq    $0,PCB_ONFAULT(%rcx)
444         ret
445
446 ENTRY(fubyte)
447         movq    PCPU(curthread),%rcx
448         movq    TD_PCB(%rcx), %rcx
449         movq    $fusufault,PCB_ONFAULT(%rcx)
450
451         movq    $VM_MAX_USER_ADDRESS-1,%rax
452         cmpq    %rax,%rdi
453         ja      fusufault
454
455         movzbl  (%rdi),%eax
456         movq    $0,PCB_ONFAULT(%rcx)
457         ret
458
459         ALIGN_TEXT
460 fusufault:
461         movq    PCPU(curthread),%rcx
462         xorl    %eax,%eax
463         movq    TD_PCB(%rcx), %rcx
464         movq    %rax,PCB_ONFAULT(%rcx)
465         decq    %rax
466         ret
467
468 /*
469  * Store a 64-bit word, a 32-bit word, a 16-bit word, or an 8-bit byte to
470  * user memory.  All these functions are MPSAFE.
471  * addr = %rdi, value = %rsi
472  */
473 ALTENTRY(suword64)
474 ENTRY(suword)
475         movq    PCPU(curthread),%rcx
476         movq    TD_PCB(%rcx), %rcx
477         movq    $fusufault,PCB_ONFAULT(%rcx)
478
479         movq    $VM_MAX_USER_ADDRESS-8,%rax
480         cmpq    %rax,%rdi                       /* verify address validity */
481         ja      fusufault
482
483         movq    %rsi,(%rdi)
484         xorl    %eax,%eax
485         movq    PCPU(curthread),%rcx
486         movq    TD_PCB(%rcx), %rcx
487         movq    %rax,PCB_ONFAULT(%rcx)
488         ret
489
490 ENTRY(suword32)
491         movq    PCPU(curthread),%rcx
492         movq    TD_PCB(%rcx), %rcx
493         movq    $fusufault,PCB_ONFAULT(%rcx)
494
495         movq    $VM_MAX_USER_ADDRESS-4,%rax
496         cmpq    %rax,%rdi                       /* verify address validity */
497         ja      fusufault
498
499         movl    %esi,(%rdi)
500         xorl    %eax,%eax
501         movq    PCPU(curthread),%rcx
502         movq    TD_PCB(%rcx), %rcx
503         movq    %rax,PCB_ONFAULT(%rcx)
504         ret
505
506 ENTRY(suword16)
507         movq    PCPU(curthread),%rcx
508         movq    TD_PCB(%rcx), %rcx
509         movq    $fusufault,PCB_ONFAULT(%rcx)
510
511         movq    $VM_MAX_USER_ADDRESS-2,%rax
512         cmpq    %rax,%rdi                       /* verify address validity */
513         ja      fusufault
514
515         movw    %si,(%rdi)
516         xorl    %eax,%eax
517         movq    PCPU(curthread),%rcx            /* restore trashed register */
518         movq    TD_PCB(%rcx), %rcx
519         movq    %rax,PCB_ONFAULT(%rcx)
520         ret
521
522 ENTRY(subyte)
523         movq    PCPU(curthread),%rcx
524         movq    TD_PCB(%rcx), %rcx
525         movq    $fusufault,PCB_ONFAULT(%rcx)
526
527         movq    $VM_MAX_USER_ADDRESS-1,%rax
528         cmpq    %rax,%rdi                       /* verify address validity */
529         ja      fusufault
530
531         movl    %esi,%eax
532         movb    %al,(%rdi)
533         xorl    %eax,%eax
534         movq    PCPU(curthread),%rcx            /* restore trashed register */
535         movq    TD_PCB(%rcx), %rcx
536         movq    %rax,PCB_ONFAULT(%rcx)
537         ret
538
539 /*
540  * copyinstr(from, to, maxlen, int *lencopied) - MP SAFE
541  *           %rdi, %rsi, %rdx, %rcx
542  *
543  *      copy a string from from to to, stop when a 0 character is reached.
544  *      return ENAMETOOLONG if string is longer than maxlen, and
545  *      EFAULT on protection violations. If lencopied is non-zero,
546  *      return the actual length in *lencopied.
547  */
548 ENTRY(copyinstr)
549         movq    %rdx,%r8                        /* %r8 = maxlen */
550         movq    %rcx,%r9                        /* %r9 = *len */
551         xchgq   %rdi,%rsi                       /* %rdi = from, %rsi = to */
552         movq    PCPU(curthread),%rcx
553         movq    TD_PCB(%rcx), %rcx
554         movq    $cpystrflt,PCB_ONFAULT(%rcx)
555
556         movq    $VM_MAX_USER_ADDRESS,%rax
557
558         /* make sure 'from' is within bounds */
559         subq    %rsi,%rax
560         jbe     cpystrflt
561
562         /* restrict maxlen to <= VM_MAX_USER_ADDRESS-from */
563         cmpq    %rdx,%rax
564         jae     1f
565         movq    %rax,%rdx
566         movq    %rax,%r8
567 1:
568         incq    %rdx
569         cld
570
571 2:
572         decq    %rdx
573         jz      3f
574
575         lodsb
576         stosb
577         orb     %al,%al
578         jnz     2b
579
580         /* Success -- 0 byte reached */
581         decq    %rdx
582         xorl    %eax,%eax
583         jmp     cpystrflt_x
584 3:
585         /* rdx is zero - return ENAMETOOLONG or EFAULT */
586         movq    $VM_MAX_USER_ADDRESS,%rax
587         cmpq    %rax,%rsi
588         jae     cpystrflt
589 4:
590         movq    $ENAMETOOLONG,%rax
591         jmp     cpystrflt_x
592
593 cpystrflt:
594         movq    $EFAULT,%rax
595
596 cpystrflt_x:
597         /* set *lencopied and return %eax */
598         movq    PCPU(curthread),%rcx
599         movq    TD_PCB(%rcx), %rcx
600         movq    $0,PCB_ONFAULT(%rcx)
601
602         testq   %r9,%r9
603         jz      1f
604         subq    %rdx,%r8
605         movq    %r8,(%r9)
606 1:
607         ret
608
609
610 /*
611  * copystr(from, to, maxlen, int *lencopied) - MP SAFE
612  *         %rdi, %rsi, %rdx, %rcx
613  */
614 ENTRY(copystr)
615         movq    %rdx,%r8                        /* %r8 = maxlen */
616
617         xchgq   %rdi,%rsi
618         incq    %rdx
619         cld
620 1:
621         decq    %rdx
622         jz      4f
623         lodsb
624         stosb
625         orb     %al,%al
626         jnz     1b
627
628         /* Success -- 0 byte reached */
629         decq    %rdx
630         xorl    %eax,%eax
631         jmp     6f
632 4:
633         /* rdx is zero -- return ENAMETOOLONG */
634         movq    $ENAMETOOLONG,%rax
635
636 6:
637
638         testq   %rcx,%rcx
639         jz      7f
640         /* set *lencopied and return %rax */
641         subq    %rdx,%r8
642         movq    %r8,(%rcx)
643 7:
644         ret
645
646 /*
647  * Handling of special amd64 registers and descriptor tables etc
648  * %rdi
649  */
650 /* void lgdt(struct region_descriptor *rdp); */
651 ENTRY(lgdt)
652         /* reload the descriptor table */
653         lgdt    (%rdi)
654
655         /* flush the prefetch q */
656         jmp     1f
657         nop
658 1:
659         movl    $KDSEL,%eax
660         movl    %eax,%ds
661         movl    %eax,%es
662         movl    %eax,%fs        /* Beware, use wrmsr to set 64 bit base */
663         movl    %eax,%gs        /* Beware, use wrmsr to set 64 bit base */
664         movl    %eax,%ss
665
666         /* reload code selector by turning return into intersegmental return */
667         popq    %rax
668         pushq   $KCSEL
669         pushq   %rax
670         MEXITCOUNT
671         lretq
672
673 /*****************************************************************************/
674 /* setjump, longjump                                                         */
675 /*****************************************************************************/
676
677 ENTRY(setjmp)
678         movq    %rbx,0(%rdi)                    /* save rbx */
679         movq    %rsp,8(%rdi)                    /* save rsp */
680         movq    %rbp,16(%rdi)                   /* save rbp */
681         movq    %r12,24(%rdi)                   /* save r12 */
682         movq    %r13,32(%rdi)                   /* save r13 */
683         movq    %r14,40(%rdi)                   /* save r14 */
684         movq    %r15,48(%rdi)                   /* save r15 */
685         movq    0(%rsp),%rdx                    /* get rta */
686         movq    %rdx,56(%rdi)                   /* save rip */
687         xorl    %eax,%eax                       /* return(0); */
688         ret
689
690 ENTRY(longjmp)
691         movq    0(%rdi),%rbx                    /* restore rbx */
692         movq    8(%rdi),%rsp                    /* restore rsp */
693         movq    16(%rdi),%rbp                   /* restore rbp */
694         movq    24(%rdi),%r12                   /* restore r12 */
695         movq    32(%rdi),%r13                   /* restore r13 */
696         movq    40(%rdi),%r14                   /* restore r14 */
697         movq    48(%rdi),%r15                   /* restore r15 */
698         movq    56(%rdi),%rdx                   /* get rta */
699         movq    %rdx,0(%rsp)                    /* put in return frame */
700         xorl    %eax,%eax                       /* return(1); */
701         incl    %eax
702         ret
703
704 /*
705  * Support for BB-profiling (gcc -a).  The kernbb program will extract
706  * the data from the kernel.
707  */
708
709         .data
710         ALIGN_DATA
711         .globl bbhead
712 bbhead:
713         .quad 0
714
715         .text
716 NON_GPROF_ENTRY(__bb_init_func)
717         movq    $1,(%rdi)
718         movq    bbhead,%rax
719         movq    %rax,32(%rdi)
720         movq    %rdi,bbhead
721         NON_GPROF_RET