Received: by 2002:a05:7412:a9a2:b0:e2:908c:2ebd with SMTP id o34csp2434472rdh; Sun, 29 Oct 2023 16:33:42 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEfBUMrOUivi2dszUAt2QqtDnSmg84G99MptTzm5WfdNYsdtT0zgPbSATd/yFHdKxlnQKr+ X-Received: by 2002:a05:6a00:990:b0:6be:35f:631b with SMTP id u16-20020a056a00099000b006be035f631bmr7025905pfg.33.1698622422017; Sun, 29 Oct 2023 16:33:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698622422; cv=none; d=google.com; s=arc-20160816; b=nTW7A5I23bytdTPb9kxwPZWZqSEEoTy/AV5w217lc7p7vgS+AIm69lFacb/2x7349w PEsTCba0HRrZ9dxoy42veNRe4Y1z/8BosMMRbX0gtE8/GrRxKkjaFeG3yEaj4MaG+/6d IIpBv5P/8sccs6RK6oH9jenX5q++D92jaltHUAttPe85sAZg9QG5kn36xTgBegCQfnma zTMW195g+guBLgQwr9GaKsApmW4W3w11sLkSR2+5boPDAg9SaKFzdfPcBj+zqRalhcar HLEmkNS+xsYKN0nHGCNvyG8LuQ84kkL58kYruqwy4IZaGPZpwlVIH+H0ynf8h1oles46 fy8A== 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=cleJnxd+HYSgSFwjBi/iOWvZ1Macdu6DaJ3SKbxF9M4=; fh=3t7NSFeSd/HxvBdat+EYiPywFNGBT2sPnHuPMj9kK2I=; b=Rx+SThY7XM77INMtSzO2BPn7BgjeT6fe8x3K9PcB7SxbTWPH0/IiodjW0f1PdX5oSi e4q+SRLPNmbN8e7BdtDQMZHGK2QVZDKCe5kfT3/W+qIJxvL5QliuRbn723DzIWPyBmrY f0c6f/yiijceLvwVowXoYCLao9xHR1zs0Y/kqV4dlAN30QLRxeX8uOFJfxPidAfuCFao jog0HysEMkVxBsRuLLok6D5fwpAKjV3HTZ6F3bp4wS9voTKlIzXKV393/NnZ8BvMyOSq htiwWl2m2wsWxEDuhV4UU48FJ+q2tPXMMPj3v/qvw1GeWE/+BlBLgaY1dzcHq5OCJNJc e7Cg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=qTebr8vJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id j12-20020a056a00234c00b0068a54522bb0si4271575pfj.144.2023.10.29.16.33.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Oct 2023 16:33:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=qTebr8vJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id D9AE280793EE; Sun, 29 Oct 2023 16:33:40 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232343AbjJ2Xd3 (ORCPT + 99 others); Sun, 29 Oct 2023 19:33:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33860 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232536AbjJ2XdO (ORCPT ); Sun, 29 Oct 2023 19:33:14 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4AF6A270D; Sun, 29 Oct 2023 15:55:55 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 89F9FC433C8; Sun, 29 Oct 2023 22:55:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1698620147; bh=KyghjT8fjcHLeQ851UGSAKU0YWIhtmCAbJN2wBmIgz8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qTebr8vJKhgpa5Z174zEAj3+X02BqURKnnmxfC44I8kfp7fruI9OWG+IhDEu0oB5S 7sAu6lYxsSto/DuvmWRF+inhMV9GE19zWhYQRIwJTnHRMjlttKjDdOQmpqrQPqYB/Y IFdvaC5LT+Omf64oGn1t+O39N2iT9uzczTseXi6q2lZuFhP9fFpcQZAhf1sfSM/ZE4 vEtModWg5Jd89tpBy3LCyID83leTNNW4YUpdBm3tlWdrO57q4wX0CxM24D56TX2Saz QrLk/VhZa9IZGpzqgzMyZDO5IWPXkCCnLiMv1IpJgMwUZkBrxeFhqMTAJj/nUwjHKQ jJmWf5adsI92A== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Vasily Gorbik , Heiko Carstens , Gerald Schaefer , Sasha Levin , agordeev@linux.ibm.com, linux-s390@vger.kernel.org Subject: [PATCH AUTOSEL 6.5 30/52] s390/kasan: handle DCSS mapping in memory holes Date: Sun, 29 Oct 2023 18:53:17 -0400 Message-ID: <20231029225441.789781-30-sashal@kernel.org> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231029225441.789781-1-sashal@kernel.org> References: <20231029225441.789781-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 6.5.9 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 (snail.vger.email [0.0.0.0]); Sun, 29 Oct 2023 16:33:41 -0700 (PDT) From: Vasily Gorbik [ Upstream commit 327899674eef18f96644be87aa5510b7523fe4f6 ] When physical memory is defined under z/VM using DEF STOR CONFIG, there may be memory holes that are not hotpluggable memory. In such cases, DCSS mapping could be placed in one of these memory holes. Subsequently, attempting memory access to such DCSS mapping would result in a kasan failure because there is no shadow memory mapping for it. To maintain consistency with cases where DCSS mapping is positioned after the kernel identity mapping, which is then covered by kasan zero shadow mapping, handle the scenario above by populating zero shadow mapping for memory holes where DCSS mapping could potentially be placed. Reviewed-by: Heiko Carstens Reviewed-by: Gerald Schaefer Signed-off-by: Vasily Gorbik Signed-off-by: Sasha Levin --- arch/s390/boot/vmem.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/arch/s390/boot/vmem.c b/arch/s390/boot/vmem.c index c67f59db7a512..f66d642251fe8 100644 --- a/arch/s390/boot/vmem.c +++ b/arch/s390/boot/vmem.c @@ -57,6 +57,7 @@ static void kasan_populate_shadow(void) pmd_t pmd_z = __pmd(__pa(kasan_early_shadow_pte) | _SEGMENT_ENTRY); pud_t pud_z = __pud(__pa(kasan_early_shadow_pmd) | _REGION3_ENTRY); p4d_t p4d_z = __p4d(__pa(kasan_early_shadow_pud) | _REGION2_ENTRY); + unsigned long memgap_start = 0; unsigned long untracked_end; unsigned long start, end; int i; @@ -101,8 +102,12 @@ static void kasan_populate_shadow(void) * +- shadow end ----+---------+- shadow end ---+ */ - for_each_physmem_usable_range(i, &start, &end) + for_each_physmem_usable_range(i, &start, &end) { kasan_populate(start, end, POPULATE_KASAN_MAP_SHADOW); + if (memgap_start && physmem_info.info_source == MEM_DETECT_DIAG260) + kasan_populate(memgap_start, start, POPULATE_KASAN_ZERO_SHADOW); + memgap_start = end; + } if (IS_ENABLED(CONFIG_KASAN_VMALLOC)) { untracked_end = VMALLOC_START; /* shallowly populate kasan shadow for vmalloc and modules */ -- 2.42.0