From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0095372 for ; Fri, 30 Jul 2021 16:00:16 +0000 (UTC) Received: from imap1.suse-dmz.suse.de (imap1.suse-dmz.suse.de [192.168.254.73]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 4368C22428; Fri, 30 Jul 2021 16:00:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1627660815; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=kw6stp8k72daDKN6GtjAkWV2DdxxOIrOovtdOiv+Lbo=; b=VWJLSUNx/UXqcLjpye1h9LwuHPVOsgkM7hkJQ8ymPmqpgoEeIKlw+m0VGitoXHpsIrIbbZ bUZLrnYuwlKrcsDcZ+nhoBTkUCfS5FepMiIkmw2GCMfaQkDhntNXYp8dkb+1SdLgjnqXfi Dus9D5j3zqWexTfrbcdpU+pK15yvxH0= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1627660815; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=kw6stp8k72daDKN6GtjAkWV2DdxxOIrOovtdOiv+Lbo=; b=5ZGpDrmFl/crYJnLVvuY6F74NkKit4pZoyVsypvoNjwAIHc+o4K5kJd0pkfMDOSYtIZDTq +zu4zbkiiVKEFIDQ== Received: from imap1.suse-dmz.suse.de (imap1.suse-dmz.suse.de [192.168.254.73]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap1.suse-dmz.suse.de (Postfix) with ESMTPS id CF57D134B1; Fri, 30 Jul 2021 16:00:14 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap1.suse-dmz.suse.de with ESMTPSA id vSnqMQ4iBGG1EgAAGKfGzw (envelope-from ); Fri, 30 Jul 2021 16:00:14 +0000 To: Brijesh Singh , x86@kernel.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, linux-efi@vger.kernel.org, platform-driver-x86@vger.kernel.org, linux-coco@lists.linux.dev, linux-mm@kvack.org, linux-crypto@vger.kernel.org Cc: Thomas Gleixner , Ingo Molnar , Joerg Roedel , Tom Lendacky , "H. Peter Anvin" , Ard Biesheuvel , Paolo Bonzini , Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Andy Lutomirski , Dave Hansen , Sergio Lopez , Peter Gonda , Peter Zijlstra , Srinivas Pandruvada , David Rientjes , Dov Murik , Tobin Feldman-Fitzthum , Borislav Petkov , Michael Roth , tony.luck@intel.com, npmccallum@redhat.com, brijesh.ksingh@gmail.com References: <20210707183616.5620-1-brijesh.singh@amd.com> <20210707183616.5620-11-brijesh.singh@amd.com> From: Vlastimil Babka Subject: Re: [PATCH Part2 RFC v4 10/40] x86/fault: Add support to handle the RMP fault for user address Message-ID: <95a27dfd-bb41-cf32-acd3-f6fdf3780d15@suse.cz> Date: Fri, 30 Jul 2021 18:00:14 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.12.0 Precedence: bulk X-Mailing-List: linux-coco@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 In-Reply-To: <20210707183616.5620-11-brijesh.singh@amd.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit On 7/7/21 8:35 PM, Brijesh Singh wrote: > --- a/mm/memory.c > +++ b/mm/memory.c > @@ -4407,6 +4407,15 @@ static vm_fault_t handle_pte_fault(struct vm_fault *vmf) > return 0; > } > > +static int handle_split_page_fault(struct vm_fault *vmf) > +{ > + if (!IS_ENABLED(CONFIG_AMD_MEM_ENCRYPT)) > + return VM_FAULT_SIGBUS; > + > + __split_huge_pmd(vmf->vma, vmf->pmd, vmf->address, false, NULL); > + return 0; > +} > + I think back in v1 Dave asked if khugepaged will just coalesce this back, and it wasn't ever answered AFAICS. I've checked the code and I think the answer is: no. Khugepaged isn't designed to coalesce a pte-mapped hugepage back to pmd in place. And the usual way (copy to a new huge page) I think will not succeed because IIRC the page is also FOLL_PIN pinned and khugepaged_scan_pmd() will see the elevated refcounts via is_refcount_suitable() and give up. So the lack of coalescing (in case the sub-page leading to split becomes guest private again later) is somewhat suboptimal, but not critical.