* [Patch v4 4/4] Add instruction fetch checking when walking guest page table
@ 2011-05-29 11:42 Yang, Wei Y
2011-05-29 13:58 ` Avi Kivity
0 siblings, 1 reply; 2+ messages in thread
From: Yang, Wei Y @ 2011-05-29 11:42 UTC (permalink / raw)
To: Avi Kivity; +Cc: kvm@vger.kernel.org
This patch adds instruction fetch checking when walking guest page table.
Signed-off-by: Yang, Wei <wei.y.yang@intel.com>
Signed-off-by: Shan, Haitao <haitao.shan@intel.com>
Signed-off-by: Li, Xin <xin.li@intel.com>
---
arch/x86/kvm/paging_tmpl.h | 9 ++++++++-
1 files changed, 8 insertions(+), 1 deletions(-)
diff --git a/arch/x86/kvm/paging_tmpl.h b/arch/x86/kvm/paging_tmpl.h
index 6c4dc01..6a56ca3 100644
--- a/arch/x86/kvm/paging_tmpl.h
+++ b/arch/x86/kvm/paging_tmpl.h
@@ -246,6 +246,12 @@ walk:
gfn_t gfn;
u32 ac;
+ /* check if the kernel is fetching from user page */
+ if (unlikely((pte_access & PT_USER_MASK) &&
+ kvm_read_cr4_bits(vcpu, X86_CR4_SMEP)))
+ if (fetch_fault && !user_fault)
+ eperm = true;
+
gfn = gpte_to_gfn_lvl(pte, lvl);
gfn += (addr & PT_LVL_OFFSET_MASK(lvl)) >> PAGE_SHIFT;
@@ -305,7 +311,8 @@ error:
walker->fault.error_code |= write_fault | user_fault;
- if (fetch_fault && mmu->nx)
+ if (fetch_fault && (mmu->nx ||
+ kvm_read_cr4_bits(vcpu, X86_CR4_SMEP)))
walker->fault.error_code |= PFERR_FETCH_MASK;
if (rsvd_fault)
walker->fault.error_code |= PFERR_RSVD_MASK;
--
1.7.4.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [Patch v4 4/4] Add instruction fetch checking when walking guest page table
2011-05-29 11:42 [Patch v4 4/4] Add instruction fetch checking when walking guest page table Yang, Wei Y
@ 2011-05-29 13:58 ` Avi Kivity
0 siblings, 0 replies; 2+ messages in thread
From: Avi Kivity @ 2011-05-29 13:58 UTC (permalink / raw)
To: Yang, Wei Y; +Cc: kvm@vger.kernel.org
On 05/29/2011 02:42 PM, Yang, Wei Y wrote:
> This patch adds instruction fetch checking when walking guest page table.
>
>
>
> + /* check if the kernel is fetching from user page */
> + if (unlikely((pte_access& PT_USER_MASK)&&
> + kvm_read_cr4_bits(vcpu, X86_CR4_SMEP)))
> + if (fetch_fault&& !user_fault)
> + eperm = true;
> +
pte_access is a union of ACC_*_MASK values, so this should be
ACC_USER_MASK (though the values are the same).
The difference is that bit 0 is execute permission, while in ptes bit 63
is the no-execute permission.
--
error compiling committee.c: too many arguments to function
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-05-29 13:58 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-05-29 11:42 [Patch v4 4/4] Add instruction fetch checking when walking guest page table Yang, Wei Y
2011-05-29 13:58 ` Avi Kivity
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox