Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp7068992ybi; Thu, 1 Aug 2019 02:44:50 -0700 (PDT) X-Google-Smtp-Source: APXvYqwwK22pvxC0W3WTiKeDSMMKZzukQ3uSiWwI9qEn+W58BAz3bNuNHyaGNO+hi3wiradylQnA X-Received: by 2002:a17:902:204:: with SMTP id 4mr38250913plc.178.1564652690306; Thu, 01 Aug 2019 02:44:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564652690; cv=none; d=google.com; s=arc-20160816; b=UnT5koPwI/npMkSGk5MRpflAs7Wq7haI42t3pQfLWxJogICn41n0S3YyV6ESN9/8yW Hi86bEzXxwZWn6WYadbZS16GKGJNsg74f8+zaLe8bMnDdOz1xp0jnjuCaGZyPftnw+5b i1XY5hbk6av4pT7hKFcbye4JAYSqilkDCatpdnwVUWOuYpAqK6ewQRAUYq/dJl1B5MWz bGGVia7yCHlQ9bBvZykvvkSwPQ3MPdMedjkgO0cVdnyieFt5xBtpMEQ6v0d55zCmenpg 52j8KzVJFrnilJCgxi1tptBjsjvR30MDLgjWJzazTYdVxXOKyJdPD0t2aICLO6kdx+DZ Sebg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=PBTnLCvDSjUrM5VA6hRLwxeWErZVATZCYstiolhIwfY=; b=f0834ypiANTvttHTbT2Q13orl13z0dotKIJfzwpR4Ds4IyzCeQfTKDAnzQa0jfnEgR 0XxDY0RLiB6vyCUdIYnwRrY/UqSoTh1b23dVQWAJSf8twma1jv6R1PVQL2I+TmVJRf6M eUCzg02Vk0Q/FvJRuAmcc4HMbzRmkmlyoIoRe9C+R2T51w1TiSo5qVlsDljRsF3absnK 31UB94+CQ2w/HKMm2DcZ17tNNSumrUqX5EaT+tEyDLHCjmx4fqVrJ9VkiDih10NlvSaX j+bbeI7Gp++HGsIPx+r6nRvPktc0ZpkPM7jFQzBDsf7LSnbJrB6Kk+aAKu11ja3kxqGY rEfQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=NoLb0vr0; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c127si39260974pga.569.2019.08.01.02.44.34; Thu, 01 Aug 2019 02:44:50 -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=@gmail.com header.s=20161025 header.b=NoLb0vr0; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728065AbfHAI40 (ORCPT + 99 others); Thu, 1 Aug 2019 04:56:26 -0400 Received: from mail-ed1-f66.google.com ([209.85.208.66]:33570 "EHLO mail-ed1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725283AbfHAI40 (ORCPT ); Thu, 1 Aug 2019 04:56:26 -0400 Received: by mail-ed1-f66.google.com with SMTP id i11so4919492edq.0 for ; Thu, 01 Aug 2019 01:56:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=PBTnLCvDSjUrM5VA6hRLwxeWErZVATZCYstiolhIwfY=; b=NoLb0vr03SaJFiFBi/AvOZ0tOGsl2F71+ULfqAHJQdNz1s6+g8ouEys8/MJETlTZEN srka9oQ1P7WPq65ngL0VmuS1fNb5kjPDXdTqtz1GLjJMS6YGrv8HmUFKH7WkNZDzAAcx 0eTb6+UXViDSIC+/jTCaQe4v72rH4sd7pZy1SNaAFmftnAdoChzd8/Mj09Idt0i2cYu2 cCYjF0UNolnQqV22RklzJJemUVinGgMLueDcFA2ZgJtgWaImKjmbkQst3rMS3KA0Q+th J7VvC6MqN6JDp1NFQpRDE9XMj9zktpMPZFpIdWoT6n0eymISZrqf0/Z088JDdIonV2pf 1B5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=PBTnLCvDSjUrM5VA6hRLwxeWErZVATZCYstiolhIwfY=; b=lg2wWoK/RhS2rDwxvH9ifIkRRUzbkexC4s5LWyxxTw8sF17c9ONPrF6GAw+nB30T1S XJI1X5CyUUI0jvTjtLChYNaniuEsl5BaB2uwXUuctAKzDIbc5WpsS+gJ+07cEQcoAMZJ jsr+AZFZgR/2VSU8rRvygGxOw7iA94cUDTIn/6Y/7jqQ3BRZ393YrGccwIsmXyFZ/zNz Wnn8TslUlbgHsLavkqlgzABdFx8FS+Mxz8ftEeJksx+2he00gvjTiO0J7ss9aQ4QkkYj vJ3TMYuHnfFS4DWs5t/+CjlmsfWNiG/ggm5nem7A49cRAvyXctQRi8oNmg0XztSy9TaP U6iA== X-Gm-Message-State: APjAAAURJmaCKuRMgYor1yo0UGPahfQdUspnq52gH/2WT6A3KEdmpDRB ppk8s5sTBmUoi8MpZDGIzpU4RCJInCG3cBzJLpk= X-Received: by 2002:a17:906:fc5:: with SMTP id c5mr56482594ejk.129.1564649783883; Thu, 01 Aug 2019 01:56:23 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Bin Meng Date: Thu, 1 Aug 2019 16:56:12 +0800 Message-ID: Subject: Re: [PATCH] riscv: kbuild: add virtual memory system selection To: Paul Walmsley Cc: linux-riscv , linux-kernel , Alexandre Ghiti Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Aug 1, 2019 at 3:37 AM Paul Walmsley wrote: > > On Sun, 28 Jul 2019, Bin Meng wrote: > > > The spec does not mention 40-bit physical addresses, but 56-bit. > > Thanks, agreed. Updated patch below > > > - Paul > > From: Paul Walmsley > Date: Fri, 26 Jul 2019 10:21:11 -0700 > Subject: [PATCH v2] riscv: kbuild: add virtual memory system selection > > The RISC-V specifications currently define three virtual memory > translation systems: Sv32, Sv39, and Sv48. Sv32 is currently specific > to 32-bit systems; Sv39 and Sv48 are currently specific to 64-bit > systems. The current kernel only supports Sv32 and Sv39, but we'd > like to start preparing for Sv48. As an initial step, allow the > virtual memory translation system to be selected via kbuild, and stop > the build if an option is selected that the kernel doen't currently > support. > > This second version of the patch fixes some errors in the Kconfig > description text, found by Bin Meng . > > This patch currently has no functional impact. > > Signed-off-by: Paul Walmsley > Cc: Alexandre Ghiti > Cc: Bin Meng > --- > arch/riscv/Kconfig | 43 +++++++++++++++++++++++++++++ > arch/riscv/include/asm/pgtable-32.h | 4 +++ > arch/riscv/include/asm/pgtable-64.h | 4 +++ > 3 files changed, 51 insertions(+) > > diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig > index 59a4727ecd6c..f5e76e25a91e 100644 > --- a/arch/riscv/Kconfig > +++ b/arch/riscv/Kconfig > @@ -155,6 +155,49 @@ config MODULE_SECTIONS > bool > select HAVE_MOD_ARCH_SPECIFIC > > +choice > + prompt "Virtual Memory System" > + default RISCV_VM_SV32 if 32BIT > + default RISCV_VM_SV39 if 64BIT > + help > + The RISC-V Instruction Set Manual Volume II: Privileged > + Architecture defines several different "virtual memory > + systems" which specify virtual and physical address formats > + and the structure of page table entries. This determines > + the amount of virtual address space present and how it is > + translated into physical addresses. > + > + config RISCV_VM_SV32 > + depends on 32BIT > + bool "RISC-V Sv32" > + help > + The Sv32 virtual memory system is a page-based > + address and page table format for RV32 systems. > + It specifies a translation between 32-bit virtual > + addresses and 33-bit physical addresses, via a > + two-stage page table layout. > + config RISCV_VM_SV39 > + depends on 64BIT > + bool "RISC-V Sv39" > + help > + The Sv39 virtual memory system is a page-based > + address and page table format for RV64 systems. > + It specifies a translation between 39-bit virtual > + addresses and 56-bit physical addresses, via a > + three-stage page table layout. > + config RISCV_VM_SV48 > + depends on 64BIT > + bool "RISC-V Sv48" > + help > + The Sv48 virtual memory system is a page-based > + address and page table format for RV64 systems. > + It specifies a translation between 48-bit virtual > + addresses and 56-bit physical addresses, via a > + four-stage page table layout. > + > +endchoice > + > + > choice > prompt "Maximum Physical Memory" > default MAXPHYSMEM_2GB if 32BIT > diff --git a/arch/riscv/include/asm/pgtable-32.h b/arch/riscv/include/asm/pgtable-32.h > index b0ab66e5fdb1..86d41a04735b 100644 > --- a/arch/riscv/include/asm/pgtable-32.h > +++ b/arch/riscv/include/asm/pgtable-32.h > @@ -6,6 +6,10 @@ > #ifndef _ASM_RISCV_PGTABLE_32_H > #define _ASM_RISCV_PGTABLE_32_H > > +#if !defined(CONFIG_RISCV_VM_SV32) > +#error Only Sv32 supported > +#endif > + > #include > #include > > diff --git a/arch/riscv/include/asm/pgtable-64.h b/arch/riscv/include/asm/pgtable-64.h > index 74630989006d..86935595115d 100644 > --- a/arch/riscv/include/asm/pgtable-64.h > +++ b/arch/riscv/include/asm/pgtable-64.h > @@ -6,6 +6,10 @@ > #ifndef _ASM_RISCV_PGTABLE_64_H > #define _ASM_RISCV_PGTABLE_64_H > > +#if !defined(CONFIG_RISCV_VM_SV39) > +#error Only Sv39 supported for now > +#endif > + > #include > > #define PGDIR_SHIFT 30 > -- Reviewed-by: Bin Meng