From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Matlack Subject: [kvm-unit-tests PATCH] x86: fix ept_access_test_paddr exit qualifications Date: Fri, 5 May 2017 13:57:23 -0700 Message-ID: <20170505205723.39601-1-dmatlack@google.com> Cc: pbonzini@redhat.com, David Matlack To: kvm@vger.kernel.org Return-path: Received: from mail-pg0-f54.google.com ([74.125.83.54]:35684 "EHLO mail-pg0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751290AbdEEU51 (ORCPT ); Fri, 5 May 2017 16:57:27 -0400 Received: by mail-pg0-f54.google.com with SMTP id o3so8263443pgn.2 for ; Fri, 05 May 2017 13:57:27 -0700 (PDT) Sender: kvm-owner@vger.kernel.org List-ID: SDM Volume 3, Section 28.2.3.2 EPT Violations: Reads by the logical processor of guest paging structures to translate a linear address are considered to be data reads. SDM Volume 3, Table 27-7, Footnote 1: If A/D flags for EPT are enabled, accesses to guest paging-structure entries are treated as writes with regard to EPT Violations. If such an access causes an EPT violation, the processor sets both bit 0 and bit 1 of the exit qualification. Signed-off-by: David Matlack --- x86/vmx_tests.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) This patch fixes the following test failures: FAIL vmx_ept_access_test_paddr_not_present_ad_enabled (65 tests, 3 unexpected failures) FAIL vmx_ept_access_test_paddr_read_only_ad_enabled (175 tests, 9 unexpected failures) FAIL vmx_ept_access_test_paddr_read_execute_ad_enabled (175 tests, 9 unexpected failures) diff --git a/x86/vmx_tests.c b/x86/vmx_tests.c index 1766af3fa708..1749c8a572e8 100644 --- a/x86/vmx_tests.c +++ b/x86/vmx_tests.c @@ -2682,17 +2682,19 @@ static void ept_access_test_paddr_not_present_ad_disabled(void) static void ept_access_test_paddr_not_present_ad_enabled(void) { + u64 qual = EPT_VLT_RD | EPT_VLT_WR; + ept_access_test_setup(); ept_enable_ad_bits_or_skip_test(); - ept_access_violation_paddr(0, PT_AD_MASK, OP_READ, EPT_VLT_WR); - ept_access_violation_paddr(0, PT_AD_MASK, OP_WRITE, EPT_VLT_WR); - ept_access_violation_paddr(0, PT_AD_MASK, OP_EXEC, EPT_VLT_WR); + ept_access_violation_paddr(0, PT_AD_MASK, OP_READ, qual); + ept_access_violation_paddr(0, PT_AD_MASK, OP_WRITE, qual); + ept_access_violation_paddr(0, PT_AD_MASK, OP_EXEC, qual); } static void ept_access_test_paddr_read_only_ad_disabled(void) { - u64 qual = EPT_VLT_WR | EPT_VLT_PERM_RD; + u64 qual = EPT_VLT_WR | EPT_VLT_RD | EPT_VLT_PERM_RD; ept_access_test_setup(); ept_disable_ad_bits(); @@ -2718,7 +2720,7 @@ static void ept_access_test_paddr_read_only_ad_enabled(void) * structures are considered writes as far as EPT translation * is concerned. */ - u64 qual = EPT_VLT_WR | EPT_VLT_PERM_RD; + u64 qual = EPT_VLT_WR | EPT_VLT_RD | EPT_VLT_PERM_RD; ept_access_test_setup(); ept_enable_ad_bits_or_skip_test(); @@ -2754,7 +2756,7 @@ static void ept_access_test_paddr_read_write_execute(void) static void ept_access_test_paddr_read_execute_ad_disabled(void) { - u64 qual = EPT_VLT_WR | EPT_VLT_PERM_RD | EPT_VLT_PERM_EX; + u64 qual = EPT_VLT_WR | EPT_VLT_RD | EPT_VLT_PERM_RD | EPT_VLT_PERM_EX; ept_access_test_setup(); ept_disable_ad_bits(); @@ -2780,7 +2782,7 @@ static void ept_access_test_paddr_read_execute_ad_enabled(void) * structures are considered writes as far as EPT translation * is concerned. */ - u64 qual = EPT_VLT_WR | EPT_VLT_PERM_RD | EPT_VLT_PERM_EX; + u64 qual = EPT_VLT_WR | EPT_VLT_RD | EPT_VLT_PERM_RD | EPT_VLT_PERM_EX; ept_access_test_setup(); ept_enable_ad_bits_or_skip_test(); -- 2.13.0.rc1.294.g07d810a77f-goog