h_mem_assist_asm.S revision 1.6.2.2 1 /* $NetBSD: h_mem_assist_asm.S,v 1.6.2.2 2019/06/10 22:10:07 christos Exp $ */
2
3 /*
4 * Copyright (c) 2018 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Maxime Villard.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
30 */
31
32 .globl test1_begin, test1_end
33 .globl test2_begin, test2_end
34 .globl test3_begin, test3_end
35 .globl test4_begin, test4_end
36 .globl test5_begin, test5_end
37 .globl test6_begin, test6_end
38 .globl test7_begin, test7_end
39 .globl test8_begin, test8_end
40 .globl test9_begin, test9_end
41 .globl test10_begin, test10_end
42 .globl test11_begin, test11_end
43 .globl test12_begin, test12_end
44 .globl test13_begin, test13_end
45 .globl test14_begin, test14_end
46 .text
47 .code64
48
49 #define TEST_END \
50 movq $0xFFFFFFFFFFFFFFFF,%rcx; \
51 rdmsr ;
52
53 .align 64
54 test1_begin:
55 movq $0x1000,%rax
56 movq $0x1000,%rbp
57
58 movq $0x1000,(%rax)
59
60 movq $1,%r11
61 movq $0x2000,(%rax,%r11,8)
62
63 movq (%rbp),%r8
64 movq 8(%rbp),%rbx
65 addq %rbx,%r8
66 movq %r8,(%rbp)
67 movb $4,(%rbp)
68
69 TEST_END
70 test1_end:
71
72 .align 64
73 test2_begin:
74 movq $0x1000,%rax
75
76 movq $0x1000,(%rax)
77 movq $0x00FF,%rbx
78 orb %bl,(%rax)
79 movq $0x0400,%rcx
80 orw %cx,(%rax)
81
82 movq $0x0200,%rcx
83 orq (%rax),%rcx
84 movq %rcx,(%rax)
85
86 TEST_END
87 test2_end:
88
89 .align 64
90 test3_begin:
91 movq $0x1000,%rax
92
93 movq $0x1FFF,(%rax)
94 movq $0x1FF0,%rbx
95 andq %rbx,(%rax)
96 movq $0x10C1,%rcx
97 andb %cl,(%rax)
98
99 TEST_END
100 test3_end:
101
102 .align 64
103 test4_begin:
104 movq $0x1000,%rax
105
106 movq $0x1FFF,(%rax)
107 movq $0x1FF0,%rbx
108 xorq %rbx,(%rax)
109 movq $0x10C0,%rcx
110 xorw %cx,(%rax)
111
112 TEST_END
113 test4_end:
114
115 .align 64
116 test5_begin:
117 movq $0xFFFFFFFF00001000,%rax
118
119 movq $0x1FFF,(%eax)
120 movb $0,(%eax,%ebx,1)
121
122 TEST_END
123 test5_end:
124
125 .align 64
126 test6_begin:
127 movq $0xFFA0,%rax
128 movabs %rax,0x1000
129
130 movabs 0x1000,%al
131 orb $0x0B,%al
132 movabs %al,0x1000
133
134 TEST_END
135 test6_end:
136
137 .align 64
138 test7_begin:
139 movq $0x56,%rax
140
141 movq $1,%rcx
142 movq $0x1000,%rdi
143 rep stosb
144
145 movq $0x1234,%rax
146 stosw
147
148 TEST_END
149 test7_end:
150
151 .align 64
152 test8_begin:
153 movq $0x1008,%rsi
154 movq $0x12345678,(%rsi)
155
156 movq $0x1000,%rdi
157
158 lodsw
159 movw %ax,(%rdi)
160 addq $2,%rdi
161
162 lodsb
163 movb %al,(%rdi)
164 addq $1,%rdi
165
166 lodsb
167 movb %al,(%rdi)
168 addq $2,%rdi
169
170 TEST_END
171 test8_end:
172
173 .align 64
174 test9_begin:
175 movq $0x1000,%rax
176
177 movq $0x12345678,8(%rax)
178
179 movq $0x1008,%rsi
180 movq $0x1000,%rdi
181
182 movq $4,%rcx
183 rep movsb
184
185 movq $2,%rcx
186 rep movsw
187
188 TEST_END
189 test9_end:
190
191 .align 64
192 test10_begin:
193 movq $0x1000,%rax
194 movq $0x12345678,(%rax)
195
196 movq $0xFFFFFFFFFFFFFFFF,%rbx
197 movzbl (%rax),%ebx
198 movq %rbx,(%rax)
199
200 TEST_END
201 test10_end:
202
203 .align 64
204 test11_begin:
205 movq $0x1000,%rax
206 movq $0x12345678,(%rax)
207
208 movq $0xFFFFFFFFFFFFFFFF,%rbx
209 movzwq (%rax),%rbx
210 movq %rbx,(%rax)
211
212 TEST_END
213 test11_end:
214
215 .align 64
216 test12_begin:
217 movq $0x1000,%rax
218 movq $0xFFFFFFFFF2345678,(%rax)
219
220 cmpb $0x78,(%rax)
221 jne .L12_failure
222 cmpb $0x77,(%rax)
223 jl .L12_failure
224 cmpb $0x79,(%rax)
225 jg .L12_failure
226
227 cmpw $0x5678,(%rax)
228 jne .L12_failure
229 cmpw $0x5677,(%rax)
230 jl .L12_failure
231 cmpw $0x5679,(%rax)
232 jg .L12_failure
233
234 cmpl $0xF2345678,(%rax)
235 jne .L12_failure
236 cmpl $0xF2345677,(%rax)
237 jl .L12_failure
238 cmpl $0xF2345679,(%rax)
239 jg .L12_failure
240
241 cmpq $0xFFFFFFFFF2345678,(%rax)
242 jne .L12_failure
243 cmpq $0xFFFFFFFFF2345677,(%rax)
244 jl .L12_failure
245 cmpq $0xFFFFFFFFF2345679,(%rax)
246 jg .L12_failure
247
248 .L12_success:
249 movq $1,(%rax)
250 TEST_END
251 .L12_failure:
252 movq $0,(%rax)
253 TEST_END
254 test12_end:
255
256 .align 64
257 test13_begin:
258 movq $0x1000,%rax
259 movq $0x000000001000A0FF,(%rax)
260
261 movq $0xFFFF,%rcx
262 subb %cl,(%rax)
263
264 movq $0xA000,%rcx
265 subw %cx,(%rax)
266
267 movq $0x0000000F1000A0FF,%rcx
268 subq (%rax),%rcx
269
270 movq %rcx,(%rax)
271
272 TEST_END
273 test13_end:
274
275 .align 64
276 test14_begin:
277 movq $0x1000,%rax
278 movq $0xA0FF,(%rax)
279
280 testb $0x0F,(%rax)
281 jz .L14_failure
282
283 testw $0x0F00,(%rax)
284 jnz .L14_failure
285
286 testl $0xA000,(%rax)
287 jz .L14_failure
288
289 .L14_success:
290 movq $1,(%rax)
291 TEST_END
292 .L14_failure:
293 movq $0,(%rax)
294 TEST_END
295 test14_end:
296