Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp4439972imw; Tue, 12 Jul 2022 08:01:04 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tsU4nXEHXo9dTwPqXJJ0qKlhFu56p1h0HKus7qYztEZvdplLriXtCPQ37ccboLS6DPnvEN X-Received: by 2002:a17:902:e747:b0:16c:3ffd:61e4 with SMTP id p7-20020a170902e74700b0016c3ffd61e4mr13683703plf.12.1657638063963; Tue, 12 Jul 2022 08:01:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657638063; cv=none; d=google.com; s=arc-20160816; b=eHsmt843xhQem8hNa6WipMiM+7mcsmoA2PEi62RMzRo3uJYpV32pvQJJBo2zykhrE5 XKENrDEwZ7KZ/SsJeTAj5DF8dtKTLH0XgoBpgdTj60w/nIE21lHPQHulnkxCinhb4Bva cemGgOU5i58aPRfeQEDNfADCCtwp1eOmH7/9be5Brc0+WO86+YFVmNgNzhECmcDT6V3u NddV+nW4BtHGEEmGL/7q1BrcgitNGI29nH6zeinPsDpXJCACKCOlJOaUeceEtOVlvOiP SzXMKN00QrPwcqpVFw6IsNp+gYl88XsX7HHysM0CTBywhhHVU00ywVAOnNWLNRNauaFC WA2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=UvIHOvehwZ+LUlek6c63Cs/tWYVVPW113KH383KcrzM=; b=GOw9vcMcfMoJxikjxp/U/53Ibjgp7YUlMX5FZA15jGBm6DqXqQaork7/VgalwRYvm2 0t8CAPjHqL3t9Jew0bKTV2aSXtKBmKjaVsqBftkZ55vjWmlhRAxjcyt5cSRzhRseKbbX Mj1YZqlrMVLwTo0mHOBkZ73/sLV4TkJI4SF0SOv+1LhiSVvbsvm6FFkmt2ES8JO9el/S sOtDwgpWhQmwAu1F/9jPCzu4QL2Efj4FBWxE3c8bVrJJ/EmVJH0X7iXe8otC/SlMr3he x5ZM+gmI/C1C2+tD+FPHnGaQxBSBVEX+SxhAiF5Gg7c185UpIbw7asYPbmSXEaOIrGcn wcng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=h60oAnU1; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bb4-20020a17090b008400b001efa68576e7si12129654pjb.72.2022.07.12.08.00.41; Tue, 12 Jul 2022 08:01:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=h60oAnU1; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233341AbiGLOyP (ORCPT + 99 others); Tue, 12 Jul 2022 10:54:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48384 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233812AbiGLOyL (ORCPT ); Tue, 12 Jul 2022 10:54:11 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 56ED620BDD; Tue, 12 Jul 2022 07:54:10 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id E881460C1A; Tue, 12 Jul 2022 14:54:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C65F4C341C0; Tue, 12 Jul 2022 14:54:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1657637649; bh=VkRGH3NNN+HIyw30NEGUMWuNTYMnRNznF6Yoz8xWvHE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=h60oAnU1aXZaRC7VpVhzHcRhXIV0KfZ9Zm2lzo6YT5TOw0wuZD1nO+KNGFKijNu34 lZMJhtnZZrJ70MJD808JKzGh4pRAxRdcL3a0ILc5SyRdisTaoaN366Hej78Ejbb9hU qQhKS8myxFGhQucR5emZKGxqwZouBqiCzh1hvojeRta93T3o+ZLOqYTTNwDbuWGHvN S3zKyxs52kUBo0yn5c18FEEkQbZthkLG59WuRvdr7PYWgFvCS36XTvHf6rkyjxirCj k0YNOyFS/olS3uOxmKphzfuDqxHtU9n41plGVYyb8bHq3C+1p8JS2e/sLZOKzUb4Ym xn26XlW9iX5Lw== Date: Tue, 12 Jul 2022 17:54:05 +0300 From: Jarkko Sakkinen To: "Kalra, Ashish" Cc: "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" , "tglx@linutronix.de" , "mingo@redhat.com" , "jroedel@suse.de" , "Lendacky, Thomas" , "hpa@zytor.com" , "ardb@kernel.org" , "pbonzini@redhat.com" , "seanjc@google.com" , "vkuznets@redhat.com" , "jmattson@google.com" , "luto@kernel.org" , "dave.hansen@linux.intel.com" , "slp@redhat.com" , "pgonda@google.com" , "peterz@infradead.org" , "srinivas.pandruvada@linux.intel.com" , "rientjes@google.com" , "dovmurik@linux.ibm.com" , "tobin@ibm.com" , "bp@alien8.de" , "Roth, Michael" , "vbabka@suse.cz" , "kirill@shutemov.name" , "ak@linux.intel.com" , "tony.luck@intel.com" , "marcorr@google.com" , "sathyanarayanan.kuppuswamy@linux.intel.com" , "alpergun@google.com" , "dgilbert@redhat.com" Subject: Re: [PATCH Part2 v6 09/49] x86/fault: Add support to handle the RMP fault for user address Message-ID: References: <0ecb0a4781be933fcadeb56a85070818ef3566e7.1655761627.git.ashish.kalra@amd.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org On Tue, Jul 12, 2022 at 02:29:18PM +0000, Kalra, Ashish wrote: > [AMD Official Use Only - General] > > >> +static int handle_user_rmp_page_fault(struct pt_regs *regs, unsigned long error_code, > >> + unsigned long address) > >> +{ > >> + int rmp_level, level; > >> + pte_t *pte; > >> + u64 pfn; > >> + > >> + pte = lookup_address_in_mm(current->mm, address, &level); > > >As discussed in [1], the lookup should be done in kvm->mm, along the lines of host_pfn_mapping_level(). > > With lookup_address_in_mm() now removed in 5.19, this is now using > lookup_address_in_pgd() though still using non init-mm, and as mentioned > here in [1], it makes sense to not use lookup_address_in_pgd() as it does > not play nice with userspace mappings, e.g. doesn't disable IRQs to block > TLB shootdowns and doesn't use READ_ONCE() to ensure an upper level entry > isn't converted to a huge page between checking the PAGE_SIZE bit and > grabbing the address of the next level down. > > But is KVM going to provide its own variant of lookup_address_in_pgd() > that is safe for use with user addresses, i.e., a generic version of > lookup_address() on kvm->mm or we need to duplicate page table walking > code of host_pfn_mapping_level() ? It's probably cpen coded for the sole reason that there is only one call site, i.e. there has not been rational reason to have a helper function. Helpers are usually created only in-need basis, and since the need comes from this patch set, it should include a patch, which simply encapsulates it into a helper. > > Thanks, > Ashish BR, Jarkko