Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp5783936rdb; Wed, 13 Dec 2023 21:57:55 -0800 (PST) X-Google-Smtp-Source: AGHT+IGQtRc2OBfpQy4X5RHHpvE/N+2wWmcgrmxQTfyeLCdfGSc4RynjB2GpBnWRWzI6jZL/eJ0s X-Received: by 2002:a05:6a20:1388:b0:18f:c6ac:ea5 with SMTP id hn8-20020a056a20138800b0018fc6ac0ea5mr9843099pzc.20.1702533475581; Wed, 13 Dec 2023 21:57:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702533475; cv=none; d=google.com; s=arc-20160816; b=gUjn/1EFFlzAmzwkdwZsuZIu8KrD5willoOkT8GuIo6I3nNDzUhrL/LUeBwV1vcd2b VtqsuT0p397U4rt1Yg+p2NSAqsnhoPPK2Nfr6gU/wuHnOKYCmDCO6wL6Z4Vtjps/yn0B +K27HTXbAOBEZ3cnsAgD1hQcRbYnm2I2UP3bpp5MW4ZSHkcJmujJ/M0+TOf8zF8L/UGl Y2fEc/aHYk4UckZ0lvhqPcW8naRSyQ93hTckY9WpiC0L3p9GPj5LIndJ4VSIDjGj93Ad QNZeAd8Q9EyKRmoRg0xDK84Cl5ao8fD50cN4khfEPIRSPNrw1dMOxI0ziFUNCF87oc81 zZYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=d9wxIuPcEttKuooqpbXdsw1bqv2JtLrtXjyZWOljfa8=; fh=JZjI76tHrPFh9wXiZ9caJKwSuDkcoMAMvZd7/HZf8J0=; b=WKkc4FlduFVYxtIg+RAAPjEfNoXWJhl2aE3dOUqUmxvzmnkNQZJ9hp6n3d+1+QlZaY tHosMVxIu88XS+PMq8k93yh6T6kyb+Erb4Q+cDcDnuL7wE29JA2hM1YBBcPrbnJJHLYE spgfylfOfShjkwli43dxp4UaQ1x4d82hOmtmyuNvG3VgMcJlBTfEejOJAtGNtPCvYIut xRNZqTBeG7iNpi/ZlC8DJweb79+FGOkdBFzPHtK6zKMypqFtF+fqPj9K5MmtYuaXypyx nBPthMHtb7EsZyqBTlkjrhlJ5Yx4uHNAc1jeyiUuScwUEychPZc77YVsFIy7pW7KExbg fYxQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=UYZPDBuP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id j3-20020a056a00174300b006cd852a8a83si11016860pfc.147.2023.12.13.21.57.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Dec 2023 21:57:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=UYZPDBuP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 2CE1E8028B67; Wed, 13 Dec 2023 21:57:53 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235572AbjLNF5V (ORCPT + 99 others); Thu, 14 Dec 2023 00:57:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55260 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235515AbjLNF5J (ORCPT ); Thu, 14 Dec 2023 00:57:09 -0500 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6AC23191 for ; Wed, 13 Dec 2023 21:56:53 -0800 (PST) Received: from pps.filterd (m0360072.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3BE5Pf2V006428; Thu, 14 Dec 2023 05:56:40 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=d9wxIuPcEttKuooqpbXdsw1bqv2JtLrtXjyZWOljfa8=; b=UYZPDBuPEsYnBXNn9bIcsLbwH9nOgpX0ngFzMXGcNxOmSNwml9oUQFPdlpZsWmRopKZZ G/HiC/7DbSwP8wNuU2eve9evV+t9dkJfA4VIbh+Lm/xmETSgRJZHB9sFis/DCvt8sTpN cAFK5uIz5SrkOkF/p+zh6fUc/QXCDsNehRsi7U9HRnocEyRNLXjFy2gtzaUs1rt8bjxT NCmjnrF3OUJBQC1rLP5GoVw0wDxTMpd5ir4G2PaBve72fkUln0TJ36eS83hRaUqqBh5P Q49xA+VkZv+hhUGLQ2sTqIh4ok1VL9WeeyZD2XArCo7WwrceaPZUBeVv6xltj9ijdBgd oQ== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3uyp5cq854-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 14 Dec 2023 05:56:39 +0000 Received: from m0360072.ppops.net (m0360072.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 3BE5oHZS007026; Thu, 14 Dec 2023 05:56:39 GMT Received: from ppma23.wdc07v.mail.ibm.com (5d.69.3da9.ip4.static.sl-reverse.com [169.61.105.93]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3uyp5cq82r-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 14 Dec 2023 05:56:39 +0000 Received: from pps.filterd (ppma23.wdc07v.mail.ibm.com [127.0.0.1]) by ppma23.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 3BE0fBUg014872; Thu, 14 Dec 2023 05:56:26 GMT Received: from smtprelay02.fra02v.mail.ibm.com ([9.218.2.226]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3uw42kggr5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 14 Dec 2023 05:56:26 +0000 Received: from smtpav07.fra02v.mail.ibm.com (smtpav07.fra02v.mail.ibm.com [10.20.54.106]) by smtprelay02.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 3BE5uON922151734 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 14 Dec 2023 05:56:24 GMT Received: from smtpav07.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1B8AC20040; Thu, 14 Dec 2023 05:56:24 +0000 (GMT) Received: from smtpav07.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A9AF020043; Thu, 14 Dec 2023 05:56:23 +0000 (GMT) Received: from ozlabs.au.ibm.com (unknown [9.192.253.14]) by smtpav07.fra02v.mail.ibm.com (Postfix) with ESMTP; Thu, 14 Dec 2023 05:56:23 +0000 (GMT) Received: from nicholasmvm.. (haven.au.ibm.com [9.192.254.114]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.au.ibm.com (Postfix) with ESMTPSA id A020D606F4; Thu, 14 Dec 2023 16:56:19 +1100 (AEDT) From: Nicholas Miehlbradt To: glider@google.com, elver@google.com, dvyukov@google.com, akpm@linux-foundation.org, mpe@ellerman.id.au, npiggin@gmail.com, christophe.leroy@csgroup.eu Cc: linux-mm@kvack.org, kasan-dev@googlegroups.com, iii@linux.ibm.com, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, Nicholas Miehlbradt Subject: [PATCH 11/13] powerpc: Implement architecture specific KMSAN interface Date: Thu, 14 Dec 2023 05:55:37 +0000 Message-Id: <20231214055539.9420-12-nicholas@linux.ibm.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231214055539.9420-1-nicholas@linux.ibm.com> References: <20231214055539.9420-1-nicholas@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: jSCLRD5AL1ZRUh81WentUJPts7nYAd0_ X-Proofpoint-GUID: SH2cEt_NsXZHfXK7AkjEQ-6Tk95O45Ww 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=2023-12-14_02,2023-12-13_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 mlxscore=0 spamscore=0 malwarescore=0 mlxlogscore=751 bulkscore=0 suspectscore=0 phishscore=0 priorityscore=1501 adultscore=0 lowpriorityscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2312140035 X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Wed, 13 Dec 2023 21:57:53 -0800 (PST) arch_kmsan_get_meta_or_null finds the metadata addresses for addresses in the ioremap region which is mapped separately on powerpc. kmsan_vir_addr_valid is the same as virt_addr_valid except excludes the check that addr is less than high_memory since this function can be called on addresses higher than this. Signed-off-by: Nicholas Miehlbradt --- arch/powerpc/include/asm/kmsan.h | 44 ++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 arch/powerpc/include/asm/kmsan.h diff --git a/arch/powerpc/include/asm/kmsan.h b/arch/powerpc/include/asm/kmsan.h new file mode 100644 index 000000000000..bc84f6ff2ee9 --- /dev/null +++ b/arch/powerpc/include/asm/kmsan.h @@ -0,0 +1,44 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * powerpc KMSAN support. + * + */ + +#ifndef _ASM_POWERPC_KMSAN_H +#define _ASM_POWERPC_KMSAN_H + +#ifndef __ASSEMBLY__ +#ifndef MODULE + +#include +#include +#include + +/* + * Functions below are declared in the header to make sure they are inlined. + * They all are called from kmsan_get_metadata() for every memory access in + * the kernel, so speed is important here. + */ + +/* + * No powerpc specific metadata locations + */ +static inline void *arch_kmsan_get_meta_or_null(void *addr, bool is_origin) +{ + unsigned long addr64 = (unsigned long)addr, off; + if (KERN_IO_START <= addr64 && addr64 < KERN_IO_END) { + off = addr64 - KERN_IO_START; + return (void *)off + (is_origin ? KERN_IO_ORIGIN_START : KERN_IO_SHADOW_START); + } else { + return 0; + } +} + +static inline bool kmsan_virt_addr_valid(void *addr) +{ + return (unsigned long)addr >= PAGE_OFFSET && pfn_valid(virt_to_pfn(addr)); +} + +#endif /* !MODULE */ +#endif /* !__ASSEMBLY__ */ +#endif /* _ASM_POWERPC_KMSAN_H */ -- 2.40.1