x86_64/page.h L1_DISALLOW_MASK, etc
In xen/include/asm-x86/x86_64/page.h, it appears the #defines for L1_DISALLOW_MASK, L2_DISALLOW_MASK, etc. have the assignment backwards in the conditional test. The current code appears to be setting the NX bit if the cpu does not have the NX feature, as opposed to if it does.
I have attached a patch of how I would change it to see if others agree.
Also, what exactly is being set when setting the 3 bits for the L2_DISALLOW_MASK, L3_DISALLOW_MASK, and L4_DISALLOW_MASK definitions?
Karen
include/asm-x86/x86_64/page.h +5 -4
@@ -93,10 +93,11 @@ typedef l4_pgentry_t root_pgentry_t;#define _PAGE_NX (cpu_has_nx ? (1UL<<63) : 0UL) -#define L1_DISALLOW_MASK ((cpu_has_nx?0:(1UL<<63)) | (3UL << 7)) -#define L2_DISALLOW_MASK ((cpu_has_nx?0:(1UL<<63)) | (7UL << 7)) -#define L3_DISALLOW_MASK ((cpu_has_nx?0:(1UL<<63)) | (7UL << 7)) -#define L4_DISALLOW_MASK ((cpu_has_nx?0:(1UL<<63)) | (7UL << 7)) +#define L1_DISALLOW_MASK ((cpu_has_nx?(1UL<<63):0) | (3UL << 7)) +#define L2_DISALLOW_MASK ((cpu_has_nx?(1UL<<63):0) | (7UL << 7)) +#define L3_DISALLOW_MASK ((cpu_has_nx?(1UL<<63):0) | (7UL << 7)) +#define L4_DISALLOW_MASK ((cpu_has_nx?(1UL<<63):0) | (7UL << 7)) +#endif /* __X86_64_PAGE_H__ */
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Quoted 4 lines · Karen White
In
xen/include/asm-x86/x86_64/page.h, it appears the #defines forL1_DISALLOW_MASK,L2_DISALLOW_MASK, etc. have the assignment backwards in the conditional test. The current code appears to be setting the NX bit if the cpu does not have the NX feature, as opposed to if it does.
Yes, because it's a disallow mask. We don't want to disallow the NX bit if the CPU supports it, so we don't OR it into the mask. The current way round is correct.
Quoted 2 lines
Also, what exactly is being set when setting the 3 bits for the
L2_DISALLOW_MASK,L3_DISALLOW_MASK, andL4_DISALLOW_MASKdefinitions?
Bit 7 is PSE, which we don't support in guest tables.
Bit 8 is PGE: also unsupported.
Bit 9 is a mistake -- it's available for OS use -- so I will remove it from the mask.
Thanks,
Keir
Quoted 5 lines
Karen <page.disallow.patch>_______________________________________________ Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel