VirtualBox

source: vbox/trunk/src/VBox/VMM/VMMAll/IEMAllN8veHlpA-arm64.S@ 103898

Last change on this file since 103898 was 103636, checked in by vboxsync, 10 months ago

VMM/IEM: Support iemNativeRecompFunc_BltIn_LogCpuState() on arm64, bugref:10371

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.0 KB
Line 
1/* $Id: IEMAllN8veHlpA-arm64.S 103636 2024-03-01 14:56:49Z vboxsync $ */
2/** @file
3 * IEM - Native Recompiler Assembly Helpers, ARM64 variant.
4 */
5
6/*
7 * Copyright (C) 2024 Oracle and/or its affiliates.
8 *
9 * This file is part of VirtualBox base platform packages, as
10 * available from https://www.virtualbox.org.
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation, in version 3 of the
15 * License.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, see <https://www.gnu.org/licenses>.
24 *
25 * SPDX-License-Identifier: GPL-3.0-only
26 */
27
28
29/*********************************************************************************************************************************
30* Header Files *
31*********************************************************************************************************************************/
32#include <iprt/asmdefs-arm.h>
33#include <iprt/x86.h>
34
35
36BEGINCODE
37
38.extern NAME(iemThreadedFunc_BltIn_LogCpuStateWorker)
39
40/**
41 * This does the epilogue of a TB, given the RBP for the frame and eax value to return.
42 *
43 * @param pFrame (x0) The frame pointer.
44 * @param rc (w1) The return value.
45 *
46 * @note This doesn't really work for MSC since xmm6 thru xmm15 are non-volatile
47 * and since we don't save them in the TB prolog we'll potentially return
48 * with different values if any functions on the calling stack uses them
49 * as they're unlikely to restore them till they return.
50 *
51 * For the GCC calling convention all xmm registers are volatile and the
52 * only worry would be someone fiddling the control bits of MXCSR or FCW
53 * without restoring them. This is highly unlikely, unless we're doing
54 * it ourselves, I think.
55 */
56 .p2align 2
57 .private_extern NAME(iemNativeTbLongJmp)
58 .globl NAME(iemNativeTbLongJmp)
59NAME(iemNativeTbLongJmp):
60
61 ;
62 ; This must exactly match what iemNativeEmitEpilog does.
63 ;
64 sub sp, x0, #0x50
65 ldp x19, x20, [sp, #0x00]
66 ldp x21, x22, [sp, #0x10]
67 ldp x23, x24, [sp, #0x20]
68 ldp x25, x26, [sp, #0x30]
69 ldp x27, x28, [sp, #0x40]
70 ldp x29, x30, [sp, #0x50] /* the pFrame address points to this entry */
71 add sp, sp, #0x60
72 mov w0, w1 /* The return value */
73#ifdef RT_OS_DARWIN
74 retab
75#else
76 ret
77#endif
78 brk #1
79
80
81
82#define IEMNATIVE_HLP_FRAME_SIZE (11 * 16)
83
84;;
85; This is wrapper function that saves and restores all volatile registers
86; so the impact of inserting LogCpuState is minimal to the other TB code.
87;
88 .p2align 2
89 .private_extern NAME(iemNativeHlpAsmSafeWrapLogCpuState)
90 .globl NAME(iemNativeHlpAsmSafeWrapLogCpuState)
91NAME(iemNativeHlpAsmSafeWrapLogCpuState):
92#ifdef RT_OS_DARWIN
93 pacibsp
94#endif
95
96 ;
97 ; Save all volatile registers.
98 ;
99 stp x29, x30, [sp, #-IEMNATIVE_HLP_FRAME_SIZE]!
100 stp x0, x1, [sp, #( 1 * 16)]
101 stp x2, x3, [sp, #( 2 * 16)]
102 stp x4, x5, [sp, #( 3 * 16)]
103 stp x5, x6, [sp, #( 4 * 16)]
104 stp x7, x8, [sp, #( 5 * 16)]
105 stp x9, x10, [sp, #( 6 * 16)]
106 stp x11, x12, [sp, #( 7 * 16)]
107 stp x13, x14, [sp, #( 8 * 16)]
108 stp x15, x16, [sp, #( 9 * 16)]
109 stp x17, x18, [sp, #(10 * 16)]
110
111 ;
112 ; Move the pVCpu pointer from the fixed register to the first argument.
113 ; @todo This needs syncing with what we use in IEMN8veRecompiler.h
114 ; but we can't include that header right now, would need some #ifndef IN_ASM_CODE...
115 ; in the header or splitting up the header into a asm safe one and a one included from C/C++.
116 ;
117 mov x0, x28
118
119 ;
120 ; Call C function to do the actual work.
121 ;
122 bl NAME(iemThreadedFunc_BltIn_LogCpuStateWorker)
123
124 ;
125 ; Restore volatile registers and return to the TB code.
126 ;
127 ldp x29, x30, [sp, #( 0 * 16)]
128 ldp x0, x1, [sp, #( 1 * 16)]
129 ldp x2, x3, [sp, #( 2 * 16)]
130 ldp x4, x5, [sp, #( 3 * 16)]
131 ldp x5, x6, [sp, #( 4 * 16)]
132 ldp x7, x8, [sp, #( 5 * 16)]
133 ldp x9, x10, [sp, #( 6 * 16)]
134 ldp x11, x12, [sp, #( 7 * 16)]
135 ldp x13, x14, [sp, #( 8 * 16)]
136 ldp x15, x16, [sp, #( 9 * 16)]
137 ldp x17, x18, [sp, #(10 * 16)]
138 add sp, sp, #IEMNATIVE_HLP_FRAME_SIZE
139
140#ifdef RT_OS_DARWIN
141 retab
142#else
143 ret
144#endif
145 brk #1
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette