Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2904224rwd; Wed, 14 Jun 2023 08:42:41 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6JxIRnJx8WjN0EC0PDvXXS6glRpCzlm71PjYi17epJMkusjA4X6Mln9NL1HnH1KdJyA7Pn X-Received: by 2002:a92:cd06:0:b0:33b:1635:359f with SMTP id z6-20020a92cd06000000b0033b1635359fmr13207102iln.22.1686757360860; Wed, 14 Jun 2023 08:42:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686757360; cv=none; d=google.com; s=arc-20160816; b=b0DaN6rSDPod50fqaBJTeGM9+f/mOHc52j+hYP5tt6DRSVQqQ/P+RxfN8Hncii0x3Y tT0Bz1Bspa2tK2JJRYMRJe/sg/YZuE2moRRIirBAzfLP07XptoO3slJkB1wmNWFC2TGx TBG2TIu0HLrc4/I62R8UBn1PmuY5UIIs+CcFlYCpTX7YNVRTf993UZrl7PffhaDcZttM Hty/C/lSIedlrn213o/gX6V7jd0j3PLb+D7ReckNoCAToWb9EoTRe4q0igMGTH9A/FTU vsxFRE/0kpg3Y3M3WwX/IIlszzTyyj+DnUqnXKCN0p2o/mN9Cohs3NdRxXeR2lTXD121 rWUg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=ABTVelKqxcbKy1Dr7WYpgzkVdsLrgfVOqAwBMONhGfc=; b=LyRo82+MU3gILyytBPCvLHU9xg8LyAuT/KsjEcb5rfWfpI+wjg2skvfvk2d5tSrHD4 h0W+XRwibcsexN38uct7RZese1wkrVgVs9TxeWYY04+wAUi0E49jUIVyx+Bc/ENRiYWi QK7/k3oNnmQ1gp3t4gIYbxL01FwsuMPnN1jA6zuSWXavWI9+P02ghpB7zHrBjc7hvkcF 2QVnqEqX5Jcq7d+GQZuorHscGl6HXnU4MMNJqoUCWXW7yjWxegQOvkNRW9xIfRVfFWg3 5exZ3lcZCtEk1T26BNmfn5mBCHKUO5RXuT55D+lve7toKSPRT5lwbwCnwVVmr5DsycPT POXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=BiZlGtQ1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w26-20020a63935a000000b0053b8570baafsi10692621pgm.444.2023.06.14.08.42.28; Wed, 14 Jun 2023 08:42:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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=@intel.com header.s=Intel header.b=BiZlGtQ1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236349AbjFNOp2 (ORCPT + 99 others); Wed, 14 Jun 2023 10:45:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33730 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235889AbjFNOp1 (ORCPT ); Wed, 14 Jun 2023 10:45:27 -0400 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BBF951BE8 for ; Wed, 14 Jun 2023 07:45:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1686753926; x=1718289926; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=6v6TbjeMW8U/IbxBNH5DXiK4YQ9SM1BrYJGznxX5fKw=; b=BiZlGtQ1EVqEb+3BOg/cyg5WN9Zg+XxJBSxrmpvLJiVi55HySylQZ0go ObYGjX9tA95MTO7FG1wPF+9bJga+LK+GsTVmOQ19FOfFhCyjzAM4muRi5 kwwfHusm0LWkvGCxy997WONk5ewZ463rZHq9qOzWqU0Q+oSubFpgTNJYi wfVKJFmAaWIDZF/Af9TTztS0PsEtEWxY5c/qL7AJDYS/6N5UrTTsQ2y+X tK3U08JkElhAwYsviJOSuhWm4Tmz1QbCPRbExHxLTnXJOnagD2iCnLHf7 Y74knSMGz9We3ycU/szCOb43E/VXfB54vYsoPuF/NqxE/oYRWs4j2vNQd g==; X-IronPort-AV: E=McAfee;i="6600,9927,10741"; a="362002433" X-IronPort-AV: E=Sophos;i="6.00,242,1681196400"; d="scan'208";a="362002433" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Jun 2023 07:45:25 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10741"; a="662420636" X-IronPort-AV: E=Sophos;i="6.00,242,1681196400"; d="scan'208";a="662420636" Received: from ngarg3-mobl3.amr.corp.intel.com (HELO [10.212.191.43]) ([10.212.191.43]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Jun 2023 07:45:24 -0700 Message-ID: <0cefb67a-6fae-daa2-c871-ae35b96aac08@intel.com> Date: Wed, 14 Jun 2023 07:45:24 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 Subject: Re: x86: pgtable / kaslr initialisation (OOB) help Content-Language: en-US To: Lee Jones , Peter Zijlstra Cc: Dave Hansen , Andy Lutomirski , Thomas Gleixner , Ingo Molnar , Borislav Petkov , x86@kernel.org, "H. Peter Anvin" , linux-kernel@vger.kernel.org, linux-mm@kvack.org References: <20230614132339.GS3635807@google.com> <20230614141654.GA1640123@hirez.programming.kicks-ass.net> <20230614143732.GW3635807@google.com> From: Dave Hansen In-Reply-To: <20230614143732.GW3635807@google.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED 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-kernel@vger.kernel.org On 6/14/23 07:37, Lee Jones wrote: > Still unsure how we (the kernel) can/should write to an area of memory > that does not belong to it. Should we allocate enough memory > (2*PAGE_SIZE? rather than 8-Bytes) for trampoline_pgd_entry to consume > in a more sane way? No. I think this: set_pgd(&trampoline_pgd_entry, __pgd(_KERNPG_TABLE | __pa(p4d_page_tramp))); is bogus-ish. set_pgd() wants to operate on a pgd_t inside a pgd *PAGE*. But it's just being pointed at a single _entry_. The address of 'trampoline_pgd_entry' in your case also just (unfortunately) happens to pass the: __pti_set_user_pgtbl -> pgdp_maps_userspace() test. I _think_ we want these to just be something like: trampoline_pgd_entry = __pgd(_KERNPG_TABLE | __pa(p4d_page_tramp); That'll keep us away from all of the set_pgd()-induced nastiness.