summaryrefslogtreecommitdiff
path: root/sys/uvm
diff options
context:
space:
mode:
authorJonathan Gray <jsg@cvs.openbsd.org>2024-11-07 09:04:56 +0000
committerJonathan Gray <jsg@cvs.openbsd.org>2024-11-07 09:04:56 +0000
commit35eff45350be179c55ee2d291a976e5ccbd25f8e (patch)
treee412e40d666df75e436ef5d1067d6e75d8cd596a /sys/uvm
parent90e21201cf7ed5a8c1a63af936004a495cae8f26 (diff)
de-macro SWAP_KEY_*; ok miod@ mpi@
Diffstat (limited to 'sys/uvm')
-rw-r--r--sys/uvm/uvm_swap.c6
-rw-r--r--sys/uvm/uvm_swap_encrypt.h32
2 files changed, 20 insertions, 18 deletions
diff --git a/sys/uvm/uvm_swap.c b/sys/uvm/uvm_swap.c
index 25a2e8c8e98..934d049492c 100644
--- a/sys/uvm/uvm_swap.c
+++ b/sys/uvm/uvm_swap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uvm_swap.c,v 1.172 2024/10/30 06:16:27 jsg Exp $ */
+/* $OpenBSD: uvm_swap.c,v 1.173 2024/11/07 09:04:55 jsg Exp $ */
/* $NetBSD: uvm_swap.c,v 1.40 2000/11/17 11:39:39 mrg Exp $ */
/*
@@ -1624,7 +1624,7 @@ uvm_swap_free(int startslot, int nslots)
key = SWD_KEY(sdp, startslot + i);
if (key->refcount != 0)
- SWAP_KEY_PUT(sdp, key);
+ swap_key_put(key);
}
/* Mark range as not decrypt */
@@ -1813,7 +1813,7 @@ uvm_swap_io(struct vm_page **pps, int startslot, int npages, int flags)
if (encrypt) {
key = SWD_KEY(sdp, startslot + i);
- SWAP_KEY_GET(sdp, key); /* add reference */
+ swap_key_get(key); /* add reference */
swap_encrypt(key, src, dst, block, PAGE_SIZE);
block += btodb(PAGE_SIZE);
diff --git a/sys/uvm/uvm_swap_encrypt.h b/sys/uvm/uvm_swap_encrypt.h
index b9ad8df8df1..bb39d18ea96 100644
--- a/sys/uvm/uvm_swap_encrypt.h
+++ b/sys/uvm/uvm_swap_encrypt.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: uvm_swap_encrypt.h,v 1.13 2024/11/07 06:04:11 jsg Exp $ */
+/* $OpenBSD: uvm_swap_encrypt.h,v 1.14 2024/11/07 09:04:55 jsg Exp $ */
/*
* Copyright 1999 Niels Provos <provos@citi.umich.edu>
@@ -60,23 +60,25 @@ void swap_decrypt(struct swap_key *,caddr_t, caddr_t, u_int64_t, size_t);
void swap_key_cleanup(struct swap_key *);
void swap_key_prepare(struct swap_key *, int);
-#define SWAP_KEY_GET(s,x) do { \
- if ((x)->refcount == 0) { \
- swap_key_create(x); \
- } \
- (x)->refcount++; \
- } while(0);
-
-#define SWAP_KEY_PUT(s,x) do { \
- (x)->refcount--; \
- if ((x)->refcount == 0) { \
- swap_key_delete(x); \
- } \
- } while(0);
-
void swap_key_create(struct swap_key *);
void swap_key_delete(struct swap_key *);
+static inline void
+swap_key_get(struct swap_key *key)
+{
+ if (key->refcount == 0)
+ swap_key_create(key);
+ key->refcount++;
+}
+
+static inline void
+swap_key_put(struct swap_key *key)
+{
+ key->refcount--;
+ if (key->refcount == 0)
+ swap_key_delete(key);
+}
+
extern int uvm_doswapencrypt; /* swapencrypt enabled/disabled */
extern int swap_encrypt_initialized;