Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix pointer masking for misaligned accesses #1905

Merged
merged 1 commit into from
Jan 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions riscv/mmu.cc
Original file line number Diff line number Diff line change
Expand Up @@ -241,8 +241,10 @@ void mmu_t::load_slow_path(reg_t original_addr, reg_t len, uint8_t* bytes, xlate

reg_t len_page0 = std::min(len, PGSIZE - transformed_addr % PGSIZE);
load_slow_path_intrapage(len_page0, bytes, access_info);
if (len_page0 != len)
load_slow_path_intrapage(len - len_page0, bytes + len_page0, access_info.split_misaligned_access(len_page0));
if (len_page0 != len) {
auto tail_access_info = generate_access_info(original_addr + len_page0, LOAD, xlate_flags);
load_slow_path_intrapage(len - len_page0, bytes + len_page0, tail_access_info);
}
}

while (len > sizeof(reg_t)) {
Expand Down Expand Up @@ -306,8 +308,10 @@ void mmu_t::store_slow_path(reg_t original_addr, reg_t len, const uint8_t* bytes

reg_t len_page0 = std::min(len, PGSIZE - transformed_addr % PGSIZE);
store_slow_path_intrapage(len_page0, bytes, access_info, actually_store);
if (len_page0 != len)
store_slow_path_intrapage(len - len_page0, bytes + len_page0, access_info.split_misaligned_access(len_page0), actually_store);
if (len_page0 != len) {
auto tail_access_info = generate_access_info(original_addr + len_page0, STORE, xlate_flags);
store_slow_path_intrapage(len - len_page0, bytes + len_page0, tail_access_info, actually_store);
}
} else {
store_slow_path_intrapage(len, bytes, access_info, actually_store);
}
Expand Down
4 changes: 0 additions & 4 deletions riscv/mmu.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,6 @@ struct mem_access_info_t {
const bool effective_virt;
const xlate_flags_t flags;
const access_type type;

mem_access_info_t split_misaligned_access(reg_t offset) const {
return {vaddr + offset, transformed_vaddr + offset, effective_priv, effective_virt, flags, type};
}
};

void throw_access_exception(bool virt, reg_t addr, access_type type);
Expand Down