h_mem_assist_asm.S revision 1.6.2.3 1 1.6.2.3 martin /* $NetBSD: h_mem_assist_asm.S,v 1.6.2.3 2020/04/13 08:05:29 martin Exp $ */
2 1.6.2.2 christos
3 1.6.2.2 christos /*
4 1.6.2.3 martin * Copyright (c) 2018-2019 The NetBSD Foundation, Inc.
5 1.6.2.2 christos * All rights reserved.
6 1.6.2.2 christos *
7 1.6.2.2 christos * This code is derived from software contributed to The NetBSD Foundation
8 1.6.2.2 christos * by Maxime Villard.
9 1.6.2.2 christos *
10 1.6.2.2 christos * Redistribution and use in source and binary forms, with or without
11 1.6.2.2 christos * modification, are permitted provided that the following conditions
12 1.6.2.2 christos * are met:
13 1.6.2.2 christos * 1. Redistributions of source code must retain the above copyright
14 1.6.2.2 christos * notice, this list of conditions and the following disclaimer.
15 1.6.2.2 christos * 2. Redistributions in binary form must reproduce the above copyright
16 1.6.2.2 christos * notice, this list of conditions and the following disclaimer in the
17 1.6.2.2 christos * documentation and/or other materials provided with the distribution.
18 1.6.2.2 christos *
19 1.6.2.2 christos * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 1.6.2.2 christos * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 1.6.2.2 christos * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 1.6.2.2 christos * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 1.6.2.2 christos * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 1.6.2.2 christos * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 1.6.2.2 christos * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 1.6.2.2 christos * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 1.6.2.2 christos * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 1.6.2.2 christos * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 1.6.2.2 christos * POSSIBILITY OF SUCH DAMAGE.
30 1.6.2.2 christos */
31 1.6.2.2 christos
32 1.6.2.2 christos .globl test1_begin, test1_end
33 1.6.2.2 christos .globl test2_begin, test2_end
34 1.6.2.2 christos .globl test3_begin, test3_end
35 1.6.2.2 christos .globl test4_begin, test4_end
36 1.6.2.2 christos .globl test5_begin, test5_end
37 1.6.2.2 christos .globl test6_begin, test6_end
38 1.6.2.2 christos .globl test7_begin, test7_end
39 1.6.2.2 christos .globl test8_begin, test8_end
40 1.6.2.2 christos .globl test9_begin, test9_end
41 1.6.2.2 christos .globl test10_begin, test10_end
42 1.6.2.2 christos .globl test11_begin, test11_end
43 1.6.2.2 christos .globl test12_begin, test12_end
44 1.6.2.2 christos .globl test13_begin, test13_end
45 1.6.2.2 christos .globl test14_begin, test14_end
46 1.6.2.3 martin .globl test_64bit_15_begin, test_64bit_15_end
47 1.6.2.3 martin .globl test_64bit_16_begin, test_64bit_16_end
48 1.6.2.2 christos .text
49 1.6.2.2 christos .code64
50 1.6.2.2 christos
51 1.6.2.2 christos #define TEST_END \
52 1.6.2.2 christos movq $0xFFFFFFFFFFFFFFFF,%rcx; \
53 1.6.2.2 christos rdmsr ;
54 1.6.2.2 christos
55 1.6.2.2 christos .align 64
56 1.6.2.2 christos test1_begin:
57 1.6.2.2 christos movq $0x1000,%rax
58 1.6.2.2 christos movq $0x1000,%rbp
59 1.6.2.2 christos
60 1.6.2.2 christos movq $0x1000,(%rax)
61 1.6.2.2 christos
62 1.6.2.2 christos movq $1,%r11
63 1.6.2.2 christos movq $0x2000,(%rax,%r11,8)
64 1.6.2.2 christos
65 1.6.2.2 christos movq (%rbp),%r8
66 1.6.2.2 christos movq 8(%rbp),%rbx
67 1.6.2.2 christos addq %rbx,%r8
68 1.6.2.2 christos movq %r8,(%rbp)
69 1.6.2.2 christos movb $4,(%rbp)
70 1.6.2.2 christos
71 1.6.2.2 christos TEST_END
72 1.6.2.2 christos test1_end:
73 1.6.2.2 christos
74 1.6.2.2 christos .align 64
75 1.6.2.2 christos test2_begin:
76 1.6.2.2 christos movq $0x1000,%rax
77 1.6.2.2 christos
78 1.6.2.2 christos movq $0x1000,(%rax)
79 1.6.2.2 christos movq $0x00FF,%rbx
80 1.6.2.2 christos orb %bl,(%rax)
81 1.6.2.2 christos movq $0x0400,%rcx
82 1.6.2.2 christos orw %cx,(%rax)
83 1.6.2.2 christos
84 1.6.2.2 christos movq $0x0200,%rcx
85 1.6.2.2 christos orq (%rax),%rcx
86 1.6.2.2 christos movq %rcx,(%rax)
87 1.6.2.2 christos
88 1.6.2.2 christos TEST_END
89 1.6.2.2 christos test2_end:
90 1.6.2.2 christos
91 1.6.2.2 christos .align 64
92 1.6.2.2 christos test3_begin:
93 1.6.2.2 christos movq $0x1000,%rax
94 1.6.2.2 christos
95 1.6.2.2 christos movq $0x1FFF,(%rax)
96 1.6.2.2 christos movq $0x1FF0,%rbx
97 1.6.2.2 christos andq %rbx,(%rax)
98 1.6.2.2 christos movq $0x10C1,%rcx
99 1.6.2.2 christos andb %cl,(%rax)
100 1.6.2.2 christos
101 1.6.2.2 christos TEST_END
102 1.6.2.2 christos test3_end:
103 1.6.2.2 christos
104 1.6.2.2 christos .align 64
105 1.6.2.2 christos test4_begin:
106 1.6.2.2 christos movq $0x1000,%rax
107 1.6.2.2 christos
108 1.6.2.2 christos movq $0x1FFF,(%rax)
109 1.6.2.2 christos movq $0x1FF0,%rbx
110 1.6.2.2 christos xorq %rbx,(%rax)
111 1.6.2.2 christos movq $0x10C0,%rcx
112 1.6.2.2 christos xorw %cx,(%rax)
113 1.6.2.2 christos
114 1.6.2.2 christos TEST_END
115 1.6.2.2 christos test4_end:
116 1.6.2.2 christos
117 1.6.2.2 christos .align 64
118 1.6.2.2 christos test5_begin:
119 1.6.2.2 christos movq $0xFFFFFFFF00001000,%rax
120 1.6.2.2 christos
121 1.6.2.2 christos movq $0x1FFF,(%eax)
122 1.6.2.2 christos movb $0,(%eax,%ebx,1)
123 1.6.2.2 christos
124 1.6.2.2 christos TEST_END
125 1.6.2.2 christos test5_end:
126 1.6.2.2 christos
127 1.6.2.2 christos .align 64
128 1.6.2.2 christos test6_begin:
129 1.6.2.2 christos movq $0xFFA0,%rax
130 1.6.2.2 christos movabs %rax,0x1000
131 1.6.2.2 christos
132 1.6.2.2 christos movabs 0x1000,%al
133 1.6.2.2 christos orb $0x0B,%al
134 1.6.2.2 christos movabs %al,0x1000
135 1.6.2.2 christos
136 1.6.2.2 christos TEST_END
137 1.6.2.2 christos test6_end:
138 1.6.2.2 christos
139 1.6.2.2 christos .align 64
140 1.6.2.2 christos test7_begin:
141 1.6.2.2 christos movq $0x56,%rax
142 1.6.2.2 christos
143 1.6.2.2 christos movq $1,%rcx
144 1.6.2.2 christos movq $0x1000,%rdi
145 1.6.2.2 christos rep stosb
146 1.6.2.2 christos
147 1.6.2.2 christos movq $0x1234,%rax
148 1.6.2.2 christos stosw
149 1.6.2.2 christos
150 1.6.2.2 christos TEST_END
151 1.6.2.2 christos test7_end:
152 1.6.2.2 christos
153 1.6.2.2 christos .align 64
154 1.6.2.2 christos test8_begin:
155 1.6.2.2 christos movq $0x1008,%rsi
156 1.6.2.2 christos movq $0x12345678,(%rsi)
157 1.6.2.2 christos
158 1.6.2.2 christos movq $0x1000,%rdi
159 1.6.2.2 christos
160 1.6.2.2 christos lodsw
161 1.6.2.2 christos movw %ax,(%rdi)
162 1.6.2.2 christos addq $2,%rdi
163 1.6.2.2 christos
164 1.6.2.2 christos lodsb
165 1.6.2.2 christos movb %al,(%rdi)
166 1.6.2.2 christos addq $1,%rdi
167 1.6.2.2 christos
168 1.6.2.2 christos lodsb
169 1.6.2.2 christos movb %al,(%rdi)
170 1.6.2.2 christos addq $2,%rdi
171 1.6.2.2 christos
172 1.6.2.2 christos TEST_END
173 1.6.2.2 christos test8_end:
174 1.6.2.2 christos
175 1.6.2.2 christos .align 64
176 1.6.2.2 christos test9_begin:
177 1.6.2.2 christos movq $0x1000,%rax
178 1.6.2.2 christos
179 1.6.2.2 christos movq $0x12345678,8(%rax)
180 1.6.2.2 christos
181 1.6.2.2 christos movq $0x1008,%rsi
182 1.6.2.2 christos movq $0x1000,%rdi
183 1.6.2.2 christos
184 1.6.2.2 christos movq $4,%rcx
185 1.6.2.2 christos rep movsb
186 1.6.2.2 christos
187 1.6.2.2 christos movq $2,%rcx
188 1.6.2.2 christos rep movsw
189 1.6.2.2 christos
190 1.6.2.2 christos TEST_END
191 1.6.2.2 christos test9_end:
192 1.6.2.2 christos
193 1.6.2.2 christos .align 64
194 1.6.2.2 christos test10_begin:
195 1.6.2.2 christos movq $0x1000,%rax
196 1.6.2.2 christos movq $0x12345678,(%rax)
197 1.6.2.2 christos
198 1.6.2.2 christos movq $0xFFFFFFFFFFFFFFFF,%rbx
199 1.6.2.2 christos movzbl (%rax),%ebx
200 1.6.2.2 christos movq %rbx,(%rax)
201 1.6.2.2 christos
202 1.6.2.2 christos TEST_END
203 1.6.2.2 christos test10_end:
204 1.6.2.2 christos
205 1.6.2.2 christos .align 64
206 1.6.2.2 christos test11_begin:
207 1.6.2.2 christos movq $0x1000,%rax
208 1.6.2.2 christos movq $0x12345678,(%rax)
209 1.6.2.2 christos
210 1.6.2.2 christos movq $0xFFFFFFFFFFFFFFFF,%rbx
211 1.6.2.2 christos movzwq (%rax),%rbx
212 1.6.2.2 christos movq %rbx,(%rax)
213 1.6.2.2 christos
214 1.6.2.2 christos TEST_END
215 1.6.2.2 christos test11_end:
216 1.6.2.2 christos
217 1.6.2.2 christos .align 64
218 1.6.2.2 christos test12_begin:
219 1.6.2.2 christos movq $0x1000,%rax
220 1.6.2.2 christos movq $0xFFFFFFFFF2345678,(%rax)
221 1.6.2.2 christos
222 1.6.2.2 christos cmpb $0x78,(%rax)
223 1.6.2.2 christos jne .L12_failure
224 1.6.2.2 christos cmpb $0x77,(%rax)
225 1.6.2.2 christos jl .L12_failure
226 1.6.2.2 christos cmpb $0x79,(%rax)
227 1.6.2.2 christos jg .L12_failure
228 1.6.2.2 christos
229 1.6.2.2 christos cmpw $0x5678,(%rax)
230 1.6.2.2 christos jne .L12_failure
231 1.6.2.2 christos cmpw $0x5677,(%rax)
232 1.6.2.2 christos jl .L12_failure
233 1.6.2.2 christos cmpw $0x5679,(%rax)
234 1.6.2.2 christos jg .L12_failure
235 1.6.2.2 christos
236 1.6.2.2 christos cmpl $0xF2345678,(%rax)
237 1.6.2.2 christos jne .L12_failure
238 1.6.2.2 christos cmpl $0xF2345677,(%rax)
239 1.6.2.2 christos jl .L12_failure
240 1.6.2.2 christos cmpl $0xF2345679,(%rax)
241 1.6.2.2 christos jg .L12_failure
242 1.6.2.2 christos
243 1.6.2.2 christos cmpq $0xFFFFFFFFF2345678,(%rax)
244 1.6.2.2 christos jne .L12_failure
245 1.6.2.2 christos cmpq $0xFFFFFFFFF2345677,(%rax)
246 1.6.2.2 christos jl .L12_failure
247 1.6.2.2 christos cmpq $0xFFFFFFFFF2345679,(%rax)
248 1.6.2.2 christos jg .L12_failure
249 1.6.2.2 christos
250 1.6.2.2 christos .L12_success:
251 1.6.2.2 christos movq $1,(%rax)
252 1.6.2.2 christos TEST_END
253 1.6.2.2 christos .L12_failure:
254 1.6.2.2 christos movq $0,(%rax)
255 1.6.2.2 christos TEST_END
256 1.6.2.2 christos test12_end:
257 1.6.2.2 christos
258 1.6.2.2 christos .align 64
259 1.6.2.2 christos test13_begin:
260 1.6.2.2 christos movq $0x1000,%rax
261 1.6.2.2 christos movq $0x000000001000A0FF,(%rax)
262 1.6.2.2 christos
263 1.6.2.2 christos movq $0xFFFF,%rcx
264 1.6.2.2 christos subb %cl,(%rax)
265 1.6.2.2 christos
266 1.6.2.2 christos movq $0xA000,%rcx
267 1.6.2.2 christos subw %cx,(%rax)
268 1.6.2.2 christos
269 1.6.2.2 christos movq $0x0000000F1000A0FF,%rcx
270 1.6.2.2 christos subq (%rax),%rcx
271 1.6.2.2 christos
272 1.6.2.2 christos movq %rcx,(%rax)
273 1.6.2.2 christos
274 1.6.2.2 christos TEST_END
275 1.6.2.2 christos test13_end:
276 1.6.2.2 christos
277 1.6.2.2 christos .align 64
278 1.6.2.2 christos test14_begin:
279 1.6.2.2 christos movq $0x1000,%rax
280 1.6.2.2 christos movq $0xA0FF,(%rax)
281 1.6.2.2 christos
282 1.6.2.2 christos testb $0x0F,(%rax)
283 1.6.2.2 christos jz .L14_failure
284 1.6.2.2 christos
285 1.6.2.2 christos testw $0x0F00,(%rax)
286 1.6.2.2 christos jnz .L14_failure
287 1.6.2.2 christos
288 1.6.2.2 christos testl $0xA000,(%rax)
289 1.6.2.2 christos jz .L14_failure
290 1.6.2.2 christos
291 1.6.2.2 christos .L14_success:
292 1.6.2.2 christos movq $1,(%rax)
293 1.6.2.2 christos TEST_END
294 1.6.2.2 christos .L14_failure:
295 1.6.2.2 christos movq $0,(%rax)
296 1.6.2.2 christos TEST_END
297 1.6.2.2 christos test14_end:
298 1.6.2.3 martin
299 1.6.2.3 martin .align 64
300 1.6.2.3 martin test_64bit_15_begin:
301 1.6.2.3 martin movq $0x1000,%rax
302 1.6.2.3 martin movq $0x120000,%rbx
303 1.6.2.3 martin movq $0x003400,%rcx
304 1.6.2.3 martin movq $0x000056,%rdx
305 1.6.2.3 martin
306 1.6.2.3 martin xchgq %rbx,(%rax)
307 1.6.2.3 martin xchgw (%rax),%cx
308 1.6.2.3 martin xchgb %dl,(%rax)
309 1.6.2.3 martin
310 1.6.2.3 martin TEST_END
311 1.6.2.3 martin test_64bit_15_end:
312 1.6.2.3 martin
313 1.6.2.3 martin .align 64
314 1.6.2.3 martin test_64bit_16_begin:
315 1.6.2.3 martin movq $0x1000,%rax
316 1.6.2.3 martin movq $0x000000,%rbx
317 1.6.2.3 martin movq $0x000000,%rcx
318 1.6.2.3 martin movq $0x000000,%rdx
319 1.6.2.3 martin
320 1.6.2.3 martin movq $0x123456,(%rax)
321 1.6.2.3 martin xchgq %rbx,(%eax)
322 1.6.2.3 martin movq $0,(%rax)
323 1.6.2.3 martin xchgq %rbx,(%eax)
324 1.6.2.3 martin
325 1.6.2.3 martin TEST_END
326 1.6.2.3 martin test_64bit_16_end:
327 1.6.2.3 martin
328 1.6.2.3 martin /* -------------------------------------------------------------------------- */
329 1.6.2.3 martin
330 1.6.2.3 martin .globl test_16bit_1_begin, test_16bit_1_end
331 1.6.2.3 martin .globl test_16bit_2_begin, test_16bit_2_end
332 1.6.2.3 martin .globl test_16bit_3_begin, test_16bit_3_end
333 1.6.2.3 martin .globl test_16bit_4_begin, test_16bit_4_end
334 1.6.2.3 martin .globl test_16bit_5_begin, test_16bit_5_end
335 1.6.2.3 martin .globl test_16bit_6_begin, test_16bit_6_end
336 1.6.2.3 martin
337 1.6.2.3 martin #define TEST16_END \
338 1.6.2.3 martin rdmsr
339 1.6.2.3 martin
340 1.6.2.3 martin .code16
341 1.6.2.3 martin
342 1.6.2.3 martin .align 64
343 1.6.2.3 martin test_16bit_1_begin:
344 1.6.2.3 martin movw $0x10f1,%bx
345 1.6.2.3 martin movw $0x123,%dx
346 1.6.2.3 martin
347 1.6.2.3 martin movb %dl,(%bx)
348 1.6.2.3 martin
349 1.6.2.3 martin TEST16_END
350 1.6.2.3 martin test_16bit_1_end:
351 1.6.2.3 martin
352 1.6.2.3 martin .align 64
353 1.6.2.3 martin test_16bit_2_begin:
354 1.6.2.3 martin movw $0x10f1,%bx
355 1.6.2.3 martin movw $2,%di
356 1.6.2.3 martin movw $0x123,%dx
357 1.6.2.3 martin
358 1.6.2.3 martin movw %dx,(%bx,%di)
359 1.6.2.3 martin
360 1.6.2.3 martin TEST16_END
361 1.6.2.3 martin test_16bit_2_end:
362 1.6.2.3 martin
363 1.6.2.3 martin .align 64
364 1.6.2.3 martin test_16bit_3_begin:
365 1.6.2.3 martin movw $0x10f1,%bp
366 1.6.2.3 martin movw $2,%si
367 1.6.2.3 martin movw $0x678,%dx
368 1.6.2.3 martin
369 1.6.2.3 martin movw %dx,-2(%bp,%si)
370 1.6.2.3 martin
371 1.6.2.3 martin TEST16_END
372 1.6.2.3 martin test_16bit_3_end:
373 1.6.2.3 martin
374 1.6.2.3 martin .align 64
375 1.6.2.3 martin test_16bit_4_begin:
376 1.6.2.3 martin movw $0x10f0,%bp
377 1.6.2.3 martin movw $2,%si
378 1.6.2.3 martin movw $2+4+4,%di
379 1.6.2.3 martin movw $0xFFFF,%dx
380 1.6.2.3 martin movl $0x0001,%eax
381 1.6.2.3 martin movl $0x0010,%ebx
382 1.6.2.3 martin movl $0x1000,%ecx
383 1.6.2.3 martin
384 1.6.2.3 martin movw %dx,4(%bp,%si) /* 16bit opr 16bit adr */
385 1.6.2.3 martin andl %eax,4(%bp,%si) /* 32bit opr 16bit adr */
386 1.6.2.3 martin orw %bx,4(%ebp,%esi) /* 16bit opr 32bit adr */
387 1.6.2.3 martin orl %ecx,-4(%bp,%di) /* 32bit opr 16bit adr, negative */
388 1.6.2.3 martin
389 1.6.2.3 martin TEST16_END
390 1.6.2.3 martin test_16bit_4_end:
391 1.6.2.3 martin
392 1.6.2.3 martin .align 64
393 1.6.2.3 martin test_16bit_5_begin:
394 1.6.2.3 martin movb $0x12,0x1234
395 1.6.2.3 martin
396 1.6.2.3 martin TEST16_END
397 1.6.2.3 martin test_16bit_5_end:
398 1.6.2.3 martin
399 1.6.2.3 martin .align 64
400 1.6.2.3 martin test_16bit_6_begin:
401 1.6.2.3 martin movw $0x1234,%bp
402 1.6.2.3 martin movw $4,%di
403 1.6.2.3 martin movw $0x1200,%bx
404 1.6.2.3 martin movw $0x0034,%cx
405 1.6.2.3 martin
406 1.6.2.3 martin xchgw %bx,(%bp)
407 1.6.2.3 martin xchgb -4(%bp,%di),%cl
408 1.6.2.3 martin
409 1.6.2.3 martin TEST16_END
410 1.6.2.3 martin test_16bit_6_end:
411