Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8F557C433F5 for ; Tue, 30 Nov 2021 19:40:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239806AbhK3Tno (ORCPT ); Tue, 30 Nov 2021 14:43:44 -0500 Received: from smtp-out1.suse.de ([195.135.220.28]:34796 "EHLO smtp-out1.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239704AbhK3Tnc (ORCPT ); Tue, 30 Nov 2021 14:43:32 -0500 Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (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 903A8212BA; Tue, 30 Nov 2021 19:40:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1638301206; 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=l63rcUE2OHW5ypUlliWqEBsLyZQmG3Hbq8IWsXXTz4A=; b=12aMtx60u9KBtb604fOld+ki3eVdJ1v+mNTfhocasVNh6L//Rl9NMhqUd4LvoT8jYWgERP nDP9hH9+Mw2T+dxZYAs72VFiJw1hYu8et+1Wb0ANyEzPPNlPeoA+CajjJbC364Nk3LnHuw Fw8oLPqRPqEXZPQcNVflvDFhZnz339I= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1638301206; 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=l63rcUE2OHW5ypUlliWqEBsLyZQmG3Hbq8IWsXXTz4A=; b=AsYbhWHpnSL6tKhtvFTF+/vcz7c8P+xPT7pr2B/izPpdBA008dOLaGWkJDiCsEoMVgb7NQ zA1obA72fekhGAAQ== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (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 imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 0E43313D6B; Tue, 30 Nov 2021 19:40:06 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id GMaQAhZ+pmEGSAAAMHmgww (envelope-from ); Tue, 30 Nov 2021 19:40:06 +0000 Message-ID: Date: Tue, 30 Nov 2021 20:40:05 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.3.2 Content-Language: en-US To: Brijesh Singh , Joerg Roedel , Dave Hansen Cc: Peter Gonda , x86@kernel.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, linux-coco@lists.linux.dev, linux-mm@kvack.org, linux-crypto@vger.kernel.org, Thomas Gleixner , Ingo Molnar , Tom Lendacky , "H. Peter Anvin" , Ard Biesheuvel , Paolo Bonzini , Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Andy Lutomirski , Dave Hansen , Sergio Lopez , Peter Zijlstra , Srinivas Pandruvada , David Rientjes , Dov Murik , Tobin Feldman-Fitzthum , Borislav Petkov , Michael Roth , "Kirill A . Shutemov" , Andi Kleen , tony.luck@intel.com, marcorr@google.com, sathyanarayanan.kuppuswamy@linux.intel.com References: <20210820155918.7518-1-brijesh.singh@amd.com> <5f3b3aab-9ec2-c489-eefd-9136874762ee@intel.com> <38282b0c-7eb5-6a91-df19-2f4cfa8549ce@intel.com> <9503ac53-1323-eade-2863-df11a5f36b6a@amd.com> <7e368c50-ff94-d87e-e93f-bae044659152@suse.cz> From: Vlastimil Babka Subject: Re: [PATCH Part2 v5 00/45] Add AMD Secure Nested Paging (SEV-SNP) Hypervisor Support In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org On 11/29/21 17:13, Brijesh Singh wrote: >> >> That could work for the kmap() context. >> What to do for the userspace context (host userspace)? >> - shared->private transition - page has to be unmapped from all userspace, >> elevated refcount (gup() in progress) can block this unmap until it goes >> away - could be doable > > An unmap of the page from all the userspace process during the page state > transition will be great. If we can somehow store the state information in > the 'struct page' then it can be later used to make better decision. I am > not sure that relying on the elevated refcount is the correct approach. e.g > in the case of encrypted guests, the HV may pin the page to prevent it from > migration. > > Thoughts on how you want to approach unmaping the page from userspace page > table? After giving it more thought and rereading the threads here it seems I thought it would be easier than it really is, and it would have to be something at least like Kirill's hwpoison based approach. >> - still, what to do if host userspace then tries to access the unmapped >> page? SIGSEGV instead of SIGBUS and it can recover? >> > > Yes, SIGSEGV makes sense to me. OTOH the newer fd-based proposal also IIUC takes care of this part better - the host userspace controls the guest's shared->private conversion requests so it can't be tricked to access a page that's changed under it. >> >> >>> Thoughts ? >>> >>>> >>>> This should turn an RMP fault in the kernel which is not covered in the >>>> uaccess exception table into a fatal error. >>>> >>>> Regards, >>>> >>