Skip to content

add support for riscv64 targets#2

Open
dbohdan wants to merge 1 commit intorzimmerman:masterfrom
dbohdan:master
Open

add support for riscv64 targets#2
dbohdan wants to merge 1 commit intorzimmerman:masterfrom
dbohdan:master

Conversation

@dbohdan
Copy link

@dbohdan dbohdan commented Feb 8, 2026

This PR adds support for 64-bit RISC-V. The syscall numbers are identical to ARM64, so I've just copied the ARM64 file. The change has been tested on the Ubuntu Server preinstalled image version 24.04.3 in QEMU on an Ubuntu 24.04 x86-64 host.

This was my QEMU configuration:

qemu-system-riscv64 \
    -append "console=ttyS0 rw root=/dev/vda1" \
    -bios /usr/lib/riscv64-linux-gnu/opensbi/generic/fw_dynamic.bin \
    -cpu rv64 \
    -device virtio-blk-device,drive=hd0 \
    -device virtio-net-device,netdev=usernet \
    -device virtio-rng-device,rng=rng0 \
    -drive file=ubuntu.qcow2,format=qcow2,id=hd0 \
    -kernel /usr/lib/u-boot/qemu-riscv64_smode/uboot.elf \
    -m 2G \
    -machine virt \
    -netdev user,id=usernet,hostfwd=tcp::22222-:22 \
    -nographic \
    -object rng-random,filename=/dev/urandom,id=rng0 \
    ;

The tests pass:

ubuntu@ubuntu:~/keyctl$ go version
go version go1.22.2 linux/riscv64

ubuntu@ubuntu:~/keyctl$ uname -a
Linux ubuntu 6.8.0-60-generic #63.1-Ubuntu SMP PREEMPT_DYNAMIC Thu May  1 06:01:27 UTC 2025 riscv64 riscv64 riscv64 GNU/Linux

ubuntu@ubuntu:~/keyctl$ go test -v
=== RUN   TestRandomKey256
    key_test.go:76: added 256 byte random value key as: 806201613 ([87 199 202 34 225 184 119 236 81 154 66 153 97 168 8 155 166 110 61 162 83 111 98 94 195 15 249 48 57 156 14 231 148 182 123 59 248 190 93 109 63 204 10 47 64 38 11 131 159 233 58 139 101 251 76 12 176 90 74 140 245 224 67 193 128 209 106 62 112 31 175 86 73 161 23 5 40 68 149 125 211 28 77 188 114 56 201 183 53 1 239 75 143 234 25 24 217 228 105 108 255 169 207 187 113 49 212 172 244 27 165 237 85 174 92 118 65 214 185 163 82 252 3 250 30 60 253 96 18 206 215 191 88 121 177 46 170 196 146 100 134 54 194 9 247 213 144 19 29 13 167 69 132 39 126 205 242 246 72 50 79 84 179 197 33 99 95 221 171 137 130 186 219 203 158 103 127 220 117 223 164 52 180 26 21 124 32 89 230 116 41 254 16 145 107 136 142 229 240 173 178 200 6 2 181 44 20 152 241 104 243 238 37 55 232 192 78 133 4 51 17 198 70 43 135 115 189 151 218 208 222 102 91 141 235 42 22 129 36 138 216 147 226 45 0 122 71 35 120 150 80 160 157 227 210 7])
--- PASS: TestRandomKey256 (0.01s)
=== RUN   TestRandomKey700
    key_test.go:92: added 700 byte random value key as: 1071554799 ([78 56 87 166 180 204 50 62 146 53 75 89 230 246 186 253 221 120 33 139 140 170 123 27 48 35 69 6 67 132 92 177 12 137 165 86 66 49 229 96 231 13 134 23 157 178 58 83 85 0 160 74 192 40 207 133 169 93 254 135 107 158 191 37 76 29 159 168 114 237 138 136 250 190 209 234 154 175 22 8 242 161 153 183 195 95 126 24 184 151 181 28 46 15 206 149 249 162 119 3 117 236 115 187 248 155 81 196 245 4 38 142 228 20 232 7 102 118 60 106 141 214 163 167 64 152 19 200 43 113 216 17 79 109 215 198 121 32 179 44 80 39 9 18 84 125 2 130 90 129 210 241 171 99 201 150 111 208 63 164 112 212 144 217 255 71 240 213 173 105 197 97 224 199 247 61 222 239 227 94 223 226 110 55 70 225 72 238 235 252 218 244 147 176 124 100 127 203 11 41 42 101 31 54 122 251 172 59 243 14 103 88 45 52 1 82 143 73 116 233 51 148 65 47 5 219 174 185 36 194 10 91 25 16 211 189 34 77 30 21 156 57 98 188 182 145 128 193 131 202 108 220 104 205 26 68 14 88 212 169 133 90 95 82 79 192 218 203 247 156 44 137 193 69 99 214 48 188 12 190 80 181 176 180 179 183 53 178 240 17 196 40 29 237 230 144 98 122 145 35 185 109 5 134 38 171 97 234 24 168 151 68 13 84 107 167 87 100 148 72 184 36 147 33 233 138 21 2 112 28 182 59 164 207 77 64 221 67 149 140 153 250 103 42 255 96 252 195 131 93 92 211 213 0 187 23 216 62 235 52 127 239 22 94 74 150 73 56 139 143 128 46 121 244 165 232 228 243 9 65 115 119 251 20 50 177 57 85 116 31 160 223 106 129 18 253 130 238 246 54 163 204 4 6 146 102 15 91 186 111 175 126 75 7 41 158 83 124 166 170 113 217 157 10 76 142 11 110 114 152 245 66 132 1 55 37 215 47 154 219 208 105 191 159 61 26 43 30 198 248 117 222 236 241 27 161 108 205 118 141 58 45 34 32 49 194 229 172 173 220 227 254 8 210 201 224 209 81 155 202 174 123 120 39 63 19 51 189 60 25 136 197 16 226 225 78 242 3 70 125 231 101 104 249 162 71 135 206 199 86 89 200 69 11 166 113 185 21 23 62 179 82 180 25 6 44 54 120 89 134 100 144 167 140 139 145 164 53 52 175 174 58 10 178 172 0 40 156 161 159 28 135 91 182 177 66 63 124 41 9 165 103 22 127 104 31 88 130 151 48 15 163 47 117 78 4 138 59 173 56 64 129 87 13 131 119 136 155 184 5 49 12 2 102 71 147 20 121 181 72 108 79 111 30 142 80 171 148 36 106 170 95 37 55 14 39 74 132 99 81 1 84 157 27 93 92 17 90 65 16 86 70 19 43 141 110 133 32 176 183 153 101 169 160 3 118 109 77 96 149 34 76 162 186 24 8 122 105 60 38 46 51 115 146 137 75 112 187 26 73 123 83 94 126 114 98 50 29 154 7 61 68 168 116 97 158 57 107 125 42 35 45 67 128 150 18 85 152 33 143])
    key_test.go:99: key 1071554799 expired after five seconds
--- PASS: TestRandomKey700 (5.02s)
=== RUN   TestAdd100BytesToSessionKeyring
    keyring_test.go:17: added 100 byte empty key as: 597369436
    keyring_test.go:24: read 100 octets from key: [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]
--- PASS: TestAdd100BytesToSessionKeyring (0.01s)
=== RUN   TestAdd128BytesToSessionExpireAfter10Seconds
    keyring_test.go:37: added 128 byte empty key as: 199709666
--- PASS: TestAdd128BytesToSessionExpireAfter10Seconds (0.00s)
=== RUN   TestFetchKey
    keyring_test.go:56: read 100 octets from key: [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]
--- PASS: TestFetchKey (0.00s)
=== RUN   TestFetchKeyFail
--- PASS: TestFetchKeyFail (0.00s)
=== RUN   TestUnlinkKey
--- PASS: TestUnlinkKey (0.00s)
=== RUN   TestCreateKeyring
    keyring_test.go:102: created keyring 307653441 named "testring"
--- PASS: TestCreateKeyring (0.00s)
=== RUN   TestCreateNestedKeyring
    keyring_test.go:102: created keyring 96773332 named "testring"
    keyring_test.go:102: created keyring 440790273 named "testring2"
    keyring_test.go:124: created nested keyring 440790273 named "testring2"
    keyring_test.go:102: created keyring 352889053 named "testring3"
    keyring_test.go:126: created nested keyring 352889053 named "testring3"
--- PASS: TestCreateNestedKeyring (0.01s)
=== RUN   TestOpenNestedKeyring
    keyring_test.go:102: created keyring 537698540 named "testring"
    keyring_test.go:102: created keyring 120178246 named "testring2"
    keyring_test.go:142: created nested keyring 120178246 named "testring2"
    keyring_test.go:102: created keyring 894158506 named "testring3"
    keyring_test.go:144: created nested keyring 894158506 named "testring3"
    keyring_test.go:150: successfully reopened keyring 894158506 named "testring3"
--- PASS: TestOpenNestedKeyring (0.01s)
=== RUN   TestUnlinkKeyring
    keyring_test.go:164: created keyring 959291654 named "testring"
    keyring_test.go:171: unlinked keyring 959291654 [testring]
--- PASS: TestUnlinkKeyring (0.00s)
=== RUN   TestMoveKey
    keyring_test.go:184: created keyring 772729558 named "testring"
    keyring_test.go:191: added test key as: 139343697
    keyring_test.go:203: found key in keyring: 139343697
--- PASS: TestMoveKey (0.01s)
=== RUN   TestStreamReader
    reader_test.go:39: compared key 1062416454 128 bytes: [160 228 246 128 139 223 163 5 127 72 22 121 108 145 204 237 23 167 207 82 86 38 67 141 251 253 242 34 84 222 181 75 42 200 175 131 142 185 65 70 16 210 94 232 88 151 166 129 212 95 96 64 179 247 240 216 0 73 171 244 193 158 188 3 170 49 146 220 168 122 219 71 10 154 98 177 111 245 119 80 9 118 238 241 52 165 164 190 255 54 116 254 27 202 133 199 45 162 186 58 77 21 29 180 221 63 178 130 19 227 35 100 138 208 6 89 183 123 136 229 233 50 147 149 211 137 20 198]
    reader_test.go:39: compared key 1062416454 128 bytes: [87 194 252 91 105 40 113 53 189 235 85 18 83 41 90 187 51 7 226 36 14 109 78 215 236 218 26 48 150 57 46 205 81 79 106 55 132 203 156 112 234 97 248 176 140 243 12 217 249 201 182 153 43 124 59 61 107 174 172 17 143 161 32 37 104 126 110 209 102 24 103 11 92 214 148 47 197 8 33 184 192 1 239 135 30 191 99 69 196 125 28 74 13 225 115 76 213 93 44 157 173 120 60 68 195 224 231 66 152 250 114 62 117 31 56 159 39 134 2 25 15 155 144 4 206 169 101 230]
    reader_test.go:39: compared key 1062416454 128 bytes: [54 255 2 180 146 35 18 226 190 177 70 27 45 113 68 163 228 22 166 36 212 16 107 191 116 208 38 25 71 148 19 4 235 240 130 77 72 213 21 117 138 37 151 176 236 10 32 62 40 24 139 209 178 109 67 122 95 74 158 169 173 242 61 84 230 58 73 29 126 100 66 93 105 89 134 196 65 225 207 42 224 111 15 195 34 237 88 227 220 164 102 143 53 183 85 132 108 222 6 136 52 200 39 48 172 46 76 8 12 87 171 26 238 188 123 14 91 214 153 149 57 63 120 131 174 168 219 83]
    reader_test.go:39: compared key 1062416454 128 bytes: [245 9 17 112 159 118 147 156 204 251 197 125 157 13 160 133 28 182 252 216 211 184 98 86 44 97 135 231 23 179 1 137 229 199 0 80 162 210 187 92 234 114 124 47 203 55 186 206 115 129 41 150 128 239 104 243 248 246 161 201 167 31 247 5 7 155 49 140 192 33 223 233 142 101 205 217 141 221 198 121 181 202 106 43 218 175 249 78 59 20 64 165 244 185 11 99 69 75 30 189 127 152 60 50 144 194 90 3 79 94 145 193 103 96 170 254 253 82 81 241 215 232 110 119 154 51 56 250]
    reader_test.go:39: compared key 1062416454 128 bytes: [76 110 204 155 116 115 111 19 88 71 3 74 182 25 147 34 103 27 189 72 190 8 53 18 170 164 118 169 157 120 21 92 13 64 87 161 136 185 141 48 171 14 73 20 123 192 143 47 140 5 186 60 134 45 93 191 197 159 112 89 41 122 203 58 114 138 174 132 165 50 35 66 52 181 128 78 196 67 183 85 28 201 106 83 15 177 81 194 26 2 205 82 49 7 23 127 100 168 198 172 30 51 130 145 44 113 206 17 63 150 104 101 12 86 40 193 84 158 175 55 133 94 98 160 69 6 180 56]
    reader_test.go:39: compared key 1062416454 79 bytes: [59 135 77 195 39 91 178 96 32 0 200 1 68 153 37 54 179 119 29 199 65 61 129 188 97 163 95 16 131 142 151 154 148 176 105 162 4 46 79 187 109 139 156 184 173 167 24 125 10 70 75 42 62 102 107 90 43 166 22 121 99 108 117 38 202 80 31 36 137 149 11 33 124 144 57 146 126 9 152]
--- PASS: TestStreamReader (0.03s)
=== RUN   TestSessionKeyringRefs
    ref_test.go:33: 1065148371: {Type:keyring Name:_uid.1000 Uid:1000 Gid:65534 Perm:-lswrvalswrv------------ valid:true} [--alswrv]
    ref_test.go:33: 199709666: {Type:key Name:expire-test Uid:1000 Gid:1000 Perm:alswrv-----v------------ valid:true} [-------v]
    ref_test.go:33: 1062416454: {Type:key Name:test1544bytestream Uid:1000 Gid:1000 Perm:alswrv-----v------------ valid:true} [-------v]
    ref_test.go:33: 1071554799: {Type: Name:key has expired Uid:0 Gid:0 Perm:------------------------ valid:false} [--------]
    ref_test.go:33: 806201613: {Type: Name:key has expired Uid:0 Gid:0 Perm:------------------------ valid:false} [--------]
    ref_test.go:65: keyring 1065148371: "_uid.1000", parent -3
    ref_test.go:71: key 199709666: "expire-test", keyring -3
    ref_test.go:76:    199709666: [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]
    ref_test.go:71: key 1062416454: "test1544bytestream", keyring -3
    ref_test.go:76:    1062416454: [160 228 246 128 139 223 163 5 127 72 22 121 108 145 204 237 23 167 207 82 86 38 67 141 251 253 242 34 84 222 181 75 42 200 175 131 142 185 65 70 16 210 94 232 88 151 166 129 212 95 96 64 179 247 240 216 0 73 171 244 193 158 188 3 170 49 146 220 168 122 219 71 10 154 98 177 111 245 119 80 9 118 238 241 52 165 164 190 255 54 116 254 27 202 133 199 45 162 186 58 77 21 29 180 221 63 178 130 19 227 35 100 138 208 6 89 183 123 136 229 233 50 147 149 211 137 20 198 87 194 252 91 105 40 113 53 189 235 85 18 83 41 90 187 51 7 226 36 14 109 78 215 236 218 26 48 150 57 46 205 81 79 106 55 132 203 156 112 234 97 248 176 140 243 12 217 249 201 182 153 43 124 59 61 107 174 172 17 143 161 32 37 104 126 110 209 102 24 103 11 92 214 148 47 197 8 33 184 192 1 239 135 30 191 99 69 196 125 28 74 13 225 115 76 213 93 44 157 173 120 60 68 195 224 231 66 152 250 114 62 117 31 56 159 39 134 2 25 15 155 144 4 206 169 101 230 54 255 2 180 146 35 18 226 190 177 70 27 45 113 68 163 228 22 166 36 212 16 107 191 116 208 38 25 71 148 19 4 235 240 130 77 72 213 21 117 138 37 151 176 236 10 32 62 40 24 139 209 178 109 67 122 95 74 158 169 173 242 61 84 230 58 73 29 126 100 66 93 105 89 134 196 65 225 207 42 224 111 15 195 34 237 88 227 220 164 102 143 53 183 85 132 108 222 6 136 52 200 39 48 172 46 76 8 12 87 171 26 238 188 123 14 91 214 153 149 57 63 120 131 174 168 219 83 245 9 17 112 159 118 147 156 204 251 197 125 157 13 160 133 28 182 252 216 211 184 98 86 44 97 135 231 23 179 1 137 229 199 0 80 162 210 187 92 234 114 124 47 203 55 186 206 115 129 41 150 128 239 104 243 248 246 161 201 167 31 247 5 7 155 49 140 192 33 223 233 142 101 205 217 141 221 198 121 181 202 106 43 218 175 249 78 59 20 64 165 244 185 11 99 69 75 30 189 127 152 60 50 144 194 90 3 79 94 145 193 103 96 170 254 253 82 81 241 215 232 110 119 154 51 56 250 76 110 204 155 116 115 111 19 88 71 3 74 182 25 147 34 103 27 189 72 190 8 53 18 170 164 118 169 157 120 21 92 13 64 87 161 136 185 141 48 171 14 73 20 123 192 143 47 140 5 186 60 134 45 93 191 197 159 112 89 41 122 203 58 114 138 174 132 165 50 35 66 52 181 128 78 196 67 183 85 28 201 106 83 15 177 81 194 26 2 205 82 49 7 23 127 100 168 198 172 30 51 130 145 44 113 206 17 63 150 104 101 12 86 40 193 84 158 175 55 133 94 98 160 69 6 180 56 59 135 77 195 39 91 178 96 32 0 200 1 68 153 37 54 179 119 29 199 65 61 129 188 97 163 95 16 131 142 151 154 148 176 105 162 4 46 79 187 109 139 156 184 173 167 24 125 10 70 75 42 62 102 107 90 43 166 22 121 99 108 117 38 202 80 31 36 137 149 11 33 124 144 57 146 126 9 152]
--- PASS: TestSessionKeyringRefs (0.03s)
=== RUN   TestListKeyring
    sys_test.go:20: id 1065148371
--- PASS: TestListKeyring (0.00s)
=== RUN   TestFSGID
    sys_test.go:32: fsgid = 1000
--- PASS: TestFSGID (0.00s)
=== RUN   TestStreamWriter
    writer_test.go:32: compared 1544 random block key in common session ring: [165 98 46 14 123 167 66 142 30 101 130 238 227 57 90 186 252 157 81 99 179 225 198 133 5 79 1 146 82 44 194 110 217 87 235 189 80 221 56 222 173 71 43 42 160 201 234 152 220 92 76 74 121 10 229 0 244 127 192 143 20 161 240 187 67 72 106 168 156 155 104 139 223 85 2 65 33 239 231 193 86 95 31 180 94 61 122 124 188 129 134 215 26 89 36 196 249 78 27 64 145 103 68 149 141 83 184 245 113 126 45 109 9 39 117 206 16 178 24 15 195 208 29 69 138 52 114 13 211 233 25 213 224 182 191 255 60 22 175 219 47 237 50 243 250 88 181 144 172 128 247 214 125 236 4 202 111 254 226 216 137 151 7 218 35 116 190 51 199 75 164 23 203 120 183 147 174 73 204 163 77 19 171 3 48 207 97 53 169 232 32 140 162 119 28 55 118 148 131 212]
--- PASS: TestStreamWriter (0.01s)
=== RUN   TestStreamWriterUpdate
    writer_test.go:70: [flushed] compared 218 random block key in "test" ring: [7 47 5 187 100 152 143 154 33 119 68 36 19 52 91 78 215 65 10 193 183 94 167 194 39 182 75 130 66 11 171 12 202 160 216 139 13 133 108 195 90 105 61 118 209 116 172 179 110 25 30 35 9 77 148 49 41 54 136 79 135 14 168 191 63 181 211 125 73 72 201 114 140 176 85 107 185 173 174 163 146 38 186 109 104 151 147 206 4 21 124 20 199 93 56 122 82 156 126 95 134 53 170 111 76 27 55 99 164 207 141 48 138 86 128 31 98 81 0 132 34 45 62 43 58 51 32 188 71 204 178 44 88 157 210 205 87 144 97 84 67 106 145 3 8 217 212 189 42 190 127 149 129 137 192 184 196 80 28 60 165 115 50 101 37 112 169 46 113 153 102 29 131 180 17 208 121 23 2 161 92 1 214 117 150 74 96 158 213 40 22 162 57 120 15 155 59 89 70 200 26 203 83 177 6 64 24 18 69 166 197 16 123 198 142 159 175 103]
--- PASS: TestStreamWriterUpdate (0.01s)
=== RUN   TestStreamWriterFlush
    writer_test.go:98: [flushed] compared 218 random block key in common session ring: [155 67 142 207 145 58 202 115 27 103 120 177 59 159 25 195 150 105 147 38 76 129 179 88 4 173 104 158 166 1 23 138 216 45 181 53 107 139 64 190 3 94 73 116 14 32 136 178 61 48 30 16 209 165 42 137 205 92 106 163 69 170 33 140 90 117 68 56 111 12 122 9 91 62 175 28 144 97 188 130 85 164 206 197 13 84 54 214 119 11 152 47 89 74 161 81 22 110 217 112 156 2 186 75 36 43 37 87 83 200 171 168 201 108 109 183 133 199 153 213 98 26 215 211 172 29 101 7 21 114 10 40 70 191 100 93 169 193 154 51 203 162 132 135 79 149 143 6 18 34 102 180 8 126 82 212 124 157 131 86 55 20 0 95 78 176 185 194 50 189 31 151 24 167 57 128 60 39 52 148 127 113 174 41 118 196 160 123 63 19 46 35 96 204 192 210 5 80 77 146 72 15 134 66 182 121 65 198 141 208 17 71 49 187 125 184 99 44]
--- PASS: TestStreamWriterFlush (0.01s)
PASS
ok      github.com/rzimmerman/keyctl    5.303s

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant