Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp4314173imw; Thu, 7 Jul 2022 16:53:39 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tkyJRfCGth3NE7dpATp38mv92zLQ4rOtKpXLhCBDNFu620i2J2r7Z3wZxcUDWAmWSlqfCq X-Received: by 2002:a17:90b:4b0c:b0:1ef:d1e4:b2eb with SMTP id lx12-20020a17090b4b0c00b001efd1e4b2ebmr6125123pjb.12.1657238018840; Thu, 07 Jul 2022 16:53:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657238018; cv=none; d=google.com; s=arc-20160816; b=sYyHbuDpToFLe/K2OKJw/jl3HboepKJ/jf05VGg7dXzzKDaW3iMM3oGuze8VqOpVvM uNI8rpt3BtbGUOFg1Ikf9YOK9q684XOiCionDzMp9ZjCZ7vXOY4jp+wJPOUE85av6daf 5fG6oTYkcyF76qG0Efgy9IaqLfVLU0Wt1ACxUs7YjTKrJUxHXOHLdPkBx5GH+sl+ge0I FwdsZWqiojxSFXxzYFJJ77BgTBJkQ/K62mhHfegFhwycY9l6PxjcHnBm3ap9E+MuJO4u 3noFXeIMFMET38ckSycjQRv8gYS3MBTXcQou3whjJlDrRYnqK+gQmoCj3GUbkQVT0vsE c+Yw== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=izEW/QlWsYwAv1ZochY3FjaPww57C5kdq40cLp75WW8=; b=zQD6+6IYBiKlMT0KILqsKJIrc7bVTGs6GY7usi7oPhsYkVOQ7nbLyXGeznD9xm686u SRKE15u5Pu8vxKH/VA4tuxU2iMmQcKTSmaFkf0GQ4r0rlgRW59n4EOTnk2tpexI7+36I R7UpcnbuZ9DQfWuhulpgiNnlJtRZMdSdXBRbTl/UrokqSQua8tSYRW312zkIE8ZQRXqM t4i5495NVGMCiR3gLzMrvLZy7lhe1FKK3v4Ycy/EOR/qzKL6sEVkUlUoOHW3Cl7xkdzq RS0ky0m50APuh0rO8ozqNIWRdlaPvDjO8sCKLwKGnDZ/XjRcwpGAMOb52QmNpiIoHJ9z hpcQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=IHvyQzKU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f10-20020a63e30a000000b0040d275d3fcesi52260513pgh.661.2022.07.07.16.53.26; Thu, 07 Jul 2022 16:53:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=IHvyQzKU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236525AbiGGXOV (ORCPT + 99 others); Thu, 7 Jul 2022 19:14:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57130 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236128AbiGGXOU (ORCPT ); Thu, 7 Jul 2022 19:14:20 -0400 Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 46F9B27FD5 for ; Thu, 7 Jul 2022 16:14:19 -0700 (PDT) Received: by mail-wr1-x433.google.com with SMTP id s1so28299809wra.9 for ; Thu, 07 Jul 2022 16:14:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=izEW/QlWsYwAv1ZochY3FjaPww57C5kdq40cLp75WW8=; b=IHvyQzKUsj6cmYt0GoU0JO/vGfv/QZ0SGCghTNipvbOxddWPTpllfdqd6WPZzJ5yfS nmpXVBhxWR3VLak28+xTua7DJ7ThAUcOcyyIJ0I/BJa+3tLiKD4P35J0LBuXePIy8fyg acNnxmifaxhC9p/P6L5kRGRaNWrosuFX8g67kNSObnRuamv1OdAteTf1Qrves5CowcCq xqEa/TaraYD8x9YnR1+vADPqqsDoNkjbqKUuQri+vRSylWapjeZmU3qnHHoSJZWjZGzS o8/cRY+egbj9YuTOrmSWcqzvzems3cK2Oq6dGGFnS/LhnvQnuyG0rq/KU9shqeDo87E8 7pIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=izEW/QlWsYwAv1ZochY3FjaPww57C5kdq40cLp75WW8=; b=RAecPae/XuLvCNdS5+dTdHdku24XI0IpYM29NuQWK9gKcEJVualJFY3DYXphv0NW4y gQVbtvEqnlSGuPWMlPutM38HkiEfqS22z/2aughdchiKYxA5Ilv31r5V8JppAysLzaE8 IrWzrWGO8vsL8USHAvNZBh6IUAR8GVWelP0F9Gu7GbHWSmjlTvA8cUbwsfVZ3GkGt7aW hHt1vbux8jhUNpDq+U7AGXOSKxmd+RNJB6LQ8sKFTYEfc90yvcS6pR31hWAerl236IIm pkmJ8QarLYYrlJyO0Zb6C1Pzs0CWQ4zDvkDYLs5rsJQMVAbYy7ECXmPISQ0PfywPt/y3 prqQ== X-Gm-Message-State: AJIora/4FpcfBRxayA0IZylpiXfkHWUE9HUF5l91L99ow1ZDPafC8dIA wP9YsX2d1BquNb4OCbHwkEcPlPa3vc0= X-Received: by 2002:adf:facc:0:b0:21d:8c8f:4b51 with SMTP id a12-20020adffacc000000b0021d8c8f4b51mr267095wrs.307.1657235657684; Thu, 07 Jul 2022 16:14:17 -0700 (PDT) Received: from localhost.localdomain (host-79-53-109-127.retail.telecomitalia.it. [79.53.109.127]) by smtp.gmail.com with ESMTPSA id q6-20020a1cf306000000b003a033177655sm201922wmq.29.2022.07.07.16.14.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Jul 2022 16:14:16 -0700 (PDT) From: "Fabio M. De Francesco" To: Eric Biederman , kexec@lists.infradead.org, linux-kernel@vger.kernel.org Cc: "Fabio M. De Francesco" , Ira Weiny Subject: [PATCH] kexec: Replace kmap() with kmap_local_page() Date: Fri, 8 Jul 2022 01:14:12 +0200 Message-Id: <20220707231412.1404-1-fmdefrancesco@gmail.com> X-Mailer: git-send-email 2.36.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 The use of kmap() and kmap_atomic() are being deprecated in favor of kmap_local_page(). With kmap_local_page(), the mappings are per thread, CPU local and not globally visible. Furthermore, the mappings can be acquired from any context (including interrupts). Therefore, use kmap_local_page() in kexec_core.c because these mappings are per thread, CPU local, and not globally visible. Tested on a QEMU + KVM 32-bits VM booting a kernel with HIGHMEM64GB enabled. Suggested-by: Ira Weiny Signed-off-by: Fabio M. De Francesco --- v1->v2: A sentence of the commit message contained an error due to a mistake in copy-pasting from a previous patch. Replace "aio.c" with "kexec_core.c". kernel/kexec_core.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/kernel/kexec_core.c b/kernel/kexec_core.c index 4d34c78334ce..6f98274765d4 100644 --- a/kernel/kexec_core.c +++ b/kernel/kexec_core.c @@ -814,7 +814,7 @@ static int kimage_load_normal_segment(struct kimage *image, if (result < 0) goto out; - ptr = kmap(page); + ptr = kmap_local_page(page); /* Start with a clear page */ clear_page(ptr); ptr += maddr & ~PAGE_MASK; @@ -827,7 +827,7 @@ static int kimage_load_normal_segment(struct kimage *image, memcpy(ptr, kbuf, uchunk); else result = copy_from_user(ptr, buf, uchunk); - kunmap(page); + kunmap_local(ptr); if (result) { result = -EFAULT; goto out; @@ -878,7 +878,7 @@ static int kimage_load_crash_segment(struct kimage *image, goto out; } arch_kexec_post_alloc_pages(page_address(page), 1, 0); - ptr = kmap(page); + ptr = kmap_local_page(page); ptr += maddr & ~PAGE_MASK; mchunk = min_t(size_t, mbytes, PAGE_SIZE - (maddr & ~PAGE_MASK)); @@ -894,7 +894,7 @@ static int kimage_load_crash_segment(struct kimage *image, else result = copy_from_user(ptr, buf, uchunk); kexec_flush_icache_page(page); - kunmap(page); + kunmap_local(ptr); arch_kexec_pre_free_pages(page_address(page), 1); if (result) { result = -EFAULT; -- 2.36.1