From patchwork Fri Apr 21 00:49:58 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Matlack X-Patchwork-Id: 9691529 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 37F0D6038D for ; Fri, 21 Apr 2017 00:50:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2A6B72847B for ; Fri, 21 Apr 2017 00:50:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1F3E028480; Fri, 21 Apr 2017 00:50:48 +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 C85BD2847B for ; Fri, 21 Apr 2017 00:50:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1034221AbdDUAuo (ORCPT ); Thu, 20 Apr 2017 20:50:44 -0400 Received: from mail-oi0-f51.google.com ([209.85.218.51]:34081 "EHLO mail-oi0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1034125AbdDUAuf (ORCPT ); Thu, 20 Apr 2017 20:50:35 -0400 Received: by mail-oi0-f51.google.com with SMTP id x184so74078611oia.1 for ; Thu, 20 Apr 2017 17:50:34 -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=KDtSzsr1rvpt31eWKsaUubfFHilOv51slf7s/cChBJA=; b=AacrPPjruB1zCKkAGTB3W01ljHr7IdZY4ri4oHHiaWCK5iQbLTztA2EmET+jF7iF2g v0RtgiuppXAUjsr9egaiKd20aa/x6SgL8pqc0buCoIzcdo+tt379qHp0/Gsa0Cd6gBN/ h1GErhWlwyZ2gaHeRAA9EU4CkfSRmjsQ08inrOCJ4stPdkvo2XT7+7yAskkDHk4Is4wq AFLYkspcD4cGTtQahSMf4F7OjygHnVWQCKIGMxewfm77S7zNQ7FNLO2oRIQCZi4mHeRY Zz23+P0W5kUIckfx47VFGk1hDKMUsqjVjj5W1UfI6R+ooluv7u/jIQRzDVzGMLP8q1vh PJoA== 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=KDtSzsr1rvpt31eWKsaUubfFHilOv51slf7s/cChBJA=; b=cGvJz3buzYvyR+ADbY4ZzP1CjUFrot5JXvQdP0bymsztXX/aMYJdiFXXwUwlWrW7P+ 8BHclb9lxEcv5V421P7X64PptgFNZdkzvyTv0bGzXxpCSWlHnFEovGd0Un5PqsSDAm3L 4AtiaL7mGCJ7Unmoj5BuNr/jYdZm1uu3cnIW8hOllZeRk2JO58OJfyLcbywsRIuOsxGt KhDpg+/2//lB+QUVdgWQtF85rvjTT2BJATdvSr3j1CUjR/OlFVQzv38rT5Tq2mbeks/x Z+W391sQIV1pRv9DaiQlbB2FN+sNqDAck848j6MFV9REw9DHhVl0ADglBOsXPc6tSUc0 ipqg== X-Gm-Message-State: AN3rC/6iuKreanVlAIHYwqAKgE+/dijbqPis3qgWvRq2tp51a0gmyc1Z rXSZ+roDT+N1wqYM X-Received: by 10.84.140.5 with SMTP id 5mr713453pls.113.1492735834336; Thu, 20 Apr 2017 17:50:34 -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.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 20 Apr 2017 17:50:33 -0700 (PDT) From: David Matlack To: kvm@vger.kernel.org Cc: Peter Feiner , David Matlack Subject: [kvm-unit-tests PATCH 26/32] x86: setup_ept code motion Date: Thu, 20 Apr 2017 17:49:58 -0700 Message-Id: <20170421005004.137260-27-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 Signed-off-by: Peter Feiner Signed-off-by: David Matlack --- x86/vmx_tests.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/x86/vmx_tests.c b/x86/vmx_tests.c index 5758b6becfa6..be01709d3057 100644 --- a/x86/vmx_tests.c +++ b/x86/vmx_tests.c @@ -940,12 +940,20 @@ static int insn_intercept_exit_handler() } +/* Enables EPT and sets up the identity map. */ static int setup_ept(bool enable_ad) { int support_2m; unsigned long end_of_memory; u32 ctrl_cpu[2]; + if (!(ctrl_cpu_rev[0].clr & CPU_SECONDARY) || + !(ctrl_cpu_rev[1].clr & CPU_EPT)) { + printf("\tEPT is not supported"); + return 1; + } + + if (!(ept_vpid.val & EPT_CAP_UC) && !(ept_vpid.val & EPT_CAP_WB)) { printf("\tEPT paging-structure memory type " @@ -992,12 +1000,6 @@ static int apic_version; static int ept_init_common(bool have_ad) { - if (!(ctrl_cpu_rev[0].clr & CPU_SECONDARY) || - !(ctrl_cpu_rev[1].clr & CPU_EPT)) { - printf("\tEPT is not supported"); - return VMX_TEST_EXIT; - } - if (setup_ept(have_ad)) return VMX_TEST_EXIT; data_page1 = alloc_page();