Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp2281559pxm; Fri, 4 Mar 2022 13:02:34 -0800 (PST) X-Google-Smtp-Source: ABdhPJzvPGPHsLzLdTNN9WPmqpTOnBR+WRqXKSfdwIUWPz3JhBlny5M0y7uKRyXXpZRRRxv4JqfF X-Received: by 2002:a05:6a00:987:b0:4f3:e5d3:448d with SMTP id u7-20020a056a00098700b004f3e5d3448dmr603103pfg.14.1646427754025; Fri, 04 Mar 2022 13:02:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646427754; cv=none; d=google.com; s=arc-20160816; b=KbNJ61B8aPrgRoKRaeHB9ucYy0ZFM6Ns8FOivEwtRmsSUel69CE0ECM5LRBiDb20RM ZVFLLI0fGss+1G6k76ZIDWC2bgUjvQ9nWSSvP0QjkNSRgbipGMObGGh+waqxpJvlSb8p oenEiBmSayevIwO390V33hRGqTZbb3YHSI0TJ35HVsJR4BcuOhhhPadax3KGe1Z0J33o Rt/dUtcRCxWPl7iiFKa3otdiyhDfNjDAdMdoGRNFu5e5syevSP4KXJWryXWP7GCAqLYn wSsC1U+hRW739FUuaLoaog2rmO6gGRUx5P9WcZA3WvSsRPE4dLS8mxxUpENJ6X07dMX+ Au6g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=3Eh5FqbVYlCJ628oy/aLNsdx3h6kyc5DLkrhN/Gmo2Q=; b=ob4nRnr/5/EwEk+pvNdW9Cb8/GPNomFjHGiAsqseZpVQDJv8DteGRPZ8pY/S91VULU 6Gi8nXwXe+Tl1wsXF8RWYLp2JjyX3rChcIKQPNsanGqq0WBYbxaVNnRA1HUFrHiLevgD T3BfybUsypoFeJ9Oyp8zBgAvmvXeCn4SCIiP2+DeKtjX+vGkbdpmo6r+QLpXuiSNQnas zob+3fiH2VRYYTQ4lA6f6CKAaswY5bmlVEv5U3rcHp3B3yU66BikASdMccIxb3yIWByz po7zb6JTL6c0QAzUuHUIod8GTBcnMwfJ9KcGfMmlJFREsie8V2j0bPwQDfx+nIAFiOWx on/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="BOqqTk8/"; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id a7-20020a170902900700b00151831fe79bsi5153436plp.601.2022.03.04.13.02.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Mar 2022 13:02:34 -0800 (PST) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="BOqqTk8/"; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 82E0C200574; Fri, 4 Mar 2022 12:13:44 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231363AbiCDULo (ORCPT + 99 others); Fri, 4 Mar 2022 15:11:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53112 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230484AbiCDUHl (ORCPT ); Fri, 4 Mar 2022 15:07:41 -0500 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0FBB7269A76; Fri, 4 Mar 2022 12:02:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1646424126; x=1677960126; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=8l8peHNVZyeS/auPKUnLmYj1Qk41lhKXin8JnhT2XHY=; b=BOqqTk8/SqdXnbd9eusAr/cKyYg6F/sJqWv8GoMrQLWjCYhR5hFOwk3b +bH1HjrfEmo6h97KaDkjbRPVje5iVD6pYz7dtNJwtcITmR2gmNeGp2QDz f4YtKfuxDiXv3z+cwjL56HFXCxmrMKx6Fbm35h7PYgTopP2qDNkPvaBIp txLycVy4jyEymfdbRysjxru77Q+Tvx3yJV27Cq9Av/SoCi5r2V3a1157t 3zg36EpqcJWZirsLT5Z/jAGg2YtYhme6pKpeoTG9lZ9rZzFX98P6D7qwX lVYD+zAaF091E/vj3lS4sThRhKKdgoHlzE2oKFcmGpyajaYYezFhjiu70 A==; X-IronPort-AV: E=McAfee;i="6200,9189,10276"; a="253983457" X-IronPort-AV: E=Sophos;i="5.90,156,1643702400"; d="scan'208";a="253983457" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Mar 2022 11:50:19 -0800 X-IronPort-AV: E=Sophos;i="5.90,156,1643702400"; d="scan'208";a="552344305" Received: from ls.sc.intel.com (HELO localhost) ([143.183.96.54]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Mar 2022 11:50:19 -0800 From: isaku.yamahata@intel.com To: kvm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: isaku.yamahata@intel.com, isaku.yamahata@gmail.com, Paolo Bonzini , Jim Mattson , erdemaktas@google.com, Connor Kuehl , Sean Christopherson Subject: [RFC PATCH v5 036/104] KVM: x86/mmu: Explicitly check for MMIO spte in fast page fault Date: Fri, 4 Mar 2022 11:48:52 -0800 Message-Id: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Sean Christopherson Explicitly check for an MMIO spte in the fast page fault flow. TDX will use a not-present entry for MMIO sptes, which can be mistaken for an access-tracked spte since both have SPTE_SPECIAL_MASK set. The fast page fault handles the case of changing access bits without obtaining mmu_lock. For example, clear write protect bit for dirty page tracking. MMIO emulation is handled in a slow path. So it doesn't affect the default VM case. Signed-off-by: Sean Christopherson Signed-off-by: Isaku Yamahata --- arch/x86/kvm/mmu/mmu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c index b68191aa39bf..9907cb759fd1 100644 --- a/arch/x86/kvm/mmu/mmu.c +++ b/arch/x86/kvm/mmu/mmu.c @@ -3167,7 +3167,7 @@ static int fast_page_fault(struct kvm_vcpu *vcpu, struct kvm_page_fault *fault) break; sp = sptep_to_sp(sptep); - if (!is_last_spte(spte, sp->role.level)) + if (!is_last_spte(spte, sp->role.level) || is_mmio_spte(spte)) break; /* -- 2.25.1