From patchwork Fri Apr 21 00:50:03 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Matlack X-Patchwork-Id: 9691537 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 2EDAD6038E for ; Fri, 21 Apr 2017 00:50:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2123F2847B for ; Fri, 21 Apr 2017 00:50:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1608028480; Fri, 21 Apr 2017 00:50:58 +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 0B0032847B for ; Fri, 21 Apr 2017 00:50:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1034275AbdDUAuz (ORCPT ); Thu, 20 Apr 2017 20:50:55 -0400 Received: from mail-io0-f177.google.com ([209.85.223.177]:36528 "EHLO mail-io0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1034197AbdDUAuk (ORCPT ); Thu, 20 Apr 2017 20:50:40 -0400 Received: by mail-io0-f177.google.com with SMTP id o22so104080607iod.3 for ; Thu, 20 Apr 2017 17:50:40 -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:in-reply-to:references; bh=4w5vZLQHmStWYk0UjhwZUK83H0EAka2iDNLcB/BZfqU=; b=UQfLdmUEo+twukdeF1zfhpNTcGqMcQs88/XSQuhHTuhLELVa3vhlb3I4ORCXdIIUBp wneAMl37AfhF03PZzUta/7/yUF81AEUlHIJiGxlguyvGnGPUk1pxhrv6+LaDdguORPLt CPQWPxEK0ZgMOBLskBdvY9vF4KZnLXnvZQkU6ZhS81AZHYGp+VaEx4e6U2GA8CuKsRpl zDoC9R8Ge+OnF6bqwNLzg6YlEH8xvWj7jIUGyqBtMeShl5xfk1msL/1op4+53sS+QuW7 OrbLUbf1+FdP3dIJG5fejj5b/AqWiIAapyN8B+t4OvJcE2qiTqEDha0O7Al9UnXMetkH W/7w== 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:in-reply-to :references; bh=4w5vZLQHmStWYk0UjhwZUK83H0EAka2iDNLcB/BZfqU=; b=peSRezizmCuG5b77w/SWxKocDUKbGiSWxXJE63ZMKpXOZMioMR8BI3zZWZ8nbR3Bxs QV87UToKf7DWTNoyf8pjTBu1ew2j0BOa8y7rdyxghrQcTRq6z6O0giVe/EjbwVVpcRQT wrVS9xDANA+Y87PTjHWKusQksq9xiOlxp9SmEfYD/DVNcOqjiK5BCFpygKIMf1nrvHT2 urpi0sP2EhHy9jmWzATpU5a2lqSg9Ikgx0g91DzzclRjkLUoGJftxOYjfDVzowH5+L9C lbMzESHfKfbx3NqxOUIjnKv7gKox6GRGMiOsS2XYrN6qPlhlg1w8gE99xmMqjnHoEo0T z8kA== X-Gm-Message-State: AN3rC/5pLm3iDwGGi2J1MTpY1Af/lN1GH57CHbOclV+J66kFKLuyr71q Kl6t/TlnpxiB+Ewr X-Received: by 10.84.229.2 with SMTP id b2mr12991702plk.154.1492735839534; Thu, 20 Apr 2017 17:50:39 -0700 (PDT) Received: from dmatlack.sea.corp.google.com ([100.100.206.82]) by smtp.gmail.com with ESMTPSA id e13sm12466486pfb.30.2017.04.20.17.50.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 20 Apr 2017 17:50:38 -0700 (PDT) From: David Matlack To: kvm@vger.kernel.org Cc: Peter Feiner , David Matlack Subject: [kvm-unit-tests PATCH 31/32] x86: force ept 2m test Date: Thu, 20 Apr 2017 17:50:03 -0700 Message-Id: <20170421005004.137260-32-dmatlack@google.com> X-Mailer: git-send-email 2.12.2.816.g2cccc81164-goog In-Reply-To: <20170421005004.137260-1-dmatlack@google.com> References: <20170421005004.137260-1-dmatlack@google.com> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Peter Feiner EPT tests don't exercise 2m support unless it's advertised properly. This test asserts that we actually advertise it and that some basic 2m stuff works. Signed-off-by: Peter Feiner Signed-off-by: David Matlack --- x86/unittests.cfg | 6 ++++++ x86/vmx_tests.c | 13 +++++++++++++ 2 files changed, 19 insertions(+) diff --git a/x86/unittests.cfg b/x86/unittests.cfg index bc245651ce80..09b2252ac2af 100644 --- a/x86/unittests.cfg +++ b/x86/unittests.cfg @@ -482,6 +482,12 @@ extra_params = -cpu host,+vmx -m 2048 -append ept_access_test_paddr_not_present_ arch = x86_64 groups = vmx +[vmx_ept_access_test_force_2m_page] +file = vmx.flat +extra_params = -cpu host,+vmx -m 2048 -append ept_access_test_force_2m_page +arch = x86_64 +groups = vmx + [debug] file = debug.flat arch = x86_64 diff --git a/x86/vmx_tests.c b/x86/vmx_tests.c index c4cd3f96001d..d59ca0baf48a 100644 --- a/x86/vmx_tests.c +++ b/x86/vmx_tests.c @@ -2807,6 +2807,18 @@ static void ept_access_test_paddr_not_present_page_fault(void) */ } +static void ept_access_test_force_2m_page(void) +{ + ept_access_test_setup(); + + TEST_ASSERT_EQ(ept_2m_supported(), true); + ept_allowed_at_level_mkhuge(true, 2, 0, 0, OP_READ); + ept_violation_at_level_mkhuge(true, 2, EPT_PRESENT, EPT_RA, OP_WRITE, + EPT_VLT_WR | EPT_VLT_PERM_RD | + EPT_VLT_LADDR_VLD | EPT_VLT_PADDR); + ept_misconfig_at_level_mkhuge(true, 2, EPT_PRESENT, EPT_WA); +} + #define TEST(name) { #name, .v2 = name } /* name/init/guest_main/exit_handler/syscall_handler/guest_regs */ @@ -2866,5 +2878,6 @@ struct vmx_test vmx_tests[] = { TEST(ept_access_test_paddr_read_execute_ad_disabled), TEST(ept_access_test_paddr_read_execute_ad_enabled), TEST(ept_access_test_paddr_not_present_page_fault), + TEST(ept_access_test_force_2m_page), { NULL, NULL, NULL, NULL, NULL, {0} }, };