Are _end and _text guaranteed to be aligned? If not, I think thecalculation might be wrong. Just for fun, imagine that _end=0xfff and_text=0x1001. npages would be 0.

Some other code like set_kernel_text_rw() does alignment on _text.

One nit is that there's quite a bit going on here, like rearranging thephys_stack arithmetic ordering that is far beyond just simplifying thepaddr vs. pfn issue, but that isn't called out in the changelog at all.