Skip to contentSkip to conversation

add SMEP support to HVM guest

PATCH Jan Beulich 2 participants 2 messages Jun 5, 2011

lore
Share & tools
lore
#0 lore raw

xen/arch/x86/hvm/hvm.c Sun Jun 05 08:07:48 2011 +0800 int hvm_set_cr4(unsigned long value) · line 1668

Quoted 10 lines
Quoted 1 line
Quoted 1 line

"Li, Xin" 06/05/11 2:12 AM >>>

xen/arch/x86/hvm/hvm.c Sun Jun 05 08:07:48 2011 +0800 renamed from xen/arch/x86/hvm/hvm.c Fri Jun 03 21:39:00 2011 +0100 +2 -1
@@ -1664,7 +1664,8 @@ int hvm_set_cr4(unsigned long value)
 hvm_update_guest_cr(v, 4);
 
 /* Modifying CR4.{PSE,PAE,PGE} invalidates all TLB entries, inc. Global. */
-    if ( (old_cr ^ value) & (X86_CR4_PSE | X86_CR4_PGE | X86_CR4_PAE) ) {
+    if ( (old_cr ^ value) & (X86_CR4_PSE | X86_CR4_PGE |
+                             X86_CR4_PAE | X86_CR4_SMEP) ) {

Not having access to the specification - why?

xen/arch/x86/hvm/hvm.c Sun Jun 05 08:07:48 2011 +0800

Quoted 10 lines
xen/arch/x86/hvm/hvm.c Sun Jun 05 08:07:48 2011 +0800 renamed from xen/arch/x86/hvm/hvm.c Fri Jun 03 21:39:00 2011 +0100 +0 -0
 if ( !nestedhvm_vmswitch_in_progress(v) && nestedhvm_vcpu_in_guestmode(v) )
 paging_update_nestedmode(v);

else

xen/arch/x86/hvm/hvm.c Sun Jun 05 08:07:48 2011 +0800 renamed from xen/arch/x86/hvm/hvm.c Fri Jun 03 21:39:00 2011 +0100 +0 -0
@@ -2312,7 +2313,8 @@ enum hvm_copy_result hvm_copy_from_guest

enum hvm_copy_result hvm_fetch_from_guest_virt( void *buf, unsigned long vaddr, int size, uint32_t pfec) {

xen/arch/x86/hvm/hvm.c Sun Jun 05 08:07:48 2011 +0800 renamed from xen/arch/x86/hvm/hvm.c Fri Jun 03 21:39:00 2011 +0100 +2 -1
-    if ( hvm_nx_enabled(current) )
+    if ( hvm_nx_enabled(current) ||
+         (!(pfec | PFEC_user_mode) && hvm_smep_enabled(current)) )

Perhaps rather "!(pfec & PFEC_user_mode)"?

         >pfec |= PFEC_insn_fetch;

xen/arch/x86/hvm/hvm.c Sun Jun 05 08:07:48 2011 +0800

Quoted 9 lines

return __hvm_copy(buf, vaddr, size, HVMCOPY_from_guest | HVMCOPY_fault | HVMCOPY_virt,

xen/arch/x86/hvm/hvm.c Sun Jun 05 08:07:48 2011 +0800 renamed from xen/arch/x86/hvm/hvm.c Fri Jun 03 21:39:00 2011 +0100 +0 -0
@@ -2338,7 +2340,8 @@ enum hvm_copy_result hvm_copy_from_guest

enum hvm_copy_result hvm_fetch_from_guest_virt_nofault( void *buf, unsigned long vaddr, int size, uint32_t pfec) {

xen/arch/x86/hvm/hvm.c Sun Jun 05 08:07:48 2011 +0800 renamed from xen/arch/x86/hvm/hvm.c Fri Jun 03 21:39:00 2011 +0100 +2 -1
-    if ( hvm_nx_enabled(current) )
+    if ( hvm_nx_enabled(current) ||
+         (!(pfec | PFEC_user_mode) && hvm_smep_enabled(current)) )

Same here.

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#1 lore raw
Quoted 6 lines
Quoted 4 lines

/* Modifying CR4.{PSE,PAE,PGE} invalidates all TLB entries, inc. Global. */

- if ( (old_cr ^ value) & (X86_CR4_PSE | X86_CR4_PGE | X86_CR4_PAE) ) {
+ if ( (old_cr ^ value) & (X86_CR4_PSE | X86_CR4_PGE |

+ X86_CR4_PAE | X86_CR4_SMEP) ) {

Not having access to the specification - why?

Intel SDM just got updated, you can find it @:
http://www.intel.com/products/processor/manuals/

Quoted 2 lines

Perhaps rather "!(pfec & PFEC_user_mode)"?
Same here.

You're right! Thanks for pointing out!
-Xin