Received: by 2002:a05:7412:f584:b0:e2:908c:2ebd with SMTP id eh4csp1061188rdb; Mon, 4 Sep 2023 01:27:31 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF9wRP5fdyp5DP4cdp6rmVlnlxn0soL6NFrLJuuL4BqBJoN1pXZR2u/fbJB0LNDcT5k5sn4 X-Received: by 2002:a05:6a21:33a0:b0:148:d5d9:aaa9 with SMTP id yy32-20020a056a2133a000b00148d5d9aaa9mr13597980pzb.33.1693816051453; Mon, 04 Sep 2023 01:27:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693816051; cv=none; d=google.com; s=arc-20160816; b=o5Xuo0BhBaJk9d+3NHmVURvNJMEDU/lfLEpaCOAVXq5ZMhBzZL1kwV5yXCYNg8vNGu W/zgt8i4QeAwSsB8bYchiBRjjAiZbj753LeHSLgOkjqRMI6di2yoNQDZoQu3q70ihdCp XZCwEsR7x7t1HXh5Bo6tFzOZbwAWTyIiwzyUvCf6EcHiJyWo7Nd8uaZaeeZGtkniTvB+ 1XgH24sDmDNoJCI+fdpCJLeyCz/vy4zMLWPZzKZ4WNB4bZebdm3l+dxkvtoAGHI2qbnI hOfe06Kay2dDY48t+IL9y1mfDOdYwX4siKhsEXptu1fgRfuqROnS4av107Hi3Y1WFWeL Znag== 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 :message-id:date:subject:cc:to:from; bh=FZpg8hIvxIVIkpNSwPwHb6hDkC5WwDfpNdEErABo4ok=; fh=ykGWL0O8n732j4v+7r3s3a+1NWcKFcz/Yg/StoP2ORA=; b=WBblyEuxWhy6XFoNC63gpoQAoSPequQhdnkn3+EkVHXVnUg80j0dAyZa3Hqx3IyNnS yHfT/085ousHV4vtuJ8Qu2Zvtp4+9hvZQ5f81rKbz5UxLWiz9OyjgPkVvuk9zmz11LjK cPpCLS8ey/etFMSAP751nr3Z8EQwhK3cUuUaLkMP60Q/31ANXYNikbTiznaYFJggvB3q R+EgoBhY8jtMdaR/gOwy3fmjXw3aqMb0ntGm/JlqP7bdatMM7FXbsy7gqgHmKZ1DXQJe xWCtDnwlQMVivDgDT56NGLPmreBKoKsHBr1bdxUYNH9Mq0iIpL6xTEMpJXh97hjux0Ol NB3g== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id cz1-20020aa79301000000b006871aa6882bsi7287375pfb.165.2023.09.04.01.27.18; Mon, 04 Sep 2023 01:27:31 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349231AbjIDBsz (ORCPT + 99 others); Sun, 3 Sep 2023 21:48:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59204 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237008AbjIDBsz (ORCPT ); Sun, 3 Sep 2023 21:48:55 -0400 Received: from mail.nfschina.com (unknown [42.101.60.195]) by lindbergh.monkeyblade.net (Postfix) with SMTP id 7F8CCF4; Sun, 3 Sep 2023 18:48:51 -0700 (PDT) Received: from localhost.localdomain (unknown [219.141.250.2]) by mail.nfschina.com (Maildata Gateway V2.8.8) with ESMTPA id 57F716018CCC6; Mon, 4 Sep 2023 09:48:49 +0800 (CST) X-MD-Sfrom: zeming@nfschina.com X-MD-SrcIP: 219.141.250.2 From: Li zeming To: seanjc@google.com, pbonzini@redhat.com, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com Cc: x86@kernel.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Li zeming Subject: [v2 PATCH] =?UTF-8?q?x86/kvm/mmu:=20Remove=20unnecessary=20=E2=80=98?= =?UTF-8?q?NULL=E2=80=99=20values=20from=20sptep?= Date: Wed, 6 Sep 2023 02:20:06 +0800 Message-Id: <20230905182006.2964-1-zeming@nfschina.com> X-Mailer: git-send-email 2.18.2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=0.9 required=5.0 tests=BAYES_00,DATE_IN_FUTURE_24_48, RDNS_NONE,SPF_HELO_NONE,SPF_PASS autolearn=no 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 Remove spte and sptep initialization assignments, add sptep assignment check and processing. Signed-off-by: Li zeming --- v2: 1. Remove spte initialization assignment. 2. Add sptep assignment check. arch/x86/kvm/mmu/mmu.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c index ec169f5c7dce..0d11bfeae2f8 100644 --- a/arch/x86/kvm/mmu/mmu.c +++ b/arch/x86/kvm/mmu/mmu.c @@ -3456,8 +3456,8 @@ static int fast_page_fault(struct kvm_vcpu *vcpu, struct kvm_page_fault *fault) { struct kvm_mmu_page *sp; int ret = RET_PF_INVALID; - u64 spte = 0ull; - u64 *sptep = NULL; + u64 spte; + u64 *sptep; uint retry_count = 0; if (!page_fault_can_be_fast(fault)) @@ -3473,6 +3473,14 @@ 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); + /* + * It's entirely possible for the mapping to have been zapped + * by a different task, but the root page is should always be + * available as the vCPU holds a reference to its root(s). + */ + if (WARN_ON_ONCE(!sptep)) + spte = REMOVED_SPTE; + if (!is_shadow_present_pte(spte)) break; -- 2.18.2