From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from fra-out-003.esa.eu-central-1.outbound.mail-perimeter.amazon.com (fra-out-003.esa.eu-central-1.outbound.mail-perimeter.amazon.com [3.72.182.33]) (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 EC61A29B76F; Fri, 6 Mar 2026 15:42:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=3.72.182.33 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772811735; cv=none; b=LKsC9d3Tfsm2+jVNtv0mxIdtlztHPmy9Cb1+c04BaoUE+oYdo2e2rHZRJ3PbPHKuEJ5hjw7DGjPNutzuHmbqvG7ife2PA9BwAzZjEHLe14HVR8eHqAoP4ecCgkSsaSt3r7dZ8v3Uig2YyvSd2Yqo+BfJ0uv/tae1kSjjF+c+iDw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772811735; c=relaxed/simple; bh=fHxvicr/4x2KROO8aKJnuupOmRnTt0JEjdAoxNKC7a0=; h=Message-ID:Date:MIME-Version:Subject:To:CC:References:From: In-Reply-To:Content-Type; b=NK+EewW1MP2nY5PFdq5Ox+57pLhpQtEIBllSlR03ISN6CyaDAL81wOwMdoPKCAwcQa8pPQ6tuqEC80MMXB4A72JLM3I89EGkcSpWP4Aj2NsMT3oulRNsK1wq1itSmcnBNNJSL7LYn3sEO9bhtBHJugH2mJA7zUJ2+kVMU5i7AVk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amazon.com; spf=pass smtp.mailfrom=amazon.co.uk; dkim=pass (2048-bit key) header.d=amazon.com header.i=@amazon.com header.b=HjUgjvU3; arc=none smtp.client-ip=3.72.182.33 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amazon.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=amazon.co.uk Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=amazon.com header.i=@amazon.com header.b="HjUgjvU3" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazoncorp2; t=1772811734; x=1804347734; h=message-id:date:mime-version:reply-to:subject:to:cc: references:from:in-reply-to:content-transfer-encoding; bh=zlv5A21skW2cpWW+wfG6AmLOagqEDkrIsCoF7K54pBc=; b=HjUgjvU3l8JCmKgYUMw4Ygy9Aim7IUwMscTQgjIYKFQOxN1QCQi3LM9K ZpvWbKNZzIlzvT0SdXoAxPhz2h3U5its1gk5MKhPEVO4j73IR3gwDdtjg 1uZxF5FQ+pFTnSOHUSDJN3ygVO+NjEGkVOix0IHzWSti39+6hNK1dMHNj F3ut/ITRAQ+fP58I3H1ZLkMGiesjuWqoQ4KQAqDxH8CL6S5U03xBYX5iH W8FB3OMlqyDjhNo0KEmoVJgZTMVnRYBZxP8vjqcU2KZHyLbA0KKtx0H74 xDYhnx+0vn7TqhzNYwbV5V80J6xqT09R+yok7M0sTV820BeTY8XCFor66 A==; X-CSE-ConnectionGUID: /M9OfjBRTeKqpDhCE8ldMA== X-CSE-MsgGUID: 0Bb6xkULS3yW60j2eb25+A== X-IronPort-AV: E=Sophos;i="6.23,105,1770595200"; d="scan'208";a="10435125" Received: from ip-10-6-6-97.eu-central-1.compute.internal (HELO smtpout.naws.eu-central-1.prod.farcaster.email.amazon.dev) ([10.6.6.97]) by internal-fra-out-003.esa.eu-central-1.outbound.mail-perimeter.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Mar 2026 15:42:09 +0000 Received: from EX19MTAEUB001.ant.amazon.com [54.240.197.226:28153] by smtpin.naws.eu-central-1.prod.farcaster.email.amazon.dev [10.0.5.165:2525] with esmtp (Farcaster) id 8290e714-6a53-45c7-af32-ec04f3406384; Fri, 6 Mar 2026 15:42:09 +0000 (UTC) X-Farcaster-Flow-ID: 8290e714-6a53-45c7-af32-ec04f3406384 Received: from EX19D005EUB003.ant.amazon.com (10.252.51.31) by EX19MTAEUB001.ant.amazon.com (10.252.51.26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) id 15.2.2562.37; Fri, 6 Mar 2026 15:42:07 +0000 Received: from [192.168.2.180] (10.106.83.26) by EX19D005EUB003.ant.amazon.com (10.252.51.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) id 15.2.2562.37; Fri, 6 Mar 2026 15:42:02 +0000 Message-ID: <6dcbcdcb-bfdd-43a3-b724-599a717c1054@amazon.com> Date: Fri, 6 Mar 2026 15:42:01 +0000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Reply-To: Subject: Re: [PATCH v10 09/15] KVM: guest_memfd: Add flag to remove from direct map To: "David Hildenbrand (Arm)" , "Kalyazin, Nikita" , "kvm@vger.kernel.org" , "linux-doc@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" , "kvmarm@lists.linux.dev" , "linux-fsdevel@vger.kernel.org" , "linux-mm@kvack.org" , "bpf@vger.kernel.org" , "linux-kselftest@vger.kernel.org" , "kernel@xen0n.name" , "linux-riscv@lists.infradead.org" , "linux-s390@vger.kernel.org" , "loongarch@lists.linux.dev" CC: "pbonzini@redhat.com" , "corbet@lwn.net" , "maz@kernel.org" , "oupton@kernel.org" , "joey.gouly@arm.com" , "suzuki.poulose@arm.com" , "yuzenghui@huawei.com" , "catalin.marinas@arm.com" , "will@kernel.org" , "seanjc@google.com" , "tglx@kernel.org" , "mingo@redhat.com" , "bp@alien8.de" , "dave.hansen@linux.intel.com" , "x86@kernel.org" , "hpa@zytor.com" , "luto@kernel.org" , "peterz@infradead.org" , "willy@infradead.org" , "akpm@linux-foundation.org" , "lorenzo.stoakes@oracle.com" , "vbabka@suse.cz" , "rppt@kernel.org" , "surenb@google.com" , "mhocko@suse.com" , "ast@kernel.org" , "daniel@iogearbox.net" , "andrii@kernel.org" , "martin.lau@linux.dev" , "eddyz87@gmail.com" , "song@kernel.org" , "yonghong.song@linux.dev" , "john.fastabend@gmail.com" , "kpsingh@kernel.org" , "sdf@fomichev.me" , "haoluo@google.com" , "jolsa@kernel.org" , "jgg@ziepe.ca" , "jhubbard@nvidia.com" , "peterx@redhat.com" , "jannh@google.com" , "pfalcato@suse.de" , "shuah@kernel.org" , "riel@surriel.com" , "ryan.roberts@arm.com" , "jgross@suse.com" , "yu-cheng.yu@intel.com" , "kas@kernel.org" , "coxu@redhat.com" , "kevin.brodsky@arm.com" , "ackerleytng@google.com" , "maobibo@loongson.cn" , "prsampat@amd.com" , "mlevitsk@redhat.com" , "jmattson@google.com" , "jthoughton@google.com" , "agordeev@linux.ibm.com" , "alex@ghiti.fr" , "aou@eecs.berkeley.edu" , "borntraeger@linux.ibm.com" , "chenhuacai@kernel.org" , "dev.jain@arm.com" , "gor@linux.ibm.com" , "hca@linux.ibm.com" , "palmer@dabbelt.com" , "pjw@kernel.org" , "shijie@os.amperecomputing.com" , "svens@linux.ibm.com" , "thuth@redhat.com" , "wyihan@google.com" , "yang@os.amperecomputing.com" , "Jonathan.Cameron@huawei.com" , "Liam.Howlett@oracle.com" , "urezki@gmail.com" , "zhengqi.arch@bytedance.com" , "gerald.schaefer@linux.ibm.com" , "jiayuan.chen@shopee.com" , "lenb@kernel.org" , "osalvador@suse.de" , "pavel@kernel.org" , "rafael@kernel.org" , "vannapurve@google.com" , "jackmanb@google.com" , "aneesh.kumar@kernel.org" , "patrick.roy@linux.dev" , "Thomson, Jack" , "Itazuri, Takahiro" , "Manwaring, Derek" , "Cali, Marco" References: <20260126164445.11867-1-kalyazin@amazon.com> <20260126164445.11867-10-kalyazin@amazon.com> <13ed00e1-f0db-4326-a800-2ba306833921@kernel.org> <690c22f9-b71a-4f14-9857-008c7c858373@amazon.com> <0c0b911c-cda2-44a4-897e-361e02be7da5@kernel.org> <936fa782-d937-4b14-b92d-cc8707336e5e@amazon.com> <9b4b9f48-595d-46c9-8f77-fc021ac2619c@kernel.org> Content-Language: en-US From: Nikita Kalyazin In-Reply-To: <9b4b9f48-595d-46c9-8f77-fc021ac2619c@kernel.org> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-ClientProxiedBy: EX19D011EUA003.ant.amazon.com (10.252.50.178) To EX19D005EUB003.ant.amazon.com (10.252.51.31) On 06/03/2026 15:16, David Hildenbrand (Arm) wrote: > On 3/6/26 15:49, Nikita Kalyazin wrote: >> >> >> On 06/03/2026 14:22, David Hildenbrand (Arm) wrote: >>> [...] >>> >>>> >>>> Dave pointed earlier that the failures were possible [1]. Do you think >>>> we can document it better? >>> >>> I'm fine with checking that somewhere (to catch any future problems). >>> >>> Why not do the WARN_ON_ONCE() in folio_restore_direct_map()? >>> >>> Then, carefully document (in the new kerneldoc for >>> folio_restore_direct_map() etc) that folio_restore_direct_map() is only >>> allowed after a prior successful folio_zap_direct_map(), and add a >>> helpful comment above the WARN_ON_ONCE() in folio_restore_direct_map() >>> that we don't expect errors etc. >> >> My only concern about that is the assumptions we make in KVM may not >> apply to the general case and the WARN_ON_ONCE may become too >> restrictive compared to proper error handling in some (rare) cases. For >> example, is it possible for the folio to migrate in between? > > Not without migration support. But then, migration would have to make > sure that the destination folio has the direct map removed. So I > wouldn't worry about that. > > Once you return an error from folio_restore_direct_map(), you better > document when/why it happens and how the caller should handle it. > > There is nothing existing callers could really do, so it's an > implementation detail of the > folio_zap_direct_map()/folio_restore_direct_map() functions to make sure > it keeps working. > > If it ever fails, we'll have to figure out how to keep the interface > working. > > You can document any restrictions regarding when > folio_zap_direct_map()/folio_restore_direct_map() is allowed to be used > in the kerneldoc. Ok, makes sense to me. > > -- > Cheers, > > David