Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp219571yba; Tue, 23 Apr 2019 23:19:59 -0700 (PDT) X-Google-Smtp-Source: APXvYqwsrAdz49ayClYrVBIbjp9cWzZ4WBNfji4wshc+yw3jgxwNg6zAKqCXfH4R18fkr/ku6xZG X-Received: by 2002:a62:4115:: with SMTP id o21mr31453658pfa.153.1556086799265; Tue, 23 Apr 2019 23:19:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556086799; cv=none; d=google.com; s=arc-20160816; b=o1b82U6XtZtiX94Mr9+x/bAHTuMoZ4AwvgaOCMauVpQ+JrkzVEyUYbvU2kHmmmWf+I Yz4aiuIhFLv6rHJWtYI9E6Q8pD4RL2GBfoGxe4JqdrblW4Pp1NxahieVTklKxCbbwI0k defzYaZ+AZAjg+Un29SytKVkyUBDeny0J9884R+iHrfNTXfdauwG58zABd9yFTM2P5dL VW8vJVmvGU0icBharK/gDstN7dBxwFLXTKSVIA4pUIkMkdnlEg5iD3Zrnq1J0PdsOHjG 3LEFrBiM5xFO9IpoSiKJRp+LJI1OmF3U8C6ovHthaY6lzUWIFG5DBJUF7+HcsodGGkf2 S8Gw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=SEf3noqNQ2kzxG4LWvcWvaCgH3RTzrdUOA69NUXO8bU=; b=hM+a5ADOmYl0aJxjn1AgnjcNyvuSEp2d0ytG3j+EqwdzSxU5d7EkY1FHqhmjE4sWcJ Wp29OdPijnkUvt8q5gT1dCEfSHTj2kBIQ5LCN6lZBnPied3zttONjw95WTSxPCRBk0RI hEdTw278PnAv5Q8nDpFUhaisNyGM/LEWembBM4VYjj738rbYLGPoPVh7goREbbNAP1u0 D8vO8DOnaMsVVWaZG8Y0eBwXi/38y1rTzsY42HYFvTUWWk/1bfDbTNM8MyVBJtdIyy5K MSku/hUlqYQHFPEbFoRVWyKQibgxJUeTS3IMSSXbJ1jw41onL1jvS40ddNa9sV8SD2Xm cS/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=YnX2l9JJ; 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=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d3si17456769pgh.238.2019.04.23.23.19.43; Tue, 23 Apr 2019 23:19:59 -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=@kernel.org header.s=default header.b=YnX2l9JJ; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729598AbfDXF5P (ORCPT + 99 others); Wed, 24 Apr 2019 01:57:15 -0400 Received: from mail.kernel.org ([198.145.29.99]:36068 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729244AbfDXF5P (ORCPT ); Wed, 24 Apr 2019 01:57:15 -0400 Received: from guoren-Inspiron-7460 (23.83.240.247.16clouds.com [23.83.240.247]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 1ED3020685; Wed, 24 Apr 2019 05:57:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1556085434; bh=V9Pz+gYUFLVTL56/7KV0ypL1it59CR9uq1PLv5VuzB0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=YnX2l9JJBTVusTxchGtFcEp6fQM0t93aRf1lW0yDXmE5Bxxp4zbsetVjL4CPQCT2W HmdGWm9G8rlkHmLD1gDyEhK95ywFbfnvWNTRacNmVV2dOMwMRIUWYt0J/791yBGyTQ CJ5asGfoMJaZBslWZa5j/9FzfRVL83DHkzhgZXMw= Date: Wed, 24 Apr 2019 13:57:03 +0800 From: Guo Ren To: Gary Guo Cc: Christoph Hellwig , "linux-arch@vger.kernel.org" , Palmer Dabbelt , Andrew Waterman , Arnd Bergmann , Anup Patel , Xiang Xiaoyan , "linux-kernel@vger.kernel.org" , Mike Rapoport , Vincent Chen , Greentime Hu , "ren_guo@c-sky.com" , "linux-riscv@lists.infradead.org" , Marek Szyprowski , Robin Murphy , Scott Wood , "tech-privileged@lists.riscv.org" Subject: Re: [PATCH] riscv: Support non-coherency memory model Message-ID: <20190424055703.GA3417@guoren-Inspiron-7460> References: <1555947870-23014-1-git-send-email-guoren@kernel.org> <20190422161814.GA30694@lst.de> <20190423001348.GA31639@guoren-Inspiron-7460> <20190423055548.GA12365@lst.de> <20190423154642.GA16001@guoren-Inspiron-7460> <20190424020803.GA27332@guoren-Inspiron-7460> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Gary, On Wed, Apr 24, 2019 at 03:21:14AM +0000, Gary Guo wrote: > > Look: > > linux-next git:(riscv_asid_allocator_v2)$ grep GLOBAL arch/riscv -r > > arch/riscv/include/asm/pgtable-bits.h:#define _PAGE_GLOBAL (1 << 5) /* > > Global */ > > arch/riscv/include/asm/pgtable-bits.h: _PAGE_USER | > > _PAGE_GLOBAL)) > > > > Your patch tell us _PAGE_USER and _PAGE_GLOBAL are duplicate and why we > > couldn't make _PAGE_USER implies _PAGE_GLOBAL? Can you give an example > > of a real scene in PTE about: > > _PAGE_USER:0 + _PAGE_GLOBAL:1 > > or > > _PAGE_USER:1 + _PAGE_GLOBAL:0 > > > > Of cause I know USER & GLOBAL are conceptually very different, but > > there are only 10 attribute-bits for riscv (In fact we've wasted two bits > > to support huge RV32-pfn :P). So I think it is time to merge these two bits > > before hardware supports GLOBAL. Reserve them for future! > > Two cases I can think of: > * vdso like things. They're user pages that can really be shared across address spaces (i.e. global). Kernels like L4 implement most systems calls similar to VDSO, so USER + GLOBAL is useful. Vdso is a user space mapping in linux, See: fs/binfmt_elf.c static int load_elf_binary(struct linux_binprm *bprm) { ... #ifdef ARCH_HAS_SETUP_ADDITIONAL_PAGES retval = arch_setup_additional_pages(bprm, !!elf_interpreter); if (retval < 0) goto out; #endif /* ARCH_HAS_SETUP_ADDITIONAL_PAGES */ All linux archs use arch_setup_additional_pages for vdso mapping and every process has its own vdso mapping to the same pages. I don't think vdso is a real scene for GLOBAL in PTE. > * hypervisor without H-extension: This requires shadow page tables. Supervisor > pages are mapped to supervisor shadow pages. However these shadow pages cannot > be GLOBAL because they can't be shared between VMs. So !USER + !GLOBAL is useful. Hypervisor use 2-stages TLB translation in hardware and shadow page tables is for stage 2 translation. Shadow page tables care vmid not asid. If hardware don't support H-extension (MMU 2-stages translation), it's hard to accept for virtualization performance. I don't think hypervisor is a real scene for GLOBAL in PTE. Are there other scene for GLOBAL in PTE? Best Regards Guo Ren