summaryrefslogtreecommitdiff
path: root/sys/uvm/uvm_meter.c
diff options
context:
space:
mode:
authorNiels Provos <provos@cvs.openbsd.org>2000-03-18 20:51:33 +0000
committerNiels Provos <provos@cvs.openbsd.org>2000-03-18 20:51:33 +0000
commit73822b33170c55f3895c839a96f283f51025560e (patch)
tree24f50553fb39536f3e774b100efb5d16ea35347a /sys/uvm/uvm_meter.c
parente777b7cb9c0e2e41ed8dcb4b818e181f92df435a (diff)
postpone memory allocation for uvm swap encryption until it is turned on with
sysctl.
Diffstat (limited to 'sys/uvm/uvm_meter.c')
-rw-r--r--sys/uvm/uvm_meter.c21
1 files changed, 18 insertions, 3 deletions
diff --git a/sys/uvm/uvm_meter.c b/sys/uvm/uvm_meter.c
index 3c287ca34e5..da160cf64e3 100644
--- a/sys/uvm/uvm_meter.c
+++ b/sys/uvm/uvm_meter.c
@@ -49,6 +49,7 @@
#include <sys/exec.h>
#ifdef UVM_SWAP_ENCRYPT
+#include <uvm/uvm_swap.h>
#include <uvm/uvm_swap_encrypt.h>
#endif
@@ -153,9 +154,23 @@ uvm_sysctl(name, namelen, oldp, oldlenp, newp, newlen, p)
return (sysctl_rdstruct(oldp, oldlenp, newp, &_ps,
sizeof(_ps)));
#ifdef UVM_SWAP_ENCRYPT
- case VM_SWAPENCRYPT:
- return (sysctl_int(oldp, oldlenp, newp, newlen,
- &uvm_doswapencrypt));
+ case VM_SWAPENCRYPT: {
+ int doencrypt = uvm_doswapencrypt;
+ int result;
+
+ result = sysctl_int(oldp, oldlenp, newp, newlen, &doencrypt);
+ if (result)
+ return result;
+
+ /* Swap Encryption has been turned on, we need to
+ * initalize state for swap devices that have been
+ * added
+ */
+ if (doencrypt)
+ uvm_swap_initcrypt_all();
+ uvm_doswapencrypt = doencrypt;
+ return (0);
+ }
#endif
default:
return (EOPNOTSUPP);