From: Simon Kagstrom Subject: Problem setting up a custom GDT Date: Fri, 09 Jun 2006 13:03:00 +0200 Message-ID: <8764jalhgb.wl%simon.kagstrom@bth.se> Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel list List-Id: xen-devel@lists.xenproject.org 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; int ret = HYPERVISOR_set_gdt(frames, 16); (The GDT Is just copied from Linux' right now). When doing this, I always get -EINVAL from set_gdt, which I suspect is because HYPERVISOR_update_va_mapping for some reason does not succeed in setting the page read-only. I've checked the Linux implementation, and it does basically the same thing (pte_wrprotect() on the machine-address before calling update_va_mapping). Does anyone see what is wrong here? // Simon