From patchwork Fri Apr 29 21:07:54 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Shi X-Patchwork-Id: 66974 Delivered-To: patch@linaro.org Received: by 10.140.93.198 with SMTP id d64csp1016208qge; Fri, 29 Apr 2016 14:34:14 -0700 (PDT) X-Received: by 10.66.25.133 with SMTP id c5mr32131340pag.104.1461965654867; Fri, 29 Apr 2016 14:34:14 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id vh16si20056935pab.164.2016.04.29.14.34.14; Fri, 29 Apr 2016 14:34:14 -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=@linaro.org; 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 dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752868AbcD2VeM (ORCPT + 29 others); Fri, 29 Apr 2016 17:34:12 -0400 Received: from mail-pa0-f52.google.com ([209.85.220.52]:34302 "EHLO mail-pa0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752379AbcD2VeK (ORCPT ); Fri, 29 Apr 2016 17:34:10 -0400 Received: by mail-pa0-f52.google.com with SMTP id r5so51129848pag.1 for ; Fri, 29 Apr 2016 14:34:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=ZY8kKM9Rjn/vvXSIVl13ZcNiD1uBVyKwXVFIswksmQQ=; b=daQDTneGvPpUZiBjzR8NZcm3V/dlXV6x3H0hMbKJ2JA8pL7iOPmIAMXEbXeU0tNwoe P1fQAXOp0+zd1+DG6uCfJI4e+dD/vPmZja0Rdp+EaGiFMf6EAMkPjgvtqwohb+B8/fbU hxpPRyLUw+OowVvpXuJzi94Q5AiuzZ48sValc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=ZY8kKM9Rjn/vvXSIVl13ZcNiD1uBVyKwXVFIswksmQQ=; b=EiLars0FDYGDnal9Ldw+TlQqvwyvH6rF1ZH+x8BLQYdrhDbrPKEbtZCKdSPOrZ+O1J Y8OZ5CYB10Ef7ebeb7wRbkrZqfAF7Rlzuw0q+JQjwdSRKbzrZchsGm/xYrfUVvTHXV56 +q/gO0BEJ+c5MzwtGXGzGhRdhduFpRFaF4CQcX/9hgJQ4ArwAlrskQZZNvXjClSQHPG5 l/3IF2HcmhnS6ixUpf97l95LMSWg8chpwrlY41o3ZdIYmHnDH9ubD8qUGzalpU4jrnlG zHHrzA6tBHUgciNTkyeP9ydd5F+tkiKvIXgXypNfUz0H0SAGph+GVl+x5zhjSHzx7QPI qrQg== X-Gm-Message-State: AOPr4FXnSQW+/Hr9FiXQNElWaNzpSXIBDJ4P/WpPxabm1EkbxOTxfV8RolTRJDR8b0cGZB4Y X-Received: by 10.66.160.201 with SMTP id xm9mr32032476pab.68.1461965649882; Fri, 29 Apr 2016 14:34:09 -0700 (PDT) Received: from yshi-Precision-T5600.corp.ad.wrs.com (unknown-216-82.windriver.com. [147.11.216.82]) by smtp.gmail.com with ESMTPSA id m12sm25847708pfi.5.2016.04.29.14.34.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 29 Apr 2016 14:34:09 -0700 (PDT) From: Yang Shi To: will.deacon@arm.com, catalin.marinas@arm.com Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linaro-kernel@lists.linaro.org, yang.shi@linaro.org, Arnd Bergmann , Ard Biesheuvel Subject: [PATCH] arm64: always use STRICT_MM_TYPECHECKS Date: Fri, 29 Apr 2016 14:07:54 -0700 Message-Id: <1461964074-12544-1-git-send-email-yang.shi@linaro.org> X-Mailer: git-send-email 2.0.2 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Inspired by the counterpart of powerpc [1], which shows there is no negative effect on code generation from enabling STRICT_MM_TYPECHECKS with a modern compiler. And, Arnd's comment [2] about that patch says STRICT_MM_TYPECHECKS could be default as long as the architecture can pass structures in registers as function arguments. ARM64 can do it as long as the size of structure <= 16 bytes. All the page table value types are u64 on ARM64. The below disassembly demonstrates it, entry is pte_t type: entry = arch_make_huge_pte(entry, vma, page, writable); 0xffff00000826fc38 <+80>: and x0, x0, #0xfffffffffffffffd 0xffff00000826fc3c <+84>: mov w3, w21 0xffff00000826fc40 <+88>: mov x2, x20 0xffff00000826fc44 <+92>: mov x1, x19 0xffff00000826fc48 <+96>: orr x0, x0, #0x400 0xffff00000826fc4c <+100>: bl 0xffff00000809bcc0 [1] http://www.spinics.net/lists/linux-mm/msg105951.html [2] http://www.spinics.net/lists/linux-mm/msg105969.html Signed-off-by: Yang Shi CC: Arnd Bergmann CC: Ard Biesheuvel --- arch/arm64/include/asm/pgtable-types.h | 32 -------------------------------- 1 file changed, 32 deletions(-) -- 2.0.2 Acked-by: Arnd Bergmann Acked-by: Catalin Marinas diff --git a/arch/arm64/include/asm/pgtable-types.h b/arch/arm64/include/asm/pgtable-types.h index 2b1bd7e..69b2fd4 100644 --- a/arch/arm64/include/asm/pgtable-types.h +++ b/arch/arm64/include/asm/pgtable-types.h @@ -27,10 +27,6 @@ typedef u64 pmdval_t; typedef u64 pudval_t; typedef u64 pgdval_t; -#undef STRICT_MM_TYPECHECKS - -#ifdef STRICT_MM_TYPECHECKS - /* * These are used to make use of C type-checking.. */ @@ -58,34 +54,6 @@ typedef struct { pteval_t pgprot; } pgprot_t; #define pgprot_val(x) ((x).pgprot) #define __pgprot(x) ((pgprot_t) { (x) } ) -#else /* !STRICT_MM_TYPECHECKS */ - -typedef pteval_t pte_t; -#define pte_val(x) (x) -#define __pte(x) (x) - -#if CONFIG_PGTABLE_LEVELS > 2 -typedef pmdval_t pmd_t; -#define pmd_val(x) (x) -#define __pmd(x) (x) -#endif - -#if CONFIG_PGTABLE_LEVELS > 3 -typedef pudval_t pud_t; -#define pud_val(x) (x) -#define __pud(x) (x) -#endif - -typedef pgdval_t pgd_t; -#define pgd_val(x) (x) -#define __pgd(x) (x) - -typedef pteval_t pgprot_t; -#define pgprot_val(x) (x) -#define __pgprot(x) (x) - -#endif /* STRICT_MM_TYPECHECKS */ - #if CONFIG_PGTABLE_LEVELS == 2 #include #elif CONFIG_PGTABLE_LEVELS == 3