Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp4684942ybl; Mon, 26 Aug 2019 14:19:49 -0700 (PDT) X-Google-Smtp-Source: APXvYqxzGtUg+wjsY2gS/zD0WCNtxewWVBsCEPk/Mi3/pvYOv8ZHxsvIFHqM/EHAOXRLnY/lTay7 X-Received: by 2002:aa7:8559:: with SMTP id y25mr22011479pfn.260.1566854389414; Mon, 26 Aug 2019 14:19:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566854389; cv=none; d=google.com; s=arc-20160816; b=kxMpYG+FsydKB4HBcMU8KDBPR5KbjcCc9LwQ3MErwlc2DM2nxq9v6Hyr/rYbWmt5fL Gnev0KFpq+mpxMDT+D8kjqAvDogmCjLkBPjIj6BwmPjB1xXFq6AhGCXSPGWO2+rj2/gQ F8YmWt1asu7UexhSZlliWptQOD6okqqhfHwdcsr/SSVc6WOVhMoZ0K/aCsS70381Xgc1 vx9cObr7oBdvL1rqHonMeJXbr1ZcRHZvRxW8S3xPyeEf8EUA9Lt0LAEq6iyPjsdSST0g VdBfPzFP0L1GRhM7MAk60hqOW1KC4vRhgJyhUkdTYXHX/d8XW29bFnT2zxwpAOa71n0t WaMA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:to:from:cc:in-reply-to:subject:date:dkim-signature; bh=4iHMLHThNJBGjTESO+UXuVCPR4zQ2/5AcoKCoGrbBlQ=; b=Ma7vWIlRZWRsTIypYc2vk57wfLJHWc6hohitD/gpjyLY22Ry8FkJDKCF3CiVSXDxyZ zPBQdDUHK7T8GAMrBHi+Qe5KuqdFPfio9HBqj3Sy0AumMoh+qGYLBZ+B6E7z1jX1wzgX jK/50/IvWm818T8Inc9n+lcUEuJf4rdxRR68v5seTK6+i1Hc+x9zVbiiBO1vnsnPeX4V Wa/WcHwJ7Jq2BD310MLSSWrh4gjVCCerr6IHbjy5G59+l9B50yaDYaKRWGgHHcdyyBy6 eVaSUNf9e5JDhdgfKZ38x4XET3Vx5xczS7ltth7yri7TqFfqKYD0LvXWNSPfyzUgnx4p shKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=W5Be1yQ3; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 123si11872825pfy.61.2019.08.26.14.19.11; Mon, 26 Aug 2019 14:19:49 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=W5Be1yQ3; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727085AbfHZVRn (ORCPT + 99 others); Mon, 26 Aug 2019 17:17:43 -0400 Received: from mail-pg1-f196.google.com ([209.85.215.196]:42117 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725866AbfHZVRn (ORCPT ); Mon, 26 Aug 2019 17:17:43 -0400 Received: by mail-pg1-f196.google.com with SMTP id p3so11324846pgb.9 for ; Mon, 26 Aug 2019 14:17:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; h=date:subject:in-reply-to:cc:from:to:message-id:mime-version :content-transfer-encoding; bh=4iHMLHThNJBGjTESO+UXuVCPR4zQ2/5AcoKCoGrbBlQ=; b=W5Be1yQ3bDSisWGF6V4Q9m+ydc849sRP0naZI4+CYyzgn4o3VQnpOx3Nz4lDPmCgb9 H9DZHtmekFPPfLQDdKNYT+tFQHK1UGzMydODz/gQUzedYRB+/n7aw5Er8mkzEG02w9FJ gNM594n8bZMI744xF/MrnFagyk0yg3J501l8upZ8smL5ZCT7nQWuxGR8OaK2ey9QfMfL ztVjwtUq8XPta3pz2KS2xBCtwCCGD8pfAWFrfa2OCMFQd3ghu6k0VRLnlXYZkBZJ7yK6 LZkliejccx4b6agYqpa+wBaUSe7jmwEYytyF3ZHCANseop1sK8hqxxQb2OYrY8Tnac+I CdcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:subject:in-reply-to:cc:from:to:message-id :mime-version:content-transfer-encoding; bh=4iHMLHThNJBGjTESO+UXuVCPR4zQ2/5AcoKCoGrbBlQ=; b=JVWKf7crWWHlKK0UYAwoP95cpTD2gEVkepB5jjZKRpQR1NU0hskL9g+oMUm7WOAqDf X2FAR56SJF+cUj47PgO9is1nqHfwheFQOImKlKqU3yR5FPLfjGOWcC4ec6MlgpMuzpFC pPU5JRL5mD+KUgGdF2llubEbDlvOOidNz1wHKfVSy4daErYUryty29lljDFUml8Vu8KZ nFV1U98bvFOA7/Tkl1y2ng0M/Ag/d2bSU49Kc7WBOG1iVtOPqWK22CckF8hYp29hG3LT iTKj8kLR2bT2tRzX6vyrqGWQ/6GzGHA81RE894LtUzYYOwPx4wgsy9z7FGSBbSyJQVg2 vaNw== X-Gm-Message-State: APjAAAXGFrbH7SAdhl5SQFXsmp2wilpZihjaM+aQ2xWW0KW1QmktzHW0 3PzEfhrjnFxpsgUrfEgu23ovbA== X-Received: by 2002:a63:6206:: with SMTP id w6mr18127988pgb.428.1566854262237; Mon, 26 Aug 2019 14:17:42 -0700 (PDT) Received: from localhost ([12.206.222.5]) by smtp.gmail.com with ESMTPSA id m13sm12988366pgn.57.2019.08.26.14.17.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Aug 2019 14:17:41 -0700 (PDT) Date: Mon, 26 Aug 2019 14:17:41 -0700 (PDT) X-Google-Original-Date: Mon, 26 Aug 2019 14:17:38 PDT (-0700) Subject: Re: [PATCH] RISC-V: Fix FIXMAP area corruption on RV32 systems In-Reply-To: CC: Christoph Hellwig , Anup Patel , Paul Walmsley , linux-kernel@vger.kernel.org, Atish Patra , Alistair Francis , linux-riscv@lists.infradead.org From: Palmer Dabbelt To: anup@brainfault.org Message-ID: Mime-Version: 1.0 (MHng) Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, 18 Aug 2019 21:49:01 PDT (-0700), anup@brainfault.org wrote: > On Sun, Aug 18, 2019 at 11:49 PM Christoph Hellwig wrote: >> >> > +#define FIXADDR_TOP (VMALLOC_START) >> >> Nit: no need for the braces, the definitions below don't use it >> either. > > Sure, I will update and send v2 soon. > >> >> > +#ifdef CONFIG_64BIT >> > +#define FIXADDR_SIZE PMD_SIZE >> > +#else >> > +#define FIXADDR_SIZE PGDIR_SIZE >> > +#endif >> > +#define FIXADDR_START (FIXADDR_TOP - FIXADDR_SIZE) >> > + >> > /* >> > - * Task size is 0x4000000000 for RV64 or 0xb800000 for RV32. >> > + * Task size is 0x4000000000 for RV64 or 0x9fc00000 for RV32. >> > * Note that PGDIR_SIZE must evenly divide TASK_SIZE. >> > */ >> > #ifdef CONFIG_64BIT >> > #define TASK_SIZE (PGDIR_SIZE * PTRS_PER_PGD / 2) >> > #else >> > -#define TASK_SIZE VMALLOC_START >> > +#define TASK_SIZE FIXADDR_START >> > #endif >> >> Mentioning the addresses is a little weird. IMHO this would be >> a much nicer place to explain the high-level memory layout, including >> maybe a little ASCII art. Also we could have one #ifdef CONFIG_64BIT >> for both related values. Last but not least instead of saying that >> something should be dividable it would be nice to have a BUILD_BUG_ON >> to enforce it. >> >> Either way we are late in the cycle, so I guess this is ok for now: >> >> Reviewed-by: Christoph Hellwig >> >> But I'd love to see this area improved a little further as it is full >> of mine fields. > > I agree with you. We also have Sparsemem and KASAN patches which > touch virtual memory layout so it's important to have virtual memory layout > documented clearly. I can add the required documentation as separate patch. Documentation is great, but if we document something that is broken then it's still broken :) I think this needs to just be redone -- we keep running into issues here and fixing them, but there are probably more issues and it'll probably be faster to just think through the memory map than to keep fixing bugs as they crop up. This was one of the areas of the port I didn't rewrite as part of the upstream submission process, and as a result it's pretty crusty. > I think the best place to add ASCII art would be asm/pgtable.h where all > virtual memory related defines are placed. Suggestions??