Received: by 2002:ac0:e350:0:0:0:0:0 with SMTP id g16csp2621353imn; Tue, 2 Aug 2022 09:38:53 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vEH+ZiTGgH4XmOE7eWFms8XMn4D+QuTxosVfC3UQE4feD+gWoZy5OrgPb8bvqo32ab4zB4 X-Received: by 2002:a17:907:9495:b0:72f:a158:7598 with SMTP id dm21-20020a170907949500b0072fa1587598mr16468021ejc.410.1659458332846; Tue, 02 Aug 2022 09:38:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659458332; cv=none; d=google.com; s=arc-20160816; b=xjC2dXEjnCZMZeHsvv5xPKCscykOhd1bDOtIyfjhHOiuAB/leMfmhYMxFBVSRW7w9s /cw7NB8DyBjIsjrepv+Q450esh0c6CBXFLMN7+rAE7q/Ezz98KFa8p/JZG4faTYYN29j L8S2R26962Egn89e1qdBm1bP0PNJb7ZlZniOcW705pt8CMLOlPtFNVgSQIfAKmaPJtrK ZNp9pQ5gHY9M00o269uzhwXSezYpu0CHzV9Y+HfCAwcddbyz6oSqV2n+KRbQwkRK1Zfd jdn7kNupD/Wd4Srgp7SCeV50cmVDsScrNI0PUb7U+khDbNOXyBj9d9PXWM5MFl/1zhA1 krTg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=SfZoTACqO1kuVkp4wgMQFVuT+8zwCFihmXjSQbfcjAY=; b=V0vfYM5yeC+MNQRgN12moHjzaxmLnwKAmPnGMcA39KD2S9V3nd45262opHipFfF9wW P2ygrjrFn3ln3Eo1RR4L7u5Uo0dcJsUo4l1HhheSNJaDWLqPxhu56fQqAwkw+DCe6szE 6UIJdHaeldvZTL8dC6bwQXYn+Ucwka4v0+fUug2mb3c6Yp9z2nnBo96o7uXPqCW7YVOy l3fN+Z+F1cYoH7COlsaFMZgDt5IJN/dKPUgwO1JRwm2nJW8o9Ix+Si8PnVkcDXkmgGyl ChxVuP5ThN1cvtXKHmYP5NqtCD023cmOtlGlF9w6q0B6u2BcCDt127VTPfhFCi8CKpdw GmuA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=rQR0qT0A; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id sd22-20020a170906ce3600b0072f4b13ecbesi13974126ejb.248.2022.08.02.09.38.27; Tue, 02 Aug 2022 09:38:52 -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=@google.com header.s=20210112 header.b=rQR0qT0A; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237842AbiHBQeg (ORCPT + 99 others); Tue, 2 Aug 2022 12:34:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42760 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237808AbiHBQeb (ORCPT ); Tue, 2 Aug 2022 12:34:31 -0400 Received: from mail-lj1-x22b.google.com (mail-lj1-x22b.google.com [IPv6:2a00:1450:4864:20::22b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7AD9C45F5E for ; Tue, 2 Aug 2022 09:34:30 -0700 (PDT) Received: by mail-lj1-x22b.google.com with SMTP id q7so16163272ljp.13 for ; Tue, 02 Aug 2022 09:34:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc; bh=SfZoTACqO1kuVkp4wgMQFVuT+8zwCFihmXjSQbfcjAY=; b=rQR0qT0A80RapBIF9aQb9iwXYo5L1YHXXsvCRm+YhJdHHIkgCDYG8JteRQSm/+R0N7 3/U47110CTA7UYkSE4hSy7eIHs866iNxI2btd3mU/c2KXH+Kod/cOtkOQf7ccKBhc7yF I5CFluHib48gwGjUldncFXjse7Vc0pO21BOIjMc8eA1B+hisvMa1OGnu8xiTbDRHyZzz BAX/539j4aIqztucsN+g1cznwXXhRComYe98ICxav1gqa9wLjZZCdwW/w0Ga1SmW9zrR z0OHLHpwakJDZR6Hf6JOkPDrOtRgdrKDriZ4iMidDk3sBi/AdrudxaR4/5iqR/HP26+O T6Rg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc; bh=SfZoTACqO1kuVkp4wgMQFVuT+8zwCFihmXjSQbfcjAY=; b=iW3UeosTMgaPNGHsdSKKPyKaJhG+230GnyjJrdRcneGJFsDDU8pEhMxFbNv7tj0VK2 Pvca+nVcwu+QtOPeZvUyGRQAzzAmX0O/x7c9R91P0m6JJEEqXK7wdDCL9pkXgotBj15A mr9+8bP3JjuNyinrW/w51LgK1tw2PDk1wEG7aF7OSk5Yb44+s8O9wWvYvhW2bl+sOi3b 1Hcs1PGhQ62NcsLllQuZUFWwBIPIpD83+db8eVDEvLd58VzRnVUE9lEkk+cZn21GWACf HDwViXEOOOZNTz5635E2O3hLcqYy4ehy892rjtwh2YibMq5jNlrT7CWea8vacLhAoKqD QH+Q== X-Gm-Message-State: AJIora+Z1MZ0d4uVhf8PIfKU3eiMy1gGtgjxZV0dmyY6CZHT/6XXhbR9 4DxD/ZE++u0tOh1LwnAdDc6jKSNhmTP+zYsWpmT2Jg== X-Received: by 2002:a2e:a884:0:b0:25d:ea06:6a3f with SMTP id m4-20020a2ea884000000b0025dea066a3fmr6462084ljq.335.1659458068698; Tue, 02 Aug 2022 09:34:28 -0700 (PDT) MIME-Version: 1.0 References: <29929897856941e0896954011d0ecc34@intel.com> In-Reply-To: <29929897856941e0896954011d0ecc34@intel.com> From: David Matlack Date: Tue, 2 Aug 2022 09:34:02 -0700 Message-ID: Subject: Re: [RFC PATCH v6 036/104] KVM: x86/mmu: Explicitly check for MMIO spte in fast page fault To: "Huang, Kai" Cc: Sean Christopherson , "Yamahata, Isaku" , "kvm@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "isaku.yamahata@gmail.com" , Paolo Bonzini , "erdemaktas@google.com" , Sagi Shahar Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL 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 On Mon, Aug 1, 2022 at 6:46 PM Huang, Kai wrote: > > > On Mon, Aug 01, 2022, David Matlack wrote: > > > On Thu, May 05, 2022 at 11:14:30AM -0700, isaku.yamahata@intel.com wrote: > > > > 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)) > > > > > > I wonder if this patch is really necessary. is_shadow_present_pte() > > > checks if SPTE_MMU_PRESENT_MASK is set (which is bit 11, not > > > shadow_present_mask). Do TDX VMs set bit 11 in MMIO SPTEs? > > > > This patch should be unnecessary, TDX's not-present SPTEs was one of my > > motivations > > for adding MMU_PRESENT. Bit 11 most definitely must not be set for MMIO > > SPTEs. > > As we already discussed, Isaku will drop this patch. Ah, I missed that discussion. Can you share a link so I can catch up?