From: Keir Fraser Date: Mon, 9 Jun 2008 16:18:27 +0000 (+0100) Subject: Allow older PAE Linux guests to access entire compat m2p. X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~14200^2~69 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=7139eef57f595d19785b979dfbfb7838853f7e63;p=xen.git Allow older PAE Linux guests to access entire compat m2p. Older PAE guests (prior to xen-unstable.hg 8924:229c602a075a, Feb 2006, this includes some vendor's kernel in the field) use a limit of 0xf6800000 on their code and data segments (i.e. up to the end of the read-only m2p table). Newer kernels use a limit of 4G and rely on the hypervisor to clamp to the actual maximum allowed. 32on64 mode takes advantage of this to allow a larger m2p than would fit in the PAEonPAE sized hole. This means that PAE guests with the hardcoded low limit cannot run on top of a 64 bit hypervisor on a host machine which has more than 16G of RAM. Fix this by extending any code or data segment which ends above the start of the hypervisor hole for that guest. Signed-off-by: Ian Campbell --- diff --git a/xen/arch/x86/x86_64/mm.c b/xen/arch/x86/x86_64/mm.c index 3d79657989..624f3bbb12 100644 --- a/xen/arch/x86/x86_64/mm.c +++ b/xen/arch/x86/x86_64/mm.c @@ -402,8 +402,33 @@ int check_descriptor(const struct domain *dom, struct desc_struct *d) /* All code and data segments are okay. No base/limit checking. */ if ( (b & _SEGMENT_S) ) { - if ( is_pv_32bit_domain(dom) && (b & _SEGMENT_L) ) - goto bad; + if ( is_pv_32bit_domain(dom) ) + { + unsigned long base, limit; + + if ( b & _SEGMENT_L ) + goto bad; + + /* + * Older PAE Linux guests use segments which are limited to + * 0xf6800000. Extend these to allow access to the larger read-only + * M2P table available in 32on64 mode. + */ + base = (b & (0xff << 24)) | ((b & 0xff) << 16) | (a >> 16); + + limit = (b & 0xf0000) | (a & 0xffff); + limit++; /* We add one because limit is inclusive. */ + + if ( (b & _SEGMENT_G) ) + limit <<= 12; + + if ( (base == 0) && (limit > HYPERVISOR_COMPAT_VIRT_START(dom)) ) + { + a |= 0x0000ffff; + b |= 0x000f0000; + } + } + goto good; }