Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp6596358rdb; Tue, 2 Jan 2024 07:06:13 -0800 (PST) X-Google-Smtp-Source: AGHT+IE1/re3ph0aquo1U0l2Beo19IbcsSEDvorRJ2JPe3Ad/w9dpbqX5kRrNyV7zNNCq0BdjVgb X-Received: by 2002:a05:6830:18e:b0:6dc:680a:6292 with SMTP id q14-20020a056830018e00b006dc680a6292mr1450387ota.37.1704207972768; Tue, 02 Jan 2024 07:06:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704207972; cv=none; d=google.com; s=arc-20160816; b=LqpmgQFwRlKyhnF5N/EoxwkDSByrWgYdecScdNcuc26YBUWga/Dj67HDM0rXuhNa+c MYAZwGdg/4pavKc35l7hdm/cq1y1HBIjySx78Tl9s3aCf2KY4x/X+VIPQ0mLe9Xqi1+U eNxhUwBFFpVtVFozQzoWcHCrsu7iqrywRV4a90fwTtNEo8SbYDDYxnAJHkTBZNn2nc2a smlzFhM+IHvzyVZ2TFxazlYq7DlWaXaJQS6Byc/SGkqxcskNhD8IPSnOj5amC+Q3k9ee 85ORGSSGUnC5Isiu4pvayN6AEaYy+nYL4AdXfzCaj8Y4/7YIA8PwKvdXhPFMoRJGkCW+ g5Qw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=yAUmslGfmAn/v408/JnMAl0laE6kfhNSkhNgHmtKlnU=; fh=mnX3wLuzTrkmgdlNsEgQXOForHn3WUzT3G0xt8tsRls=; b=IvqDLKlXkN3e/ydYYa0ObBpxaFMN68jYHYhFXupEf+OrpT/rOCyMgntkQi5v+IZi7j g+FbYiT/uKRYm5JrGXjsy3IIYTAUcKxjO6YWlRP4weYeEGXz/TWnkQDlnqa2nbo7HB4T lDh9ZXKSsPL9nEv5pVfoEdbMEsL2WSS1fq3tcsT3c7Q0rcUficehP+9SpON0iZReWOGP xZU4jZJBPmYjPXXU9vJdUGJaR85Lq/yjRPVBY37naPaMHDRy5pXaRPRCOsEFfyuj/2Aj LbwBzuHw+fhRmydTIw1WX+PwIKFUnDIdCN+SfUxxE5rmpzHcKoE0ynrhVzsg4tVcMXEx t/6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=ieo1go8j; spf=pass (google.com: domain of linux-kernel+bounces-14524-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-14524-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id e17-20020ab07e51000000b007cc1cef1e14si3406285uax.66.2024.01.02.07.06.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jan 2024 07:06:12 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-14524-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=ieo1go8j; spf=pass (google.com: domain of linux-kernel+bounces-14524-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-14524-linux.lists.archive=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 7DC681C223C6 for ; Tue, 2 Jan 2024 15:06:12 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 113A512E78; Tue, 2 Jan 2024 15:06:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="ieo1go8j" X-Original-To: linux-kernel@vger.kernel.org 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 E1C5912E6B; Tue, 2 Jan 2024 15:06:03 +0000 (UTC) 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 (m0353727.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 402EQJ9x007842; Tue, 2 Jan 2024 15:05:39 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=date : from : to : cc : subject : message-id : references : mime-version : content-type : in-reply-to; s=pp1; bh=yAUmslGfmAn/v408/JnMAl0laE6kfhNSkhNgHmtKlnU=; b=ieo1go8j8kWEwJEEg5WO5vqKGg10aSk8+UtbSP/lq+gTsFu7bhHsL8dk9O0Pyb0xCOka lPLOwNHlS9mVhlub+fQfuNPYrAWqE8+/bDNkHm5Q9D7TzRwMTeu5kykgM+1BePfhuD1d bug+utmcst7Ol4gcDORK8Ef0cc3TKi8JQRta/VDfWlwG3ew14GeKqaAua9l1mZ0PA1hQ mUIi1/Jzr+5ZsiOa0DzBH6/YlbWvNkGhPSOtOISnyCmuxhS6/kasesUkVii/tMHZo41/ z1Vqzjuhvyg+bSK0KKIf+g5RQmO0VCUI9bJlbs+7wqXcWnTPgM3XZ4MPDebT/fHaG7et GA== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3vcf2j7s58-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 02 Jan 2024 15:05:38 +0000 Received: from m0353727.ppops.net (m0353727.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 402EurZf010225; Tue, 2 Jan 2024 15:05:38 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 3vcf2j7s4t-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 02 Jan 2024 15:05:38 +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 402CNLmp017971; Tue, 2 Jan 2024 15:05:36 GMT Received: from smtprelay03.fra02v.mail.ibm.com ([9.218.2.224]) by ppma13.dal12v.mail.ibm.com (PPS) with ESMTPS id 3vayrkd7fk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 02 Jan 2024 15:05:36 +0000 Received: from smtpav07.fra02v.mail.ibm.com (smtpav07.fra02v.mail.ibm.com [10.20.54.106]) by smtprelay03.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 402F5Xi514680808 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 2 Jan 2024 15:05:33 GMT Received: from smtpav07.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A82E120043; Tue, 2 Jan 2024 15:05:33 +0000 (GMT) Received: from smtpav07.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8E97820040; Tue, 2 Jan 2024 15:05:32 +0000 (GMT) Received: from osiris (unknown [9.171.22.30]) by smtpav07.fra02v.mail.ibm.com (Postfix) with ESMTPS; Tue, 2 Jan 2024 15:05:32 +0000 (GMT) Date: Tue, 2 Jan 2024 16:05:31 +0100 From: Heiko Carstens To: Ilya Leoshkevich Cc: Alexander Gordeev , Alexander Potapenko , Andrew Morton , Christoph Lameter , David Rientjes , Joonsoo Kim , Marco Elver , Masami Hiramatsu , Pekka Enberg , Steven Rostedt , Vasily Gorbik , Vlastimil Babka , Christian Borntraeger , Dmitry Vyukov , Hyeonggon Yoo <42.hyeyoo@gmail.com>, kasan-dev@googlegroups.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-s390@vger.kernel.org, linux-trace-kernel@vger.kernel.org, Mark Rutland , Roman Gushchin , Sven Schnelle Subject: Re: [PATCH v3 28/34] s390/mm: Define KMSAN metadata for vmalloc and modules Message-ID: <20240102150531.6306-F-hca@linux.ibm.com> References: <20231213233605.661251-1-iii@linux.ibm.com> <20231213233605.661251-29-iii@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231213233605.661251-29-iii@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-GUID: Ha6_F5y1dtYwlryom_EL-MOezepsJYos X-Proofpoint-ORIG-GUID: YUgncFyGNiUc-bIEjUnn1fILOqO8p_p- X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-01-02_04,2024-01-02_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 adultscore=0 phishscore=0 lowpriorityscore=0 impostorscore=0 mlxscore=0 malwarescore=0 spamscore=0 mlxlogscore=925 clxscore=1015 suspectscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2401020115 On Thu, Dec 14, 2023 at 12:24:48AM +0100, Ilya Leoshkevich wrote: > The pages for the KMSAN metadata associated with most kernel mappings > are taken from memblock by the common code. However, vmalloc and module > metadata needs to be defined by the architectures. > > Be a little bit more careful than x86: allocate exactly MODULES_LEN > for the module shadow and origins, and then take 2/3 of vmalloc for > the vmalloc shadow and origins. This ensures that users passing small > vmalloc= values on the command line do not cause module metadata > collisions. > > Reviewed-by: Alexander Potapenko > Signed-off-by: Ilya Leoshkevich > --- > arch/s390/boot/startup.c | 8 ++++++++ > arch/s390/include/asm/pgtable.h | 10 ++++++++++ > 2 files changed, 18 insertions(+) > > diff --git a/arch/s390/boot/startup.c b/arch/s390/boot/startup.c > index 8104e0e3d188..e37e7ffda430 100644 > --- a/arch/s390/boot/startup.c > +++ b/arch/s390/boot/startup.c > @@ -253,9 +253,17 @@ static unsigned long setup_kernel_memory_layout(void) > MODULES_END = round_down(__abs_lowcore, _SEGMENT_SIZE); > MODULES_VADDR = MODULES_END - MODULES_LEN; > VMALLOC_END = MODULES_VADDR; > +#ifdef CONFIG_KMSAN > + VMALLOC_END -= MODULES_LEN * 2; > +#endif > > /* allow vmalloc area to occupy up to about 1/2 of the rest virtual space left */ > vmalloc_size = min(vmalloc_size, round_down(VMALLOC_END / 2, _REGION3_SIZE)); > +#ifdef CONFIG_KMSAN > + /* take 2/3 of vmalloc area for KMSAN shadow and origins */ > + vmalloc_size = round_down(vmalloc_size / 3, _REGION3_SIZE); > + VMALLOC_END -= vmalloc_size * 2; > +#endif Please use if (IS_ENABLED(CONFIG_KMSAN)) above, since this way we get more compile time checks. > +#ifdef CONFIG_KMSAN > +#define KMSAN_VMALLOC_SIZE (VMALLOC_END - VMALLOC_START) > +#define KMSAN_VMALLOC_SHADOW_START VMALLOC_END > +#define KMSAN_VMALLOC_ORIGIN_START (KMSAN_VMALLOC_SHADOW_START + \ > + KMSAN_VMALLOC_SIZE) > +#define KMSAN_MODULES_SHADOW_START (KMSAN_VMALLOC_ORIGIN_START + \ > + KMSAN_VMALLOC_SIZE) Long single lines for these, please :) With that, and Alexander Gordeev's comments addressed: Acked-by: Heiko Carstens