svn commit: r242418 - in projects/amd64_xen_pv/sys/amd64: amd64 xen

Cherry G. Mathew cherry at FreeBSD.org
Wed Oct 31 22:16:09 UTC 2012


Author: cherry
Date: Wed Oct 31 22:16:08 2012
New Revision: 242418
URL: http://svn.freebsd.org/changeset/base/242418

Log:
  Fetch %cr2 from xen via the shared page save it on the stack frame before trap() is called.
  
  Approved by:	gibbs (implicit)

Modified:
  projects/amd64_xen_pv/sys/amd64/amd64/genassym.c
  projects/amd64_xen_pv/sys/amd64/xen/exception.S

Modified: projects/amd64_xen_pv/sys/amd64/amd64/genassym.c
==============================================================================
--- projects/amd64_xen_pv/sys/amd64/amd64/genassym.c	Wed Oct 31 22:11:51 2012	(r242417)
+++ projects/amd64_xen_pv/sys/amd64/amd64/genassym.c	Wed Oct 31 22:16:08 2012	(r242418)
@@ -255,6 +255,7 @@ ASSYM(PMC_FN_USER_CALLCHAIN, PMC_FN_USER
 #include <xen/hypervisor.h>
 ASSYM(HYPERVISOR_VIRT_START, __HYPERVISOR_VIRT_START);
 ASSYM(EVTCHN_UPCALL_MASK, offsetof(struct vcpu_info, evtchn_upcall_mask));
+ASSYM(VCPU_RCR2, offsetof(struct vcpu_info, arch.cr2));
 #include <xen/interface/xen.h>
 ASSYM(__HYPERVISOR_iret, __HYPERVISOR_iret);
 #endif

Modified: projects/amd64_xen_pv/sys/amd64/xen/exception.S
==============================================================================
--- projects/amd64_xen_pv/sys/amd64/xen/exception.S	Wed Oct 31 22:11:51 2012	(r242417)
+++ projects/amd64_xen_pv/sys/amd64/xen/exception.S	Wed Oct 31 22:16:08 2012	(r242418)
@@ -140,6 +140,14 @@
 	movl	$(a), TF_TRAPNO(%rsp) 	; \
 	movq	$0, TF_ADDR(%rsp)
 
+/* Fetch page fault address (%cr2) from hypervisor */
+#define SETUP_TF_ADDR 			/* Clobbers %rsi %rdi */  \
+	movq 	PCPU(CPUID), %rsi	; \
+	shlq	$6, %rsi		/* cpuid * sizeof(struct vcpu_info) */ 	   ; \
+	addq	HYPERVISOR_shared_info, %rsi 	/* shared_info.vcpu_info[cpuid] */ ; \
+	movq	VCPU_RCR2(%rsi), %rdi	     ; \
+	movq	%rdi, TF_ADDR(%rsp)
+
 #define CALLTRAP \
 	cld			; \
 	movq	%rsp, %rdi	; \
@@ -397,7 +405,8 @@ IDTVEC(pf)			/* Page-Fault */
 	SAVE_SEGMENT_REGS	;
 	SAVE_GENERAL_REGS	;
 	DO_STI_MAYBE		;
-	CALLTRAP		;
+	SETUP_TF_ADDR		; /* Fault Address - clobbers %rsi %rdi */
+	CALLTRAP		; /* %rsi is ignored */
 	DO_AST_MAYBE		;
 	RESTORE_GENERAL_REGS	;
 	RESTORE_SEGMENT_REGS	;


More information about the svn-src-projects mailing list