Received: by 2002:a05:6500:1b45:b0:1f5:f2ab:c469 with SMTP id cz5csp430045lqb; Tue, 16 Apr 2024 23:48:15 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU99H3e+2V7n9jjVQ+QNaNIb5X3AZgp0N6ncUTE1G5cnUAr1t1aZjOjzT60XYlj5qDQLp1t7U9tlMvcbQZ5w71GAb7WCEQibpEbLUz+5g== X-Google-Smtp-Source: AGHT+IEy0ThZ+Ix6zXT4+p6wHcOrwbb0S9fqxPDkCVeKYIs+0VrI5Qp6+wzKbbpOaPux0QoosGRL X-Received: by 2002:a50:d78e:0:b0:56e:2452:f867 with SMTP id w14-20020a50d78e000000b0056e2452f867mr11929606edi.37.1713336495215; Tue, 16 Apr 2024 23:48:15 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713336495; cv=pass; d=google.com; s=arc-20160816; b=Paek3jjRFmrGQ5RvJ4LlwdM2wCPMRKTyQCItx4nT1G4J+iviwdxKKvzUj6jAbpkC1M o7x8iUM2Q5DCyjr/mgbGZWvfq0K36X47PuDJ0EmFeyjDVU3Yr0U5+i3V/Eix5mEmSBcd jZlfv6hmHKjJqLsiKHUMv0yjEtKHdskdQnqhBVA9zMum7jua9Fjs1PfXLWj0OYi+XY+A c9vj1gOLENR43Qm9XW15ougDYRMVA6y6ewzmVulBuxlWoTpBKKthIyPAMzT9UC2wzGg/ FrNOaLpN2s2pw6yachrQMhOtK/G5G6IYJ9XhnvgXM7ax3O4Md0UeUGcP3UNfo7oNfULF g1Dg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=isTVxNiMkug6ZFXhKfKDXrjqkfld8RbIGk1DIzk8+ww=; fh=4/Sni7H/PbGLJ1Wr6mG2prnDgpRXzqWoGlM04mJR1jE=; b=NH9GRkRhqd+dtDVc6rYy2juPqrXTUtnQK4/x5vFIXpBZt2Shr7lmlQzwaV2DDE3+gU tg/v9/b77LxARUnpNYFxgRtWtR2i5D0JaK58KPO2fAgzKn9NGKd7rr3sy9Cqko1lRkHG +7aMrv7Wz84U+4mfoTfeRxXjkTZDapllUFpigSllyJBLNn9f/Ww/hyMV8S4ljxhylMsH xehso98JFZzaMcD2vYmJ3eNJG/amQoLNZSulzaVzFjPDaSWgO07oBoYc4is0iBr3vBh2 wouF/hdBOgUqYEbuy6yddY6rrY7Ts+shQXMjIAI+Zg18m+SeuuEXhZcri/rdZf87bZV2 8drA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=W8+Opz2a; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-148006-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-148006-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id y22-20020a056402359600b0056c526b191fsi6637992edc.119.2024.04.16.23.48.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Apr 2024 23:48:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-148006-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=W8+Opz2a; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-148006-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-148006-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 64EBB1F2446A for ; Wed, 17 Apr 2024 06:47:20 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 28DE06A335; Wed, 17 Apr 2024 06:47:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="W8+Opz2a" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.14]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B44BE2AF0A; Wed, 17 Apr 2024 06:47:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.14 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713336429; cv=none; b=eRjHIlrRsRurVx63yrTTZO70pNCK94WjzAURpKxDI4XvPuvT7rdC4vn/zZNf9ZYauidar9Azg6zJbqhxn5Ou1RikMslMC2hlISFcBQRYruEtqU7ciTgVY0Tw3BgKFSnqWIjJvcLWoTxBZ+BxwYF91rcv7ia1u3z/Yb2SdhZoJIs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713336429; c=relaxed/simple; bh=iN8fjmMLo89h+vHLb9rYvsnDFPIxSlHHgs1h/iLpzvo=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=N+uoN1uCcbfJvew2QvX7hIJiFQKw7fGkBGJ0LnGVQtdD/XeHOO3SXCwis0lzqGSsIF9JFlTPeB3zd0bLRK2VbnIkrRqduB9RvI/j7FJ+KEQPL72YPz4A39IPBsEGzKuD3WmndHgbItXlMeECVRcV8evfsUe/Q3it/uP1XCgbc/U= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=W8+Opz2a; arc=none smtp.client-ip=192.198.163.14 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1713336428; x=1744872428; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=iN8fjmMLo89h+vHLb9rYvsnDFPIxSlHHgs1h/iLpzvo=; b=W8+Opz2aCVnlv//VgpPTgwPOeBr90UsHId499SWRSOdGoAGfVw3sAQtq cIhG0s+7xy0o+vTIHH9/ttTqxAZqJfqcTieg481xnAAQbTPo6KSeVz2ms nGiijYdiFCRx2THb/qKV9dfICQmnJ2uNwBySoqRB5t4OYlm8vSpgqc6pC qrZRxf02gW9OWfokvWf1Z2OrS9o8Tu7Vda45cJCN6iv/8UBIjKZ6FtTBf TbeShJhcvN4NLfZu04tzyH0bLDcMN1W+VIGrnB3oMxlzgqmT/8AlSNIaH xorBjNUPWmX13RK5H1e6hC4EWx7qCZipu6i79Fa3NVxWyHGapI5dolYgE A==; X-CSE-ConnectionGUID: O2cNej9mQzKVdPbJ9/Jx5g== X-CSE-MsgGUID: 7xoJl23MQUW+MZM2PqZh8g== X-IronPort-AV: E=McAfee;i="6600,9927,11046"; a="9032028" X-IronPort-AV: E=Sophos;i="6.07,208,1708416000"; d="scan'208";a="9032028" Received: from fmviesa008.fm.intel.com ([10.60.135.148]) by fmvoesa108.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Apr 2024 23:47:07 -0700 X-CSE-ConnectionGUID: 5fTzK/apTdeu9vd5aJkFJg== X-CSE-MsgGUID: gy4L9eKJQRCas0HRd0J3MA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,208,1708416000"; d="scan'208";a="22584918" Received: from ls.sc.intel.com (HELO localhost) ([172.25.112.31]) by fmviesa008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Apr 2024 23:47:06 -0700 Date: Tue, 16 Apr 2024 23:47:06 -0700 From: Isaku Yamahata To: Chao Gao 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 , Kai Huang , chen.bo@intel.com, hang.yuan@intel.com, tina.zhang@intel.com, Sean Christopherson , isaku.yamahata@linux.intel.com Subject: Re: [PATCH v19 059/130] KVM: x86/tdp_mmu: Don't zap private pages for unsupported cases Message-ID: <20240417064706.GD3039520@ls.amr.corp.intel.com> References: <1ed955a44cd81738b498fe52823766622d8ad57f.1708933498.git.isaku.yamahata@intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: On Wed, Apr 17, 2024 at 10:21:16AM +0800, Chao Gao wrote: > On Mon, Feb 26, 2024 at 12:26:01AM -0800, isaku.yamahata@intel.com wrote: > >@@ -779,6 +780,10 @@ static bool tdp_mmu_zap_leafs(struct kvm *kvm, struct kvm_mmu_page *root, > > > > lockdep_assert_held_write(&kvm->mmu_lock); > > > >+ WARN_ON_ONCE(zap_private && !is_private_sp(root)); > >+ if (!zap_private && is_private_sp(root)) > >+ return false; > > Should be "return flush;". > > Fengwei and I spent one week chasing a bug where virtio-net in the TD guest may > stop working at some point after bootup if the host enables numad. We finally > found that the bug was introduced by the 'return false' statement, which left > some stale EPT entries unflushed. Thank you for chasing it down. > I am wondering if we can refactor related functions slightly to make it harder > to make such mistakes and make it easier to identify them. e.g., we could make > "@flush" an in/out parameter of tdp_mmu_zap_leafs(), kvm_tdp_mmu_zap_leafs() > and kvm_tdp_mmu_unmap_gfn_range(). It looks more apparent that "*flush = false" > below could be problematic if the changes were something like: > > if (!zap_private && is_private_sp(root)) { > *flush = false; > return; > } Yes, let me look into it. -- Isaku Yamahata