Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp2947458iob; Fri, 6 May 2022 14:06:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwJ7B1ztLwL4UZ6jFZKJ+2ahcQQRCW84HsTfolszxH+/ySkIdyXBj5eloDRyUK6ROWR25wy X-Received: by 2002:a17:907:3da3:b0:6f4:4292:6d6 with SMTP id he35-20020a1709073da300b006f4429206d6mr4626863ejc.162.1651871181137; Fri, 06 May 2022 14:06:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651871181; cv=none; d=google.com; s=arc-20160816; b=IMceyQYZdZVRyYqrsiqORmLfbWDpY9295cBAkexl1inFREXICX4tq5JzLzNn3KqrPu xvd0ph6PC1mEg7/HXqnFXX2uo8eKZS0tqHhsRd0eZtiI8MbFPypHR+/Xr2/KuMLCD9Bz 8o1d5DfzZnKu4reyb/3qevAXxpJ8ai6fApMwxYsch2xxXnK6JpDk8bhaqeRiiI8ig4Ps papnXHCHJkgg49dUsA4Gm/wUR535b0zaSfs0xAwH70pTQ1kSq80ZCUZQ+5Y9WUD3XYmW +vNiebNKi1xzOMi6z6KforWkjK/OZ9tgtbBqYhM3T9mxJ7MTCgGYhZbqDttdIgSSYtod xkwQ== 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=AbRNQ9Xc47DCU3INLVRQU1GNJFi7egoMYGI1UJQgdeo=; b=Xuv/bDtZuEx6ObWSekzIPMNqajnaAqnjupDmq2VUeenTxqmr6wiFEDEKsnhMoD9Cw7 7jyMrZUF8Nj4bmWLWhFq+hce/7e5zjJ5cCa0dt1fZDgMF+i37P17b0qW7oRqrxzdH9db s4wltIaiXff18tEtdfRuib0tEjg9Uax3TC3By3msxVPZl0eeeyGIYUkyOCqRTEVKsv/z Qw3VD1jkrBRJNecS4Ycvj6TQATXFeZs0fVOtqi3WFcg7j0pnu7q3sm/02G+9IladEvB2 DpaRjUVLHoB75obP9NYc7TXno+AOHaigrrPmoo//hV+nrD02bYxoxIAgafuSr65Nwvxp 2RdQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=hRutbVcx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x5-20020a170906148500b006df76385b7asi6149175ejc.26.2022.05.06.14.05.54; Fri, 06 May 2022 14:06:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=hRutbVcx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1383996AbiEES0s (ORCPT + 99 others); Thu, 5 May 2022 14:26:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36890 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1383211AbiEESTl (ORCPT ); Thu, 5 May 2022 14:19:41 -0400 Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4A57A41FAE; Thu, 5 May 2022 11:15:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1651774553; x=1683310553; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=c4l/dtPeYjGdPkK10ruYt5hIF0woALL4dwVeXy0KjaY=; b=hRutbVcxKGYmQS4BmALpfPmhHvRcKPq0zrEaKPyhMl+RvrwdYqDcqYZu zrTYfrKtVot5MvrCfUhq5Tg8qcNWfaIbo+WteMU0lyxuV/kCPZ96VWIYZ EKiGDSkgeEdlUuirGXzlwvF52FkaFt8RKtIuSCO0BOS2gZwdy/Mahw4sa UrYqOxIqySq05pD6fQW6FfR/+Y32HXfJeArYIqHd1N3004YrZKqpW9Ean P4UXI5EDVE+JAm2KPjFctthkAw8p4pOMemcHATPrQ/gq9QEyC9MO4NtV8 GuD/Fqo4oKKvcU95+Ob1VrpDkFMCHgM+BP9di/d8lThgwqosfgE1p36w7 Q==; X-IronPort-AV: E=McAfee;i="6400,9594,10338"; a="248742018" X-IronPort-AV: E=Sophos;i="5.91,202,1647327600"; d="scan'208";a="248742018" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 May 2022 11:15:45 -0700 X-IronPort-AV: E=Sophos;i="5.91,202,1647327600"; d="scan'208";a="665083257" Received: from ls.sc.intel.com (HELO localhost) ([143.183.96.54]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 May 2022 11:15:45 -0700 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 , erdemaktas@google.com, Sean Christopherson , Sagi Shahar Subject: [RFC PATCH v6 036/104] KVM: x86/mmu: Explicitly check for MMIO spte in fast page fault Date: Thu, 5 May 2022 11:14:30 -0700 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=-5.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham 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. MMIO sptes are handled in handle_mmio_page_fault for non-TDX VMs, so this patch does not affect them. TDX will handle MMIO emulation through a hypercall instead. 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 d1c37295bb6e..4a12d862bbb6 100644 --- a/arch/x86/kvm/mmu/mmu.c +++ b/arch/x86/kvm/mmu/mmu.c @@ -3184,7 +3184,7 @@ static int fast_page_fault(struct kvm_vcpu *vcpu, struct kvm_page_fault *fault) else sptep = fast_pf_get_last_sptep(vcpu, fault->addr, &spte); - if (!is_shadow_present_pte(spte)) + if (!is_shadow_present_pte(spte) || is_mmio_spte(spte)) break; sp = sptep_to_sp(sptep); -- 2.25.1