Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp2385895pxb; Mon, 19 Apr 2021 04:40:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzbpqowWu6X33dEhfLT0ATYyCjtcxHYL8VdlpbZjmyY48vGXYL53Ebs3tSMlXO38wuASWJC X-Received: by 2002:a65:5203:: with SMTP id o3mr11281842pgp.305.1618832427097; Mon, 19 Apr 2021 04:40:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618832427; cv=none; d=google.com; s=arc-20160816; b=JVdNlrqpZZlsMbUmhUJ62TfKST6SJ9fL3HTx2qfb/5/2i+8tjJ3mBBqGu/ul/AylIx 6nboYYDmy8an2IKmhkG4z/1j2TrObzhuhq5g0C2IXmwIw/T5B5OZRhC6/1EI2QmCU0j/ Sp2C2WWh1mt6VEudb70iVkzwXB7bZxjuOXT+d7cqIlgcnwCYFGxXvlhWCNAyr6CHm0p/ AQD8HRPw5cn0A3a11/ISS5KV/1qcUSbZFJDc4953E/UXQVWPMIyTj9PfytGTQfj00p8T C59KqploU17ktrmuivG4BCiW/7Z6V/T83vp9ob93Mzp2g8ol6bXrTaW1hH5aLia3BSF6 ++cg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:ironport-sdr:ironport-sdr; bh=w8CjqiuQaaCSDCgs9ViXxyQfYu3VHoN4CZs5WYldd7o=; b=U+sJYxnG2Ozfb6JVKYCxDt9GHoHXPVdRcJEIEnDMJvpia5kpuHG+d5sz6O9T9j4XKC V3azwRreVtpg5GWBSGuQxYXW7mjgBs8CVcByZr3Fjpnos/229j+WJBd9zXuRn+YW6yMx 3LxEnCHfDXT2CwheKkK/LlY+wfkLFdaLarAlLxGspxIGbZ3utovHVjUV9OImA3PsPYBh Mp2dG8O+AmdvL8mDEUc2RkyHMKaM9Wj5wjiIvn33jkZ/M5igp88Av3YgizjfiszgAA00 NHtjfuSCd1F2pBL147ENSgRfP+RZg0sG/l95iBqGArsmIqYLPuUp/FIMWK9dGfL3N1mD uDcA== 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 d5si16246117pls.48.2021.04.19.04.40.15; Mon, 19 Apr 2021 04:40:27 -0700 (PDT) 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 S233990AbhDSLdG (ORCPT + 99 others); Mon, 19 Apr 2021 07:33:06 -0400 Received: from mga12.intel.com ([192.55.52.136]:6102 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230272AbhDSLdF (ORCPT ); Mon, 19 Apr 2021 07:33:05 -0400 IronPort-SDR: YbmF5Gd1digfDYP8vxklHNb4ndCUIPlI72zNh9nhnuSzu42Zg9iMf4w1qrWYIha16n5S4D9qFj VcJ2L5W/Qq/Q== X-IronPort-AV: E=McAfee;i="6200,9189,9958"; a="174798621" X-IronPort-AV: E=Sophos;i="5.82,234,1613462400"; d="scan'208";a="174798621" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Apr 2021 04:32:29 -0700 IronPort-SDR: SxlERyW6wwLteodLNuqR0qSiCcGDyl4OveuD9/VOlwvMWExEwcI3sV5YIZTgUhBeoz7qcmfz03 SivOd1e5ObmA== X-IronPort-AV: E=Sophos;i="5.82,234,1613462400"; d="scan'208";a="426476438" Received: from xiaoyaol-mobl.ccr.corp.intel.com (HELO [10.254.213.121]) ([10.254.213.121]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Apr 2021 04:32:25 -0700 Subject: Re: [RFCv2 13/13] KVM: unmap guest memory using poisoned pages To: Sean Christopherson , "Kirill A. Shutemov" Cc: Dave Hansen , Andy Lutomirski , Peter Zijlstra , Jim Mattson , David Rientjes , "Edgecombe, Rick P" , "Kleen, Andi" , "Yamahata, Isaku" , Erdem Aktas , Steve Rutherford , Peter Gonda , David Hildenbrand , x86@kernel.org, kvm@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <20210416154106.23721-1-kirill.shutemov@linux.intel.com> <20210416154106.23721-14-kirill.shutemov@linux.intel.com> From: Xiaoyao Li Message-ID: Date: Mon, 19 Apr 2021 19:32:23 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.9.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 4/17/2021 1:30 AM, Sean Christopherson wrote: > On Fri, Apr 16, 2021, Kirill A. Shutemov wrote: [...] >> index fadaccb95a4c..cd2374802702 100644 >> --- a/include/linux/kvm_host.h >> +++ b/include/linux/kvm_host.h >> @@ -436,6 +436,8 @@ static inline int kvm_arch_vcpu_memslots_id(struct kvm_vcpu *vcpu) >> } >> #endif >> >> +#define KVM_NR_SHARED_RANGES 32 >> + >> /* >> * Note: >> * memslots are not sorted by id anymore, please use id_to_memslot() >> @@ -513,6 +515,10 @@ struct kvm { >> pid_t userspace_pid; >> unsigned int max_halt_poll_ns; >> u32 dirty_ring_size; >> + bool mem_protected; >> + void *id; >> + int nr_shared_ranges; >> + struct range shared_ranges[KVM_NR_SHARED_RANGES]; > > Hard no for me. IMO, anything that requires KVM to track shared/pinned pages in > a separate tree/array is non-starter. More specific to TDX #MCs, KVM should not > be the canonical reference for the state of a page. > Do you mean something in struct page to track if the page is shared or private?