Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp277640pxm; Tue, 1 Mar 2022 20:45:27 -0800 (PST) X-Google-Smtp-Source: ABdhPJytc54Voeftj+etQyqLJqfxgbd+v+SFE4tYxH30sbcS0V0fnTO/Ua0HBRulZJqPVm+Iznv9 X-Received: by 2002:a17:902:e74a:b0:150:25f4:f433 with SMTP id p10-20020a170902e74a00b0015025f4f433mr25363166plf.21.1646196327606; Tue, 01 Mar 2022 20:45:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646196327; cv=none; d=google.com; s=arc-20160816; b=ipl/xzWya8JY6vt/7Ez3dgxgVyd7Zv9wLhubkfximFkADFcyVuroM1RUnencjnEE8o jb2XIOwz5d9p/NWzNJasvriyBtIQ9AceSpNmMQ6yRxqV0XplPkPVqQ1JjPT6cKQRLRB0 djCnbeRon6nXPz7oBfbY8Fb/veTO6Sh/Z6XbeLLMzM5HUQvtNde57z6jnaFAkBXQuQrN PQz+kTXMX4FgAcZS8x4HyN72ksR0/nC4cL1ujOL72cRg9ViL+x84s50jqIH5FuwEjgmi 23098q/WO8g1CcvN6HASF5Y3+HrM8KydhWEn/sRIegAjsY6yNv8wgZpaiMS9GXCt8VZr vX7Q== 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=hc+la0U9z5sF1wjuzpoAsI8bZOypHdVZX1vD0aADe74=; b=AgvCoQelwzV1NnEDt5kXhPN9BHh3e2dEU35CaeeGFpe/O2lnFiJAg5YfkXOtBVerZQ PCDtwgvbn9SiUtoApLLejtljemG2A8VDuzIBMvODeeJMbZrL+dwCiJNmtOoml0jrVtuy 6YrIK3Qkh7M3Q3URCgyEC5t2Rg/yTUt8oDsNzJl7YSQ7pc1MnY4c8C47pAeBL7P0QB+d G2u7+HZyzQEpoXCZamGribGxk5wQgdDTacDGut33HM33pKKe2ezk6Ya1znvD0HdqEl+i NoIUUknJ3iIZptWSrmmK8MvDpXGGql8j6SAM2oxDR15KW6rZ1EX04C2wxZT6O7BMUNt8 jfhg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=qKpw9l26; 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 x22-20020a056a00189600b004cebcdda432si14988502pfh.25.2022.03.01.20.45.11; Tue, 01 Mar 2022 20:45:27 -0800 (PST) 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=qKpw9l26; 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 S236809AbiCASHY (ORCPT + 99 others); Tue, 1 Mar 2022 13:07:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52872 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232297AbiCASHX (ORCPT ); Tue, 1 Mar 2022 13:07:23 -0500 Received: from mail-ej1-x633.google.com (mail-ej1-x633.google.com [IPv6:2a00:1450:4864:20::633]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3EBE363BC9 for ; Tue, 1 Mar 2022 10:06:42 -0800 (PST) Received: by mail-ej1-x633.google.com with SMTP id p14so33079229ejf.11 for ; Tue, 01 Mar 2022 10:06:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=hc+la0U9z5sF1wjuzpoAsI8bZOypHdVZX1vD0aADe74=; b=qKpw9l26wiRybylQJZiYYTneChfm1HgNCnDKaEpsBSDFGb6rKM/cmHEFJ208nnRnwp xQfa1UWshwsZL5m5CtpsnVwLGMpQ/OGX35605LcC2XqstLRT4n3v1wKI+OLrYbqxVaPC MgUaCwJk5wuauXVDWcc/4N7NWDZcn8ldsfrPtzbXRwVD47MOXSeNihZ+9CusBpfPeR0N ZiLnwialy6z4jd32aXsc1SjMyL3eXgSFE7netwfjP388Twl8GBoCTT8iKN7kfacRjQqP oEZEXc2R6nsLB7jwrghgfpQqlLwikO2yrDOStfV69i/T1ZeHT9cfCnYl+fv0sQkMUDup qx5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=hc+la0U9z5sF1wjuzpoAsI8bZOypHdVZX1vD0aADe74=; b=2pkCavp668fXvx87mxc3gdiIPEXU4ZSXRMeHWZIRjj24DcOuxU5Pfs1te7mqNH894k DFX4aZBS62IuXzF4UckCSBR9/EEZy5+xpZaGmCtPa6RtF56hDJFkjVwOPUZOmF3RQtaS 4uwMBKfOHpzt7Esr5urKggQT4sxe9Jygl47ICell0BdgFPhGkKtbLfauMOHQNgPT6lX5 1X/6K2/qU9eM7a/vNSW3Md8nJ3fXkkSDTxx+H1xpGTd5pd6uPcXTdGIIlLgCRC8wLOYz EHGeePXF8J1j2eaHuEiKgYmwglhJTuaBSshfP7N2Ns/tdfkM5A40dWpDgWQOG1P2Vonm 0tcA== X-Gm-Message-State: AOAM533zbGsK29sOtRJm6zLPj04ePiLEa5BmRmSvZpQVhtv7qEbQucN0 1QQXzDqfmGH8QNWavea5tLHz7z+ammw8NPdoPnYaGg== X-Received: by 2002:a17:906:2486:b0:6cf:ced9:e4cc with SMTP id e6-20020a170906248600b006cfced9e4ccmr19870864ejb.201.1646158000527; Tue, 01 Mar 2022 10:06:40 -0800 (PST) MIME-Version: 1.0 References: <20220226001546.360188-1-seanjc@google.com> <20220226001546.360188-24-seanjc@google.com> In-Reply-To: <20220226001546.360188-24-seanjc@google.com> From: Ben Gardon Date: Tue, 1 Mar 2022 10:06:29 -0800 Message-ID: Subject: Re: [PATCH v3 23/28] KVM: x86/mmu: Check for a REMOVED leaf SPTE before making the SPTE To: Sean Christopherson Cc: Paolo Bonzini , Christian Borntraeger , Janosch Frank , Claudio Imbrenda , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , David Hildenbrand , kvm , LKML , David Matlack , Mingwei Zhang Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-18.1 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, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL 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 On Fri, Feb 25, 2022 at 4:16 PM Sean Christopherson wrote: > > Explicitly check for a REMOVED leaf SPTE prior to attempting to map > the final SPTE when handling a TDP MMU fault. Functionally, this is a > nop as tdp_mmu_set_spte_atomic() will eventually detect the frozen SPTE. > Pre-checking for a REMOVED SPTE is a minor optmization, but the real goal > is to allow tdp_mmu_set_spte_atomic() to have an invariant that the "old" > SPTE is never a REMOVED SPTE. > > Signed-off-by: Sean Christopherson Reviewed-by: Ben Gardon > --- > arch/x86/kvm/mmu/tdp_mmu.c | 6 +++++- > 1 file changed, 5 insertions(+), 1 deletion(-) > > diff --git a/arch/x86/kvm/mmu/tdp_mmu.c b/arch/x86/kvm/mmu/tdp_mmu.c > index 4151e61245a7..1acd12bf309f 100644 > --- a/arch/x86/kvm/mmu/tdp_mmu.c > +++ b/arch/x86/kvm/mmu/tdp_mmu.c > @@ -1250,7 +1250,11 @@ int kvm_tdp_mmu_map(struct kvm_vcpu *vcpu, struct kvm_page_fault *fault) > } > } > > - if (iter.level != fault->goal_level) { > + /* > + * Force the guest to retry the access if the upper level SPTEs aren't > + * in place, or if the target leaf SPTE is frozen by another CPU. > + */ > + if (iter.level != fault->goal_level || is_removed_spte(iter.old_spte)) { > rcu_read_unlock(); > return RET_PF_RETRY; > } > -- > 2.35.1.574.g5d30c73bfb-goog >