From patchwork Fri May 5 20:57:23 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Matlack X-Patchwork-Id: 9714367 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 4B6D96034B for ; Fri, 5 May 2017 20:57:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3EFE920223 for ; Fri, 5 May 2017 20:57:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 33D45204C1; Fri, 5 May 2017 20:57:31 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C9F0A20223 for ; Fri, 5 May 2017 20:57:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751606AbdEEU52 (ORCPT ); Fri, 5 May 2017 16:57:28 -0400 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) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=rOAPoJoc+R1ZW71WvhYPDyl/uOZ3jVO72aQ+ZIfoxTI=; b=eKS4nLPwGs1BRu4IdKMbUw6MER22tbJXWVOnrY4/+Go2d8trLzJ9p9g1yRHYVNdR7a htf+Zi/LiPA0AvPFNn+YO7xvndrVZel0q6Uald6EPwXq/AhTVSUhCPYmkE8nqviIU2rf sztNO/c7puwLYtCwXmy7w39Prrp4HO/i4ZDdRIkXzlRQFageKMHjEKKth0EkXHmEzWJr BcnuRjca6UhmXz5scRVCQ0hv8C2lrwiTz799hIU96sS/0IHxdCuV+BMBuN/snKmHb2A+ 5OdVV/gPjuIpYV/HHygrlxPPMCvXwcLZdV6kxY4L4yARRYMS6LLjDGxM5Iwn64iHUxWQ hnlw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=rOAPoJoc+R1ZW71WvhYPDyl/uOZ3jVO72aQ+ZIfoxTI=; b=aqzUqCFEfQl7QvhNgfx5mV5lZT/xSvYWKt233MBXmlTTHQ+nu3fTj+43MFiMMdi1Zv Y+Cam5e+gEmi9FjoOPfXjbiFgxfORzIVl7wX0MBrjIuCLg3q/PgRvrQZNl1nWDu95/VR ZW7aJXmdt76TJnRoW7pwTqJImtwv9hdktJsbWDz+KyZCZOAptAtg/fXO/YsH46Zn8zTX F6ag3i9XBfDYndmeHBo3RxlVrmNLVNJlP0AeIbCZkQhP1huRYvST8rqr+M55tMhq7cD0 4HKfHMnwfkx7CwlN/fdGB8mk9d9/0gTM3krLhCCxUUAGikVYPV40tXH6REgNXS4wGxxA uyXA== X-Gm-Message-State: AN3rC/5D4NLbDrSLSeYLMheYb61p+I0QMfEA9mbqA5suZe7Z5diTCSwI eim1tHCszqsTHKTH X-Received: by 10.98.17.156 with SMTP id 28mr3874839pfr.267.1494017846948; Fri, 05 May 2017 13:57:26 -0700 (PDT) Received: from dmatlack.sea.corp.google.com ([100.100.206.82]) by smtp.gmail.com with ESMTPSA id b126sm4835634pga.3.2017.05.05.13.57.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 05 May 2017 13:57:26 -0700 (PDT) From: David Matlack To: kvm@vger.kernel.org Cc: pbonzini@redhat.com, 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> X-Mailer: git-send-email 2.13.0.rc1.294.g07d810a77f-goog Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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();