Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp132203iof; Sun, 5 Jun 2022 23:19:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw1DUcs55UsTdx53PAGqxHHD4Xg5OCt+E7F4Ul7Q1qHsF76PjDoyOBmIUCZeUxlFoa9KTf5 X-Received: by 2002:a17:902:e54a:b0:166:50b6:a08b with SMTP id n10-20020a170902e54a00b0016650b6a08bmr17902170plf.90.1654496340371; Sun, 05 Jun 2022 23:19:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654496340; cv=none; d=google.com; s=arc-20160816; b=FVpEN2Ew6igOD/OavPX3zlTrzFZZ/BSOBkSf25u949miu+J9hLcvvggQjOl3OuwNSg L+33AE/Uu33vm0ZPYbGFT5Mgzio1QBJ23Rod/Zw8CBGPYFpef1pme1lYK36mwKW6i0J1 62D+9C84x6p5yw/Bep3/sPRALZn90VsTzSAN8Qwgfi8pAZpCMMQl8D5w0ceysbaibi/7 qCUBJTO2i4KS64ULrURBRlNqLnU1BJdsj5tTZz9peuwtJn6mNmdMwx5GvvgLu3VYO5mH 8PDg7cO1LJsladx3IgZ7gvQYm1dXw90Y/T6DlDfl1reBne5kJsAxL9gNxJtXBxvogJEn 27pQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=KM1oikz+Ia9mBiSM3+pw9WjtCt1EQ9hMQl48+WeL5cM=; b=fLVIWBqhFpUcZst78uqRMV5u3JoC6d1yDGUsu3uFpUyAocLH7ArOGwe3mFTuMKT9md DpF+zKYlKoGRqXGbz2Njlr4V9SdEGXvHQff0faKLKLFPSsINHtJ2EEIpvdV31MvJoTI5 HP90geKIPaPMFvjlmTPK3O2cJASVHfK5rBYrsXOrt0cNQ0aMrEhvi1NNVZypI3eZxKtw 2ya4ZOh6ueBWT84wNzNCpUXl7ke7G76LucsWaFLW1qfNrav/kvsuMh7JiK+CK2hiL+kE 1ygjQoj5Jj7gbEXUbvtJt1FKmvfsd3fsu8fQ1D8zNogFht+hfjmnes/+fNDIOAJngkE3 Lt6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=HX8EfDf5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id g4-20020a056a0023c400b004fa3a8e002csi21368638pfc.227.2022.06.05.23.19.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Jun 2022 23:19:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=HX8EfDf5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 84A25101917; Sun, 5 Jun 2022 21:58:21 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348549AbiFEGnG (ORCPT + 99 others); Sun, 5 Jun 2022 02:43:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35182 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243907AbiFEGnA (ORCPT ); Sun, 5 Jun 2022 02:43:00 -0400 Received: from mail-pf1-x42a.google.com (mail-pf1-x42a.google.com [IPv6:2607:f8b0:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3EFBE29805; Sat, 4 Jun 2022 23:42:56 -0700 (PDT) Received: by mail-pf1-x42a.google.com with SMTP id x4so1768343pfj.10; Sat, 04 Jun 2022 23:42:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=KM1oikz+Ia9mBiSM3+pw9WjtCt1EQ9hMQl48+WeL5cM=; b=HX8EfDf5WIq4AlYOacnyiqpv687wfE7clq7qblX2gZCKD/SJjyRVEpsfdmEE5hN/dx GRa3nOiWAHG1Qg50NUnkvf+jgvHXyiCvP0j/toJmLOfbbYTw7KMI4aXADgSZZ0EMPGLS 8K+s0TrmN5QbiuPEMix7EiyfHFT0yCqcfEbup9cp87hzCUUUcSXdDlVyZt1owQIKruug sTslzmaP3akqW43NdPrGlxKHheK0Jpmn7Qt4SEPMo+VvW6wqtpgE34ClnOjzCuWYPEyB 8iXFKONQFTKMCnGoBTScxRc+yLVPgUIY4QTQh0Zyh/rHoKwyyfJnYLS/q5VVJbejr9+E KFmg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=KM1oikz+Ia9mBiSM3+pw9WjtCt1EQ9hMQl48+WeL5cM=; b=GKT+8sPSbgFk1ZYdLa8mWZmEqvqFzRddqrqKTwDq8CtB68+6k63fwtNuEoOby1dFGa Lyfso9Z2tR4uFDTZ621009YaBxMyf9gO6edFVBkUzCeeBWreru9SocP969jvnoSDgpX3 t/D9a+qKDGWtwWfki2Eq3AM7pxdGQ3WVpOjqAP25JIbJzMaYhA6PYZlqEXTou2TwVZ1k buJkRjIPb95fMaJusL+ACq2VQOCULrtnWU3ziImAiYOoWtDy28xdmcWeAiHvlsZbAjek +nqHAQP8AnRf2l/mrOz1DbV+0YB0vexrWjWRbDERPnJe58pDKc2ZDoEN++ZFO3vUkpn/ z/gg== X-Gm-Message-State: AOAM5318vT9O0Q1R4sJ2D/dbKItX2RytAO+QTCcqp2ffxeVrn/TeTOWp JMvYSEMKIsr8zXZzcymRkaEFb0LLXwk= X-Received: by 2002:a05:6a00:2293:b0:51b:f02e:de32 with SMTP id f19-20020a056a00229300b0051bf02ede32mr7524558pfe.17.1654411375583; Sat, 04 Jun 2022 23:42:55 -0700 (PDT) Received: from localhost ([198.11.178.15]) by smtp.gmail.com with ESMTPSA id q15-20020a170902eb8f00b0015e8d4eb25asm8059385plg.164.2022.06.04.23.42.54 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 04 Jun 2022 23:42:55 -0700 (PDT) From: Lai Jiangshan To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org, Paolo Bonzini Cc: Sean Christopherson , Vitaly Kuznetsov , Maxim Levitsky , Lai Jiangshan Subject: [PATCH 01/12] KVM: X86/MMU: Warn if sp->unsync_children > 0 in link_shadow_page() Date: Sun, 5 Jun 2022 14:43:31 +0800 Message-Id: <20220605064342.309219-2-jiangshanlai@gmail.com> X-Mailer: git-send-email 2.19.1.6.gb485710b In-Reply-To: <20220605064342.309219-1-jiangshanlai@gmail.com> References: <20220605064342.309219-1-jiangshanlai@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE 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 From: Lai Jiangshan The check for sp->unsync_children in link_shadow_page() can be removed since FNAME(fetch) ensures it is zero. (@sp is direct when link_shadow_page() is called from other places, which also means sp->unsync_children is zero.) link_shadow_page() is not a fast path, check it and warn instead. Signed-off-by: Lai Jiangshan --- arch/x86/kvm/mmu/mmu.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c index 086f32dffdbe..f61416818116 100644 --- a/arch/x86/kvm/mmu/mmu.c +++ b/arch/x86/kvm/mmu/mmu.c @@ -2197,7 +2197,13 @@ static void link_shadow_page(struct kvm_vcpu *vcpu, u64 *sptep, mmu_page_add_parent_pte(vcpu, sp, sptep); - if (sp->unsync_children || sp->unsync) + /* + * Propagate the unsync bit when sp->unsync. + * + * The caller ensures the sp is synced when it has unsync children, + * so sp->unsync_children must be zero. See FNAME(fetch). + */ + if (sp->unsync || WARN_ON_ONCE(sp->unsync_children)) mark_unsync(sptep); } -- 2.19.1.6.gb485710b