summaryrefslogtreecommitdiff
path: root/sys/uvm
diff options
context:
space:
mode:
authorMiod Vallat <miod@cvs.openbsd.org>2008-04-12 20:36:39 +0000
committerMiod Vallat <miod@cvs.openbsd.org>2008-04-12 20:36:39 +0000
commit15180c410d235285778f8c09233a4279f9b18870 (patch)
treed80fc75bbc26bd5967b1bde81304d5f877af1423 /sys/uvm
parent9b63e75ed54a94db4b22c78fb20bc8de6d6e3ba2 (diff)
When enabling swap encryption, pass the correct number of swap pages to
uvm_swap_initcrypt. The number of available pages may not match, if we are using a miniroot in the swap partition.
Diffstat (limited to 'sys/uvm')
-rw-r--r--sys/uvm/uvm_swap.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/sys/uvm/uvm_swap.c b/sys/uvm/uvm_swap.c
index 60af2e8bdd9..105d25f33d7 100644
--- a/sys/uvm/uvm_swap.c
+++ b/sys/uvm/uvm_swap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uvm_swap.c,v 1.76 2007/12/18 11:05:52 thib Exp $ */
+/* $OpenBSD: uvm_swap.c,v 1.77 2008/04/12 20:36:38 miod Exp $ */
/* $NetBSD: uvm_swap.c,v 1.40 2000/11/17 11:39:39 mrg Exp $ */
/*
@@ -323,13 +323,17 @@ uvm_swap_initcrypt_all(void)
{
struct swapdev *sdp;
struct swappri *spp;
+ int npages;
simple_lock(&uvm.swap_data_lock);
LIST_FOREACH(spp, &swap_priority, spi_swappri) {
CIRCLEQ_FOREACH(sdp, &spp->spi_swapdev, swd_next)
- if (sdp->swd_decrypt == NULL)
- uvm_swap_initcrypt(sdp, sdp->swd_npages);
+ if (sdp->swd_decrypt == NULL) {
+ npages = dbtob((uint64_t)sdp->swd_nblks) >>
+ PAGE_SHIFT;
+ uvm_swap_initcrypt(sdp, npages);
+ }
}
simple_unlock(&uvm.swap_data_lock);
}
@@ -1028,8 +1032,9 @@ swap_on(p, sdp)
mp = rootvnode->v_mount;
sp = &mp->mnt_stat;
rootblocks = sp->f_blocks * btodb(sp->f_bsize);
- rootpages = round_page(dbtob(rootblocks)) >> PAGE_SHIFT;
- if (rootpages > size)
+ rootpages = round_page(dbtob((u_int64_t)rootblocks))
+ >> PAGE_SHIFT;
+ if (rootpages >= size)
panic("swap_on: miniroot larger than swap?");
if (extent_alloc_region(sdp->swd_ex, addr,
@@ -1200,7 +1205,7 @@ swstrategy(bp)
* be yanked out from under us because we are holding resources
* in it (i.e. the blocks we are doing I/O on).
*/
- pageno = dbtob((int64_t)bp->b_blkno) >> PAGE_SHIFT;
+ pageno = dbtob((u_int64_t)bp->b_blkno) >> PAGE_SHIFT;
simple_lock(&uvm.swap_data_lock);
sdp = swapdrum_getsdp(pageno);
simple_unlock(&uvm.swap_data_lock);