Received: by 2002:a05:6358:bb9e:b0:b9:5105:a5b4 with SMTP id df30csp1693944rwb; Sat, 3 Sep 2022 23:38:23 -0700 (PDT) X-Google-Smtp-Source: AA6agR44KXoIk7AM2SMI5YSFul0lryaOQn6HU/nob+kYNuwKMbbqYuWJ0Wgra5ozll3yHV9Mzu2Y X-Received: by 2002:a05:6402:1388:b0:447:a3a4:6152 with SMTP id b8-20020a056402138800b00447a3a46152mr38976915edv.13.1662273502925; Sat, 03 Sep 2022 23:38:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662273502; cv=none; d=google.com; s=arc-20160816; b=iqITn0g9+UNrmaADu7z0+EoGA55U+xfCCvNesFTfA/FYZWB0AR7G67n/Ri0n/8YGqX qJjMZKckOxAjZz4/683KxbzkPLkABG7Eu0L9z4N0gpsVgjjT2xDgL3H1dLgKaB1SVqjX aMlN9kgK5sfwDe4wAr6qws1hBWyuMMDSK6p7adXY0DzHSCOHDussDmLsvNLd8qwUFHJb NECQknAp0RZ0Jb1ajMQZhlpfwFcJnTgJN2ANg0bJ8o6URiXb3rF6BoF9ijO1zwNqywKF Y8lG9hjdz9Ucu8JWfas/XZXlT8AwrajRcAdR5cPjtsiAwuIGGIqdJ1XbsP1HduFWDGgW p5Qg== 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-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=A/yg6xLScDG3nkcrMuFvwn0cTlwl9YzQi+dbx7SZXE4=; b=iat4je9uGE5VRfXrUQRAKKhIHgZHau3OrhKoF8p5Wl5eB04FIP4/qrJRmozx3HrJA2 F3Pf/P4I9Q8cm2P/0rtCk+k4tIhxdxgjVAuIey/sbZXSAZyKVqyYg8UNp0ywQdCupsOB CLPvSxXx3FjMsDUYfSKTm0Dp7HwpEcMvVhugBQ0er7LwwrbYh8cT3+hJt+H13rzJgYjs e1HPElQuUaEpQkFcsdK5E6DcynkWAGGhBqdKhUmTRhEOydsWZGxSIhroh9qEh8zTp3bE MTRD1kvpeyWEeS1ATDqwaB5LBOhmO+y1vtRaIMXAXZIk9NPAIOx093OSpnAjiKDYqcNz 2Kjg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=pN97dF0f; 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=alien8.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l6-20020a056402254600b00447820ba16dsi5213181edb.434.2022.09.03.23.37.45; Sat, 03 Sep 2022 23:38:22 -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=@alien8.de header.s=dkim header.b=pN97dF0f; 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=alien8.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229993AbiIDGhL (ORCPT + 99 others); Sun, 4 Sep 2022 02:37:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52794 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229537AbiIDGhK (ORCPT ); Sun, 4 Sep 2022 02:37:10 -0400 Received: from mail.skyhub.de (mail.skyhub.de [IPv6:2a01:4f8:190:11c2::b:1457]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C4DF0474C1; Sat, 3 Sep 2022 23:37:07 -0700 (PDT) Received: from nazgul.tnic (dynamic-002-247-250-198.2.247.pool.telefonica.de [2.247.250.198]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.skyhub.de (SuperMail on ZX Spectrum 128k) with ESMTPSA id 609571EC03EA; Sun, 4 Sep 2022 08:37:01 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1662273421; h=from:from:reply-to:subject:subject: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=A/yg6xLScDG3nkcrMuFvwn0cTlwl9YzQi+dbx7SZXE4=; b=pN97dF0fDmXybRWJ/KRiBRIBo09g3o8gogusERQNNw/JE8r+lwYvwNsl/Jei5OIwVjhq/B b4JnlpbPeLY2hOK5QXqEsipafAphSpvCQIRejvFSC4daKFKQhmr2vc9Y4uQKMLfCCpLJxz kn63o730nFrlWU4nmmHm95lGJS7I//U= Date: Sun, 4 Sep 2022 08:37:08 +0200 From: Borislav Petkov To: "Kalra, Ashish" Cc: "x86@kernel.org" , "linux-kernel@vger.kernel.org" , "kvm@vger.kernel.org" , "rientjes@google.com" , "linux-mm@kvack.org" , "linux-coco@lists.linux.dev" , "tglx@linutronix.de" , "slp@redhat.com" , "peterz@infradead.org" , "linux-crypto@vger.kernel.org" , "mingo@redhat.com" , "hpa@zytor.com" , "ak@linux.intel.com" , "Lendacky, Thomas" , "alpergun@google.com" , "jroedel@suse.de" , "dave.hansen@linux.intel.com" , "seanjc@google.com" , "pgonda@google.com" , "pbonzini@redhat.com" , "srinivas.pandruvada@linux.intel.com" , "ardb@kernel.org" , "dovmurik@linux.ibm.com" , "tobin@ibm.com" , "Roth, Michael" , "jmattson@google.com" , "kirill@shutemov.name" , "vkuznets@redhat.com" , "tony.luck@intel.com" , "vbabka@suse.cz" , "sathyanarayanan.kuppuswamy@linux.intel.com" , "luto@kernel.org" , "dgilbert@redhat.com" , "marcorr@google.com" , "jarkko@kernel.org" Subject: Re: [PATCH Part2 v6 09/49] x86/fault: Add support to handle the RMP fault for user address Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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 Sat, Sep 03, 2022 at 05:30:28PM +0000, Kalra, Ashish wrote: > There is 1 64-bit RMP entry for every physical 4k page of DRAM, so > essentially every 4K page of DRAM is represented by a RMP entry. Before we get to the rest - this sounds wrong to me. My APM has: "PSMASH Page Smash Expands a 2MB-page RMP entry into a corresponding set of contiguous 4KB-page RMP entries. The 2MB page’s system physical address is specified in the RAX register. The new entries inherit the attributes of the original entry. Upon completion, a return code is stored in EAX. rFLAGS bits OF, ZF, AF, PF and SF are set based on this return code..." So there *are* 2M entries in the RMP table. > So even if host page is 1G and underlying (smashed/split) RMP > entries are 2M, the RMP table entry has to be indexed to a 4K entry > corresponding to that. So if there are 2M entries in the RMP table, how does that indexing with 4K entries is supposed to work? Hell, even PSMASH pseudocode shows how you go and write all those 512 4K entries using the 2M entry as a template. So *before* you have smashed that 2M entry, it *is* an *actual* 2M entry. So if you fault on a page which is backed by that 2M RMP entry, you will get that 2M RMP entry. > If it was simply a 2M entry in the RMP table, then pmd_index() will > work correctly. Judging by the above text, it *can* *be* a 2M RMP entry! By reading your example you're trying to tell me that a RMP #PF will always need to work on 4K entries. Which would then need for a 2M entry as above to be PSMASHed in order to get the 4K thing. But that would be silly - RMP PFs will this way gradually break all 2M pages and degrage performance for no real reason. So this still looks real wrong to me. Thx. -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette