accel/tcg: Fix the comment for CPUTLBEntryFull

When memory region is ram, the lower TARGET_PAGE_BITS is not the
physical section number. Instead, its value is always 0.

Add comment and assert to make it clear.

Signed-off-by: LIU Zhiwei <zhiwei_liu@linux.alibaba.com>
Message-Id: <20230901060118.379-1-zhiwei_liu@linux.alibaba.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
This commit is contained in:
LIU Zhiwei 2023-09-01 14:01:18 +08:00 committed by Richard Henderson
parent 0e5903436d
commit dff1ab68d8
2 changed files with 13 additions and 10 deletions

View File

@ -1193,6 +1193,7 @@ void tlb_set_page_full(CPUState *cpu, int mmu_idx,
write_flags = read_flags; write_flags = read_flags;
if (is_ram) { if (is_ram) {
iotlb = memory_region_get_ram_addr(section->mr) + xlat; iotlb = memory_region_get_ram_addr(section->mr) + xlat;
assert(!(iotlb & ~TARGET_PAGE_MASK));
/* /*
* Computing is_clean is expensive; avoid all that unless * Computing is_clean is expensive; avoid all that unless
* the page is actually writable. * the page is actually writable.
@ -1255,10 +1256,12 @@ void tlb_set_page_full(CPUState *cpu, int mmu_idx,
/* refill the tlb */ /* refill the tlb */
/* /*
* At this point iotlb contains a physical section number in the lower * When memory region is ram, iotlb contains a TARGET_PAGE_BITS
* TARGET_PAGE_BITS, and either * aligned ram_addr_t of the page base of the target RAM.
* + the ram_addr_t of the page base of the target RAM (RAM) * Otherwise, iotlb contains
* + the offset within section->mr of the page base (I/O, ROMD) * - a physical section number in the lower TARGET_PAGE_BITS
* - the offset within section->mr of the page base (I/O, ROMD) with the
* TARGET_PAGE_BITS masked off.
* We subtract addr_page (which is page aligned and thus won't * We subtract addr_page (which is page aligned and thus won't
* disturb the low bits) to give an offset which can be added to the * disturb the low bits) to give an offset which can be added to the
* (non-page-aligned) vaddr of the eventual memory access to get * (non-page-aligned) vaddr of the eventual memory access to get

View File

@ -100,12 +100,12 @@
typedef struct CPUTLBEntryFull { typedef struct CPUTLBEntryFull {
/* /*
* @xlat_section contains: * @xlat_section contains:
* - in the lower TARGET_PAGE_BITS, a physical section number * - For ram, an offset which must be added to the virtual address
* - with the lower TARGET_PAGE_BITS masked off, an offset which * to obtain the ram_addr_t of the target RAM
* must be added to the virtual address to obtain: * - For other memory regions,
* + the ram_addr_t of the target RAM (if the physical section * + in the lower TARGET_PAGE_BITS, the physical section number
* number is PHYS_SECTION_NOTDIRTY or PHYS_SECTION_ROM) * + with the TARGET_PAGE_BITS masked off, the offset within
* + the offset within the target MemoryRegion (otherwise) * the target MemoryRegion
*/ */
hwaddr xlat_section; hwaddr xlat_section;