Why is the MAXVA value defined differently in the xv6 textbook of MIT 6s081 and the xv6 source code? The textbook states that the maximum address is 2^38 - 1 = 0x3fffffffff, while the source code defines MAXVA as (1L << (9 + 9 + 9 + 12 - 1)), which seems to be missing the -1. Can anyone explain the discrepancy and which one is correct?
The following screenshot is from xv6.pdf describing MAXVA, look at the yellow highlighted sentence:

The following code snippet is from (kernel/kernel/riscv.h:348):
// one beyond the highest possible virtual address.
// MAXVA is actually one bit less than the max allowed by
// Sv39, to avoid having to sign-extend virtual addresses
// that have the high bit set.
#define MAXVA (1L << (9 + 9 + 9 + 12 - 1))
The last address available is
2^38-1The goal of
MAXVAis that no address points to2^38or more.That's how
MAXVAis used:We can check that in
vm.h: Note that the address is compared toMAXVAwith "greater on equal", not just "greater than".It's also explained in risc.h, the discrepancy you see is explained at lines 360, 361: