From mboxrd@z Thu Jan 1 00:00:00 1970 From: Xiao Guangrong Subject: Re: [PATCH kvm-unit-tests] access: check SMEP on prefetch pte path Date: Mon, 27 Jun 2011 14:02:42 +0800 Message-ID: <4E081D02.1060906@cn.fujitsu.com> References: <1308899818-9027-1-git-send-email-wei.y.yang@intel.com> <4E0454D4.8050106@cn.fujitsu.com> <5D8008F58939784290FAB48F549751984686BBA312@shsmsx502.ccr.corp.intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Cc: "avi@redhat.com" , "kvm@vger.kernel.org" , "Li, Xin" , "Shan, Haitao" To: "Yang, Wei Y" Return-path: Received: from cn.fujitsu.com ([222.73.24.84]:52905 "EHLO song.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1756679Ab1F0GAx (ORCPT ); Mon, 27 Jun 2011 02:00:53 -0400 In-Reply-To: <5D8008F58939784290FAB48F549751984686BBA312@shsmsx502.ccr.corp.intel.com> Sender: kvm-owner@vger.kernel.org List-ID: On 06/25/2011 10:44 AM, Yang, Wei Y wrote: > >> >>> +void set_cr4_smep(int smep) >>> +{ >>> + unsigned long cr4 = read_cr4(); >>> + >>> + cr4 &= ~CR4_SMEP_MASK; >>> + if (smep) >>> + cr4 |= CR4_SMEP_MASK; >>> + write_cr4(cr4); >>> +} >>> + >> >> It can work if the box does not support SMEP? > > It will report unhandled exception 13 in access.out which > we count as errors either. Do we need verify it before > running the smep test case? > It can generate the wrong report that is not caused by the fault of KVM, we'd better avoid it. >> >>> void set_efer_nx(int nx) >>> { >>> unsigned long long efer; >>> @@ -176,7 +188,7 @@ void ac_test_init(ac_test_t *at, void *virt) >>> >>> int ac_test_bump_one(ac_test_t *at) >>> { >>> - for (int i = 0; i < NR_AC_FLAGS; ++i) >>> + for (int i = 0; i < NR_AC_FLAGS-1; ++i) >> >> Why not test "SMEP" for all test case? > > It's actually the last question. :) > The page where the current code stays is user page. > If enabled SMEP, we must add some code to convert the current page > into kernel page, or the page fault will occur again and again. And it seems > no need to test SMEP for all test case. We just need fetch access which we > do in a separate case. > Oh, i see, thanks for your explanation, i think we'd better test SMEP for all kinds of access, but i don't have strong opinion :-)