From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id C190DC3DA6E for ; Wed, 10 Jan 2024 03:54:55 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3A8526B0080; Tue, 9 Jan 2024 22:54:55 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 359486B0093; Tue, 9 Jan 2024 22:54:55 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1F8D26B0095; Tue, 9 Jan 2024 22:54:55 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 0F33A6B0080 for ; Tue, 9 Jan 2024 22:54:55 -0500 (EST) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id DD726C03DF for ; Wed, 10 Jan 2024 03:54:54 +0000 (UTC) X-FDA: 81662035308.26.5C697B3 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by imf11.hostedemail.com (Postfix) with ESMTP id 3075640016 for ; Wed, 10 Jan 2024 03:54:52 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=pWydVyLK; spf=pass (imf11.hostedemail.com: domain of nicholas@linux.ibm.com designates 148.163.158.5 as permitted sender) smtp.mailfrom=nicholas@linux.ibm.com; dmarc=pass (policy=none) header.from=ibm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1704858892; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=pUVAfEd8UZ3Kgup8PAC9DYXLhqDnscMMx6ZISfm/AQk=; b=haPWMyNjO4G6zK7IEDbZk/RwJArCmXHx/EY9WHgd1WGn1w5Ez+jxhyn7rAAJCDoqpr/idD Nizt01pAYODA8ujgSvwM7NIBxqzh50vle7Re+ck/P0uxC7yQjMux9Phs41zG+7MgnlMYnW 7QKTUQ278NC4OvgTEDFcbRxuerEpdUo= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1704858892; a=rsa-sha256; cv=none; b=qn1nielTL1mp+3IWpzmheRHuUR4hpT0RvGWFQKjle91XX9g5q2r37j4x2NShZySjcSiMjD RTt3Wn3cXVwt709mgBNHJuSO+1/mJVioUppa5ZcJi67tL0sJYzSnqbWF4Q2PVblilW10kh t0/6wm9soxLx7u1TBP5VseaZ6/eSBM8= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=pWydVyLK; spf=pass (imf11.hostedemail.com: domain of nicholas@linux.ibm.com designates 148.163.158.5 as permitted sender) smtp.mailfrom=nicholas@linux.ibm.com; dmarc=pass (policy=none) header.from=ibm.com Received: from pps.filterd (m0353725.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 40A3okpQ001962; Wed, 10 Jan 2024 03:54:43 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=message-id : date : mime-version : subject : to : cc : references : from : in-reply-to : content-type : content-transfer-encoding; s=pp1; bh=pUVAfEd8UZ3Kgup8PAC9DYXLhqDnscMMx6ZISfm/AQk=; b=pWydVyLKGGPmxZhuha3gk3Prcbyg3OH+amTdw7dUElYRWTNxAXGqjmA5xE/BWRHzhBxQ zDISFDYoMP7DfpLar24xEydEFX2MQLnFO9vLtNZ1ZZjEQy0UjPUBiO533SeTJjtDCItJ lw0THHlZLb9PMOAbWAPTOKs05YF9MA/z1KOVo+wDPrNPQMzAHtlTPEyORGOSeWa+Os9T cFv3jbcWB6O0lyl9LmT1gMDA5/T3Jsa9gtKXpV/RMzhtG/G8EqRaoOl+oqFWdAnRnTqt dAYrWlwm5P4vmmCHHAqp5hRQh/iIK8Ts8cyq85vNl7meihD+vKwZE8bt8ofPvJpBQ9tP SQ== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3vher165ge-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 10 Jan 2024 03:54:42 +0000 Received: from m0353725.ppops.net (m0353725.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 40A3pPpm003780; Wed, 10 Jan 2024 03:54:42 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 3vher165g9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 10 Jan 2024 03:54:42 +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 40A1AjOq022793; Wed, 10 Jan 2024 03:54:41 GMT Received: from smtprelay06.fra02v.mail.ibm.com ([9.218.2.230]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3vfhjyk3m1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 10 Jan 2024 03:54:41 +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 40A3sdW728836314 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 10 Jan 2024 03:54:39 GMT Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5229920043; Wed, 10 Jan 2024 03:54:39 +0000 (GMT) Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 87BE720040; Wed, 10 Jan 2024 03:54:38 +0000 (GMT) Received: from ozlabs.au.ibm.com (unknown [9.192.253.14]) by smtpav03.fra02v.mail.ibm.com (Postfix) with ESMTP; Wed, 10 Jan 2024 03:54:38 +0000 (GMT) Received: from [10.61.2.106] (haven.au.ibm.com [9.192.254.114]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.au.ibm.com (Postfix) with ESMTPSA id F126560218; Wed, 10 Jan 2024 14:54:33 +1100 (AEDT) Message-ID: <74ad4d5f-7bf7-484c-9386-07945f0c6c5d@linux.ibm.com> Date: Wed, 10 Jan 2024 14:54:06 +1100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 10/13] powerpc: Define KMSAN metadata address ranges for vmalloc and ioremap To: Christophe Leroy , "glider@google.com" , "elver@google.com" , "dvyukov@google.com" , "akpm@linux-foundation.org" , "mpe@ellerman.id.au" , "npiggin@gmail.com" Cc: "linux-mm@kvack.org" , "kasan-dev@googlegroups.com" , "iii@linux.ibm.com" , "linuxppc-dev@lists.ozlabs.org" , "linux-kernel@vger.kernel.org" References: <20231214055539.9420-1-nicholas@linux.ibm.com> <20231214055539.9420-11-nicholas@linux.ibm.com> Content-Language: en-US From: Nicholas Miehlbradt In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-GUID: hNZCu3MwXqikP36POMF8gOd8dje9b0A4 X-Proofpoint-ORIG-GUID: aw9dGrggdNPFi0nAkY_dW39AreN6AI7l 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-09_13,2024-01-09_02,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 priorityscore=1501 adultscore=0 bulkscore=0 clxscore=1011 spamscore=0 mlxlogscore=999 impostorscore=0 suspectscore=0 malwarescore=0 mlxscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2401100029 X-Rspamd-Queue-Id: 3075640016 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: e611h46ishdxfm151sjqcm3ngxqjw1yx X-HE-Tag: 1704858892-982338 X-HE-Meta: U2FsdGVkX1++h/mheaHbhg8IaEuBnyONuVW2ZTnqxDbxY8C0Z9V6k9p6PYZSZcP0V9EBi698CgTptCDoPfo2t/E3/Wehf0ZQQHp1kRiAnftXF/R55/5T9/zrqIh7A8ylaGypjTUYxhdDBPRuU1zqrOV75oEhF86EXQoAw9JHcu5lW4c5C7cAdmjByMFA6ARgdosREYRg5p+zzseqDPqDuzVlMbPguncF6pApCpJyr/gJo4vUjaKXGPekB0+q7a5yj774NURLZzUSZ5A9amgORIfOPwllP/2gh0rkODlBsKkXE1tWdLnC6sJYnhfWi5us/A5EZa0XtpQyYNPntVs3rwMGlQpp6dkFbCnG1wdXswykwIry3BDDYKZPx3NP/V2nyjvSbe0GndqQgPMIcP+dKSr3xdaTW4OTrvZ7JF6Mm5LgM8Ll8R6PzwjzwZpALvdgYg6i8YcXvle96/uxw4PT82nQmC09ApSJ5amnIwcOyD5e03h+QSp3itLWx+cVVwaI7JgBLsKtiq34rsNdKvKImFBQkzI/8ImgR5hgkyDavWz6wiLPOmVR/7zjMX2YdwPkuVaP163KbQZ1jQ5qHFd9dkDLHuNTmqW7nRtfaQbvS8LjVCOLvNIDsgnlMawWDk2gGdDdqkyKoRw8+LWKSWe2wEueXJD0wbQwGdhsTXJ2143gF2WIYSVfhHMn+TDwFXNWRYWoHuHoiS0E3dUzNf+t5ZsBGfSlaaodQ4rxpH/CYuv7IT9TqKJ9H9QbzN6e5URQEtfrIVzi60+PoQrRPvbE1msLcbo8zOL0+nB5xBzj/cgH/YkcSFKy1bmaajbxsRo+LXyvOTsviEVuFRU+C0w7cCojam5CZ1SkvCCVHNbCo/r/6bMMlgmasI2CaiXI+cfDfGiUNw0OcpSZomcHTJr9tnOz/MTfWJ0K6R7ua6KEARzgIfhcELuUs6b73RsjtkuG8Yagu84oj3qfDtUZ/Vu mSQ8yirX //USGNbUqoTE6pjgjM3WkXf6yT5mYwgObhX8OihitZQ9QbRD5XnpR3Y4TVztDFiQsaGExk6VKu/daNrWfMgiqEmOsjTqwHKVzHM6cVSLbzca1fksmvFzQ3DgEeSSn21/8y2sBSF+4TJpm3S2Ai3uhGGiErxCeZEcCEWQrJWBzBmXHB/tzQu4I4kQAIIK4fzQ4+7bgkY4O72ayojNQxE3coGVN95jZO/ytc0dR5C26CW9EtsDwaPg1Z1f5k0QqP8R3iyRwQHiOrVq9g3E6OA5ud7bx+A== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On 14/12/2023 8:17 pm, Christophe Leroy wrote: > > > Le 14/12/2023 à 06:55, Nicholas Miehlbradt a écrit : >> Splits the vmalloc region into four. The first quarter is the new >> vmalloc region, the second is used to store shadow metadata and the >> third is used to store origin metadata. The fourth quarter is unused. >> >> Do the same for the ioremap region. >> >> Module data is stored in the vmalloc region so alias the modules >> metadata addresses to the respective vmalloc metadata addresses. Define >> MODULES_VADDR and MODULES_END to the start and end of the vmalloc >> region. >> >> Since MODULES_VADDR was previously only defined on ppc32 targets checks >> for if this macro is defined need to be updated to include >> defined(CONFIG_PPC32). > > Why ? > > In your case MODULES_VADDR is above PAGE_OFFSET so there should be no > difference. > > Christophe > On 64 bit builds the BUILD_BUG always triggers since MODULES_VADDR expands to __vmalloc_start which is defined in a different translation unit. I can restrict the #ifdef CONFIG_PPC32 to just around the BUILD_BUG since as you pointed out there is no difference otherwise. >> >> Signed-off-by: Nicholas Miehlbradt >> --- >> arch/powerpc/include/asm/book3s/64/pgtable.h | 42 ++++++++++++++++++++ >> arch/powerpc/kernel/module.c | 2 +- >> 2 files changed, 43 insertions(+), 1 deletion(-) >> >> diff --git a/arch/powerpc/include/asm/book3s/64/pgtable.h b/arch/powerpc/include/asm/book3s/64/pgtable.h >> index cb77eddca54b..b3a02b8d96e3 100644 >> --- a/arch/powerpc/include/asm/book3s/64/pgtable.h >> +++ b/arch/powerpc/include/asm/book3s/64/pgtable.h >> @@ -249,7 +249,38 @@ enum pgtable_index { >> extern unsigned long __vmalloc_start; >> extern unsigned long __vmalloc_end; >> #define VMALLOC_START __vmalloc_start >> + >> +#ifndef CONFIG_KMSAN >> #define VMALLOC_END __vmalloc_end >> +#else >> +/* >> + * In KMSAN builds vmalloc area is four times smaller, and the remaining 3/4 >> + * are used to keep the metadata for virtual pages. The memory formerly >> + * belonging to vmalloc area is now laid out as follows: >> + * >> + * 1st quarter: VMALLOC_START to VMALLOC_END - new vmalloc area >> + * 2nd quarter: KMSAN_VMALLOC_SHADOW_START to >> + * KMSAN_VMALLOC_SHADOW_START+VMALLOC_LEN - vmalloc area shadow >> + * 3rd quarter: KMSAN_VMALLOC_ORIGIN_START to >> + * KMSAN_VMALLOC_ORIGIN_START+VMALLOC_LEN - vmalloc area origins >> + * 4th quarter: unused >> + */ >> +#define VMALLOC_LEN ((__vmalloc_end - __vmalloc_start) >> 2) >> +#define VMALLOC_END (VMALLOC_START + VMALLOC_LEN) >> + >> +#define KMSAN_VMALLOC_SHADOW_START VMALLOC_END >> +#define KMSAN_VMALLOC_ORIGIN_START (VMALLOC_END + VMALLOC_LEN) >> + >> +/* >> + * Module metadata is stored in the corresponding vmalloc metadata regions >> + */ >> +#define KMSAN_MODULES_SHADOW_START KMSAN_VMALLOC_SHADOW_START >> +#define KMSAN_MODULES_ORIGIN_START KMSAN_VMALLOC_ORIGIN_START >> +#endif /* CONFIG_KMSAN */ >> + >> +#define MODULES_VADDR VMALLOC_START >> +#define MODULES_END VMALLOC_END >> +#define MODULES_LEN (MODULES_END - MODULES_VADDR) >> >> static inline unsigned int ioremap_max_order(void) >> { >> @@ -264,7 +295,18 @@ extern unsigned long __kernel_io_start; >> extern unsigned long __kernel_io_end; >> #define KERN_VIRT_START __kernel_virt_start >> #define KERN_IO_START __kernel_io_start >> +#ifndef CONFIG_KMSAN >> #define KERN_IO_END __kernel_io_end >> +#else >> +/* >> + * In KMSAN builds IO space is 4 times smaller, the remaining space is used to >> + * store metadata. See comment for vmalloc regions above. >> + */ >> +#define KERN_IO_LEN ((__kernel_io_end - __kernel_io_start) >> 2) >> +#define KERN_IO_END (KERN_IO_START + KERN_IO_LEN) >> +#define KERN_IO_SHADOW_START KERN_IO_END >> +#define KERN_IO_ORIGIN_START (KERN_IO_SHADOW_START + KERN_IO_LEN) >> +#endif /* !CONFIG_KMSAN */ >> >> extern struct page *vmemmap; >> extern unsigned long pci_io_base; >> diff --git a/arch/powerpc/kernel/module.c b/arch/powerpc/kernel/module.c >> index f6d6ae0a1692..5043b959ad4d 100644 >> --- a/arch/powerpc/kernel/module.c >> +++ b/arch/powerpc/kernel/module.c >> @@ -107,7 +107,7 @@ __module_alloc(unsigned long size, unsigned long start, unsigned long end, bool >> >> void *module_alloc(unsigned long size) >> { >> -#ifdef MODULES_VADDR >> +#if defined(MODULES_VADDR) && defined(CONFIG_PPC32) >> unsigned long limit = (unsigned long)_etext - SZ_32M; >> void *ptr = NULL; >>