.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
---|
1 | 2 | /* Driver for Virtio crypto device. |
---|
2 | 3 | * |
---|
3 | 4 | * Copyright 2016 HUAWEI TECHNOLOGIES CO., LTD. |
---|
4 | | - * |
---|
5 | | - * This program is free software; you can redistribute it and/or modify |
---|
6 | | - * it under the terms of the GNU General Public License as published by |
---|
7 | | - * the Free Software Foundation; either version 2 of the License, or |
---|
8 | | - * (at your option) any later version. |
---|
9 | | - * |
---|
10 | | - * This program is distributed in the hope that it will be useful, |
---|
11 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
12 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
13 | | - * GNU General Public License for more details. |
---|
14 | | - * |
---|
15 | | - * You should have received a copy of the GNU General Public License |
---|
16 | | - * along with this program; if not, see <http://www.gnu.org/licenses/>. |
---|
17 | 5 | */ |
---|
18 | 6 | |
---|
19 | 7 | #include <linux/err.h> |
---|
.. | .. |
---|
29 | 17 | virtcrypto_clear_request(struct virtio_crypto_request *vc_req) |
---|
30 | 18 | { |
---|
31 | 19 | if (vc_req) { |
---|
32 | | - kzfree(vc_req->req_data); |
---|
| 20 | + kfree_sensitive(vc_req->req_data); |
---|
33 | 21 | kfree(vc_req->sgs); |
---|
34 | 22 | } |
---|
35 | 23 | } |
---|
.. | .. |
---|
216 | 204 | u32 status; |
---|
217 | 205 | int err; |
---|
218 | 206 | |
---|
219 | | - virtio_cread(vcrypto->vdev, |
---|
220 | | - struct virtio_crypto_config, status, &status); |
---|
| 207 | + virtio_cread_le(vcrypto->vdev, |
---|
| 208 | + struct virtio_crypto_config, status, &status); |
---|
221 | 209 | |
---|
222 | 210 | /* |
---|
223 | 211 | * Unknown status bits would be a host error and the driver |
---|
.. | .. |
---|
335 | 323 | if (!vcrypto) |
---|
336 | 324 | return -ENOMEM; |
---|
337 | 325 | |
---|
338 | | - virtio_cread(vdev, struct virtio_crypto_config, |
---|
| 326 | + virtio_cread_le(vdev, struct virtio_crypto_config, |
---|
339 | 327 | max_dataqueues, &max_data_queues); |
---|
340 | 328 | if (max_data_queues < 1) |
---|
341 | 329 | max_data_queues = 1; |
---|
342 | 330 | |
---|
343 | | - virtio_cread(vdev, struct virtio_crypto_config, |
---|
344 | | - max_cipher_key_len, &max_cipher_key_len); |
---|
345 | | - virtio_cread(vdev, struct virtio_crypto_config, |
---|
346 | | - max_auth_key_len, &max_auth_key_len); |
---|
347 | | - virtio_cread(vdev, struct virtio_crypto_config, |
---|
348 | | - max_size, &max_size); |
---|
349 | | - virtio_cread(vdev, struct virtio_crypto_config, |
---|
350 | | - crypto_services, &crypto_services); |
---|
351 | | - virtio_cread(vdev, struct virtio_crypto_config, |
---|
352 | | - cipher_algo_l, &cipher_algo_l); |
---|
353 | | - virtio_cread(vdev, struct virtio_crypto_config, |
---|
354 | | - cipher_algo_h, &cipher_algo_h); |
---|
355 | | - virtio_cread(vdev, struct virtio_crypto_config, |
---|
356 | | - hash_algo, &hash_algo); |
---|
357 | | - virtio_cread(vdev, struct virtio_crypto_config, |
---|
358 | | - mac_algo_l, &mac_algo_l); |
---|
359 | | - virtio_cread(vdev, struct virtio_crypto_config, |
---|
360 | | - mac_algo_h, &mac_algo_h); |
---|
361 | | - virtio_cread(vdev, struct virtio_crypto_config, |
---|
362 | | - aead_algo, &aead_algo); |
---|
| 331 | + virtio_cread_le(vdev, struct virtio_crypto_config, |
---|
| 332 | + max_cipher_key_len, &max_cipher_key_len); |
---|
| 333 | + virtio_cread_le(vdev, struct virtio_crypto_config, |
---|
| 334 | + max_auth_key_len, &max_auth_key_len); |
---|
| 335 | + virtio_cread_le(vdev, struct virtio_crypto_config, |
---|
| 336 | + max_size, &max_size); |
---|
| 337 | + virtio_cread_le(vdev, struct virtio_crypto_config, |
---|
| 338 | + crypto_services, &crypto_services); |
---|
| 339 | + virtio_cread_le(vdev, struct virtio_crypto_config, |
---|
| 340 | + cipher_algo_l, &cipher_algo_l); |
---|
| 341 | + virtio_cread_le(vdev, struct virtio_crypto_config, |
---|
| 342 | + cipher_algo_h, &cipher_algo_h); |
---|
| 343 | + virtio_cread_le(vdev, struct virtio_crypto_config, |
---|
| 344 | + hash_algo, &hash_algo); |
---|
| 345 | + virtio_cread_le(vdev, struct virtio_crypto_config, |
---|
| 346 | + mac_algo_l, &mac_algo_l); |
---|
| 347 | + virtio_cread_le(vdev, struct virtio_crypto_config, |
---|
| 348 | + mac_algo_h, &mac_algo_h); |
---|
| 349 | + virtio_cread_le(vdev, struct virtio_crypto_config, |
---|
| 350 | + aead_algo, &aead_algo); |
---|
363 | 351 | |
---|
364 | 352 | /* Add virtio crypto device to global table */ |
---|
365 | 353 | err = virtcrypto_devmgr_add_dev(vcrypto); |
---|
.. | .. |
---|
510 | 498 | } |
---|
511 | 499 | #endif |
---|
512 | 500 | |
---|
513 | | -static unsigned int features[] = { |
---|
| 501 | +static const unsigned int features[] = { |
---|
514 | 502 | /* none */ |
---|
515 | 503 | }; |
---|
516 | 504 | |
---|
517 | | -static struct virtio_device_id id_table[] = { |
---|
| 505 | +static const struct virtio_device_id id_table[] = { |
---|
518 | 506 | { VIRTIO_ID_CRYPTO, VIRTIO_DEV_ANY_ID }, |
---|
519 | 507 | { 0 }, |
---|
520 | 508 | }; |
---|