From patchwork Wed Apr 28 15:47:57 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Avi Kivity X-Patchwork-Id: 95715 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o3SFm9lE024878 for ; Wed, 28 Apr 2010 15:48:09 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753647Ab0D1PsE (ORCPT ); Wed, 28 Apr 2010 11:48:04 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47141 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752222Ab0D1Pr7 (ORCPT ); Wed, 28 Apr 2010 11:47:59 -0400 Received: from int-mx08.intmail.prod.int.phx2.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o3SFlxmu018483 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 28 Apr 2010 11:47:59 -0400 Received: from cleopatra.tlv.redhat.com (cleopatra.tlv.redhat.com [10.35.255.11]) by int-mx08.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o3SFlwd4000945 for ; Wed, 28 Apr 2010 11:47:59 -0400 Received: from localhost.localdomain (file.tlv.redhat.com [10.35.255.8]) by cleopatra.tlv.redhat.com (Postfix) with ESMTP id 5F2E2250ADA; Wed, 28 Apr 2010 18:47:58 +0300 (IDT) From: Avi Kivity To: Marcelo Tosatti Cc: kvm@vger.kernel.org Subject: [PATCH 4/5] test: access: allow the processor not to set pde.a if a fault occurs Date: Wed, 28 Apr 2010 18:47:57 +0300 Message-Id: <1272469678-10728-5-git-send-email-avi@redhat.com> In-Reply-To: <1272469678-10728-1-git-send-email-avi@redhat.com> References: <1272469678-10728-1-git-send-email-avi@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.21 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Wed, 28 Apr 2010 15:48:09 +0000 (UTC) diff --git a/kvm/user/test/x86/access.c b/kvm/user/test/x86/access.c index c7a7075..5addd15 100644 --- a/kvm/user/test/x86/access.c +++ b/kvm/user/test/x86/access.c @@ -137,6 +137,7 @@ typedef struct { pt_element_t expected_pte; pt_element_t *pdep; pt_element_t expected_pde; + pt_element_t ignore_pde; int expected_fault; unsigned expected_error; idt_entry_t idt[256]; @@ -370,6 +371,7 @@ void ac_test_setup_pte(ac_test_t *at) if (at->ptep) at->expected_pte = *at->ptep; at->expected_pde = *at->pdep; + at->ignore_pde = 0; at->expected_fault = 0; at->expected_error = PFERR_PRESENT_MASK; @@ -416,13 +418,17 @@ void ac_test_setup_pte(ac_test_t *at) if (at->flags[AC_ACCESS_FETCH] && at->flags[AC_PDE_NX]) at->expected_fault = 1; - if (at->expected_fault) + if (!at->flags[AC_PDE_ACCESSED]) + at->ignore_pde = PT_ACCESSED_MASK; + + if (!pde_valid) goto fault; - at->expected_pde |= PT_ACCESSED_MASK; + if (!at->expected_fault) + at->expected_pde |= PT_ACCESSED_MASK; if (at->flags[AC_PDE_PSE]) { - if (at->flags[AC_ACCESS_WRITE]) + if (at->flags[AC_ACCESS_WRITE] && !at->expected_fault) at->expected_pde |= PT_DIRTY_MASK; goto no_pte; } @@ -455,7 +461,8 @@ void ac_test_setup_pte(ac_test_t *at) no_pte: fault: - ; + if (!at->expected_fault) + at->ignore_pde = 0; } static void ac_test_check(ac_test_t *at, _Bool *success_ret, _Bool cond, @@ -484,6 +491,13 @@ static void ac_test_check(ac_test_t *at, _Bool *success_ret, _Bool cond, printf("FAIL: %s\n", buf); } +static int pt_match(pt_element_t pte1, pt_element_t pte2, pt_element_t ignore) +{ + pte1 &= ~ignore; + pte2 &= ~ignore; + return pte1 == pte2; +} + int ac_test_do_access(ac_test_t *at) { static unsigned unique = 42; @@ -571,7 +585,8 @@ int ac_test_do_access(ac_test_t *at) "error code %x expected %x", e, at->expected_error); ac_test_check(at, &success, at->ptep && *at->ptep != at->expected_pte, "pte %x expected %x", *at->ptep, at->expected_pte); - ac_test_check(at, &success, *at->pdep != at->expected_pde, + ac_test_check(at, &success, + !pt_match(*at->pdep, at->expected_pde, at->ignore_pde), "pde %x expected %x", *at->pdep, at->expected_pde); if (success && verbose) {