]> Git Repo - J-linux.git/blob - arch/arm64/mm/mem_encrypt.c
Merge tag 'vfs-6.13-rc7.fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs
[J-linux.git] / arch / arm64 / mm / mem_encrypt.c
1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3  * Implementation of the memory encryption/decryption API.
4  *
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.
9  *
10  * Author: Will Deacon <[email protected]>
11  * Copyright (C) 2024 Google LLC
12  *
13  * "Hello, boils and ghouls!"
14  */
15
16 #include <linux/bug.h>
17 #include <linux/compiler.h>
18 #include <linux/err.h>
19 #include <linux/mm.h>
20
21 #include <asm/mem_encrypt.h>
22
23 static const struct arm64_mem_crypt_ops *crypt_ops;
24
25 int arm64_mem_crypt_ops_register(const struct arm64_mem_crypt_ops *ops)
26 {
27         if (WARN_ON(crypt_ops))
28                 return -EBUSY;
29
30         crypt_ops = ops;
31         return 0;
32 }
33
34 int set_memory_encrypted(unsigned long addr, int numpages)
35 {
36         if (likely(!crypt_ops) || WARN_ON(!PAGE_ALIGNED(addr)))
37                 return 0;
38
39         return crypt_ops->encrypt(addr, numpages);
40 }
41 EXPORT_SYMBOL_GPL(set_memory_encrypted);
42
43 int set_memory_decrypted(unsigned long addr, int numpages)
44 {
45         if (likely(!crypt_ops) || WARN_ON(!PAGE_ALIGNED(addr)))
46                 return 0;
47
48         return crypt_ops->decrypt(addr, numpages);
49 }
50 EXPORT_SYMBOL_GPL(set_memory_decrypted);
This page took 0.025894 seconds and 4 git commands to generate.