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] Explanation of set_pte_at

To: xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxx>
Subject: [Xen-devel] Explanation of set_pte_at
From: Michael Abd-El-Malek <mabdelmalek@xxxxxxx>
Date: Tue, 18 Mar 2008 12:40:18 -0400
Delivery-date: Tue, 18 Mar 2008 09:41:19 -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>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
Hi,

Can someone please explain the function set_pte_at to me? In particular, I'm trying to understand the page fault handling in a PV 64-bit Linux.

Here's the sequence that I trace:
1) The Linux page fault handler at linux-2.6.18-xen.hg/mm/ memory.c:do_no_page runs.
2) After getting the page in memory, it calls set_pte_at.
3) set_pte_at has the following definition:

#define set_pte_at(_mm,addr,ptep,pteval) do {
       if (((_mm) != current->mm && (_mm) != &init_mm) ||          \
     HYPERVISOR_update_va_mapping((addr), (pteval), 0))          \
        set_pte((ptep), (pteval));                                  \

In the case of a page fault, I think _mm will be equal to init_mm. As a result, the first if condition fails, and we end up calling HYPERVISOR_update_va_mapping. If that succeeds, then we're done. Otherwise, we call set_pte which just sets the PTE directly. Since in PV Linux, page tables don't have writeable mappings, this write causes an instruction fault and Xen's ptwr_emulated_update tries to perform the page table update.

So here are my questions:
1) What is the purpose of the first if condition ((_mm) != current->mm && (_mm) != &init_mm)? If the fault happens in a kernel virtual memory context, why do we always want to call set_pte? Why don't we just call HYPERVISOR_update_va_mapping? Does ptwr_emulated_update handle a larger subset of the page table updates logic than HYPERVISOR_update_va_mapping? 2) On a related note, if we do call HYPERVISOR_update_va_mapping and it fails, why do we retry the page table update through ptwr_emulated_update?

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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-devel] Explanation of set_pte_at, Michael Abd-El-Malek <=