Changeset View
Changeset View
Standalone View
Standalone View
sys/kern/vfs_bio.c
Show First 20 Lines • Show All 1,038 Lines • ▼ Show 20 Lines | |||||
* being reserved at this time. | * being reserved at this time. | ||||
*/ | */ | ||||
caddr_t | caddr_t | ||||
kern_vfs_bio_buffer_alloc(caddr_t v, long physmem_est) | kern_vfs_bio_buffer_alloc(caddr_t v, long physmem_est) | ||||
{ | { | ||||
int tuned_nbuf; | int tuned_nbuf; | ||||
long maxbuf, maxbuf_sz, buf_sz, biotmap_sz; | long maxbuf, maxbuf_sz, buf_sz, biotmap_sz; | ||||
#ifdef KASAN | |||||
/* | /* | ||||
* With KASAN enabled, the kernel map is shadowed. Account for this | * With KASAN or KMSAN enabled, the kernel map is shadowed. Account for | ||||
* when sizing maps based on the amount of physical memory available. | * this when sizing maps based on the amount of physical memory | ||||
* available. | |||||
*/ | */ | ||||
#if defined(KASAN) | |||||
physmem_est = (physmem_est * KASAN_SHADOW_SCALE) / | physmem_est = (physmem_est * KASAN_SHADOW_SCALE) / | ||||
(KASAN_SHADOW_SCALE + 1); | (KASAN_SHADOW_SCALE + 1); | ||||
#elif defined(KMSAN) | |||||
physmem_est /= 3; | |||||
#endif | #endif | ||||
/* | /* | ||||
* physmem_est is in pages. Convert it to kilobytes (assumes | * physmem_est is in pages. Convert it to kilobytes (assumes | ||||
* PAGE_SIZE is >= 1K) | * PAGE_SIZE is >= 1K) | ||||
*/ | */ | ||||
physmem_est = physmem_est * (PAGE_SIZE / 1024); | physmem_est = physmem_est * (PAGE_SIZE / 1024); | ||||
▲ Show 20 Lines • Show All 108 Lines • ▼ Show 20 Lines | KASSERT(maxbcachebuf >= MAXBSIZE, | ||||
("maxbcachebuf (%d) must be >= MAXBSIZE (%d)\n", maxbcachebuf, | ("maxbcachebuf (%d) must be >= MAXBSIZE (%d)\n", maxbcachebuf, | ||||
MAXBSIZE)); | MAXBSIZE)); | ||||
bq_init(&bqempty, QUEUE_EMPTY, -1, "bufq empty lock"); | bq_init(&bqempty, QUEUE_EMPTY, -1, "bufq empty lock"); | ||||
mtx_init(&rbreqlock, "runningbufspace lock", NULL, MTX_DEF); | mtx_init(&rbreqlock, "runningbufspace lock", NULL, MTX_DEF); | ||||
mtx_init(&bdlock, "buffer daemon lock", NULL, MTX_DEF); | mtx_init(&bdlock, "buffer daemon lock", NULL, MTX_DEF); | ||||
mtx_init(&bdirtylock, "dirty buf lock", NULL, MTX_DEF); | mtx_init(&bdirtylock, "dirty buf lock", NULL, MTX_DEF); | ||||
unmapped_buf = (caddr_t)kva_alloc(maxphys); | unmapped_buf = (caddr_t)kva_alloc(maxphys); | ||||
#ifdef KMSAN | |||||
/* | |||||
* KMSAN cannot reliably determine whether buffer data is initialized | |||||
* unless it is updated through a KVA mapping. | |||||
*/ | |||||
unmapped_buf_allowed = 0; | |||||
#endif | |||||
/* finally, initialize each buffer header and stick on empty q */ | /* finally, initialize each buffer header and stick on empty q */ | ||||
for (i = 0; i < nbuf; i++) { | for (i = 0; i < nbuf; i++) { | ||||
bp = nbufp(i); | bp = nbufp(i); | ||||
bzero(bp, sizeof(*bp) + sizeof(vm_page_t) * atop(maxbcachebuf)); | bzero(bp, sizeof(*bp) + sizeof(vm_page_t) * atop(maxbcachebuf)); | ||||
bp->b_flags = B_INVAL; | bp->b_flags = B_INVAL; | ||||
bp->b_rcred = NOCRED; | bp->b_rcred = NOCRED; | ||||
bp->b_wcred = NOCRED; | bp->b_wcred = NOCRED; | ||||
▲ Show 20 Lines • Show All 4,355 Lines • Show Last 20 Lines |