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 AF67BC2B9F4 for ; Tue, 22 Jun 2021 18:02:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 93896611CE for ; Tue, 22 Jun 2021 18:02:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232870AbhFVSEv (ORCPT ); Tue, 22 Jun 2021 14:04:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37650 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232983AbhFVSEM (ORCPT ); Tue, 22 Jun 2021 14:04:12 -0400 Received: from mail-qk1-x749.google.com (mail-qk1-x749.google.com [IPv6:2607:f8b0:4864:20::749]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 63815C0604CA for ; Tue, 22 Jun 2021 10:59:21 -0700 (PDT) Received: by mail-qk1-x749.google.com with SMTP id y5-20020a37af050000b02903a9c3f8b89fso19031996qke.2 for ; Tue, 22 Jun 2021 10:59:21 -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=GFmSqL1fRu1x77v6GuXyeRAd8lytkFiB6WoZ78NJftw=; b=h8rKZtqgcHWYDg6qYyOxcz5EXRhV7X7mk5TWb1CDO+/bWd0H1HZ3pw50iIQX4bz3c6 nQ+pfAFc99yXSG6lCHTjJd3VGPvS2TQJqeyUjE9s1vyYpGERitUZObd7VBOjLUov3w8U zmDyHVpOpnhGFyTSTA6YYya0vXr2YLGWqRybmpkf5xTgVv1XmS231qLr6vDQL3bF8yml PnbNMf3Jem+GsQgAreft00w7MZDSptyrHnlBDnZO1vIu4KXFcw0QhQ4IRBsIQXHlp60Y Um8WOXlYY89+qte2GKxLXCAhFPg3APbntPckSTx5GEHhNiFZ6ffOIZJ37pl2olysLMug B7lQ== 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=GFmSqL1fRu1x77v6GuXyeRAd8lytkFiB6WoZ78NJftw=; b=S9LkdFJwH55Pv1ePyY29NvlxRmeYLgUt24NyaaciZ6WAranc7TsG3JTv9G4T9Qywf3 zJx7IRq0OtOJvpMfm3f+Rasw0JztPQPqmBD8pumRJmUOMEVY2mAAvV/qI8E4Y92ZVFz6 zrBVaPiNpuupgpseR6zt1xxSfouDy3tCIvyypTRTryYzbBT/ROCE32x1jxu3jLzJAeZp gO9HpjeFxB3GsdSidArpKQMrLZOByu0MBDQJOJQpWp7x++JEv9ocri88WpbpW6UPk+1O gjjB2ARwZ/G4vYaz7315S3aNzj2kKnrpu5zdPtNfsPb2xxbdHHRQNnsBBwdBP8vEnZdV gruA== X-Gm-Message-State: AOAM530G7op7mwlETfftwkM9qDBbGjNiIqdO2eFAn3Xgjnr1ovD47+n3 IczAO7BaAEA866MWpYsTB8tTUfM9M6g= X-Google-Smtp-Source: ABdhPJxb9mJtgwKjWHe9lS4lXfoF74aK0R3gmHDbTDDxAJcbJV/tSyQ6pl8euCgd6zj/1MHVAFHr9aQbt8U= X-Received: from seanjc798194.pdx.corp.google.com ([2620:15c:f:10:5722:92ce:361f:3832]) (user=seanjc job=sendgmr) by 2002:a25:2d0b:: with SMTP id t11mr7180655ybt.106.1624384760559; Tue, 22 Jun 2021 10:59:20 -0700 (PDT) Reply-To: Sean Christopherson Date: Tue, 22 Jun 2021 10:57:22 -0700 In-Reply-To: <20210622175739.3610207-1-seanjc@google.com> Message-Id: <20210622175739.3610207-38-seanjc@google.com> Mime-Version: 1.0 References: <20210622175739.3610207-1-seanjc@google.com> X-Mailer: git-send-email 2.32.0.288.g62a8d224e6-goog Subject: [PATCH 37/54] KVM: x86/mmu: Use MMU's role to get EFER.NX during MMU configuration 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, Yu Zhang , Maxim Levitsky Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Get the MMU's effective EFER.NX from its role instead of using the one-off, dedicated flag. This will allow dropping said flag in a future commit. No functional change intended. Signed-off-by: Sean Christopherson --- arch/x86/kvm/mmu/mmu.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c index 30cbc6cdb0db..eb6386bcc2ef 100644 --- a/arch/x86/kvm/mmu/mmu.c +++ b/arch/x86/kvm/mmu/mmu.c @@ -4212,7 +4212,7 @@ static void reset_rsvds_bits_mask(struct kvm_vcpu *vcpu, { __reset_rsvds_bits_mask(&context->guest_rsvd_check, vcpu->arch.reserved_gpa_bits, - context->root_level, context->nx, + context->root_level, is_efer_nx(context), guest_cpuid_has(vcpu, X86_FEATURE_GBPAGES), is_cr4_pse(context), guest_cpuid_is_amd_or_hygon(vcpu)); @@ -4278,7 +4278,7 @@ static void reset_shadow_zero_bits_mask(struct kvm_vcpu *vcpu, * NX can be used by any non-nested shadow MMU to avoid having to reset * MMU contexts. Note, KVM forces EFER.NX=1 when TDP is disabled. */ - bool uses_nx = context->nx || !tdp_enabled; + bool uses_nx = is_efer_nx(context) || !tdp_enabled; /* @amd adds a check on bit of SPTEs, which KVM shouldn't use anyways. */ bool is_amd = true; @@ -4375,6 +4375,7 @@ static void update_permission_bitmask(struct kvm_mmu *mmu, bool ept) bool cr4_smep = is_cr4_smep(mmu); bool cr4_smap = is_cr4_smap(mmu); bool cr0_wp = is_cr0_wp(mmu); + bool efer_nx = is_efer_nx(mmu); for (byte = 0; byte < ARRAY_SIZE(mmu->permissions); ++byte) { unsigned pfec = byte << 1; @@ -4400,7 +4401,7 @@ static void update_permission_bitmask(struct kvm_mmu *mmu, bool ept) u8 kf = (pfec & PFERR_USER_MASK) ? 0 : u; /* Not really needed: !nx will cause pte.nx to fault */ - if (!mmu->nx) + if (!efer_nx) ff = 0; /* Allow supervisor writes if !cr0.wp */ -- 2.32.0.288.g62a8d224e6-goog