From: Simon Kagstrom Subject: Re: Problem setting up a custom GDT Date: Mon, 12 Jun 2006 08:19:31 +0200 Message-ID: <871wtuopzg.wl%simon.kagstrom@bth.se> References: <8764jalhgb.wl%simon.kagstrom@bth.se> <44895656.8040905@adviseo.fr> Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Return-path: In-Reply-To: <44895656.8040905@adviseo.fr> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Mathieu Ropert Cc: xen-devel list List-Id: xen-devel@lists.xenproject.org At Fri, 09 Jun 2006 13:07:02 +0200, Mathieu Ropert wrote: > > Simon Kagstrom wrote: > > >Hello! > > > >I have some problems setting up a custom GDT (I need one where the > >code is readable). Anyway, I try to switch to my own GDT as follows: > > > > unsigned long frames[16]; > > > > volatile unsigned long va = (unsigned long)GDT; > > volatile unsigned long pa = to_phys(va); > > volatile unsigned long ma = phys_to_machine(pa) & ~_PAGE_RW | _PAGE_PRESENT | _PAGE_ACCESSED | _PAGE_DIRTY; > > > > /* Make it read-only */ > > HYPERVISOR_update_va_mapping(va, (pte_t){ ma }, 0); > > frames[0] = ma; > > The machine address you pass to Xen is a page table entry. Xen want a > machine frame number. > > frames[0] = ma >> PAGE_SHIFT; > > should fix you problem. Ah, thank you! This fixed the problem! I see now that Linux uses virt_to_mfn() - I should have looked at that one... // Simon