github.com/jlmucb/cloudproxy@v0.0.0-20170830161738-b5aa0b619bc4/cpvmm/vmm/host/hw/em64t/em64t_isr.s (about)

     1  #
     2  # Copyright (c) 2013 Intel Corporation
     3  #
     4  # Licensed under the Apache License, Version 2.0 (the "License");
     5  # you may not use this file except in compliance with the License.
     6  # You may obtain a copy of the License at
     7  #     http://www.apache.org/licenses/LICENSE-2.0
     8  # Unless required by applicable law or agreed to in writing, software
     9  # distributed under the License is distributed on an "AS IS" BASIS,
    10  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    11  # See the License for the specific language governing permissions and
    12  # limitations under the License.
    13  
    14  
    15  .intel_syntax
    16  .text
    17  
    18  
    19  .extern VMM_GP_REGISTERS
    20  
    21  #   This code was originally written for the Microsoft calling convention.
    22  #   The first few arguments were passed in rcx, rdx,r8 and r9, floating
    23  #   point in xmm0-3 and the caller was responsible for stack cleanup;
    24  #   further, MS specifies a 32 byte shadow buffer where arguments can be 
    25  #   spilled.
    26  #   By contrast, gcc (and most other compilers) pass the first few arguments
    27  #   in rdi, rsi, rdx, rcx, r8, r9  and the callee is responsible for stack
    28  #   cleanup.   FP returns are still in xmm0-xmm3.
    29  
    30  
    31  .extern g_exception_gpr
    32  .extern exception_class
    33  .extern isr_c_handler
    34  
    35  .set    VECTOR_19, 19
    36  .set    FAULT_CLASS, 2
    37  
    38  .text
    39  
    40  
    41  #  UINT8 __stdcall hw_isr ( void);
    42  #  ISR handler. Pushes hardcoded CPU ID onto stack and jumps to vector routine
    43  #  Stack offsets on entry:
    44  #        eax register will contain result         
    45  #              Bits 7-0: #Physical Address Bits
    46  #              Bits 15-8: #Virtual Address Bits
    47  #              Bits 31-16: Reserved =
    48  
    49  .macro isr_entry_macro vector
    50          push vector
    51          jmp  hw_isr_c_wrapper
    52  .endm
    53  
    54  .globl  hw_isr_c_wrapper
    55  hw_isr_c_wrapper:
    56          push   %rax     # offset 08
    57          push   %rbx     # offset 00
    58  
    59          # If an exception fault is detected, save the GPRs
    60          # for the assertion debug buffer
    61  
    62          mov    %rbx, qword ptr [%rsp+0x10]      # vector number
    63          # all exception faults have vector number up to 19
    64          cmp    %rbx, VECTOR_19
    65          jg    1f 
    66  
    67          # check the exception type
    68          lea    %rax, qword ptr exception_class
    69          movzx  %ebx, byte ptr [%rbx+%rax]
    70          cmp    %ebx, FAULT_CLASS
    71          jne    1f 
    72  
    73          # Save GPRs
    74          mov    %rax, qword ptr [%rsp+0x08]             # this is rax
    75          mov    %rbx, g_exception_gpr
    76          mov    [%rbx], %rax
    77  
    78          mov    %rax, qword ptr [%rsp+0x00]             # this is rbx
    79          mov    8[%rbx], %rax
    80  
    81          # now save all other GP registers except RIP,RSP,RFLAGS
    82          mov    16[%rbx], %rcx
    83          mov    24[%rbx], %rdx
    84          mov    32[%rbx], %rdi
    85          mov    40[%rbx], %rsi
    86          mov    48[%rbx], %rbp
    87          mov    64[%rbx],  %r8
    88          mov    72[%rbx],  %r9
    89          mov    80[%rbx], %r10
    90          mov    88[%rbx], %r11
    91          mov    96[%rbx], %r12
    92          mov    104[%rbx], %r13
    93          mov    112[%rbx], %r14
    94          mov    120[%rbx], %r15
    95                          1:
    96          pop    %rbx
    97          pop    %rax
    98  
    99          # save context and prepare stack for C-function
   100          # at this point stack contains
   101          # [       SS         ]
   102          # [       RSP        ]
   103          # [      RFLAGS      ]
   104          # [       CS         ]
   105          # [       RIP        ] <= here RSP should point prior iret
   106          # [[   errcode      ]]    optionally
   107          # [    vector ID     ] <= RSP
   108          
   109          push    %rdi             # save RDI which used for argument passing
   110          mov     %rdi, %rsp
   111          add     %rdi, 0x8         # now RDI points to the location of vector ID
   112          push    %rsi            # just in case
   113          push    %rcx            # just in case
   114          
   115          push    %rdx
   116          push    %rax
   117          push    %r8
   118          push    %r9
   119          push    %r10
   120          push    %r11
   121          push    %r15             # used for saving unaligned stack
   122          mov     %r15, %rsp        # save RSP prior alignment
   123          and     %rsp, 0x0FFFFFFFFFFFFFFF0 # align on 16 bytes boundary
   124          sub     %rsp, 0x020       # prepare space for C-function
   125          call    isr_c_handler
   126          mov     %rsp, %r15        # restore unaligned RSP
   127          pop     %r15
   128          pop     %r11
   129          pop     %r10
   130          pop     %r9
   131          pop     %r8
   132          pop     %rax
   133          pop     %rdx
   134          
   135          # the following is the substitute code for gcc
   136          pop     %rcx    # just in case
   137          pop     %rsi    # just in case
   138          pop     %rdi    # restored from parameter passing
   139          pop     %rsp    # isr_c_handler replaces vector ID with pointer to the
   140                          # RIP. Just pop the pointer to the RIP into RSP.
   141          iretq
   142  
   143  #; functions below instantiate isr_entry_macro for 256 vectors (IDT entries)
   144  
   145  .func isr_entry_00
   146          push 0x000
   147          jmp  hw_isr_c_wrapper
   148  .endfunc
   149  #isr_entry_00 ENDP
   150  
   151  .func isr_entry_01
   152          push 0x001
   153          jmp  hw_isr_c_wrapper
   154  .endfunc
   155  
   156  .func isr_entry_02
   157          push 0x002
   158          jmp  hw_isr_c_wrapper
   159  .endfunc
   160  
   161  .func isr_entry_03
   162          push 0x003
   163          jmp  hw_isr_c_wrapper
   164  .endfunc
   165  
   166  .func isr_entry_04
   167          push 0x004
   168          jmp  hw_isr_c_wrapper
   169  .endfunc
   170  
   171  .func isr_entry_05
   172          push 0x005
   173          jmp  hw_isr_c_wrapper
   174  .endfunc
   175  
   176  .func isr_entry_06
   177          push 0x006
   178          jmp  hw_isr_c_wrapper
   179  .endfunc
   180  
   181  .func isr_entry_07
   182          push 0x007
   183          jmp  hw_isr_c_wrapper
   184  .endfunc
   185  
   186  .func isr_entry_08
   187          push 0x008
   188          jmp  hw_isr_c_wrapper
   189  .endfunc
   190  
   191  .func isr_entry_09
   192          push 0x009
   193          jmp  hw_isr_c_wrapper
   194  .endfunc
   195  
   196  .func isr_entry_0a
   197          push 0x00a
   198          jmp  hw_isr_c_wrapper
   199  .endfunc
   200  
   201  .func isr_entry_0b
   202          push 0x00b
   203          jmp  hw_isr_c_wrapper
   204  .endfunc
   205  
   206  .func isr_entry_0c
   207          push 0x00c
   208          jmp  hw_isr_c_wrapper
   209  .endfunc
   210  
   211  .func isr_entry_0d
   212          push 0x00d
   213          jmp  hw_isr_c_wrapper
   214  .endfunc
   215  
   216  .func isr_entry_0e
   217          push 0x00e
   218          jmp  hw_isr_c_wrapper
   219  .endfunc
   220  
   221  .func isr_entry_0f
   222          push 0x00f
   223          jmp  hw_isr_c_wrapper
   224  .endfunc
   225  
   226  .func isr_entry_10
   227          push 0x010
   228          jmp  hw_isr_c_wrapper
   229  .endfunc
   230  
   231  .func isr_entry_11
   232          push 0x011
   233          jmp  hw_isr_c_wrapper
   234  .endfunc
   235  
   236  .func isr_entry_12
   237          push 0x012
   238          jmp  hw_isr_c_wrapper
   239  .endfunc
   240  
   241  .func isr_entry_13
   242          push 0x013
   243          jmp  hw_isr_c_wrapper
   244  .endfunc
   245  
   246  .func isr_entry_14
   247          push 0x014
   248          jmp  hw_isr_c_wrapper
   249  .endfunc
   250  
   251  .func isr_entry_15
   252          push 0x015
   253          jmp  hw_isr_c_wrapper
   254  .endfunc
   255  
   256  .func isr_entry_16
   257          push 0x016
   258          jmp  hw_isr_c_wrapper
   259          
   260  .endfunc
   261  
   262  .func isr_entry_17
   263          push 0x017
   264          jmp  hw_isr_c_wrapper
   265          
   266  .endfunc
   267  
   268  .func isr_entry_18
   269          push 0x018
   270          jmp  hw_isr_c_wrapper
   271          
   272  .endfunc
   273  
   274  .func isr_entry_19
   275          push 0x019
   276          jmp  hw_isr_c_wrapper
   277          
   278  .endfunc
   279  
   280  .func isr_entry_1a
   281          push 0x01a
   282          jmp  hw_isr_c_wrapper
   283          
   284  .endfunc
   285  
   286  .func isr_entry_1b
   287          push 0x01b
   288          jmp  hw_isr_c_wrapper
   289          
   290  .endfunc
   291  
   292  .func isr_entry_1c
   293          push 0x01c
   294          jmp  hw_isr_c_wrapper
   295          
   296  .endfunc
   297  
   298  .func isr_entry_1d
   299          push 0x01d
   300          jmp  hw_isr_c_wrapper
   301          
   302  .endfunc
   303  
   304  .func isr_entry_1e
   305          push 0x01e
   306          jmp  hw_isr_c_wrapper
   307          
   308  .endfunc
   309  
   310  .func isr_entry_1f
   311          push 0x01f
   312          jmp  hw_isr_c_wrapper
   313          
   314  .endfunc
   315  
   316  .func isr_entry_20
   317          push 0x020
   318          jmp  hw_isr_c_wrapper
   319          
   320  .endfunc
   321  
   322  .func isr_entry_21
   323          push 0x021
   324          jmp  hw_isr_c_wrapper
   325          
   326  .endfunc
   327  
   328  .func isr_entry_22
   329          push 0x022
   330          jmp  hw_isr_c_wrapper
   331          
   332  .endfunc
   333  
   334  .func isr_entry_23
   335          push 0x023
   336          jmp  hw_isr_c_wrapper
   337          
   338  .endfunc
   339  
   340  .func isr_entry_24
   341          
   342  .endfunc
   343  
   344  .func isr_entry_25
   345          push 0x025
   346          jmp  hw_isr_c_wrapper
   347          
   348  .endfunc
   349  
   350  .func isr_entry_26
   351          push 0x026
   352          jmp  hw_isr_c_wrapper
   353          
   354  .endfunc
   355  
   356  .func isr_entry_27
   357          push 0x027
   358          jmp  hw_isr_c_wrapper
   359          
   360  .endfunc
   361  
   362  .func isr_entry_28
   363          push 0x028
   364          jmp  hw_isr_c_wrapper
   365          
   366  .endfunc
   367  
   368  .func isr_entry_29
   369          push 0x029
   370          jmp  hw_isr_c_wrapper
   371          
   372  .endfunc
   373  
   374  .func isr_entry_2a
   375          push 0x02a
   376          jmp  hw_isr_c_wrapper
   377          
   378  .endfunc
   379  
   380  .func isr_entry_2b
   381          push 0x02b
   382          jmp  hw_isr_c_wrapper
   383          
   384  .endfunc
   385  
   386  .func isr_entry_2c
   387          push 0x02c
   388          jmp  hw_isr_c_wrapper
   389          
   390  .endfunc
   391  
   392  .func isr_entry_2d
   393          push 0x02d
   394          jmp  hw_isr_c_wrapper
   395          
   396  .endfunc
   397  
   398  .func isr_entry_2e
   399          push 0x02e
   400          jmp  hw_isr_c_wrapper
   401          
   402  .endfunc
   403  
   404  .func isr_entry_2f
   405          push 0x02f
   406          jmp  hw_isr_c_wrapper
   407          
   408  .endfunc
   409  
   410  .func isr_entry_30
   411          push 0x030
   412          jmp  hw_isr_c_wrapper
   413          
   414  .endfunc
   415  
   416  .func isr_entry_31
   417          push 0x031
   418          jmp  hw_isr_c_wrapper
   419          
   420  .endfunc
   421  
   422  .func isr_entry_32
   423          push 0x032
   424          jmp  hw_isr_c_wrapper
   425          
   426  .endfunc
   427  
   428  .func isr_entry_33
   429          push 0x033
   430          jmp  hw_isr_c_wrapper
   431          
   432  .endfunc
   433  
   434  .func isr_entry_34
   435          push 0x034
   436          jmp  hw_isr_c_wrapper
   437          
   438  .endfunc
   439  
   440  .func isr_entry_35
   441          push 0x035
   442          jmp  hw_isr_c_wrapper
   443          
   444  .endfunc
   445  
   446  .func isr_entry_36
   447          push 0x036
   448          jmp  hw_isr_c_wrapper
   449          
   450  .endfunc
   451  
   452  .func isr_entry_37
   453          push 0x037
   454          jmp  hw_isr_c_wrapper
   455          
   456  .endfunc
   457  
   458  .func isr_entry_38
   459          push 0x038
   460          jmp  hw_isr_c_wrapper
   461          
   462  .endfunc
   463  
   464  .func isr_entry_39
   465          push 0x039
   466          jmp  hw_isr_c_wrapper
   467          
   468  .endfunc
   469  
   470  .func isr_entry_3a
   471          push 0x03a
   472          jmp  hw_isr_c_wrapper
   473          
   474  .endfunc
   475  
   476  .func isr_entry_3b
   477          push 0x03b
   478          jmp  hw_isr_c_wrapper
   479          
   480  .endfunc
   481  
   482  .func isr_entry_3c
   483          push 0x03c
   484          jmp  hw_isr_c_wrapper
   485          
   486  .endfunc
   487  
   488  .func isr_entry_3d
   489          push 0x03d
   490          jmp  hw_isr_c_wrapper
   491          
   492  .endfunc
   493  
   494  .func isr_entry_3e
   495          push 0x03e
   496          jmp  hw_isr_c_wrapper
   497          
   498  .endfunc
   499  
   500  .func isr_entry_3f
   501          push 0x03f
   502          jmp  hw_isr_c_wrapper
   503          
   504  .endfunc
   505  
   506  .func isr_entry_40
   507          push 0x040
   508          jmp  hw_isr_c_wrapper
   509          
   510  .endfunc
   511  
   512  .func isr_entry_41
   513          push 0x041
   514          jmp  hw_isr_c_wrapper
   515          
   516  .endfunc
   517  
   518  .func isr_entry_42
   519          push 0x042
   520          jmp  hw_isr_c_wrapper
   521          
   522  .endfunc
   523  
   524  .func isr_entry_43
   525          push 0x043
   526          jmp  hw_isr_c_wrapper
   527          
   528  .endfunc
   529  
   530  .func isr_entry_44
   531          push 0x044
   532          jmp  hw_isr_c_wrapper
   533          
   534  .endfunc
   535  
   536  .func isr_entry_45
   537          push 0x045
   538          jmp  hw_isr_c_wrapper
   539          
   540  .endfunc
   541  
   542  .func isr_entry_46
   543          push 0x046
   544          jmp  hw_isr_c_wrapper
   545          
   546  .endfunc
   547  
   548  .func isr_entry_47
   549          
   550  .endfunc
   551  
   552  .func isr_entry_48
   553          push 0x048
   554          jmp  hw_isr_c_wrapper
   555          
   556  .endfunc
   557  
   558  .func isr_entry_49
   559          push 0x049
   560          jmp  hw_isr_c_wrapper
   561          
   562  .endfunc
   563  
   564  .func isr_entry_4a
   565          push 0x04a
   566          jmp  hw_isr_c_wrapper
   567          
   568  .endfunc
   569  
   570  .func isr_entry_4b
   571          push 0x04b
   572          jmp  hw_isr_c_wrapper
   573          
   574  .endfunc
   575  
   576  .func isr_entry_4c
   577          push 0x04c
   578          jmp  hw_isr_c_wrapper
   579          
   580  .endfunc
   581  
   582  .func isr_entry_4d
   583          push 0x04d
   584          jmp  hw_isr_c_wrapper
   585          
   586  .endfunc
   587  
   588  .func isr_entry_4e
   589          push 0x04e
   590          jmp  hw_isr_c_wrapper
   591          
   592  .endfunc
   593  
   594  .func isr_entry_4f
   595          push 0x04f
   596          jmp  hw_isr_c_wrapper
   597          
   598  .endfunc
   599  
   600  .func isr_entry_50
   601          push 0x050
   602          jmp  hw_isr_c_wrapper
   603          
   604  .endfunc
   605  
   606  .func isr_entry_51
   607          push 0x051
   608          jmp  hw_isr_c_wrapper
   609          
   610  .endfunc
   611  
   612  .func isr_entry_52
   613          push 0x052
   614          jmp  hw_isr_c_wrapper
   615          
   616  .endfunc
   617  
   618  .func isr_entry_53
   619          push 0x053
   620          jmp  hw_isr_c_wrapper
   621          
   622  .endfunc
   623  
   624  .func isr_entry_54
   625          push 0x054
   626          jmp  hw_isr_c_wrapper
   627          
   628  .endfunc
   629  
   630  .func isr_entry_55
   631          push 0x055
   632          jmp  hw_isr_c_wrapper
   633          
   634  .endfunc
   635  
   636  .func isr_entry_56
   637          push 0x056
   638          jmp  hw_isr_c_wrapper
   639          
   640  .endfunc
   641  
   642  .func isr_entry_57
   643          push 0x057
   644          jmp  hw_isr_c_wrapper
   645          
   646  .endfunc
   647  
   648  .func isr_entry_58
   649          push 0x058
   650          jmp  hw_isr_c_wrapper
   651          
   652  .endfunc
   653  
   654  .func isr_entry_59
   655          push 0x059
   656          jmp  hw_isr_c_wrapper
   657          
   658  .endfunc
   659  
   660  .func isr_entry_5a
   661          push 0x05a
   662          jmp  hw_isr_c_wrapper
   663          
   664  .endfunc
   665  
   666  .func isr_entry_5b
   667          push 0x05b
   668          jmp  hw_isr_c_wrapper
   669          
   670  .endfunc
   671  
   672  .func isr_entry_5c
   673          push 0x05c
   674          jmp  hw_isr_c_wrapper
   675          
   676  .endfunc
   677  
   678  .func isr_entry_5d
   679          push 0x05d
   680          jmp  hw_isr_c_wrapper
   681          
   682  .endfunc
   683  
   684  .func isr_entry_5e
   685          push 0x05e
   686          jmp  hw_isr_c_wrapper
   687          
   688  .endfunc
   689  
   690  .func isr_entry_5f
   691          push 0x05f
   692          jmp  hw_isr_c_wrapper
   693          
   694  .endfunc
   695  
   696  .func isr_entry_60
   697          push 0x060
   698          jmp  hw_isr_c_wrapper
   699          
   700  .endfunc
   701  
   702  .func isr_entry_61
   703          push 0x061
   704          jmp  hw_isr_c_wrapper
   705          
   706  .endfunc
   707  
   708  .func isr_entry_62
   709          push 0x062
   710          jmp  hw_isr_c_wrapper
   711          
   712  .endfunc
   713  
   714  .func isr_entry_63
   715          push 0x063
   716          jmp  hw_isr_c_wrapper
   717          
   718  .endfunc
   719  
   720  .func isr_entry_64
   721          push 0x064
   722          jmp  hw_isr_c_wrapper
   723          
   724  .endfunc
   725  
   726  .func isr_entry_65
   727          push 0x065
   728          jmp  hw_isr_c_wrapper
   729          
   730  .endfunc
   731  
   732  .func isr_entry_66
   733          push 0x066
   734          jmp  hw_isr_c_wrapper
   735          
   736  .endfunc
   737  
   738  .func isr_entry_67
   739          push 0x067
   740          jmp  hw_isr_c_wrapper
   741          
   742  .endfunc
   743  
   744  .func isr_entry_68
   745          push 0x068
   746          jmp  hw_isr_c_wrapper
   747          
   748  .endfunc
   749  
   750  .func isr_entry_69
   751          push 0x069
   752          jmp  hw_isr_c_wrapper
   753          
   754  .endfunc
   755  
   756  .func isr_entry_6a
   757          push 0x06a
   758          jmp  hw_isr_c_wrapper
   759          
   760  .endfunc
   761  
   762  .func isr_entry_6b
   763          push 0x06b
   764          jmp  hw_isr_c_wrapper
   765          
   766  .endfunc
   767  
   768  .func isr_entry_6c
   769          push 0x06c
   770          jmp  hw_isr_c_wrapper
   771          
   772  .endfunc
   773  
   774  .func isr_entry_6d
   775          push 0x06d
   776          jmp  hw_isr_c_wrapper
   777          
   778  .endfunc
   779  
   780  .func isr_entry_6e
   781          push 0x06e
   782          jmp  hw_isr_c_wrapper
   783          
   784  .endfunc
   785  
   786  .func isr_entry_6f
   787          push 0x06f
   788          jmp  hw_isr_c_wrapper
   789          
   790  .endfunc
   791  
   792  .func isr_entry_70
   793          push 0x070
   794          jmp  hw_isr_c_wrapper
   795          
   796  .endfunc
   797  
   798  .func isr_entry_71
   799          push 0x071
   800          jmp  hw_isr_c_wrapper
   801          
   802  .endfunc
   803  
   804  .func isr_entry_72
   805          push 0x072
   806          jmp  hw_isr_c_wrapper
   807          
   808  .endfunc
   809  
   810  .func isr_entry_73
   811          push 0x073
   812          jmp  hw_isr_c_wrapper
   813          
   814  .endfunc
   815  
   816  .func isr_entry_74
   817          push 0x074
   818          jmp  hw_isr_c_wrapper
   819          
   820  .endfunc
   821  
   822  .func isr_entry_75
   823          push 0x075
   824          jmp  hw_isr_c_wrapper
   825          
   826  .endfunc
   827  
   828  .func isr_entry_76
   829          push 0x076
   830          jmp  hw_isr_c_wrapper
   831          
   832  .endfunc
   833  
   834  .func isr_entry_77
   835          push 0x077
   836          jmp  hw_isr_c_wrapper
   837          
   838  .endfunc
   839  
   840  .func isr_entry_78
   841          push 0x078
   842          jmp  hw_isr_c_wrapper
   843          
   844  .endfunc
   845  
   846  .func isr_entry_79
   847          
   848  .endfunc
   849  
   850  .func isr_entry_7a
   851          push 0x07a
   852          jmp  hw_isr_c_wrapper
   853          
   854  .endfunc
   855  
   856  .func isr_entry_7b
   857          push 0x07b
   858          jmp  hw_isr_c_wrapper
   859          
   860  .endfunc
   861  
   862  .func isr_entry_7c
   863          push 0x07c
   864          jmp  hw_isr_c_wrapper
   865          
   866  .endfunc
   867  
   868  .func isr_entry_7d
   869          push 0x07d