Received: by 2002:ac0:e350:0:0:0:0:0 with SMTP id g16csp2218444imn; Mon, 1 Aug 2022 15:58:42 -0700 (PDT) X-Google-Smtp-Source: AA6agR7Kd1q8Q9eej/5Bv8Ayph1wf69TeUKEcS+pF3ZZ6ena6xuznspFqJxMYUNEVXxifp6E4PWp X-Received: by 2002:a17:902:ef96:b0:16d:aa3b:a580 with SMTP id iz22-20020a170902ef9600b0016daa3ba580mr18576050plb.19.1659394722052; Mon, 01 Aug 2022 15:58:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659394722; cv=none; d=google.com; s=arc-20160816; b=Z4obCK9oSdMOmFMQoaILcMmn7ZGIlJKz36OxLN3a6QCshnFJvwakRVNbGTVUkE7Ggs crk+MZ37mFiVQTeJdRgXXwkjqPfZF92PQqZ8ZhfALjYpJ/IKPxF8Ru5t674+WXJMJc4c A6nfy7bVxAUlDDfQl6hSk8N/9F0cojnv+1FEO2nD6/p84vL77k9Qdf2Slyzqe8wUfuit ks8vUqYvsm33DpjobFydkbk6HBEnn+a4nyYbVvxJKlKQGfdrCHsXV0Qo85jLtAehVLWT ZtyP4KIehs9EMZpZXEdokA4LqCIESHOn+HEYFPueJfahh6oQtmCaBlMZccQ1Np1l2Xhp WzNg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=3Q6E/4wJML3+dZQ/vFh6w9chsrslWFwyy3w4tz3NuUc=; b=iOv5IZW8d38nw8lZ5R23ZoaWI0FZlDSRkxBGdhYb4GviUf8mV8p53oaGkYs26+Y2w3 0ryucedblOPuxJeBSEiLFveKM9dF75oQanj9er4k1riwt7m+0Dcy8gBI7Ry8UtyQ/580 q/bsCFH4jaE/+8CprSHGDVoL2U6Auzjsua4xtdngGqhchsFSchOyi0KPTkPwSR2bO6fz 5mRTX3LkBPzWodLEdgRiBqfocVJA802SfuDaEG1UeAzq93fQUzb9egr7OJKhZRJUCKUu oztM6Y1tuYPhnQKV53poOy5Bd//JPtfWeNWtA00p5c8fT/JtNos+l0BIHNzthEwAqBQz Guug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=hcOlhhGy; 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 203-20020a6300d4000000b0041bdaa2fab5si7463613pga.657.2022.08.01.15.58.28; Mon, 01 Aug 2022 15:58:42 -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=hcOlhhGy; 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 S235363AbiHAW1W (ORCPT + 99 others); Mon, 1 Aug 2022 18:27:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41254 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235352AbiHAW1T (ORCPT ); Mon, 1 Aug 2022 18:27:19 -0400 Received: from mail-pg1-x52f.google.com (mail-pg1-x52f.google.com [IPv6:2607:f8b0:4864:20::52f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B9D4A43E7E for ; Mon, 1 Aug 2022 15:27:17 -0700 (PDT) Received: by mail-pg1-x52f.google.com with SMTP id s206so10861252pgs.3 for ; Mon, 01 Aug 2022 15:27:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc; bh=3Q6E/4wJML3+dZQ/vFh6w9chsrslWFwyy3w4tz3NuUc=; b=hcOlhhGydI4ECtzVfXVnZaKOgxOl8FahXdD9fNBauhkCdPWTAh8qFJyhhY7raFH22u WTdIwKlIcEmtgNEEx3fdTagjbUtlNaOHOl3zA2QEp8GeeNCtxVrtjSyB5Jx28F7xxlqw oupS5xVbDmjYhy1ygwBI/xPr8EfjOjOUwlH3KZbjxiCcph13YStezRq9PUo3Gso+4NAy U8wHR8YsA11fuUp/7V9Yx/AMlWRznKILNV6bWDoBXIDAEcFS1BaUWor3IWL7Vi5wg/45 uM4JBJsyuaUfcklg4Pxe4QqIO2fdjhqFOU3Y0BOznNN8HRrvIIxNxi/wIFotdzBkJBIC LyrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc; bh=3Q6E/4wJML3+dZQ/vFh6w9chsrslWFwyy3w4tz3NuUc=; b=AN96MBVQcp54l9ekk+cq/Z1i854QhV0r3DJExdxpfoX9ngpCXBwpZjFrgY0bPRa+MB arKcsx5kS67QDkSUW/F+ZYDJZoJ9X3TZ7d4u/Z9dUbVKmNoUNhWsudqBYT5ePQg1s6+J xLTFOdmxMZlivjxeXXfH2EJJ1wCyS2UZug0zcb1f3axVZZBV40QTv0PTtpdkkiZ4Hw0R wuPM9pN8JCaADJhy+T2p4OarPRH83u2KAeLxbR0YW9PLmwlPBA77hCfnZ05vGsEelCXz dffL2V63/HP192XpZSf3qH1iNeAPkRq+AgHlupCVOL3rTifbWTXKhbZg2Xkrgdbrlzdt d6sg== X-Gm-Message-State: AJIora/ajGTrCNPxFNH6m78OgBnVaNr3Fj0+Z3GXP7G/YA5FbF+wBW6V ZgsL+ITU09YqKNLWXaFjt/MDVw== X-Received: by 2002:a05:6a00:1745:b0:52a:f0d3:ae7 with SMTP id j5-20020a056a00174500b0052af0d30ae7mr18659685pfc.72.1659392836646; Mon, 01 Aug 2022 15:27:16 -0700 (PDT) Received: from google.com (223.103.125.34.bc.googleusercontent.com. [34.125.103.223]) by smtp.gmail.com with ESMTPSA id oo8-20020a17090b1c8800b001f3244768d4sm9392005pjb.13.2022.08.01.15.27.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Aug 2022 15:27:15 -0700 (PDT) Date: Mon, 1 Aug 2022 15:27:11 -0700 From: David Matlack To: isaku.yamahata@intel.com Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, isaku.yamahata@gmail.com, Paolo Bonzini , erdemaktas@google.com, Sean Christopherson , Sagi Shahar Subject: Re: [RFC PATCH v6 036/104] KVM: x86/mmu: Explicitly check for MMIO spte in fast page fault Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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 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? > break; > > sp = sptep_to_sp(sptep); > -- > 2.25.1 >