Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp606088pxu; Thu, 3 Dec 2020 08:17:13 -0800 (PST) X-Google-Smtp-Source: ABdhPJzYJkJl4yMaQA0myjJb/47GCFcXBqE061gvPdKfVKzyitcNLT0PEbMKfq8RJbIWqud0j65A X-Received: by 2002:a17:907:2122:: with SMTP id qo2mr1085903ejb.539.1607012232885; Thu, 03 Dec 2020 08:17:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607012232; cv=none; d=google.com; s=arc-20160816; b=aTml9K/DBidOVnIGqX2kGN5//mmgTWrdmlDY8YPDl1lN4nlz7wIGLfRH2LJos6rIA6 kG10XoPu2W+hys5FGDIhvi35R/yddx+3/xrxmvkBA4Za/uSgqHrpH/5+eCVtmVZChACz sf9wCSRggWr0Ag7ysyL42uIYTZIIrweO3ybbe3CUbyoxIHCznAFKNfy36ANoyA/2FGBh zTSwrxOAxTnnDYjyWLSiweyQKbfc5phtWH/Oxk16YiGYRLBitgmJcU8RWo2+oha8ExIr 7tDznmvGG7NCM//6Tdpaj93DcpqfMSsJr19sSECMg4C6aB4AYwawicU7z7TM6iXfYaMm xXpQ== 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:date:from:sender:dkim-signature; bh=3C2IXAzqvDwlkSCP0xY3vlc/cNVEEj2yRnHaCw31rPw=; b=o5Mh3d1+JtYLqZphpUhxZJ6ugNTx0Ax+qK8XrA9NPyPqstp9kPtfLsMsrDcWs4xpp0 Ci9suvkVAH/B5wZTU3ZsxdEEZfNZTgl/Q9SfNHYn3HtF6woB5JkLfGl+aKrs7sEjVfg+ gijLs54ME7l2thc1V8LvIqLH6egLW5yDR3WENSa3sQ5IVi9g8fyJ5VM9CtQmjP2UnKWV mTDfAyvSRf4Bm9J+Nqq/cYsucVY0jmL1FV/PUt+aSDTSYPr5gmoDM1QQ8d8bxa0JitkJ D1mO83cpnZESH1ppC69TUVrzho9Z7fyaoduUjWG2p3/J65AwMwQJwiDR/xA7P24TY/H9 et1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=O3ScHLjO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k1si1420860ejz.139.2020.12.03.08.16.48; Thu, 03 Dec 2020 08:17:12 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=O3ScHLjO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389324AbgLCQOu (ORCPT + 99 others); Thu, 3 Dec 2020 11:14:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56456 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389318AbgLCQOu (ORCPT ); Thu, 3 Dec 2020 11:14:50 -0500 Received: from mail-qt1-x844.google.com (mail-qt1-x844.google.com [IPv6:2607:f8b0:4864:20::844]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C588FC061A4E for ; Thu, 3 Dec 2020 08:14:09 -0800 (PST) Received: by mail-qt1-x844.google.com with SMTP id r6so1721029qtm.3 for ; Thu, 03 Dec 2020 08:14:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:date:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=3C2IXAzqvDwlkSCP0xY3vlc/cNVEEj2yRnHaCw31rPw=; b=O3ScHLjOE4nAdbi1Lea4bUAn1LU1kQb/kuBnh0lUPCh2f1xOigDCreW4IGQeEfPaCM BUkW52UkoFJ0LEfNJj/Ef7cqSVx1FBft91mndnNkrMkF8KJyd0Go0UQI7lVCy9Uc+cRs ieAwj/81yQgu7NjZwRjweg/OUVCxLoDzjGL4Db/XWmx8mYJKpAjwcVO0pOqiL8oLDw5+ T0ppQaow61wKiI0yi94jVhh6RBjonx6PeOptvxuR8gSSo9eehX2aMJEG26DEb+6rjfZh iqVKluh0EfseA0IoeYt7zcwLslxCEkHDvYoGLO55iIiY1I3cSlFqdHv5PVWwPsPxB7XN JY4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:date:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to; bh=3C2IXAzqvDwlkSCP0xY3vlc/cNVEEj2yRnHaCw31rPw=; b=Gu+sn+0Fc13/RNB1ZOHQfQPOr17pjlj75DIlx1yToSvJdPc9vhy3ubglBlqouNKKaQ eqNARVf6PomLoRPW3bqErzq8HpmS4L5voEEvvX1RZTBTPh33WbgkiVnEcGgyv0mfE98O KkJdoi5jgury1l/hYlupXLOMK4Mg+eu40JD97Q4rBh2isu2suxCHqdvm8s6m1xRM7Cl1 Ugg/BIV+TYN+sU6wfSKuXPvHjOWW3qK8pPJjdD8DUR7SeRRInkx1jqYNYXVNDw4DT0mf EY8vBW6W3ppW02FR20CVgpNyD/OYiGSSNVP2YQY+SOEaOdZZNvn9MGnehNN5EKEdjTJg h0GQ== X-Gm-Message-State: AOAM5333oqtQLtE/u8PB5lYmS012oXMDXL9GfQOn4Nev5kKU4AUplVE8 hh3B+62ClIrPHeO9HhRyCPg= X-Received: by 2002:ac8:7a95:: with SMTP id x21mr3914143qtr.307.1607012048849; Thu, 03 Dec 2020 08:14:08 -0800 (PST) Received: from rani.riverdale.lan ([2001:470:1f07:5f3::b55f]) by smtp.gmail.com with ESMTPSA id 9sm1894554qkm.81.2020.12.03.08.14.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Dec 2020 08:14:07 -0800 (PST) Sender: Arvind Sankar From: Arvind Sankar X-Google-Original-From: Arvind Sankar Date: Thu, 3 Dec 2020 11:14:06 -0500 To: Borislav Petkov Cc: Arvind Sankar , Tom Lendacky , x86@kernel.org, Kim Phillips , Yazen Ghannam , Pu Wen , linux-kernel@vger.kernel.org Subject: Re: [PATCH] x86/cpu/amd: Remove dead code for TSEG region remapping Message-ID: References: <20201127171324.1846019-1-nivedita@alum.mit.edu> <20201127172747.GE13163@zn.tnic> <20201203084857.GD3059@zn.tnic> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20201203084857.GD3059@zn.tnic> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Dec 03, 2020 at 09:48:57AM +0100, Borislav Petkov wrote: > On Wed, Dec 02, 2020 at 05:32:32PM -0500, Arvind Sankar wrote: > > The pfn_range_is_mapped() call just checks whether it is mapped at all > > in the direct mapping. Is the TSEG range supposed to be marked as > > non-RAM in the E820 map? AFAICS, the only case when a direct mapping is > > created for non-RAM is for the 0-1Mb real-mode range, and that will > > always use 4k pages. Above that anything not marked as RAM will create > > an unmapped hole in the direct map, so in this case the memory just > > below the TSEG base would already use smaller pages if needed. > > > > If it's possible that the E820 mapping says this range is RAM, then > > should we also break up the direct map just after the end of the TSEG > > range for the same reason? > > So I have a machine where TSEG is not 2M aligned and somewhere in the 1G > range: > > [ 1.135094] tseg: 003bf00000 > > It is not in the E820 map either: > > [ 0.019784] init_memory_mapping: [mem 0x00000000-0x000fffff] > [ 0.020014] init_memory_mapping: [mem 0x3bc00000-0x3bdfffff] > [ 0.020166] init_memory_mapping: [mem 0x20000000-0x3bbfffff] > [ 0.020327] init_memory_mapping: [mem 0x00100000-0x1fffffff] > [ 0.020677] init_memory_mapping: [mem 0x3be00000-0x3be8ffff] > > That doesn't mean that it can happen that there might be some > configuration where it ends up being mapped. > > So looking at what the code does, it kinda makes sense: you want the 2M > range between 0x3be00000 and 0x3c000000 to be split into 4K mappings, > *if* it is mapped. > > I need to find a box where it is mapped *and* not 2M aligned, though, > for testing. Which appears kinda hard to do as all the new ones are > aligned. Do any of them have it mapped at all, regardless of the alignment? There seems to be nothing else in the kernel that ever looks at the TSEG MSR, so I would guess that it has to be non-RAM in the E820 map, otherwise nothing would prevent the kernel from allocating and using that space. I found the actual original commit, which does has a description of the reasoning. It's 8346ea17aa20 ("x86: split large page mapping for AMD TSEG") It looks like at the time, the direct mapping didn't really look at the E820 map in any detail, and was always set up with at least 2Mb pages, or Gb pages if they were available, from 0 to max_pfn_mapped. So the direct mapping would have covered even holes that weren't in the E820 map. Commit 66520ebc2df3 ("x86, mm: Only direct map addresses that are marked as E820_RAM") changed the direct map setup to avoid mapping holes, because it apparently became more serious than performance issues: this commit mentions MCE's getting triggered because of the overmapping. > > The above is from a K8 box which should already be dead, as a matter of > fact. > > -- > Regards/Gruss, > Boris. > > https://people.kernel.org/tglx/notes-about-netiquette