aboutsummaryrefslogtreecommitdiff
path: root/kernel/virtio_disk.c
diff options
context:
space:
mode:
authorFrans Kaashoek <kaashoek@mit.edu>2019-07-19 08:38:51 -0400
committerFrans Kaashoek <kaashoek@mit.edu>2019-07-19 08:38:51 -0400
commit91566327012cad2ca99df47f9321dfc012d8a7ff (patch)
treee9cb082d502a9f56857270264bea254149a3318d /kernel/virtio_disk.c
parentb924e44f06c9c0882a2cffe6c9215b12c5aee2e6 (diff)
downloadxv6-labs-2022-91566327012cad2ca99df47f9321dfc012d8a7ff.tar.xz
xv6-labs-2022-91566327012cad2ca99df47f9321dfc012d8a7ff.zip
One way of supporting a guard page below kstack: allocate kstacks in
procinit() and map them high up (below TRAMPOLNE) with an empty mapping below each stack. Never free a kernel stack. Another way would be to allocate and map them dynamically, but then we need to reload page table when switching processes in scheduler() and/or have a kernel pagetable per proc (if we want k->stack to be the same virtual address in each process). One gotcha: kernel addresses are not equal to physical addresses for stack addresses. A stack address must be translated if we need its physical address (e.g., virtio passes a stack address to the disk).
Diffstat (limited to 'kernel/virtio_disk.c')
-rw-r--r--kernel/virtio_disk.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/kernel/virtio_disk.c b/kernel/virtio_disk.c
index 1a29ce7..6620037 100644
--- a/kernel/virtio_disk.c
+++ b/kernel/virtio_disk.c
@@ -199,7 +199,7 @@ virtio_disk_rw(struct buf *b)
buf0.reserved = 0;
buf0.sector = sector;
- desc[idx[0]].addr = (uint64) &buf0;
+ desc[idx[0]].addr = (uint64) kernelpa((uint64) &buf0);
desc[idx[0]].len = sizeof(buf0);
desc[idx[0]].flags = VRING_DESC_F_NEXT;
desc[idx[0]].next = idx[1];