Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp4063947imw; Thu, 7 Jul 2022 12:06:12 -0700 (PDT) X-Google-Smtp-Source: AGRyM1s2e9/T7a18gQINDlsL/WhJaiR1Ek7uhT2xZB+kbiwICrXZXj0y2nsNciRnsSAPdzTtkE23 X-Received: by 2002:a17:907:6ea7:b0:726:41de:78ac with SMTP id sh39-20020a1709076ea700b0072641de78acmr47667098ejc.452.1657220772502; Thu, 07 Jul 2022 12:06:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657220772; cv=none; d=google.com; s=arc-20160816; b=u/BAPu69D5L7Gf0tdIIyzyiqAgrnzrVfQ/vfpHhw1IZJyGcwLs4K2AucZ6sMeCIfKJ O2N6QgJljAs8rYHuHT0swm6MeD3RGjS3uixDYRZY9A9XAYjkv+EVjiBfXW1culK2M+bf 8b8l+LFK05s8wZUmGNQHrsHtcTEJ/lapWQ8KssvPAGjEIctanj4/ZYzhmVHtB4DhI5qt 9AwHoT9Z8009wDGCIrL8WbNY3XcyRMN/yQf0B40vAB0gIdIymdj8Nfx5bp/4MCYdoous m1611Rk9Ztz9A6RStjE7dcCbqqf6DA2ifepYoLbxOHJejO60tm+VxHi4aJQ+7ae4q8mK XVXw== 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=By3T6Z5JDK5VvmvI0n3THPKQqdtLxJBkH/DaezIVYE0=; b=g5zLAg0V5MHRDrTxCcsITz7RkZwAPypGVPJ2+kZBlEAw8nh2CDANjChsQzS4JcfDc5 oQ3A/xKQjlicuuxTBuO0RkJxZ22LZaTBkrwVorux5bW4u3ap4CW1yvPocAo9apLQLAwR rjerQzZInTadOKciiW1XmKIHKT2USIEShjSeRVhTDvutcPp9ur3vnxAdlh6UJXZnO8Gw rHr0CnRzChem1FbsS9jbt+rnC7tH3PP05RruOqZV7LC3b2DLHDNJw+LhwODSMNRHBbln rcbd4/bIwLoYr3Rzk8N8V0pLxHJl60Fffh1TkkrKvvxQtUnxqqC940bxvIXEgMZd3Zmu Fsiw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=UcJwhV8p; 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 et8-20020a056402378800b0043771535df1si1828530edb.260.2022.07.07.12.05.47; Thu, 07 Jul 2022 12:06:12 -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=UcJwhV8p; 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 S236353AbiGGStu (ORCPT + 99 others); Thu, 7 Jul 2022 14:49:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46850 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235452AbiGGSts (ORCPT ); Thu, 7 Jul 2022 14:49:48 -0400 Received: from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com [IPv6:2a00:1450:4864:20::32d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 087D7201A6 for ; Thu, 7 Jul 2022 11:49:47 -0700 (PDT) Received: by mail-wm1-x32d.google.com with SMTP id ay25so1534341wmb.1 for ; Thu, 07 Jul 2022 11:49:46 -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=By3T6Z5JDK5VvmvI0n3THPKQqdtLxJBkH/DaezIVYE0=; b=UcJwhV8pPQf4CAMOaf2znH1HntdU1cBMU8tyt9pzArCbkZGGDwErnBt8m86tQK9dxa HcLrCVCOdiHht2vDiwCi4rzwEvLi5Cmu6JhEAmHMJvK2W1eODp6clKPUTA4El1iWyRQY 6RXW5TWyrX9LsIxjY64M6+jfyEpylCJGLL3Ii2DxkW9GhJG4CtiXaB1YsrKPcnTfmvno Bg7chmUDKYbyao8BwLr4ICGm+tOc99ag/ZCBIvshf5C3c9gois6pyyQuiNsTbhC2LswA ZLJqpybLLTbFd5bYNrRA+1YcC1AQwEvEPq2PA5vjU57nBou97z3stLYQNuOO+lZspdfB FfIg== 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=By3T6Z5JDK5VvmvI0n3THPKQqdtLxJBkH/DaezIVYE0=; b=SqeAjO0vXlqmUrYuuD/SA+44DyRG89qNaVgWXjllw87Gu0JvXnd8YM+4nNoyhcfZ9q raP9rC4mvofE+Zpn5zzV/vm91z8uCkWLuqmx7yH+u1ZqzbIl7fNkPJMcPJWlUy4qzwhk fUvbCC4xnFo0fvb8LWz2XkfdKxhTlDbCum5lqgsojJZ/Qnjmv8nFryOyereoedcNGsU5 gpxtfCxwltsjuuSq0+LYnnbTQmMX6mzTKkL/RhhHcceO3WQ7fY7Mxhn4CGXfLRPh3fWY KpgD3UAmxF83fKKUxHiT7JMf4G30lrM7CEOzALGnzH9fxgVb6FzFHyIX1wzYGTBMqtnb qszg== X-Gm-Message-State: AJIora8xVnNPfTMg1gIMNKvVRgmBv8ASxMUHJFiL0DJB1kpeaUF0jcTz SuiC+D4cYBOgY3mbA64Sk9s= X-Received: by 2002:a1c:19c3:0:b0:39c:6479:3ca with SMTP id 186-20020a1c19c3000000b0039c647903camr6037084wmz.27.1657219785494; Thu, 07 Jul 2022 11:49:45 -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 z5-20020adfe545000000b0021b81855c1csm47280088wrm.27.2022.07.07.11.49.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Jul 2022 11:49:43 -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: Thu, 7 Jul 2022 20:49:39 +0200 Message-Id: <20220707184939.6086-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 aio.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 --- 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