WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] x86-64 machine_to_phys vs NX bit

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] x86-64 machine_to_phys vs NX bit
From: Rik van Riel <riel@xxxxxxxxxx>
Date: Thu, 24 Aug 2006 15:25:09 -0400
Delivery-date: Thu, 24 Aug 2006 12:25:44 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Organization: Red Hat, Inc
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Thunderbird 1.5.0.4 (X11/20060614)
On x86-64 machine_to_phys looks like it should never succeed, yet I'm
guessing it must somehow be lucky...

The problem would be that the NX bit is bit 63 of the pte, meaning that
when pte_val is called we are working with a value 2^63 higher than we
should be.

#define pte_val(x)      (((x).pte & 1) ? machine_to_phys((x).pte) : \
                         (x).pte)

static inline paddr_t machine_to_phys(maddr_t machine)
{
        paddr_t phys = mfn_to_pfn(machine >> PAGE_SHIFT);
        phys = (phys << PAGE_SHIFT) | (machine & ~PAGE_MASK);
        return phys;
}

Should we mask the 'machine' variable with PHYSICAL_MASK at
some point so we cut off the NX bit and other reserved bits?

Say, something like the following?

-    paddr_t phys = mfn_to_pfn(machine >> PAGE_SHIFT);
+    paddr_t phys = mfn_to_pfn((machine >> PAGE_SHIFT) & PHYSICAL_MASK);

I'm still thinking I may have missed something in the code
somewhere, but I've been looking at this for over an hour now
and can't seem to find it...

Any ideas?

--
What is important?  What you want to be true, or what is true?

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel