From patchwork Mon Feb 5 15:48:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiko Carstens X-Patchwork-Id: 196879 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp961463dyb; Mon, 5 Feb 2024 07:49:41 -0800 (PST) X-Google-Smtp-Source: AGHT+IGEjs2nSNwUtidROPDsvUOq1LIciIoX2H4b7S9Uzp0vOwdWfmVuTnWAKbaLce1d8lKWQRDC X-Received: by 2002:a05:6808:99a:b0:3bf:de66:cda2 with SMTP id a26-20020a056808099a00b003bfde66cda2mr65151oic.46.1707148181247; Mon, 05 Feb 2024 07:49:41 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707148181; cv=pass; d=google.com; s=arc-20160816; b=YWzlrGAgELGSoe0hdqqKJ4Vkg1E9uxYra6GXqRHenOi6ucIQj4ElVCNybI5h4XEA/d 7Oj7HIiJvOxmY8nm8mO6SGpUGlWXwPKRRVqQhhmh5pVlP6ZtU8qtC4NRwhuKRGV4o3yt WR4GvsLnsPDwMIfbCGPPPbC0La9wTPHmmsBw81IvmZOtxiSyrT9WTkOEQ9UDP8EByTiK invutVcoZUrCUPhJ6JUGPPfHOjZdgFgXx+2iZ4MiovkTzCrAMVOnTr0XB5zGSOI13tza ah2OGzEjJOg6WKRrVDHvPhksH4ZJHkZVjlRKeKmvnSEYcoz0HX+Zf2BojTEB6oac/NKV 1HmA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :content-transfer-encoding:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=PIj80zllNqkfH4CbEH1UNiL5y7/XAz4sdfYcehyLvwE=; fh=tEFCE/uvBVSw2e8hbDFnlRZWQmFAqXG/u99029E5T1Q=; b=LR5SDyBlGgTVjXaqzQudhn8CXLJZR5Fh+0wsQr2huu0gh4GCSFUihSoSezrnU6I1zc XaV96SQPcorWHaOqHPoBL/Ia6ND0AmFqa0e58qlkDI+fdL+A4qAVCek0yi21XGKI4hHa HUJk5Yb1A8SxnEQeJKFotFKmQi9wIIGyB01pw1Bq/574IZCKayOVymnMFudUKp1N610K lFhS2xQGi8svPhQDEFXIi7ve4dg4A2DsTZ6sbIi17AlLs/nyAzv1xtXrF0joVJbxrDtQ wciBCE+HOTvdQXMLyQ45hf43Uf7GfVsXV78VSSxVdJ5wjmcUxoExsPeMfqiLjge94AUn t+gQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=Qs7V20L5; arc=pass (i=1 spf=pass spfdomain=linux.ibm.com dkim=pass dkdomain=ibm.com dmarc=pass fromdomain=linux.ibm.com); spf=pass (google.com: domain of linux-kernel+bounces-52945-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-52945-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com X-Forwarded-Encrypted: i=1; AJvYcCVIPjA3q9tsYh4g06g2JSf9N6HZszngnqKenk2H9mRzvd4MV64XzmA1x59harTpXF2kezIokxmNq5on5V5QoS9GmYHGsA== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id vz14-20020a05620a494e00b007857ab7549bsi86318qkn.251.2024.02.05.07.49.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Feb 2024 07:49:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-52945-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=Qs7V20L5; arc=pass (i=1 spf=pass spfdomain=linux.ibm.com dkim=pass dkdomain=ibm.com dmarc=pass fromdomain=linux.ibm.com); spf=pass (google.com: domain of linux-kernel+bounces-52945-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-52945-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 0C6E91C22017 for ; Mon, 5 Feb 2024 15:49:41 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C39823FE5F; Mon, 5 Feb 2024 15:48:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="Qs7V20L5" Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2275E2E417; Mon, 5 Feb 2024 15:48:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.156.1 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707148136; cv=none; b=LYac9AoGj/D+/rZFbTA6ygq/TkOVoqvTRlmM0k+Mvgl/koydAA8tJB9EqRGd6OY9fyy4l9YYM1NlZPdbw1k2D0b2vWBy2Bl0iUCDIhGZrERY4W2CQabM1/jnIgZFdQzTB6YhE2OHmelngMTxfil5TiFTpyuCAaDxeFqSVVyEBBA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707148136; c=relaxed/simple; bh=4GpfbZ2TFsq7JnL4hPEixlhDO6oCAPgBkfULLDcsLwc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=aogNPK3gWX6Ri6q88/BtVndk2w2aKlYIY7XbOHiDRF3e7MlWx85+du0ZhfxFiYZqmmWU5GABcF2WFK17ZkE1Fzv+UUjLAHHYpdIIqMnLUFMr7TDrNLzu9klv1JhpX3Pe+c4yu1zo/yWYgQQ+J0S69b8YZ0KbR2y+vQvkoADoyuo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=Qs7V20L5; arc=none smtp.client-ip=148.163.156.1 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Received: from pps.filterd (m0353729.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 415FgDbt019713; Mon, 5 Feb 2024 15:48:51 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : mime-version; s=pp1; bh=PIj80zllNqkfH4CbEH1UNiL5y7/XAz4sdfYcehyLvwE=; b=Qs7V20L59VisxoGY3PYfmiXZadLKg6xTxv2iVhmOHAqc3EZjrK7rEHy0UNP1qPvWEk8S mzTLTa9Bu+3IEkp3b02dIMGS5MEuWn5rp0hr3xvr1w2dguVDS8I2wDCbt7Dfl59UIM8u EIouK7NQ0PClJMJmgWtpcFE0g7ZWog+e7G+TWK6r9GiB+iji7FJzg0fp8iuYoiuyuvrv uvC1Ytm7oKlrXevHRWnO0SniQ1Ls3UeM3w3KOIZ8FvDFslWwvaV2cjuJWDgJNswKsm6b 4TuI0HbJuTm1MYOJJQKMfscwrPU8cfN7Xs4zOqEwRGUHsPo6UUq615bH3xaOMKzENvry Fg== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3w32j007vf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 05 Feb 2024 15:48:50 +0000 Received: from m0353729.ppops.net (m0353729.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 415FgOmc020637; Mon, 5 Feb 2024 15:48:50 GMT Received: from ppma22.wdc07v.mail.ibm.com (5c.69.3da9.ip4.static.sl-reverse.com [169.61.105.92]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3w32j007uy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 05 Feb 2024 15:48:50 +0000 Received: from pps.filterd (ppma22.wdc07v.mail.ibm.com [127.0.0.1]) by ppma22.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 415DDCDW008758; Mon, 5 Feb 2024 15:48:48 GMT Received: from smtprelay06.fra02v.mail.ibm.com ([9.218.2.230]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3w206y9he0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 05 Feb 2024 15:48:48 +0000 Received: from smtpav03.fra02v.mail.ibm.com (smtpav03.fra02v.mail.ibm.com [10.20.54.102]) by smtprelay06.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 415Fmjp919661162 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 5 Feb 2024 15:48:45 GMT Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8CFAF20043; Mon, 5 Feb 2024 15:48:45 +0000 (GMT) Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 56A4C2004B; Mon, 5 Feb 2024 15:48:45 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by smtpav03.fra02v.mail.ibm.com (Postfix) with ESMTP; Mon, 5 Feb 2024 15:48:45 +0000 (GMT) From: Heiko Carstens To: Kees Cook , Nathan Chancellor , Nick Desaulniers Cc: linux-kernel@vger.kernel.org, linux-s390@vger.kernel.org, Vasily Gorbik , Alexander Gordeev Subject: [PATCH 1/2] Compiler Attributes: Add __uninitialized macro Date: Mon, 5 Feb 2024 16:48:43 +0100 Message-Id: <20240205154844.3757121-2-hca@linux.ibm.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240205154844.3757121-1-hca@linux.ibm.com> References: <20240205154844.3757121-1-hca@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-GUID: wi9a64xAkzuDakLO5HAnrDh7zXf2ZXid X-Proofpoint-ORIG-GUID: MZexhMpaL87nb2c4TOhf222vS46Rr41A X-Proofpoint-UnRewURL: 0 URL was un-rewritten Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-02-05_10,2024-01-31_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 phishscore=0 mlxlogscore=999 lowpriorityscore=0 malwarescore=0 clxscore=1015 bulkscore=0 suspectscore=0 impostorscore=0 mlxscore=0 priorityscore=1501 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2402050119 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790074611226688993 X-GMAIL-MSGID: 1790074611226688993 With INIT_STACK_ALL_PATTERN or INIT_STACK_ALL_ZERO enabled the kernel will be compiled with -ftrivial-auto-var-init=<...> which causes initialization of stack variables at function entry time. In order to avoid the performance impact that comes with this users can use the "uninitialized" attribute to prevent such initialization. Therefore provide the __uninitialized macro which can be used for cases where INIT_STACK_ALL_PATTERN or INIT_STACK_ALL_ZERO is enabled, but only selected variables should not be initialized. Signed-off-by: Heiko Carstens Acked-by: Kees Cook Reviewed-by: Nathan Chancellor --- include/linux/compiler_attributes.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/include/linux/compiler_attributes.h b/include/linux/compiler_attributes.h index 28566624f008..f5859b8c68b4 100644 --- a/include/linux/compiler_attributes.h +++ b/include/linux/compiler_attributes.h @@ -333,6 +333,18 @@ */ #define __section(section) __attribute__((__section__(section))) +/* + * Optional: only supported since gcc >= 12 + * + * gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Variable-Attributes.html#index-uninitialized-variable-attribute + * clang: https://clang.llvm.org/docs/AttributeReference.html#uninitialized + */ +#if __has_attribute(__uninitialized__) +# define __uninitialized __attribute__((__uninitialized__)) +#else +# define __uninitialized +#endif + /* * gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-unused-function-attribute * gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Type-Attributes.html#index-unused-type-attribute From patchwork Mon Feb 5 15:48:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiko Carstens X-Patchwork-Id: 196892 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp966727dyb; Mon, 5 Feb 2024 07:59:20 -0800 (PST) X-Google-Smtp-Source: AGHT+IEjnbDXFzjtzdu3tuPuwtcCAGtBDJix2ZsRuIOenZdi8PATvJpfr7nIE3LYNZvDozUetGQX X-Received: by 2002:a17:903:94d:b0:1d8:b6c8:d9e0 with SMTP id ma13-20020a170903094d00b001d8b6c8d9e0mr10708271plb.68.1707148759802; Mon, 05 Feb 2024 07:59:19 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707148759; cv=pass; d=google.com; s=arc-20160816; b=Wo/88g0ucrrMlkMO/kozWkczxTiqWE2+ROwZo/36UK2tRUIh2zgM612cHFtQnx8T00 h0HWsimxKX4NtD6+guK2j49amWtSGEvkRcLfkQmdaSLzoak0hJGRwU8b6xW4B/oPWGEZ gVKUxCTSk9d7FnTsT2xYUCAo6WtUEGu3DDLH4cpsv/x/DuwWrTq2RY9hxd+ya/9XL0f0 INSB6RoMeF8GYkRCgQS90FknHbZ3L09jZAgm6J5M77KQP4s6KiK4qgpGrVUNcOXTeeHU TvlYSB+JaYo/tni51rvTp4O1pYsnhfa6LoWhKxOS9LvuDkdgT6PUhfk1P2SgIFKL3XsE F02Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=byL1VZic0PAkagwNpfsFqhW47Ni0iSoIxFYu0LryJo4=; fh=ikuG6fm0hSqvjLyrSqhCDjc2QOevTz+oGMWw6eNAbRs=; b=SxVRBhukSoduE9SfUO5kOZhzF0Lqg4U2I+e5BWMnKcZ1bJo9cTwQJyMDLc2Vhv8s3N 2GwESWSGmkyozc+BmHVgYQ/ISALhL/sS+qT9ay3ZBZXGU8g+iAJ1bw9fhGPZewtK+rtq amaFoyAGX0XxhJ9mYsDD4bXBX4xlWHSTQ6f4UBDZBdXLavi5BRO2YtjjZJF8P5/46QmC UCr9L0XJeb9tKuR02Z4mHOaetQ+IywZDSb3FSnO9yTxTOTrk7J0Qi7mmTSo+pNE2D4Fe g3Y/5FlIvWGSw9b2XM0MG/QR9gP9iuG1j+1/m0lwSQyDmFCoHeJP9mOsbfypBWexAbMv 4zqw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=ZJkhX9jj; arc=pass (i=1 spf=pass spfdomain=linux.ibm.com dkim=pass dkdomain=ibm.com dmarc=pass fromdomain=linux.ibm.com); spf=pass (google.com: domain of linux-kernel+bounces-52946-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-52946-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com X-Forwarded-Encrypted: i=1; AJvYcCVbZ6Gft7v7w/3SuS3J3UEyNj2BhAdxQRh2aCo9lhpsOaLt916bQM630ivISObQ3NXWmVfwRxHMUePP+uOaQ7m82RLtgQ== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id a20-20020a170902ee9400b001d92086fe43si29930pld.436.2024.02.05.07.59.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Feb 2024 07:59:19 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-52946-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=ZJkhX9jj; arc=pass (i=1 spf=pass spfdomain=linux.ibm.com dkim=pass dkdomain=ibm.com dmarc=pass fromdomain=linux.ibm.com); spf=pass (google.com: domain of linux-kernel+bounces-52946-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-52946-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 3E31D287AD7 for ; Mon, 5 Feb 2024 15:49:47 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 20CE340C0C; Mon, 5 Feb 2024 15:49:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="ZJkhX9jj" Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 67F172C6A6; Mon, 5 Feb 2024 15:48:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.158.5 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707148137; cv=none; b=a7KqOifBLo0Jj1dU2StKhliJ1uEQX/lf1sQbtCifRUMD8QVd/faIYMNh2pLaWVkIkUY2/uRMUAtgIIdq6ycCSIBRwtXLP7LzlsRWk5Jj3pl4RhB+Wi/bVXIPUfXP10TPnmWAA5Hqaakhv2aixck634t8kAD4gwGlMdUuJm6nZow= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707148137; c=relaxed/simple; bh=WQKDA6ycF9zyAiJKm/9j1u2voHFq4rPW4zGv0elkG0U=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=HHuabQqnKSdjqlDepThpCegGB4pUzzmBc3dv54Xgxvweqr3SL5mxE8LUdOIGdBA7FpYVtNOEPFfahjRMeQiAYTnq8ftWnY3RvQVy7+kNtRdJDd10RlDDGBHE/if7yFPZqIKo5+3bW3zaNMTRSAxqPjmAJpIiFYo8V2xYTVZWcNI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=ZJkhX9jj; arc=none smtp.client-ip=148.163.158.5 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Received: from pps.filterd (m0353723.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 415FTKAR029375; Mon, 5 Feb 2024 15:48:50 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=byL1VZic0PAkagwNpfsFqhW47Ni0iSoIxFYu0LryJo4=; b=ZJkhX9jjobfE/sT4cTQNKdqmw+lrIMGT6R3z3d9xu5KsEPKW/g5U4aUUYMp7uL/Gfdbn J6m71xm44FAYqRVkxtA4gHFxa/RDzaNwGrcvz8dmup4QA+ZLLNd05LqdhQQ2SOl9gJZE STeujizWFLnf2+tkaXV0KIFUsVQVNuwEjVWPHvdR++XaPrFmr3iOhZNWlCP7nMF2S5g5 mAgo43lW/1Un5t+5HGNdux/6tAC+y1840sOGaEMuxGSnN09iFrlXvBO9Sws1QWcCB0ek lWX8e7hNrU5OgxoO+pDyIxW+BSMsjOK7LUwOqadDV+b2AqB3xKfc6Ipe3cK0dmXkgerN MQ== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3w32bx8pf8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 05 Feb 2024 15:48:50 +0000 Received: from m0353723.ppops.net (m0353723.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 415FdIsm007223; Mon, 5 Feb 2024 15:48:50 GMT Received: from ppma13.dal12v.mail.ibm.com (dd.9e.1632.ip4.static.sl-reverse.com [50.22.158.221]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3w32bx8pet-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 05 Feb 2024 15:48:49 +0000 Received: from pps.filterd (ppma13.dal12v.mail.ibm.com [127.0.0.1]) by ppma13.dal12v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 415EpLMT008519; Mon, 5 Feb 2024 15:48:49 GMT Received: from smtprelay06.fra02v.mail.ibm.com ([9.218.2.230]) by ppma13.dal12v.mail.ibm.com (PPS) with ESMTPS id 3w221js0k0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 05 Feb 2024 15:48:49 +0000 Received: from smtpav03.fra02v.mail.ibm.com (smtpav03.fra02v.mail.ibm.com [10.20.54.102]) by smtprelay06.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 415Fmj6f19661164 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 5 Feb 2024 15:48:46 GMT Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id CC41320043; Mon, 5 Feb 2024 15:48:45 +0000 (GMT) Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 969962004D; Mon, 5 Feb 2024 15:48:45 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by smtpav03.fra02v.mail.ibm.com (Postfix) with ESMTP; Mon, 5 Feb 2024 15:48:45 +0000 (GMT) From: Heiko Carstens To: Kees Cook , Nathan Chancellor , Nick Desaulniers Cc: linux-kernel@vger.kernel.org, linux-s390@vger.kernel.org, Vasily Gorbik , Alexander Gordeev Subject: [PATCH 2/2] s390/fpu: make use of __uninitialized macro Date: Mon, 5 Feb 2024 16:48:44 +0100 Message-Id: <20240205154844.3757121-3-hca@linux.ibm.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240205154844.3757121-1-hca@linux.ibm.com> References: <20240205154844.3757121-1-hca@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: sTRo0zi2J2zYRPUPIc8TYQ-XRqG4f-Gh X-Proofpoint-ORIG-GUID: jgcjCb9p1o1Bo_dS6_KzVs51MqdBDXpP X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-02-05_10,2024-01-31_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 impostorscore=0 phishscore=0 mlxscore=0 malwarescore=0 suspectscore=0 lowpriorityscore=0 adultscore=0 clxscore=1015 mlxlogscore=999 priorityscore=1501 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2402050119 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790075218153179777 X-GMAIL-MSGID: 1790075218153179777 Code sections in s390 specific kernel code which use floating point or vector registers all come with a 520 byte stack variable to save already in use registers, if required. With INIT_STACK_ALL_PATTERN or INIT_STACK_ALL_ZERO enabled this variable will always be initialized on function entry in addition to saving register contents, which contradicts the intend (performance improvement) of such code sections. Therefore provide a DECLARE_KERNEL_FPU_ONSTACK() macro which provides struct kernel_fpu variables with an __uninitialized attribute, and convert all existing code to use this. This way only this specific type of stack variable will not be initialized, regardless of config options. Signed-off-by: Heiko Carstens Reviewed-by: Kees Cook Reviewed-by: Nathan Chancellor --- arch/s390/crypto/chacha-glue.c | 2 +- arch/s390/crypto/crc32-vx.c | 2 +- arch/s390/include/asm/fpu/types.h | 3 +++ arch/s390/kernel/sysinfo.c | 2 +- lib/raid6/s390vx.uc | 4 ++-- 5 files changed, 8 insertions(+), 5 deletions(-) diff --git a/arch/s390/crypto/chacha-glue.c b/arch/s390/crypto/chacha-glue.c index ed9959e6f714..a823132fc563 100644 --- a/arch/s390/crypto/chacha-glue.c +++ b/arch/s390/crypto/chacha-glue.c @@ -22,7 +22,7 @@ static void chacha20_crypt_s390(u32 *state, u8 *dst, const u8 *src, unsigned int nbytes, const u32 *key, u32 *counter) { - struct kernel_fpu vxstate; + DECLARE_KERNEL_FPU_ONSTACK(vxstate); kernel_fpu_begin(&vxstate, KERNEL_VXR); chacha20_vx(dst, src, nbytes, key, counter); diff --git a/arch/s390/crypto/crc32-vx.c b/arch/s390/crypto/crc32-vx.c index 017143e9cef7..6ae3e3ff5b0a 100644 --- a/arch/s390/crypto/crc32-vx.c +++ b/arch/s390/crypto/crc32-vx.c @@ -49,8 +49,8 @@ u32 crc32c_le_vgfm_16(u32 crc, unsigned char const *buf, size_t size); static u32 __pure ___fname(u32 crc, \ unsigned char const *data, size_t datalen) \ { \ - struct kernel_fpu vxstate; \ unsigned long prealign, aligned, remaining; \ + DECLARE_KERNEL_FPU_ONSTACK(vxstate); \ \ if (datalen < VX_MIN_LEN + VX_ALIGN_MASK) \ return ___crc32_sw(crc, data, datalen); \ diff --git a/arch/s390/include/asm/fpu/types.h b/arch/s390/include/asm/fpu/types.h index d889e9436865..b1afa13c07b7 100644 --- a/arch/s390/include/asm/fpu/types.h +++ b/arch/s390/include/asm/fpu/types.h @@ -35,4 +35,7 @@ struct kernel_fpu { }; }; +#define DECLARE_KERNEL_FPU_ONSTACK(name) \ + struct kernel_fpu name __uninitialized + #endif /* _ASM_S390_FPU_TYPES_H */ diff --git a/arch/s390/kernel/sysinfo.c b/arch/s390/kernel/sysinfo.c index f6f8f498c9be..b439f17516eb 100644 --- a/arch/s390/kernel/sysinfo.c +++ b/arch/s390/kernel/sysinfo.c @@ -426,9 +426,9 @@ subsys_initcall(create_proc_service_level); */ void s390_adjust_jiffies(void) { + DECLARE_KERNEL_FPU_ONSTACK(fpu); struct sysinfo_1_2_2 *info; unsigned long capability; - struct kernel_fpu fpu; info = (void *) get_zeroed_page(GFP_KERNEL); if (!info) diff --git a/lib/raid6/s390vx.uc b/lib/raid6/s390vx.uc index cd0b9e95f499..7b0b355e1a26 100644 --- a/lib/raid6/s390vx.uc +++ b/lib/raid6/s390vx.uc @@ -81,7 +81,7 @@ static inline void COPY_VEC(int x, int y) static void raid6_s390vx$#_gen_syndrome(int disks, size_t bytes, void **ptrs) { - struct kernel_fpu vxstate; + DECLARE_KERNEL_FPU_ONSTACK(vxstate); u8 **dptr, *p, *q; int d, z, z0; @@ -114,7 +114,7 @@ static void raid6_s390vx$#_gen_syndrome(int disks, size_t bytes, void **ptrs) static void raid6_s390vx$#_xor_syndrome(int disks, int start, int stop, size_t bytes, void **ptrs) { - struct kernel_fpu vxstate; + DECLARE_KERNEL_FPU_ONSTACK(vxstate); u8 **dptr, *p, *q; int d, z, z0;