From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-26.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT,USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EA086C48BE8 for ; Tue, 15 Jun 2021 16:45:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CC7366191A for ; Tue, 15 Jun 2021 16:45:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230364AbhFOQrt (ORCPT ); Tue, 15 Jun 2021 12:47:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43078 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230205AbhFOQrr (ORCPT ); Tue, 15 Jun 2021 12:47:47 -0400 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4EB62C06175F for ; Tue, 15 Jun 2021 09:45:41 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id r5-20020a2582850000b02905381b1b616eso20912944ybk.6 for ; Tue, 15 Jun 2021 09:45:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=reply-to:date:in-reply-to:message-id:mime-version:references :subject:from:to:cc; bh=KoATQjf1bqJX5+Cn3Pm5jquL1TOAr2SZYGD15c6rjGI=; b=i8b5Rxvb8TY33lBOb2tS3EkwWuF2Wot9rZRAyYQvgF4is7spcEvT+E5xX5qaHgplJf /oTkbqp2GWi259MVdZkiunqm3ZPf82XNW4yuibpf5bLVsr0a2vQhhsme5la0C0mDQAKz e/RqVpQ8qUz0vPJ5h4OI00Smty6GASYEiG0FLschtY50a7SX3NiuUFy/8hIhvz0RG4FW kVAe10AFzCivihB9+pV4MUUK3HfPwG6om1vCKbVpYOFQZX7liv6ripc1aRM84Ux/9cMM w1wetKMj68BHuEyHzsSmgXKHgPsxk7tLs6JxNmV02iOk3ZrOxwoeO7sHWKJBVl9brvfd /Bpg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:reply-to:date:in-reply-to:message-id :mime-version:references:subject:from:to:cc; bh=KoATQjf1bqJX5+Cn3Pm5jquL1TOAr2SZYGD15c6rjGI=; b=MF8fvMP2jI1LV009lBo4IHg1dChxfsJcCqo/CQgrb+wMUaGEGfdnUDCNerUpagiPF9 wPiSN9gw9z6HqDIhQuByeCZ/pt5zA70Cgb7rXiCQWdzLcjOuj1j233ZZ5I4/5nxrR6GS +FzQxRqt5zDGKGkc9YmEg7MPqACOl/j/f6gmJhWW853wn5GlmRAJVQX4E0vNE1umR/z1 jA6j0HTU1olZNoXijwzl9rLMEqlXgC0mU8z2wtVsZIn0xqCgsbmYHQaNJDYvF2pwkGMq tCrs88zBCvtmNAeaZYLFb0d9Z+wllI6aJxMcjE/ShtE8Wi10G4s20Yj89RcpZywcvF8Q MJkw== X-Gm-Message-State: AOAM531w6zDK7vpsAaWotMCHrv0rB2Sp3SDUJoCkT4LchZOXWVuVdmzK vMhpk95X2Q5bV89mhYr830xinlwzCz0= X-Google-Smtp-Source: ABdhPJzMuxBn6CbXj7dqEDl/F6v5foDuq6XtTIS9K1vgrOxspUwq2OsoSvuLlfBrfAomFRe15lFYc5UdzeA= X-Received: from seanjc798194.pdx.corp.google.com ([2620:15c:f:10:13fc:a8bd:9d6b:e5]) (user=seanjc job=sendgmr) by 2002:a25:dc8f:: with SMTP id y137mr108064ybe.248.1623775540537; Tue, 15 Jun 2021 09:45:40 -0700 (PDT) Reply-To: Sean Christopherson Date: Tue, 15 Jun 2021 09:45:32 -0700 In-Reply-To: <20210615164535.2146172-1-seanjc@google.com> Message-Id: <20210615164535.2146172-2-seanjc@google.com> Mime-Version: 1.0 References: <20210615164535.2146172-1-seanjc@google.com> X-Mailer: git-send-email 2.32.0.272.g935e593368-goog Subject: [PATCH 1/4] KVM: VMX: Refuse to load kvm_intel if EPT and NX are disabled From: Sean Christopherson To: Paolo Bonzini Cc: Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , kvm@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Refuse to load KVM if NX support is not available and EPT is not enabled. Shadow paging has assumed NX support since commit 9167ab799362 ("KVM: vmx, svm: always run with EFER.NXE=1 when shadow paging is active"), so for all intents and purposes this has been a de facto requirement for over a year. Do not require NX support if EPT is enabled purely because Intel CPUs let firmware disable NX support via MSR_IA32_MISC_ENABLES. If not for that, VMX (and KVM as a whole) could require NX support with minimal risk to breaking userspace. Fixes: 9167ab799362 ("KVM: vmx, svm: always run with EFER.NXE=1 when shadow paging is active") Signed-off-by: Sean Christopherson --- arch/x86/kvm/vmx/vmx.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c index 68a72c80bd3f..889e83f71235 100644 --- a/arch/x86/kvm/vmx/vmx.c +++ b/arch/x86/kvm/vmx/vmx.c @@ -7723,6 +7723,12 @@ static __init int hardware_setup(void) !cpu_has_vmx_invept_global()) enable_ept = 0; + /* NX support is required for shadow paging. */ + if (!enable_ept && !boot_cpu_has(X86_FEATURE_NX)) { + pr_err_ratelimited("kvm: NX (Execute Disable) not supported\n"); + return -EOPNOTSUPP; + } + if (!cpu_has_vmx_ept_ad_bits() || !enable_ept) enable_ept_ad_bits = 0; -- 2.32.0.272.g935e593368-goog