drm/virtio: Don't return error if virtio-gpu PCI dev is not found
[drm/drm-misc.git] / arch / arm64 / mm / mem_encrypt.c
blobee3c0ab043845f9dc62715da4e60afa829f8ccb2
1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3 * Implementation of the memory encryption/decryption API.
5 * Since the low-level details of the operation depend on the
6 * Confidential Computing environment (e.g. pKVM, CCA, ...), this just
7 * acts as a top-level dispatcher to whatever hooks may have been
8 * registered.
10 * Author: Will Deacon <will@kernel.org>
11 * Copyright (C) 2024 Google LLC
13 * "Hello, boils and ghouls!"
16 #include <linux/bug.h>
17 #include <linux/compiler.h>
18 #include <linux/err.h>
19 #include <linux/mm.h>
21 #include <asm/mem_encrypt.h>
23 static const struct arm64_mem_crypt_ops *crypt_ops;
25 int arm64_mem_crypt_ops_register(const struct arm64_mem_crypt_ops *ops)
27 if (WARN_ON(crypt_ops))
28 return -EBUSY;
30 crypt_ops = ops;
31 return 0;
34 int set_memory_encrypted(unsigned long addr, int numpages)
36 if (likely(!crypt_ops) || WARN_ON(!PAGE_ALIGNED(addr)))
37 return 0;
39 return crypt_ops->encrypt(addr, numpages);
41 EXPORT_SYMBOL_GPL(set_memory_encrypted);
43 int set_memory_decrypted(unsigned long addr, int numpages)
45 if (likely(!crypt_ops) || WARN_ON(!PAGE_ALIGNED(addr)))
46 return 0;
48 return crypt_ops->decrypt(addr, numpages);
50 EXPORT_SYMBOL_GPL(set_memory_decrypted);