diff --git a/dep/sddf b/dep/sddf index d7476333..174352b4 160000 --- a/dep/sddf +++ b/dep/sddf @@ -1 +1 @@ -Subproject commit d7476333af02edc2b61a548131aa130eefc13384 +Subproject commit 174352b4c03683bb13a14bcf81788f6f012cc0f3 diff --git a/examples/virtio/Makefile b/examples/virtio/Makefile index 75f7a9fb..ae000cf7 100644 --- a/examples/virtio/Makefile +++ b/examples/virtio/Makefile @@ -55,10 +55,15 @@ CURRENT_DIR := $(shell pwd) LINUX_DIR := $(VMM_TOOLS)/linux LINUX_BLK_DIR := $(LINUX_DIR)/blk +LINUX_BLK_BOARD_DIR := $(LINUX_BLK_DIR)/board/$(BOARD) + UIO_DIR := $(LINUX_DIR)/uio +UIO_DRIVER_BLK_DIR := $(LINUX_DIR)/uio_drivers/blk SDDF_DIR := $(abspath ../../dep/sddf) +VMM_INCLUDE := include + BLK_DRIVER_VM_DIR := board/$(BOARD)/blk_driver_vm BLK_DRIVER_VM_DTS_DIR := $(BLK_DRIVER_VM_DIR)/dts BLK_DRIVER_VM_ROOTFS_TMP_DIR := $(BUILD_DIR)/blk_driver_vm_rootfs @@ -123,26 +128,16 @@ $(error Unsupported BOARD given) endif SDDF_SERIAL_DRIVER := $(SDDF_DIR)/drivers/serial/$(UART_DRIVER_DIR) -SERIAL_CONFIG_INCLUDE:= include/serial_config - ELFS := client_vmm_1.elf client_vmm_2.elf blk_driver_vmm.elf serial_virt_tx.elf serial_virt_rx.elf uart_driver.elf blk_virt.elf -BLK_DRIVER_VM_USERLEVEL_qemu_arm_virt := uio_blk_driver -BLK_DRIVER_VM_USERLEVEL_odroidc4 := uio_blk_driver -BLK_DRIVER_VM_USERLEVEL := ${BLK_DRIVER_VM_USERLEVEL_${BOARD}} -BLK_DRIVER_VM_USERLEVEL_INIT_qemu_arm_virt := qemu_blk_driver_init -BLK_DRIVER_VM_USERLEVEL_INIT_odroidc4 := blk_driver_init -BLK_DRIVER_VM_USERLEVEL_INIT := ${BLK_DRIVER_VM_USERLEVEL_INIT_${BOARD}} +BLK_DRIVER_VM_USERLEVEL := uio_blk_driver +BLK_DRIVER_VM_USERLEVEL_INIT := blk_driver_init CLIENT_VM_1_USERLEVEL := -CLIENT_VM_1_USERLEVEL_INIT_qemu_arm_virt := qemu_blk_client_init -CLIENT_VM_1_USERLEVEL_INIT_odroidc4 := blk_client_init -CLIENT_VM_1_USERLEVEL_INIT := ${CLIENT_VM_1_USERLEVEL_INIT_${BOARD}} +CLIENT_VM_1_USERLEVEL_INIT := blk_client_init CLIENT_VM_2_USERLEVEL := -CLIENT_VM_2_USERLEVEL_INIT_qemu_arm_virt := qemu_blk_client_init -CLIENT_VM_2_USERLEVEL_INIT_odroidc4 := blk_client_init -CLIENT_VM_2_USERLEVEL_INIT := ${CLIENT_VM_2_USERLEVEL_INIT_${BOARD}} +CLIENT_VM_2_USERLEVEL_INIT:= blk_client_init IMAGE_FILE = $(BUILD_DIR)/loader.img REPORT_FILE = $(BUILD_DIR)/report.txt @@ -202,7 +197,7 @@ CFLAGS := -mstrict-align \ -Wall -Wno-unused-function -Werror \ -I$(VMM_SRC_DIR)/arch/aarch64 -I$(VMM_SRC_DIR) -I$(VMM_SRC_DIR)/util -I$(BOARD_DIR)/include \ -I$(SDDF_DIR)/include \ - -I$(SERIAL_CONFIG_INCLUDE) \ + -I$(VMM_INCLUDE) \ -DBOARD_$(BOARD) \ -DCONFIG_$(CONFIG) \ -target aarch64-none-elf @@ -214,6 +209,7 @@ CFLAGS_LINUX := -g3 \ -D_GNU_SOURCE \ -I$(SDDF_DIR)/include \ -I$(LINUX_DIR)/include \ + -I$(VMM_INCLUDE) \ -target aarch64-linux-gnu LDFLAGS := -L$(BOARD_DIR)/lib @@ -348,7 +344,7 @@ $(BUILD_DIR)/%.o: $(VMM_SRC_DIR)/virtio/%.c Makefile $(CC) -c $(CFLAGS) $< -o $@ $(BUILD_DIR)/sddf_blk_%.o: $(SDDF_BLK_COMPONENTS)/%.c Makefile - $(CC) -c $(CFLAGS) -DBLK_NUM_CLIENTS=2 $< -o $@ + $(CC) -c $(CFLAGS) $< -o $@ $(BUILD_DIR)/sddf_blk_%.o: $(SDDF_BLK_UTIL)/%.c Makefile $(CC) -c $(CFLAGS) $< -o $@ @@ -371,18 +367,15 @@ $(BUILD_DIR)/postmark: $(LINUX_BLK_DIR)/postmark.c $(BUILD_DIR)/blk_client_init: $(LINUX_BLK_DIR)/blk_client_init cp $< $@ -$(BUILD_DIR)/blk_driver_init: $(LINUX_BLK_DIR)/blk_driver_init - cp $< $@ - -$(BUILD_DIR)/qemu_blk_client_init: $(LINUX_BLK_DIR)/qemu_blk_client_init - cp $< $@ - -$(BUILD_DIR)/qemu_blk_driver_init: $(LINUX_BLK_DIR)/qemu_blk_driver_init +$(BUILD_DIR)/blk_driver_init: $(LINUX_BLK_BOARD_DIR)/blk_driver_init cp $< $@ $(BUILD_DIR)/%.o: $(UIO_DIR)/%.c Makefile $(CC_USERLEVEL) -c $(CFLAGS_LINUX) $< -o $@ +$(BUILD_DIR)/%.o: $(UIO_DRIVER_BLK_DIR)/%.c Makefile + $(CC_USERLEVEL) -c $(CFLAGS_LINUX) $< -o $@ + $(BUILD_DIR)/uio_blk_driver: $(addprefix $(BUILD_DIR)/, $(UIO_BLK_DRIVER_OBJS)) $(CC_USERLEVEL) $(CFLAGS_LINUX) $^ -o $@ diff --git a/examples/virtio/board/odroidc4/virtio.system b/examples/virtio/board/odroidc4/virtio.system index d27f3d80..6f24c30c 100644 --- a/examples/virtio/board/odroidc4/virtio.system +++ b/examples/virtio/board/odroidc4/virtio.system @@ -223,28 +223,27 @@ - - - - - - - - + + + + + + + - + - + - + diff --git a/examples/virtio/board/qemu_arm_virt/virtio.system b/examples/virtio/board/qemu_arm_virt/virtio.system index 56a49a0c..d0396225 100644 --- a/examples/virtio/board/qemu_arm_virt/virtio.system +++ b/examples/virtio/board/qemu_arm_virt/virtio.system @@ -216,28 +216,27 @@ - - - - - - - - + + + + + + + - + - + - + diff --git a/examples/virtio/client_vmm.c b/examples/virtio/client_vmm.c index 44a384d0..1d5c59df 100644 --- a/examples/virtio/client_vmm.c +++ b/examples/virtio/client_vmm.c @@ -19,6 +19,7 @@ #include #include #include +#include #define GUEST_RAM_SIZE 0x6000000 @@ -130,7 +131,7 @@ void init(void) blk_queue_init(&blk_queue_h, (blk_req_queue_t *)blk_req_queue, (blk_resp_queue_t *)blk_resp_queue, - BLK_QUEUE_SIZE); + blk_cli_queue_size(microkit_name)); /* Initialise virtIO block device */ success = virtio_mmio_blk_init(&virtio_blk, diff --git a/examples/virtio/include/blk_config.h b/examples/virtio/include/blk_config.h new file mode 100644 index 00000000..47b6f294 --- /dev/null +++ b/examples/virtio/include/blk_config.h @@ -0,0 +1,115 @@ +#pragma once + +#include +#include + +#define BLK_NUM_CLIENTS 2 + +#define BLK_NAME_CLI0 "CLIENT_VMM-1" +#define BLK_NAME_CLI1 "CLIENT_VMM-2" + +#define BLK_QUEUE_SIZE_CLI0 1024 +#define BLK_QUEUE_SIZE_CLI1 1024 +#define BLK_QUEUE_SIZE_DRIV (BLK_QUEUE_SIZE_CLI0 + BLK_QUEUE_SIZE_CLI1) + +#define BLK_REGION_SIZE 0x200000 +#define BLK_CONFIG_REGION_SIZE_CLI0 BLK_REGION_SIZE +#define BLK_CONFIG_REGION_SIZE_CLI1 BLK_REGION_SIZE + +#define BLK_DATA_REGION_SIZE_CLI0 BLK_REGION_SIZE +#define BLK_DATA_REGION_SIZE_CLI1 BLK_REGION_SIZE +#define BLK_DATA_REGION_SIZE_DRIV BLK_REGION_SIZE + +#define BLK_QUEUE_REGION_SIZE_CLI0 BLK_REGION_SIZE +#define BLK_QUEUE_REGION_SIZE_CLI1 BLK_REGION_SIZE +#define BLK_QUEUE_REGION_SIZE_DRIV BLK_REGION_SIZE + +_Static_assert(BLK_DATA_REGION_SIZE_CLI0 >= BLK_TRANSFER_SIZE && BLK_DATA_REGION_SIZE_CLI0 % BLK_TRANSFER_SIZE == 0, + "Client0 data region size must be a multiple of the transfer size"); +_Static_assert(BLK_DATA_REGION_SIZE_CLI1 >= BLK_TRANSFER_SIZE && BLK_DATA_REGION_SIZE_CLI1 % BLK_TRANSFER_SIZE == 0, + "Client1 data region size must be a multiple of the transfer size"); +_Static_assert(BLK_DATA_REGION_SIZE_DRIV >= BLK_TRANSFER_SIZE && BLK_DATA_REGION_SIZE_DRIV % BLK_TRANSFER_SIZE == 0, + "Driver data region size must be a multiple of the transfer size"); + +static inline blk_storage_info_t *blk_virt_cli_config_info(blk_storage_info_t *info, unsigned int id) +{ + switch (id) { + case 0: + return info; + case 1: + return (blk_storage_info_t *)((uintptr_t)info + BLK_CONFIG_REGION_SIZE_CLI0); + default: + return NULL; + } +} + +static inline uintptr_t blk_virt_cli_data_region(uintptr_t data, unsigned int id) +{ + switch (id) { + case 0: + return data; + case 1: + return (uintptr_t)data + BLK_DATA_REGION_SIZE_CLI0; + default: + return 0; + } +} + +static inline uint64_t blk_virt_cli_data_region_size(unsigned int id) +{ + switch (id) { + case 0: + return BLK_DATA_REGION_SIZE_CLI0; + case 1: + return BLK_DATA_REGION_SIZE_CLI1; + default: + return 0; + } +} + +static inline blk_req_queue_t *blk_virt_cli_req_queue(blk_req_queue_t *req, unsigned int id) +{ + switch (id) { + case 0: + return req; + case 1: + return (blk_req_queue_t *)((uintptr_t)req + BLK_QUEUE_REGION_SIZE_CLI0); + default: + return NULL; + } +} + +static inline blk_resp_queue_t *blk_virt_cli_resp_queue(blk_resp_queue_t *resp, unsigned int id) +{ + switch (id) { + case 0: + return resp; + case 1: + return (blk_resp_queue_t *)((uintptr_t)resp + BLK_QUEUE_REGION_SIZE_CLI0); + default: + return NULL; + } +} + +static inline uint32_t blk_virt_cli_queue_size(unsigned int id) +{ + switch (id) { + case 0: + return BLK_QUEUE_SIZE_CLI0; + case 1: + return BLK_QUEUE_SIZE_CLI1; + default: + return 0; + } +} + +static inline uint32_t blk_cli_queue_size(char *pd_name) +{ + if (!sddf_strcmp(pd_name, BLK_NAME_CLI0)) { + return BLK_QUEUE_SIZE_CLI0; + } else if (!sddf_strcmp(pd_name, BLK_NAME_CLI1)) { + return BLK_QUEUE_SIZE_CLI1; + } else { + return 0; + } +} diff --git a/examples/virtio/include/serial_config/serial_config.h b/examples/virtio/include/serial_config.h similarity index 100% rename from examples/virtio/include/serial_config/serial_config.h rename to examples/virtio/include/serial_config.h diff --git a/src/virtio/block.c b/src/virtio/block.c index 3965b0fd..737093a5 100644 --- a/src/virtio/block.c +++ b/src/virtio/block.c @@ -1,7 +1,9 @@ #include #include #include -#include "sddf/blk/queue.h" +#include +#include +#include #include "virtio/config.h" #include "virtio/virtq.h" #include "virtio/mmio.h" @@ -244,7 +246,8 @@ static int virtio_blk_mmio_queue_notify(struct virtio_device *dev) virtio_data, virtio_data_size, 0 }; - err = blk_enqueue_req(&state->queue_h, READ_BLOCKS, sddf_data, sddf_block_number, sddf_count, req_id); + uintptr_t offset = sddf_data - ((struct virtio_blk_device *)dev->device_data)->data_region; + err = blk_enqueue_req(&state->queue_h, READ_BLOCKS, offset, sddf_block_number, sddf_count, req_id); assert(!err); break; } @@ -289,7 +292,8 @@ static int virtio_blk_mmio_queue_notify(struct virtio_device *dev) virtio_data, virtio_data_size, aligned }; - err = blk_enqueue_req(&state->queue_h, READ_BLOCKS, sddf_data, sddf_block_number, sddf_count, req_id); + uintptr_t offset = sddf_data - ((struct virtio_blk_device *)dev->device_data)->data_region; + err = blk_enqueue_req(&state->queue_h, READ_BLOCKS, offset, sddf_block_number, sddf_count, req_id); assert(!err); } else { if (!sddf_make_req_check(state, sddf_count)) { @@ -316,7 +320,9 @@ static int virtio_blk_mmio_queue_notify(struct virtio_device *dev) /* Copy data from virtio buffer to data buffer, create sddf write request and initialise it with data buffer */ memcpy((void *)sddf_data, (void *)virtq->desc[curr_desc_head].addr, virtq->desc[curr_desc_head].len); - err = blk_enqueue_req(&state->queue_h, WRITE_BLOCKS, sddf_data, sddf_block_number, sddf_count, req_id); + + uintptr_t offset = sddf_data - ((struct virtio_blk_device *)dev->device_data)->data_region; + err = blk_enqueue_req(&state->queue_h, WRITE_BLOCKS, offset, sddf_block_number, sddf_count, req_id); assert(!err); } break; @@ -424,7 +430,7 @@ bool virtio_blk_handle_resp(struct virtio_blk_device *state) err = blk_enqueue_req(&state->queue_h, WRITE_BLOCKS, - data->sddf_data, + data->sddf_data - state->data_region, data->sddf_block_number, data->sddf_count, new_sddf_id); @@ -518,6 +524,7 @@ bool virtio_mmio_blk_init(struct virtio_blk_device *blk_dev, blk_dev->storage_info = storage_info; blk_dev->queue_h = *queue_h; + blk_dev->data_region = data_region; blk_dev->server_ch = server_ch; size_t sddf_data_buffers = data_region_size / BLK_TRANSFER_SIZE; diff --git a/src/virtio/block.h b/src/virtio/block.h index 0f6cbc20..96c49eee 100644 --- a/src/virtio/block.h +++ b/src/virtio/block.h @@ -137,7 +137,7 @@ struct virtio_blk_outhdr { #define SDDF_BLK_NUM_HANDLES 1 #define SDDF_BLK_DEFAULT_HANDLE 0 /* Maximum number of buffers in sddf data region */ -#define SDDF_MAX_DATA_BUFFERS 4096 +#define SDDF_MAX_DATA_BUFFERS 8192 #define VIRTIO_BLK_NUM_VIRTQ 1 #define VIRTIO_BLK_DEFAULT_VIRTQ 0 @@ -173,6 +173,7 @@ struct virtio_blk_device { blk_storage_info_t *storage_info; blk_queue_handle_t queue_h; + uintptr_t data_region; int server_ch; }; diff --git a/tools/linux/blk/blk_driver_init b/tools/linux/blk/board/odroidc4/blk_driver_init similarity index 100% rename from tools/linux/blk/blk_driver_init rename to tools/linux/blk/board/odroidc4/blk_driver_init diff --git a/tools/linux/blk/qemu_blk_driver_init b/tools/linux/blk/board/qemu_arm_virt/blk_driver_init similarity index 100% rename from tools/linux/blk/qemu_blk_driver_init rename to tools/linux/blk/board/qemu_arm_virt/blk_driver_init diff --git a/tools/linux/blk/qemu_blk_client_init b/tools/linux/blk/qemu_blk_client_init deleted file mode 100644 index e8377412..00000000 --- a/tools/linux/blk/qemu_blk_client_init +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -mount /dev/vda /mnt \ No newline at end of file diff --git a/tools/linux/uio/blk.c b/tools/linux/uio_drivers/blk/blk.c similarity index 68% rename from tools/linux/uio/blk.c rename to tools/linux/uio_drivers/blk/blk.c index 2aa7a762..62dd3e8d 100644 --- a/tools/linux/uio/blk.c +++ b/tools/linux/uio_drivers/blk/blk.c @@ -16,6 +16,7 @@ #include #include +#include #include #include @@ -38,12 +39,6 @@ int storage_fd; blk_storage_info_t *blk_config; blk_queue_handle_t h; uintptr_t blk_data; -uintptr_t blk_data_phys; - -uintptr_t data_phys_to_virt(uintptr_t phys_addr) -{ - return phys_addr - blk_data_phys + blk_data; -} int driver_init(void **maps, uintptr_t *maps_phys, int num_maps, int argc, char **argv) { @@ -65,12 +60,11 @@ int driver_init(void **maps, uintptr_t *maps_phys, int num_maps, int argc, char blk_req_queue_t *req_queue = (blk_req_queue_t *)maps[1]; blk_resp_queue_t *resp_queue = (blk_resp_queue_t *)maps[2]; blk_data = (uintptr_t)maps[3]; - blk_data_phys = maps_phys[3]; LOG_UIO_BLOCK("maps_phys[0]: 0x%lx, maps_phys[1]: 0x%lx, maps_phys[2]: 0x%lx, maps_phys[3]: 0x%lx\n", maps_phys[0], maps_phys[1], maps_phys[2], maps_phys[3]); - blk_queue_init(&h, req_queue, resp_queue, BLK_QUEUE_SIZE); + blk_queue_init(&h, req_queue, resp_queue, BLK_QUEUE_SIZE_DRIV); storage_fd = open(storage_path, O_RDWR); if (storage_fd < 0) { @@ -79,58 +73,56 @@ int driver_init(void **maps, uintptr_t *maps_phys, int num_maps, int argc, char } LOG_UIO_BLOCK("Opened storage drive: %s\n", storage_path); - // Determine whether storage drive is a block device or regular file - // and set the blk queue configuration fields accordingly struct stat storageStat; if (fstat(storage_fd, &storageStat) < 0) { LOG_UIO_BLOCK_ERR("Failed to get storage drive status: %s\n", strerror(errno)); return -1; } - if (S_ISBLK(storageStat.st_mode)) { - /* Set drive as read-write */ - int read_only_set = 0; - if (ioctl(storage_fd, BLKROSET, &read_only_set) == -1) { - LOG_UIO_BLOCK_ERR("Failed to set storage drive as read-write: %s\n", strerror(errno)); - return -1; - } - - /* Get read only status */ - int read_only; - if (ioctl(storage_fd, BLKROGET, &read_only) == -1) { - LOG_UIO_BLOCK_ERR("Failed to get storage drive read only status: %s\n", strerror(errno)); - return -1; - } - blk_config->read_only = (bool)read_only; + if (!S_ISBLK(storageStat.st_mode)) { + LOG_UIO_BLOCK_ERR("Storage drive is of an unsupported type\n"); + return -1; + } - /* Get logical sector size */ - int sector_size; - if (ioctl(storage_fd, BLKSSZGET, §or_size) == -1) { - LOG_UIO_BLOCK_ERR("Failed to get storage drive sector size: %s\n", strerror(errno)); - return -1; - } - blk_config->sector_size = (uint16_t)sector_size; + /* Set drive as read-write */ + int read_only_set = 0; + if (ioctl(storage_fd, BLKROSET, &read_only_set) == -1) { + LOG_UIO_BLOCK_ERR("Failed to set storage drive as read-write: %s\n", strerror(errno)); + return -1; + } - /* Get size */ - uint64_t size; - if (ioctl(storage_fd, BLKGETSIZE64, &size) == -1) { - LOG_UIO_BLOCK_ERR("Failed to get storage drive size: %s\n", strerror(errno)); - return -1; - } - blk_config->size = size / BLK_TRANSFER_SIZE; + /* Get read only status */ + int read_only; + if (ioctl(storage_fd, BLKROGET, &read_only) == -1) { + LOG_UIO_BLOCK_ERR("Failed to get storage drive read only status: %s\n", strerror(errno)); + return -1; + } + blk_config->read_only = (bool)read_only; - LOG_UIO_BLOCK("Raw block device: read_only=%d, sector_size=%d, size=%ld\n", (int)blk_config->read_only, - blk_config->sector_size, blk_config->size); + /* Get logical sector size */ + int sector_size; + if (ioctl(storage_fd, BLKSSZGET, §or_size) == -1) { + LOG_UIO_BLOCK_ERR("Failed to get storage drive sector size: %s\n", strerror(errno)); + return -1; + } + blk_config->sector_size = (uint16_t)sector_size; - /* Optimal size */ - /* As far as I know linux does not let you query this from userspace, set as 0 to mean undefined */ - blk_config->block_size = 0; - } else { - LOG_UIO_BLOCK_ERR("Storage drive is of an unsupported type\n"); + /* Get size */ + uint64_t size; + if (ioctl(storage_fd, BLKGETSIZE64, &size) == -1) { + LOG_UIO_BLOCK_ERR("Failed to get storage drive size: %s\n", strerror(errno)); return -1; } + blk_config->size = size / BLK_TRANSFER_SIZE; + + LOG_UIO_BLOCK("Raw block device: read_only=%d, sector_size=%d, size=%ld\n", (int)blk_config->read_only, + blk_config->sector_size, blk_config->size); - /* May need to barrier all writes before this point of setting ready = true */ + /* Optimal size */ + /* As far as I know linux does not let you query this from userspace, set as 0 to mean undefined */ + blk_config->block_size = 0; + + /* Driver is ready to go, set ready in shared config page */ __atomic_store_n(&blk_config->ready, true, __ATOMIC_RELEASE); LOG_UIO_BLOCK("Driver initialized\n"); @@ -141,14 +133,14 @@ int driver_init(void **maps, uintptr_t *maps_phys, int num_maps, int argc, char void driver_notified() { blk_request_code_t req_code; - uintptr_t req_addr; + uintptr_t req_offset; uint32_t req_block_number; uint16_t req_count; uint32_t req_id; while (!blk_req_queue_empty(&h)) { - blk_dequeue_req(&h, &req_code, &req_addr, &req_block_number, &req_count, &req_id); - LOG_UIO_BLOCK("Received command: code=%d, addr=%p, block_number=%d, count=%d, id=%d\n", req_code, (void *)req_addr, + blk_dequeue_req(&h, &req_code, &req_offset, &req_block_number, &req_count, &req_id); + LOG_UIO_BLOCK("Received command: code=%d, offset=0x%lx, block_number=%d, count=%d, id=%d\n", req_code, req_offset, req_block_number, req_count, req_id); blk_response_status_t status = SUCCESS; @@ -168,8 +160,8 @@ void driver_notified() success_count = 0; break; } - LOG_UIO_BLOCK("Reading from storage at mmaped address: 0x%lx\n", data_phys_to_virt(req_addr)); - int bytes_read = read(storage_fd, (void *)data_phys_to_virt(req_addr), req_count * BLK_TRANSFER_SIZE); + LOG_UIO_BLOCK("Reading from storage at mmaped address: 0x%lx\n", req_offset + blk_data); + int bytes_read = read(storage_fd, (void *)(req_offset + blk_data), req_count * BLK_TRANSFER_SIZE); LOG_UIO_BLOCK("Read from storage successfully: %d bytes\n", bytes_read); if (bytes_read < 0) { LOG_UIO_BLOCK_ERR("Failed to read from storage: %s\n", strerror(errno)); @@ -189,8 +181,8 @@ void driver_notified() success_count = 0; break; } - LOG_UIO_BLOCK("Writing to storage at mmaped address: 0x%lx\n", data_phys_to_virt(req_addr)); - int bytes_written = write(storage_fd, (void *)data_phys_to_virt(req_addr), req_count * BLK_TRANSFER_SIZE); + LOG_UIO_BLOCK("Writing to storage at mmaped address: 0x%lx\n", req_offset + blk_data); + int bytes_written = write(storage_fd, (void *)(req_offset + blk_data), req_count * BLK_TRANSFER_SIZE); LOG_UIO_BLOCK("Wrote to storage successfully: %d bytes\n", bytes_written); if (bytes_written < 0) { LOG_UIO_BLOCK_ERR("Failed to write to storage: %s\n", strerror(errno));