From: Hollis Blanchard Subject: Re: [PATCH] paging_enabled and non-HVM guests Date: Wed, 10 May 2006 10:42:34 -0500 Message-ID: <1147275754.27510.14.camel@basalt.austin.ibm.com> References: <87wtcv5t9e.wl%simon.kagstrom@bth.se> <1147204426.19485.67.camel@basalt.austin.ibm.com> <87r7325s83.wl%simon.kagstrom@bth.se> <1147272714.27510.8.camel@basalt.austin.ibm.com> Mime-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1147272714.27510.8.camel@basalt.austin.ibm.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Simon Kagstrom Cc: xen-devel list List-Id: xen-devel@lists.xenproject.org On Wed, 2006-05-10 at 09:51 -0500, Hollis Blanchard wrote: > On Wed, 2006-05-10 at 08:06 +0200, Simon Kagstrom wrote: > > > > I won't argue for an incorrect fix, but as the code is right now it > > segmentation faults because the virtual address passed to > > > > page = page_array[va >> PAGE_SHIFT] << PAGE_SHIFT; > > > > (with libxc incorrectly believing paging is disabled) accesses outside > > of page_array. I'll keep the patch privately for now since gdbserver > > breaks without it. > > Yes, and the reason is that page_array is supposed to be indexed with > *physical* addresses. The current code thinks that paging is disabled > (because CR0 is bad), assumes a virtual address is physical, and tries > to index into the array with it. > > Pretty much every use of page_array needs to be abstracted so that it > does the right thing on both HVM and normal guests (normal guests will > have machine addresses in its page tables; HVM guests will have > physical). It's very unfortunate that the people who worked on this > code seem not to have tested or even thought about paravirtualized > guests. To elaborate on my previous mail, it's not just CR0/paging at fault. For example, this use of page_array: ... l3p = l4[l4_table_offset(va)] >> PAGE_SHIFT; l3p = page_array[l3p]; ... in map_domain_va_64() is obviously incorrect for paravirtualized domains. Also, I noticed there's another place that already tests VGCF_HVM_GUEST before paging_enabled(), which I guess is where you got the idea for your patch. Simon, would you care to submit the more complete patch? -- Hollis Blanchard IBM Linux Technology Center