Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp2378740pxp; Fri, 18 Mar 2022 09:19:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwxbY28IPZg4Q42hj4V5uLo5xIpiquCmEfdFnZ/0YKUOE1OcWtyWtCHwmovHRY/civlX0qT X-Received: by 2002:a17:907:6e21:b0:6db:3e2a:a7cd with SMTP id sd33-20020a1709076e2100b006db3e2aa7cdmr9823130ejc.291.1647620343964; Fri, 18 Mar 2022 09:19:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647620343; cv=none; d=google.com; s=arc-20160816; b=HfxqEVymlhzMsnbL3JGLjqIvL0FWIuevSw3NA7BO6WcS6txQ9v6ksEcNUP4t/R4+CQ IxUUkmpml++Ue7hv94zDBs5ghJGyqz+CnoXe03eRSSf+8a/8hv7eiceOIj5QPyyLSL7j kMghrBhGK3l1i99c7EoKf+YFskfNt5i+kB94Mz8FEnq0HMtPFgGh3jjJYX5MFmIuR5KI aR9fI0eD7GH25+AAXA1Kn99Rrukq+0MJC/iMyQYyDasg85SHtl0xtM0/x04vJIANVDRB h8ZibRGCMGMV0n5lUqbho2CNJ2/+roMRfzyB7jB6C0+wJ/7PPoJMj4yi0dxnvZuR87vV Xk4g== 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=/b2o0BdzcwY9Tmgob1KBIWJnoOrpkLRZ+Jjx3XbgB9Y=; b=aFvwWmkMxrbty/4Fnb04JyzJSt5Tui8U/Dp10qPa/X693KqIF7NuzEJRQT5tahJWCi eW5ceVtpFFw2/NNeltkNHVsXZqbAUGoHLVFw9KSucOvYntF3Qh2ebVnq8SacVkVmsKmI UfsxlNlmL/DpVPXTEPgNzxJBj4iEbmQzfe17cDK3csYyNR/dSPVXNyotoeI4W7mk5xnx y8ldi2CImZs8peu/46JUSapmmJgMkcDQWJSXd3sCUWUMIxpfieWBmzzEu9C2LmnphCF4 yjVZCqOHpLwrfyU1+YIaJK8X9jTeocVrHd9l20IFExGQTykPvwx4sU7be5auq0f6SEip mDoA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Vf1YULD3; 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=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u16-20020a50a410000000b00418c2b5bd88si4054626edb.106.2022.03.18.09.18.39; Fri, 18 Mar 2022 09:19:03 -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=@redhat.com header.s=mimecast20190719 header.b=Vf1YULD3; 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=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234551AbiCRJjD (ORCPT + 99 others); Fri, 18 Mar 2022 05:39:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42754 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234526AbiCRJi7 (ORCPT ); Fri, 18 Mar 2022 05:38:59 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 8FD642EA92E for ; Fri, 18 Mar 2022 02:37:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1647596256; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/b2o0BdzcwY9Tmgob1KBIWJnoOrpkLRZ+Jjx3XbgB9Y=; b=Vf1YULD3D7ATSMbTmDLoIDoM/gmNlSA+0ck+66ZEPZhqzr9+qg8xUyXP2RpE53Pg2mYUER WEF+Uk7xNhYEMJD2JV17uIlzVS938fK2QyuEiV7JaFB6vuMHvfyu02wuKB4ngnUHWXQsEc q0zyX9zj6M6Ft1oGmrnEW4eyPOaUEPI= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-37-ZMOOYaNnOam9cYaTNjBFbA-1; Fri, 18 Mar 2022 05:37:33 -0400 X-MC-Unique: ZMOOYaNnOam9cYaTNjBFbA-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id BD8FD811E76; Fri, 18 Mar 2022 09:37:32 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-13-174.pek2.redhat.com [10.72.13.174]) by smtp.corp.redhat.com (Postfix) with ESMTP id 70C55112C08E; Fri, 18 Mar 2022 09:37:28 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: willy@infradead.org, bhe@redhat.com, kexec@lists.infradead.org, yangtiezhu@loongson.cn, amit.kachhap@arm.com, hch@lst.de, linux-fsdevel@vger.kernel.org, viro@zeniv.linux.org.uk Subject: [PATCH v4 3/4] vmcore: Convert read_from_oldmem() to take an iov_iter Date: Fri, 18 Mar 2022 17:37:05 +0800 Message-Id: <20220318093706.161534-4-bhe@redhat.com> In-Reply-To: <20220318093706.161534-1-bhe@redhat.com> References: <20220318093706.161534-1-bhe@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Spam-Status: No, score=-3.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, 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 lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: "Matthew Wilcox (Oracle)" Remove the read_from_oldmem() wrapper introduced earlier and convert all the remaining callers to pass an iov_iter. Signed-off-by: Matthew Wilcox (Oracle) Reviewed-by: Christoph Hellwig Acked-by: Baoquan He --- arch/x86/kernel/crash_dump_64.c | 7 +++++- fs/proc/vmcore.c | 40 +++++++++++++-------------------- include/linux/crash_dump.h | 10 ++++----- 3 files changed, 25 insertions(+), 32 deletions(-) diff --git a/arch/x86/kernel/crash_dump_64.c b/arch/x86/kernel/crash_dump_64.c index f922d51c9d1f..0fa87648e55c 100644 --- a/arch/x86/kernel/crash_dump_64.c +++ b/arch/x86/kernel/crash_dump_64.c @@ -55,6 +55,11 @@ ssize_t copy_oldmem_page_encrypted(struct iov_iter *iter, unsigned long pfn, ssize_t elfcorehdr_read(char *buf, size_t count, u64 *ppos) { - return read_from_oldmem(buf, count, ppos, 0, + struct kvec kvec = { .iov_base = buf, .iov_len = count }; + struct iov_iter iter; + + iov_iter_kvec(&iter, READ, &kvec, 1, count); + + return read_from_oldmem(&iter, count, ppos, cc_platform_has(CC_ATTR_GUEST_MEM_ENCRYPT)); } diff --git a/fs/proc/vmcore.c b/fs/proc/vmcore.c index cebf49160ea5..4cbb8db7c507 100644 --- a/fs/proc/vmcore.c +++ b/fs/proc/vmcore.c @@ -127,7 +127,7 @@ static int open_vmcore(struct inode *inode, struct file *file) } /* Reads a page from the oldmem device from given offset. */ -static ssize_t read_from_oldmem_iter(struct iov_iter *iter, size_t count, +ssize_t read_from_oldmem(struct iov_iter *iter, size_t count, u64 *ppos, bool encrypted) { unsigned long pfn, offset; @@ -175,27 +175,6 @@ static ssize_t read_from_oldmem_iter(struct iov_iter *iter, size_t count, return read; } -ssize_t read_from_oldmem(char *buf, size_t count, - u64 *ppos, int userbuf, - bool encrypted) -{ - struct iov_iter iter; - struct iovec iov; - struct kvec kvec; - - if (userbuf) { - iov.iov_base = (__force void __user *)buf; - iov.iov_len = count; - iov_iter_init(&iter, READ, &iov, 1, count); - } else { - kvec.iov_base = buf; - kvec.iov_len = count; - iov_iter_kvec(&iter, READ, &kvec, 1, count); - } - - return read_from_oldmem_iter(&iter, count, ppos, encrypted); -} - /* * Architectures may override this function to allocate ELF header in 2nd kernel */ @@ -215,7 +194,12 @@ void __weak elfcorehdr_free(unsigned long long addr) */ ssize_t __weak elfcorehdr_read(char *buf, size_t count, u64 *ppos) { - return read_from_oldmem(buf, count, ppos, 0, false); + struct kvec kvec = { .iov_base = buf, .iov_len = count }; + struct iov_iter iter; + + iov_iter_kvec(&iter, READ, &kvec, 1, count); + + return read_from_oldmem(&iter, count, ppos, false); } /* @@ -223,7 +207,13 @@ ssize_t __weak elfcorehdr_read(char *buf, size_t count, u64 *ppos) */ ssize_t __weak elfcorehdr_read_notes(char *buf, size_t count, u64 *ppos) { - return read_from_oldmem(buf, count, ppos, 0, cc_platform_has(CC_ATTR_MEM_ENCRYPT)); + struct kvec kvec = { .iov_base = buf, .iov_len = count }; + struct iov_iter iter; + + iov_iter_kvec(&iter, READ, &kvec, 1, count); + + return read_from_oldmem(&iter, count, ppos, + cc_platform_has(CC_ATTR_MEM_ENCRYPT)); } /* @@ -398,7 +388,7 @@ static ssize_t __read_vmcore(struct iov_iter *iter, loff_t *fpos) m->offset + m->size - *fpos, iter->count); start = m->paddr + *fpos - m->offset; - tmp = read_from_oldmem_iter(iter, tsz, &start, + tmp = read_from_oldmem(iter, tsz, &start, cc_platform_has(CC_ATTR_MEM_ENCRYPT)); if (tmp < 0) return tmp; diff --git a/include/linux/crash_dump.h b/include/linux/crash_dump.h index a1cf7d5c03c7..0f3a656293b0 100644 --- a/include/linux/crash_dump.h +++ b/include/linux/crash_dump.h @@ -134,13 +134,11 @@ static inline int vmcore_add_device_dump(struct vmcoredd_data *data) #endif /* CONFIG_PROC_VMCORE_DEVICE_DUMP */ #ifdef CONFIG_PROC_VMCORE -ssize_t read_from_oldmem(char *buf, size_t count, - u64 *ppos, int userbuf, - bool encrypted); +ssize_t read_from_oldmem(struct iov_iter *iter, size_t count, + u64 *ppos, bool encrypted); #else -static inline ssize_t read_from_oldmem(char *buf, size_t count, - u64 *ppos, int userbuf, - bool encrypted) +static inline ssize_t read_from_oldmem(struct iov_iter *iter, size_t count, + u64 *ppos, bool encrypted) { return -EOPNOTSUPP; } -- 2.34.1