All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH][HAP][2/2] fix CR4 initialization when hap is on
@ 2007-03-22 16:13 Huang2, Wei
  2007-03-27 16:13 ` Keir Fraser
  0 siblings, 1 reply; 3+ messages in thread
From: Huang2, Wei @ 2007-03-22 16:13 UTC (permalink / raw)
  To: xen-devel, Tim Deegan


[-- Attachment #1.1: Type: text/plain, Size: 263 bytes --]

This patch initializes VMCB CR4 and shadow CR4 with 0 when VMCB is being
constructed under nested paging mode. It complies with recent
reset_to_realmode change in hvmloader.
 
Signed-off-by: Wei Huang (wei.huang2@amd.com <mailto:wei.huang2@amd.com>
)
 
 

[-- Attachment #1.2: Type: text/html, Size: 1328 bytes --]

[-- Attachment #2: hap_svm_fix.txt --]
[-- Type: text/plain, Size: 537 bytes --]

diff -r 058a37255d48 -r b25ab286fde8 xen/arch/x86/hvm/svm/vmcb.c
--- a/xen/arch/x86/hvm/svm/vmcb.c	Thu Mar 22 03:05:59 2007 -0600
+++ b/xen/arch/x86/hvm/svm/vmcb.c	Thu Mar 22 03:07:32 2007 -0600
@@ -203,6 +203,7 @@ static int construct_vmcb(struct vcpu *v
         vmcb->g_pat = 0x0007040600070406ULL; /* guest PAT */
         vmcb->exception_intercepts &= ~EXCEPTION_BITMAP_PG;
         vmcb->h_cr3 = pagetable_get_paddr(v->domain->arch.phys_table);
+        vmcb->cr4 = arch_svm->cpu_shadow_cr4 = 0;
     }
 
     return 0;

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH][HAP][2/2] fix CR4 initialization when hap is on
  2007-03-22 16:13 [PATCH][HAP][2/2] fix CR4 initialization when hap is on Huang2, Wei
@ 2007-03-27 16:13 ` Keir Fraser
  2007-03-27 17:32   ` Huang2, Wei
  0 siblings, 1 reply; 3+ messages in thread
From: Keir Fraser @ 2007-03-27 16:13 UTC (permalink / raw)
  To: Huang2, Wei, xen-devel, Tim Deegan


[-- Attachment #1.1: Type: text/plain, Size: 763 bytes --]

This seems an odd change. The earlier setting of CR4 in construct_vmcb()
already masks out paging-related bits. So why would the remaining bits¹
behaviour differ between hap and shadow paging modes? It would seem to me
that either CR4 should be zero at start-of-day in all cases (seems quite
likely to me as that¹s what happens in a native system), or the existing
code should be okay in both cases.

 -- Keir

On 22/3/07 16:13, "Huang2, Wei" <Wei.Huang2@amd.com> wrote:

> This patch initializes VMCB CR4 and shadow CR4 with 0 when VMCB is being
> constructed under nested paging mode. It complies with recent
> reset_to_realmode change in hvmloader.
>  
> Signed-off-by: Wei Huang (wei.huang2@amd.com <mailto:wei.huang2@amd.com> )
>  
>  



[-- Attachment #1.2: Type: text/html, Size: 1534 bytes --]

[-- Attachment #2: Type: text/plain, Size: 138 bytes --]

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: [PATCH][HAP][2/2] fix CR4 initialization when hap is on
  2007-03-27 16:13 ` Keir Fraser
@ 2007-03-27 17:32   ` Huang2, Wei
  0 siblings, 0 replies; 3+ messages in thread
From: Huang2, Wei @ 2007-03-27 17:32 UTC (permalink / raw)
  To: Keir Fraser, xen-devel, Tim Deegan


[-- Attachment #1.1: Type: text/plain, Size: 1820 bytes --]

There are two CR4 related variables (vmcb->cr4 and cpu_shadow_cr4). I
agree that cpu_shadow_cr4 should be zero at start-of-day for both cases.
Current construct_vmcb() initializes cpu_shadow_cr4 with read_cr4() &
~(X86_CR4_PGE | X86_CR4_PSE | X86_CR4_PAE), which seems imperfect to me
(although it works well so far).
 
On the other hand, initial values of vmcb->cr4 should differ between hap
and shadow modes. Nested paging relies vmcb->cr4 (and other control
registers) to determine guest paging mode. When hap is on, vmcb->cr4
should be initialized with 0 to reflect correct state of guest. Under
shadow mode, the value of vmcb->cr4 is initialized with proper values
(none-zero) to utilize shadow page table. That is why we need a
different code path for hap.
 
-Wei

________________________________

From: Keir Fraser [mailto:keir@xensource.com] 
Sent: Tuesday, March 27, 2007 11:14 AM
To: Huang2, Wei; xen-devel@lists.xensource.com; Tim Deegan
Subject: Re: [Xen-devel] [PATCH][HAP][2/2] fix CR4 initialization when
hap is on


This seems an odd change. The earlier setting of CR4 in construct_vmcb()
already masks out paging-related bits. So why would the remaining bits'
behaviour differ between hap and shadow paging modes? It would seem to
me that either CR4 should be zero at start-of-day in all cases (seems
quite likely to me as that's what happens in a native system), or the
existing code should be okay in both cases.

 -- Keir

On 22/3/07 16:13, "Huang2, Wei" <Wei.Huang2@amd.com> wrote:



	This patch initializes VMCB CR4 and shadow CR4 with 0 when VMCB
is being constructed under nested paging mode. It complies with recent
reset_to_realmode change in hvmloader.
	
	Signed-off-by: Wei Huang (wei.huang2@amd.com
<mailto:wei.huang2@amd.com> )
	
	 
	




[-- Attachment #1.2: Type: text/html, Size: 3555 bytes --]

[-- Attachment #2: Type: text/plain, Size: 138 bytes --]

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2007-03-27 17:32 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-03-22 16:13 [PATCH][HAP][2/2] fix CR4 initialization when hap is on Huang2, Wei
2007-03-27 16:13 ` Keir Fraser
2007-03-27 17:32   ` Huang2, Wei

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.