From patchwork Thu Mar 1 01:02:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 879515 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3zsDkY4G2Lz9s3F for ; Thu, 1 Mar 2018 12:05:25 +1100 (AEDT) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="N1sTAsF4"; dkim-atps=neutral Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3zsDkY2PspzF1H5 for ; Thu, 1 Mar 2018 12:05:25 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="N1sTAsF4"; dkim-atps=neutral X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=chromium.org (client-ip=2607:f8b0:400e:c00::243; helo=mail-pf0-x243.google.com; envelope-from=keescook@chromium.org; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: lists.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="N1sTAsF4"; dkim-atps=neutral Received: from mail-pf0-x243.google.com (mail-pf0-x243.google.com [IPv6:2607:f8b0:400e:c00::243]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 3zsDgk2RgyzF1dj for ; Thu, 1 Mar 2018 12:02:55 +1100 (AEDT) Received: by mail-pf0-x243.google.com with SMTP id h19so874947pfd.12 for ; Wed, 28 Feb 2018 17:02:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:mime-version:content-disposition; bh=vbpeHCfUBWUEBIGlaxt3RYj3+QXHATaV6bvY3RhqF6E=; b=N1sTAsF4sQyD1ohjpTh+kojU+CFad6RAQ7/0NSS4xlaMsYHfbwtC3YtzOezecSnY9k pi/rOPiMjnglGLIyEXL/S7rtC7glABs/S1S9pX/cnMBW/9n0lzDCCg+uDaCbROBRp90F f4FKzAwByeL9md/+izjNAlj22qE5NMXCA8NHY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition; bh=vbpeHCfUBWUEBIGlaxt3RYj3+QXHATaV6bvY3RhqF6E=; b=EmtRDonosAoSTbObujdZ6ZQ4VcoQ5sEqUeXwEChiru4MGLzhE+goRnYIPAWAVc+MGt 9uO2GpPBi0broHEo+2iQdGXlID5Hvs3/kcdkFb7uk1AincfPWw/2VaIdiO64upXn8Yr9 1rl4f1JSqYdyBTnAAxazhyU53BLoWEllyZ3v2zWmYwIUS9x6TG7JpCyx+EnAMjhVfoPN zbYA2NZyJuD1BJ9FK9jk4iIdcARV8fS6xuHaHlKPLJ3dWgJ8/J/pqYXdbVSpowlZDyaI 4qQ1+Clvu+1va7aqRpaQtSsnpqiqzMpG1/lyHrH5ZfadJNEwrdP6GUeXGmT8BYxjOM9t dY0g== X-Gm-Message-State: APf1xPBld430LHRVSVpSHRXgRQ8EMpxewPA0I8hsbu7Dqs3lb49guPiW 8O0B7lQdOqhy2PYDg2r1YlqYOw== X-Google-Smtp-Source: AG47ELvPHdrsDyAhgsug3xeCBPJfKrGzl29rJrA6iRzuhVXhg/KDtydeQFGmMbAxLxyT3KiZVT4Vag== X-Received: by 10.98.227.10 with SMTP id g10mr56989pfh.200.1519866172314; Wed, 28 Feb 2018 17:02:52 -0800 (PST) Received: from www.outflux.net (173-164-112-133-Oregon.hfc.comcastbusiness.net. [173.164.112.133]) by smtp.gmail.com with ESMTPSA id 12sm5243492pfr.147.2018.02.28.17.02.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 28 Feb 2018 17:02:50 -0800 (PST) Date: Wed, 28 Feb 2018 17:02:49 -0800 From: Kees Cook To: Michael Ellerman Subject: [PATCH] powerpc: Keep const vars out of writable .sdata Message-ID: <20180301010249.GA18370@beast> MIME-Version: 1.0 Content-Disposition: inline X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-kernel@vger.kernel.org, Paul Mackerras , linuxppc-dev@lists.ozlabs.org Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" From: Segher Boessenkool Newer gcc will support "-mno-readonly-in-sdata"[1], which makes sure that the optimization on PPC32 for variables getting moved into the .sdata section will not apply to const variables (which must be in .rodata). This was originally noticed in mm/rodata_test.c when rodata_test_data was not static: c0695034 g O .data 00000004 rodata_test_data After this patch with an updated compiler, this is correctly in .rodata. [1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82411 Reported-by: Christophe Leroy Signed-off-by: Segher Boessenkool Signed-off-by: Kees Cook --- arch/powerpc/Makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile index ccd2556bdb53..c7628e973084 100644 --- a/arch/powerpc/Makefile +++ b/arch/powerpc/Makefile @@ -141,7 +141,9 @@ AFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mabi=elfv1) endif CFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mcmodel=medium,$(call cc-option,-mminimal-toc)) CFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mno-pointers-to-nested-functions) + CFLAGS-$(CONFIG_PPC32) := -ffixed-r2 $(MULTIPLEWORD) +CFLAGS-$(CONFIG_PPC32) += $(call cc-option,-mno-readonly-in-sdata) ifeq ($(CONFIG_PPC_BOOK3S_64),y) CFLAGS-$(CONFIG_GENERIC_CPU) += $(call cc-option,-mtune=power7,-mtune=power4)