On 8/29/19 10:20 AM, Philippe Mathieu-Daudé wrote: >> + /* Avoid trapping reads of pages with a write breakpoint. */ >> + match = (prot & PAGE_READ ? BP_MEM_READ : 0) >> + | (prot & PAGE_WRITE ? BP_MEM_WRITE : 0); > > Isn't it cheaper to do here: > > if (!match) { > return iotlb; > } > > or > > if (match) {
Note that PROT_NONE pages never reach here; they always trap in tlb_fill. The only way we can get match == 0 here is for the case of an execute-only page. Which is possible, but extremely unlikely. Almost all targets merge the text and rodata sections, which means that virtually all executable pages are also readable. (Although I must say that in this age of ROP-gadgets, leaving the rodata section executable is probably a mistake, and tools should be updated to *not* merge them. That's still not necessarily execute-only for the text section, but I don't see anything in principal that would prevent it.) r~