So in the page fault handler, we have some tests against kernel / user
CS which avoid the logic of actually figuring out the segment limit. I
propose we use the same trick as arch/i386/mm/extable.c, which simply
masks the RPL off and combines the segments together to test for faults
before setting the pnp_bios_is_utter_crap variable. In this case, we
can simply test:
if (likely((seg & 0xe8) == __KERNEL_CS)
and be done with any RPL masking at all. Perhaps this is best put in a
macro in segment.h,
#define SEGMENT_IS_FLAT_CODE(x) (((x) & 0xe8) == GDT_ENTRY_KERNEL_CS * 8)
Also, note the segment check for PnP faults is broken, as it masks off
the TI bit, thus returning false positives for LDT entries (which are
fortunately unused by the kernel).
Zach