target-i386: fix protection bits in the TLB for SMEP
User pages must be marked as non-executable when running under SMEP; otherwise, fetching the page first and then calling it will fail. With this patch, all SMEP testcases in kvm-unit-tests now pass. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
		
							parent
							
								
									de431a655a
								
							
						
					
					
						commit
						b09481de91
					
				@ -749,8 +749,10 @@ do_check_protect_pse36:
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    /* the page can be put in the TLB */
 | 
					    /* the page can be put in the TLB */
 | 
				
			||||||
    prot = PAGE_READ;
 | 
					    prot = PAGE_READ;
 | 
				
			||||||
    if (!(ptep & PG_NX_MASK))
 | 
					    if (!(ptep & PG_NX_MASK) &&
 | 
				
			||||||
 | 
					        !((env->cr[4] & CR4_SMEP_MASK) && (ptep & PG_USER_MASK))) {
 | 
				
			||||||
        prot |= PAGE_EXEC;
 | 
					        prot |= PAGE_EXEC;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
    if (pte & PG_DIRTY_MASK) {
 | 
					    if (pte & PG_DIRTY_MASK) {
 | 
				
			||||||
        /* only set write access if already dirty... otherwise wait
 | 
					        /* only set write access if already dirty... otherwise wait
 | 
				
			||||||
           for dirty access */
 | 
					           for dirty access */
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user