Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp2504161rwb; Thu, 17 Nov 2022 11:42:13 -0800 (PST) X-Google-Smtp-Source: AA0mqf7wnNFJ+97eeow+C2NxvmoSjTG+RmNfJA+qO3Z+XB2Z4dX4V2/Yo4KYDZl94/40K7G7ebtM X-Received: by 2002:aa7:cad5:0:b0:461:948e:55db with SMTP id l21-20020aa7cad5000000b00461948e55dbmr3504918edt.131.1668714133354; Thu, 17 Nov 2022 11:42:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668714133; cv=none; d=google.com; s=arc-20160816; b=WLTB2Z9f9AJrdz+k5QyQqMNR6k4KWUFi5ZT97d8extG/ebQZ3jb8tndP/yv3sZ7MZB dgQSZ7TApeMOadXgq/GzufVMGGevTdnwVlI15/ZWjjltl/0UuLba9fjJpSVhaV4wcHG/ +4m1qAknL4Rr+jNk0CZEjeQFEQInn0oFBbFjEExcxHCH/gNkq34EtU6+Rso8LYPKnjpl U0ePSzHgLE9Nn3d2/LyHH7lUQ5lJU0gV/H+SL1+bkeh4yaXYgsS2FDjdemUCGKPdOzpu gqNU5hEd2+C6D3y9mkbXIIHPgl5Cu7LNcbpjMemkSzpgt1Ca0yP2rfS6mDaC+pJGF1iC /tkg== 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=y71MJucuUf5PzoAmht6G11w2phAOT05/ACj/kjL1Fvg=; b=zAwqTwbUZiB3w+kA41RK61WcM385cIileMp0JsgoSLfQe23hYSkJdgx2eq9BkPGTSH Pw1NN9ku0W5/5tVRMQwrKrWCAEWkGO97Q0w8BDFGl1hUo2TbErFPifGa71hqg7sQ+4J/ y3PrqwdvHK9oay2Bcxl8eqBfWz5UdeOqfGd97SRD7yd0s+tMolRDE14z2cZdur4iy6iD vA4EzMgWguENGCTHTOGk0Wojkv8/Ltf/PhGoJjn8qYUgebZcoxwHsb6gu3p0v8JqaTJm 975QsLKlskWjkmgiGsqpq3ukCJdbCb0S+dX5pdIax+CKUnsbkn2Vpy8N0AnTaq3RbXjW x35Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=RWBqUf+9; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g13-20020a056402090d00b004595af54eacsi1637308edz.226.2022.11.17.11.41.48; Thu, 17 Nov 2022 11:42:13 -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=@gmail.com header.s=20210112 header.b=RWBqUf+9; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240552AbiKQT07 (ORCPT + 92 others); Thu, 17 Nov 2022 14:26:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37674 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234974AbiKQT05 (ORCPT ); Thu, 17 Nov 2022 14:26:57 -0500 Received: from mail-pj1-x102a.google.com (mail-pj1-x102a.google.com [IPv6:2607:f8b0:4864:20::102a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0787579E2B; Thu, 17 Nov 2022 11:26:56 -0800 (PST) Received: by mail-pj1-x102a.google.com with SMTP id k2-20020a17090a4c8200b002187cce2f92so1102164pjh.2; Thu, 17 Nov 2022 11:26:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=y71MJucuUf5PzoAmht6G11w2phAOT05/ACj/kjL1Fvg=; b=RWBqUf+9Q4ctah+HUiqbi9uD5rT/ypQMEjxar268uJaesdQBOMO15KeY31cpQrRyZb uZMKmE1JxzsO7rj4GR/6LfDYv7FVJ4Xmg440r3ZLHJuHu1aLmY+MQjDVR96vCO8ChgzY 9FmeGlQipGv1ltH+d5xXVAMIHaOaAZRlNfX4DccXquLgq+EdJOgCxRENNIZHJausYF3E YkLCa1E4prcY+WfNKqKRCbvRHmrvV9sv5fa1q9n316jLIByqYvndE7hlQcCLpYDTmLW+ tnPBb3sjxnhKpyZTh51lDuNHJ/Lnid+fO6TgZMC+8UKlZ4/D6PSDUDvH61zw5vN4t+kk RNZA== 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:subject:date :message-id:reply-to; bh=y71MJucuUf5PzoAmht6G11w2phAOT05/ACj/kjL1Fvg=; b=2XHeUoIRlIqmqWvDFu6wMEiXQGvMJ6DztGGyewNMQNYU6dKM+ptjjL39ekHuNUxK8h Kl2W940yWNL2iiFNaAI/h9GAbVEsamTJqkTrzV8NgiONzZphD93FpNLNCXMhanPArpD5 Y0U+jsteX9i1h82/NEYVxsKECML3NdBTbxDqnH314AGIBVDgn+EuPiw52LI8c8wkMDrw l/TeC8jTyu79EuEDZ6/UOPFZJfRGYNJKsGiZB0xBYrXI28uFFl7lRkLjCiOVq4UIfAfd CEmZRQbW52KWfqbw/kdjeKHgi5iu3arpI1wKIaA2HxS9A7w8PmXFpZG7pIUB5alSOfV0 FYEw== X-Gm-Message-State: ANoB5plIWXMu4xNzqrntxqJO7qn90Ier0XJGqL462V7dljg1eO379TH+ 9GQyF7+k+i2f8yJDnNdUzbc= X-Received: by 2002:a17:90a:6fc5:b0:218:1e70:2af with SMTP id e63-20020a17090a6fc500b002181e7002afmr4342125pjk.46.1668713215450; Thu, 17 Nov 2022 11:26:55 -0800 (PST) Received: from localhost ([192.55.54.55]) by smtp.gmail.com with ESMTPSA id qe1-20020a17090b4f8100b00210039560c0sm3940135pjb.49.2022.11.17.11.26.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Nov 2022 11:26:54 -0800 (PST) Date: Thu, 17 Nov 2022 11:26:53 -0800 From: Isaku Yamahata To: Chenyi Qiang Cc: isaku.yamahata@intel.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, isaku.yamahata@gmail.com, Paolo Bonzini , erdemaktas@google.com, Sean Christopherson , Sagi Shahar , David Matlack , Kai Huang Subject: Re: [PATCH v10 049/108] KVM: x86/tdp_mmu: Support TDX private mapping for TDP MMU Message-ID: <20221117192653.GM2350331@ls.amr.corp.intel.com> References: <9d5595dfe1b5ab77bcb5650bc4d940dd977b0a32.1667110240.git.isaku.yamahata@intel.com> <67b782ee-c95c-d6bc-3cca-cdfe75f4bf6a@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <67b782ee-c95c-d6bc-3cca-cdfe75f4bf6a@intel.com> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS 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 Wed, Nov 16, 2022 at 09:40:38AM +0800, Chenyi Qiang wrote: > > +static int __must_check handle_changed_private_spte(struct kvm *kvm, gfn_t gfn, > > + u64 old_spte, u64 new_spte, > > + int level) > > +{ > > + bool was_present = is_shadow_present_pte(old_spte); > > + bool is_present = is_shadow_present_pte(new_spte); > > + bool was_leaf = was_present && is_last_spte(old_spte, level); > > + bool is_leaf = is_present && is_last_spte(new_spte, level); > > + kvm_pfn_t old_pfn = spte_to_pfn(old_spte); > > + kvm_pfn_t new_pfn = spte_to_pfn(new_spte); > > + int ret; > > int ret = 0; > > > + > > + lockdep_assert_held(&kvm->mmu_lock); > > + if (is_present) { > > + /* TDP MMU doesn't change present -> present */ > > + KVM_BUG_ON(was_present, kvm); > > + > > + /* > > + * Use different call to either set up middle level > > + * private page table, or leaf. > > + */ > > + if (is_leaf) > > + ret = static_call(kvm_x86_set_private_spte)(kvm, gfn, level, new_pfn); > > + else { > > + void *private_spt = get_private_spt(gfn, new_spte, level); > > + > > + KVM_BUG_ON(!private_spt, kvm); > > + ret = static_call(kvm_x86_link_private_spt)(kvm, gfn, level, private_spt); > > + } > > + } else if (was_leaf) { > > + /* non-present -> non-present doesn't make sense. */ > > + KVM_BUG_ON(!was_present, kvm); > > + /* > > + * Zap private leaf SPTE. Zapping private table is done > > + * below in handle_removed_tdp_mmu_page(). > > + */ > > + lockdep_assert_held_write(&kvm->mmu_lock); > > + ret = static_call(kvm_x86_zap_private_spte)(kvm, gfn, level); > > + if (!ret) { > > + ret = static_call(kvm_x86_remove_private_spte)(kvm, gfn, level, old_pfn); > > + WARN_ON_ONCE(ret); > > + } > > + } > > Otherwise, "ret" may be returned without initialization. Then it will > trigger the WARN_ON_ONCE(ret) after handle_changed_spte() in patch 48. Thanks for catching it. Compiler didn't complain it. Maybe W=1 is needed. -- Isaku Yamahata