Jan Beulich wrote: >>>> "Yang, Xiaowei" 20.03.09 09:34 >>> >> Jan Beulich wrote: >>>>>> "Yang, Xiaowei" 20.03.09 06:05 >>> >>>> DIRECTMAP_VIRT_END can't be passed to virt_to_mfn(), as it's just beyond >>>> direct map boundary and triggers ASSERT very early at boot time. >>> While I agree to the analysis, I would think that this >>> >>> + mfn + needed <= virt_to_mfn(DIRECTMAP_VIRT_END - PAGE_SIZE) ) >>> >>> should rather be >>> >>> + mfn + needed <= virt_to_mfn(DIRECTMAP_VIRT_END - 1) + 1 ) >>> >> virt_to_mfn(DIRECTMAP_VIRT_END - 1) is equal to > > Depending on whether DIRECTMAP_VIRT_END is the last byte or the first > following byte. Using "- 1" avoids such a dependency. > >> virt_to_mfn(DIRECTMAP_VIRT_END - PAGE_SIZE). Why +1? We use '<=' here. > > Because on the left side of the comparison we also calculate the first > following mfn, not the last included one. > Jan, Thanks for the clarification! Now I found another potential issue. Since mfn+needed could be equal to virt_to_mfn(DIRECTMAP_VIRT_END-1)+1, it can't be passed to mfn_to_virt() directly - the valid range is [0,DIRECT_MAP_BYTES>>PAGE_SHIFT). Here is the patch to fix it. More assert and 32 bit counterpart are added. Signed-off-by: Xiaowei Yang Thanks, xiaowei