1/* 2 * Copyright (c) 2019-2021 Maxime Villard, m00nbsd.net 3 * All rights reserved. 4 * 5 * This code is part of the NVMM hypervisor. 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 * 16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 19 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 21 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 23 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 24 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 * SUCH DAMAGE. 27 */ 28 29 .globl test1_begin, test1_end 30 .globl test2_begin, test2_end 31 .globl test3_begin, test3_end 32 .globl test4_begin, test4_end 33 .globl test5_begin, test5_end 34 .globl test6_begin, test6_end 35 .globl test7_begin, test7_end 36 .globl test8_begin, test8_end 37 .globl test9_begin, test9_end 38 .globl test10_begin, test10_end 39 .globl test11_begin, test11_end 40 .globl test12_begin, test12_end 41 .text 42 .code64 43 44#define TEST_END \ 45 movq $0xFFFFFFFFFFFFFFFF,%rcx; \ 46 rdmsr ; 47 48/* 49 * IN 50 */ 51 52 .align 64 53test1_begin: 54 movq $0x1000,%rbx 55 56 inb $123 57 movb %al,(%rbx) 58 incq %rbx 59 60 movq $123,%rdx 61 inb %dx 62 movb %al,(%rbx) 63 64 TEST_END 65test1_end: 66 67 .align 64 68test2_begin: 69 movq $0x1000,%rbx 70 71 inw $123 72 movw %ax,(%rbx) 73 addq $2,%rbx 74 75 movq $123,%rdx 76 inw %dx 77 movw %ax,(%rbx) 78 79 TEST_END 80test2_end: 81 82 .align 64 83test3_begin: 84 movq $0x1000,%rbx 85 86 inl $123 87 movl %eax,(%rbx) 88 addq $4,%rbx 89 90 movq $123,%rdx 91 inl %dx 92 movl %eax,(%rbx) 93 94 TEST_END 95test3_end: 96 97 .align 64 98test4_begin: 99 movq $0x1000,%rdi 100 movq $5,%rcx 101 102 movq $123,%rdx 103 rep 104 insb 105 106 TEST_END 107test4_end: 108 109 .align 64 110test5_begin: 111 movq $0x1000,%rdi 112 movq $14,%rcx 113 114 movq $123,%rdx 115 rep 116 insw 117 118 TEST_END 119test5_end: 120 121 .align 64 122test6_begin: 123 movq $0x1000,%rdi 124 movq $7,%rcx 125 126 movq $123,%rdx 127 rep 128 insl 129 130 TEST_END 131test6_end: 132 133/* 134 * OUT 135 */ 136 137 .align 64 138test7_begin: 139 movq $0x1000,%rbx 140 141 movb (%rbx),%al 142 outb $123 143 incq %rbx 144 145 movb (%rbx),%al 146 movq $123,%rdx 147 outb %dx 148 149 TEST_END 150test7_end: 151 152 .align 64 153test8_begin: 154 movq $0x1000,%rbx 155 156 movw (%rbx),%ax 157 outw $123 158 addq $2,%rbx 159 160 movw (%rbx),%ax 161 movq $123,%rdx 162 outw %dx 163 164 TEST_END 165test8_end: 166 167 .align 64 168test9_begin: 169 movq $0x1000,%rbx 170 171 movl (%rbx),%eax 172 outl $123 173 addq $4,%rbx 174 175 movl (%rbx),%eax 176 movq $123,%rdx 177 outl %dx 178 179 TEST_END 180test9_end: 181 182 .align 64 183test10_begin: 184 movq $0x1000,%rsi 185 movq $5,%rcx 186 187 movq $123,%rdx 188 rep 189 outsb 190 191 TEST_END 192test10_end: 193 194 .align 64 195test11_begin: 196 movq $0x1000,%rsi 197 movq $8,%rcx 198 199 movq $123,%rdx 200 rep 201 outsw 202 203 TEST_END 204test11_end: 205 206 .align 64 207test12_begin: 208 movq $0x1000,%rsi 209 movq $7,%rcx 210 211 movq $123,%rdx 212 rep 213 outsl 214 215 TEST_END 216test12_end: 217