Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp189149pxb; Mon, 8 Feb 2021 19:50:49 -0800 (PST) X-Google-Smtp-Source: ABdhPJwde9ZX8ocnnnE+d0UcpbJj3jRG0zl+yGm8e16M5mkGxFEC9NloVEFBrvtBIu2VuZZnklYF X-Received: by 2002:a50:d307:: with SMTP id g7mr19687083edh.204.1612842649581; Mon, 08 Feb 2021 19:50:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612842649; cv=none; d=google.com; s=arc-20160816; b=IS4yXC3yNMzWcZTuN8CugsQre4VncY003s+gtLdPe+pgtvJaYC0gPNPqt3gJEhU5sy mm0QlRIknxsz8cnvbSTUE/nOWBm1pLygoaXyVRlMam6B8/sOB0BPBLIKvxuUOx8sC7SX S4tfmhHUH5i+escb/+TsmrgASsmxPIpZr9iojYPBOaJSM6ohJKURjI/TrBYSjKi2ZTc5 xphmMbyMn0XoNZEQ4p/vaLoT2s8vv8/2ToZqGPuV0uT92VRgRSdmaLmux/cYS8WiEYnX +yjHgZwPwh0nB1INpAZRnEQip3pnaRK7SuGArEiBdprLr3JO0V8xQRGpHSA397cUup3g fQcA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:ironport-sdr:ironport-sdr; bh=lCJaDfzQJsgIPcKlbsvs2HrGDJLt+Ov/7ZP6AGYNw54=; b=C36goWr0+0IFFXQHb3yVHX5PfYr5XcBwNm5zlCyt0mkshYurQOB+CYgBGbDSo5CNt4 u4VbeEFk2GSuP9ENOCXSqPRqq/NITvoAttIR6huLTqIZrKougluvnj11WgmReBr1PVW7 tlxoGqu4t+gSdhB8WdlIaawAz+/heDQUH6HPW3R4MeSKCt8etKqTXWEbAs/giS0In+S6 /SYVnmzCScIITwjhCCW3FaJdJJass1GsSr9DV1hvFpsrL+HhIc6VaFvKXLBOkQOk3kx3 +huSLoha4v+lv2fnizQZ2Otq1yAMYLLl6yWtu/slvgZIrh8X/qeAX+T6JudDueKokZDA +n7g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m7si13929015edj.442.2021.02.08.19.50.26; Mon, 08 Feb 2021 19:50:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229866AbhBIDtK (ORCPT + 99 others); Mon, 8 Feb 2021 22:49:10 -0500 Received: from mga18.intel.com ([134.134.136.126]:44474 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229984AbhBIDjv (ORCPT ); Mon, 8 Feb 2021 22:39:51 -0500 IronPort-SDR: FWSkOf6/tfAYd/UC2Nn++DrMOTWgNSeW9p3AigZnZGjav8eF2BYL1zrWEJcr/BouGM4gWHJV36 D19/Oir7xdPg== X-IronPort-AV: E=McAfee;i="6000,8403,9889"; a="169503536" X-IronPort-AV: E=Sophos;i="5.81,163,1610438400"; d="scan'208";a="169503536" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Feb 2021 19:33:25 -0800 IronPort-SDR: MLXNXSLOs5NonPdltpG54jRdOM0dLYdU7ndPMGyayNWH3GN9UGb1pJ9J/5xTk4hJqIbeDJ6HIG o5SfOnkWdeGA== X-IronPort-AV: E=Sophos;i="5.81,163,1610438400"; d="scan'208";a="378409896" Received: from liujiaq1-mobl2.ccr.corp.intel.com (HELO localhost) ([10.249.174.87]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Feb 2021 19:33:22 -0800 Date: Tue, 9 Feb 2021 11:33:19 +0800 From: Yu Zhang To: Paolo Bonzini Cc: seanjc@google.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, vkuznets@redhat.com, wanpengli@tencent.com, jmattson@google.com, joro@8bytes.org Subject: Re: [PATCH v2] KVM: x86/MMU: Do not check unsync status for root SP. Message-ID: <20210209033319.w6nfb4s567zuly2c@linux.intel.com> References: <20210207122254.23056-1-yu.c.zhang@linux.intel.com> <671ae214-22b9-1d89-75cb-0c6da5230988@redhat.com> <20210208134923.smtvzeonvwxzdlwn@linux.intel.com> <404bce5c-19ef-e103-7b68-5c81697d2a1f@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <404bce5c-19ef-e103-7b68-5c81697d2a1f@redhat.com> User-Agent: NeoMutt/20171215 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Feb 08, 2021 at 05:47:22PM +0100, Paolo Bonzini wrote: > On 08/02/21 14:49, Yu Zhang wrote: > > On Mon, Feb 08, 2021 at 12:36:57PM +0100, Paolo Bonzini wrote: > > > On 07/02/21 13:22, Yu Zhang wrote: > > > > In shadow page table, only leaf SPs may be marked as unsync. > > > > And for non-leaf SPs, we use unsync_children to keep the number > > > > of the unsynced children. In kvm_mmu_sync_root(), sp->unsync > > > > shall always be zero for the root SP, , hence no need to check > > > > it. Instead, a warning inside mmu_sync_children() is added, in > > > > case someone incorrectly used it. > > > > > > > > Also, clarify the mmu_need_write_protect(), by moving the warning > > > > into kvm_unsync_page(). > > > > > > > > Signed-off-by: Yu Zhang > > > > Signed-off-by: Sean Christopherson > > > > > > This should really be more of a Co-developed-by, and there are a couple > > > adjustments that could be made in the commit message. I've queued the patch > > > and I'll fix it up later. > > > > Indeed. Thanks for the remind, and I'll pay attention in the future. :) > > Also: > > arch/x86/kvm/mmu/mmu.c: In function ‘mmu_sync_children’: > arch/x86/kvm/mmu/mmu.c:2002:17: error: ‘sp’ is used uninitialized in this > function [-Werror=uninitialized] > WARN_ON_ONCE(sp->unsync); Oops. This is wrong. Should be WARN_ON_ONCE(parent->unsync); > > so how was this tested? > I ran access test in kvm-unit-test for previous version, which hasn't this code(also in my local repo "enable_ept" was explicitly set to 0 in order to test the shadow mode). But I did not test this one. I'm truely sorry for the negligence - even trying to compile should make this happen! Should we submit another version? Any suggestions on the test cases? Thanks Yu > Paolo >