Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp704903pxb; Thu, 25 Feb 2021 12:56:20 -0800 (PST) X-Google-Smtp-Source: ABdhPJwmuMeu3KEBPUlAxwx5h/L089LX4l2KwoYGGVfg3JVMNoivpDd8S/6/QxHBz4Tt9G9Rv7vj X-Received: by 2002:a17:906:9147:: with SMTP id y7mr4430738ejw.243.1614286580699; Thu, 25 Feb 2021 12:56:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614286580; cv=none; d=google.com; s=arc-20160816; b=n2m/Y8ts00NpL6F18nDSDim32QmMkAF77lge6PwMx897V/ZrfYI7cGKXC3fxDRIiDj 79cmDrsxOgt5Qj5GIf/77Bywq6qeDXzhr3BWkqcubdUNmF/I4nhHP6SKK2II6qoxED30 qPM6L6MoEyqiPuIDUIyzg+G9gpZJsgXx+w6P0gRl2Wl1OKPH6HCbjUtJsNu456Y7fpHB S6Ga3C2FJDR6TlNUnBS4EQCR3tLLcq9Oalc5nmJ+QrapChQV2G87BnPzQSXoFxOHTb8y +LSAwcp5BaYpOYpaUpkTkanL3ekNNUpdNc2uDLK81P+QrqO+FhnvgPDH2toTbBh9l1Ou B9DA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:references:mime-version :message-id:in-reply-to:date:reply-to:sender:dkim-signature; bh=R+3qyk75OyMv69ToYBZnoUD1V0Rjb1vbME1iuRO3dNg=; b=oKB1WGbMar4dsxOu6JkkFXyebvE6VY5vZ2JYNehXSXg9tRGr1G3sC2HX9kO/onLWW6 flX3TYAr/GbfWHD095w1QiSbI7EoLtwJn81JFY4t9befrSsF/KbGZLlizamviKscYa/u yMvOQN2zOD81zEoSIDS/k0ocr3YTlYmTfpaT3NYj0sDkqOdoOXrT90kUulTCDSXpz6xV RiNMFzdMS2DIq2MFsksf808FlKwtthW+qiky2yMmJ0kYznu2ojsNhxfinbC5pxX3txjC kkAgYVtIUWegvmCNe9DCg4b8qMmRwdDw6QqbAknbp84JV1mdHL0v9pj2TV9sjpkBCWvr e1vg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=H5v2Kf6t; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s7si3973100edw.490.2021.02.25.12.55.57; Thu, 25 Feb 2021 12:56:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=H5v2Kf6t; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234660AbhBYUwc (ORCPT + 99 others); Thu, 25 Feb 2021 15:52:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50544 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233732AbhBYUtg (ORCPT ); Thu, 25 Feb 2021 15:49:36 -0500 Received: from mail-qk1-x74a.google.com (mail-qk1-x74a.google.com [IPv6:2607:f8b0:4864:20::74a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 79221C06178B for ; Thu, 25 Feb 2021 12:48:06 -0800 (PST) Received: by mail-qk1-x74a.google.com with SMTP id o8so5480982qkl.3 for ; Thu, 25 Feb 2021 12:48:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:reply-to:date:in-reply-to:message-id:mime-version:references :subject:from:to:cc; bh=R+3qyk75OyMv69ToYBZnoUD1V0Rjb1vbME1iuRO3dNg=; b=H5v2Kf6tbzCtssLZcl4hWSoGFPeWy7/JqV4By6Wycn1UfvewDWxDCg8TxM8YEA/W/d c44KERXz0vSFS3/fZ2ADSsMvbxx0OKIlQD9wIDyaoqqC7jhxSsbX6THRxkfrVuQjny+x QYDGMUsAZo5hpGcjOzeEvD05lWMnz+Q1E0lFczc3P7LnLGfhg8g8utYOCCOgVG91j2RU CAY1XlAedXlAnJh/w2kcePHLdvhXrBsJWTJGKWZTlGoOkJ4h0KvSbyaaCz5K+TPfi02l kricOdkcZ839sAdCjnr5PooTQQ69GAFeHNtmW0P5AV6K4bs/mYPCN1GI6MNeL5u2xRMQ 8M4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:reply-to:date:in-reply-to:message-id :mime-version:references:subject:from:to:cc; bh=R+3qyk75OyMv69ToYBZnoUD1V0Rjb1vbME1iuRO3dNg=; b=lz0DShO56xp3z5pYw8Hwd1SNImDHp5WMhg+k0ORoZwTnNzaU+qHOZzjGZZP4bZTCoV IBrpmNu/up7TA+tdHO/Au7OQO5ek+eb7SIrly67fzo0XQr8X0hoy2BOTADoSwu+3BGA1 u6rUMcyZ/oVXnxe+3WbXLP1lgBwqJ/j1lHTicq+yJAQ+t6nt73TstOf+GXzlDg/tyHBU hpL1xxoIEVpLwijbKc3gJs+mEmHkKDRqNIiAqxDD9Ncz0ZnlKlc6btbYe3yJF6iXzq2F 6+SAD3fiHgXprtTLa/u6GA9dhtlfDI5FteCK+yJjrD9Rs3mCzz6RL2TmEY6Kzn7GTEOV 9WUA== X-Gm-Message-State: AOAM531q58TlQd6Tx3hXAV1sclQ8tYL2C3IFeKTJ8sdBwt6zOif1Xk0A a66j7mGMVDiIFbtMjZgjf880VIpDC3s= Sender: "seanjc via sendgmr" X-Received: from seanjc798194.pdx.corp.google.com ([2620:15c:f:10:34c4:7c1d:f9ba:4576]) (user=seanjc job=sendgmr) by 2002:ad4:496b:: with SMTP id p11mr3307590qvy.33.1614286085594; Thu, 25 Feb 2021 12:48:05 -0800 (PST) Reply-To: Sean Christopherson Date: Thu, 25 Feb 2021 12:47:28 -0800 In-Reply-To: <20210225204749.1512652-1-seanjc@google.com> Message-Id: <20210225204749.1512652-4-seanjc@google.com> Mime-Version: 1.0 References: <20210225204749.1512652-1-seanjc@google.com> X-Mailer: git-send-email 2.30.1.766.gb4fecdf3b7-goog Subject: [PATCH 03/24] KVM: x86/mmu: Bail from fast_page_fault() if SPTE is not shadow-present 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, Ben Gardon Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Bail from fast_page_fault() if the SPTE is not a shadow-present SPTE. Functionally, this is not strictly necessary as the !is_access_allowed() check will eventually reject the fast path, but an early check on shadow-present skips unnecessary checks and will allow a future patch to tweak the A/D status auditing to warn if KVM attempts to query A/D bits without first ensuring the SPTE is a shadow-present SPTE. Note, is_shadow_present_pte() is quite expensive at this time, i.e. this might be a net negative in the short term. A future patch will optimize is_shadow_present_pte() to a single AND operation and remedy the issue. Signed-off-by: Sean Christopherson --- arch/x86/kvm/mmu/mmu.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c index d75524bc8423..93b0285e8b38 100644 --- a/arch/x86/kvm/mmu/mmu.c +++ b/arch/x86/kvm/mmu/mmu.c @@ -3061,6 +3061,9 @@ static int fast_page_fault(struct kvm_vcpu *vcpu, gpa_t cr2_or_gpa, if (!is_shadow_present_pte(spte)) break; + if (!is_shadow_present_pte(spte)) + break; + sp = sptep_to_sp(iterator.sptep); if (!is_last_spte(spte, sp->role.level)) break; -- 2.30.1.766.gb4fecdf3b7-goog