Received: by 2002:a05:6a10:144:0:0:0:0 with SMTP id 4csp124665pxw; Fri, 8 Apr 2022 03:09:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxrCNGj3fjFi7HqrEXqCaHcHhUML4bOi/81oCUrP1wmBFgMbFWKK+roQ1M0ig6v/SeuXT9D X-Received: by 2002:aa7:d047:0:b0:41d:57cf:d588 with SMTP id n7-20020aa7d047000000b0041d57cfd588mr342206edo.172.1649412562921; Fri, 08 Apr 2022 03:09:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649412562; cv=none; d=google.com; s=arc-20160816; b=sDjbzNFYLgX1KpRswKSffV9KVI+oiBp6+jejawa0kk6pgfuOhwCtAFS/x+r11a9z1Z 75mUk5V8qA0c518F8pPo0f4CtuOXtalS14pj/W1035Upf/wh77Gu51gsT13egnLUP6JR 0K8f+2HnOsiPXyEGXxgIMGnPwQaNvQLXRmD39loPUCdAGzW5ujyICrXPyZAbvxkcD5U4 e94mdKRnpOtAF225zIid2cPPzCMvPBo917TzuITwIou8qpCzp7oXB1F+ApWfKnjHXfd+ mtsywM9rs+T2dXzYIENSZw+1lAPuAozzpnbnShbsMuF529k5PwZlVeHKRWnXMdmjN/YP ZObQ== 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=yHLCjlYnnFOLeGoKpgGlpY1aKWwlRcZvbE9KjRYMfXU=; b=uKThADtRNf1iMaT1AtZtfsELfRj49BpNGrpVZzKW4RrcDUZfzcr6v4H7J2XHHSJKmk yWYwwmyLbhn04IKeojhSPZ8VxgWyCOoCM0sSN1OAjYWsD0NnGr/1wJHIPdQhWl/3HGnz rc/s0BFU5sJS9CVkC6fs8/d/s/eiv4FSCbXyLNqCIwUMBKKou1o74bz40T1FJmHpk4Lj ecaS8rS+A5hD9Ne5cfTTIqaYTeQItgXAaq50QZAH5+Lw5SrOaOBXRAw+e9MZ59budEap kp7CVAEH/wuLXXlNSkOKYIv5NAGmrE9AkiB6pKsCXMU+8Hdz3M0tGT2FYPx388+ybtg+ 7i3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=MlCbcKTq; 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 ho38-20020a1709070ea600b006dfd10f9edfsi966735ejc.759.2022.04.08.03.08.56; Fri, 08 Apr 2022 03:09:22 -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=MlCbcKTq; 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 S232645AbiDHJJ1 (ORCPT + 99 others); Fri, 8 Apr 2022 05:09:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58290 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231255AbiDHJJP (ORCPT ); Fri, 8 Apr 2022 05:09:15 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id D27C01017ED for ; Fri, 8 Apr 2022 02:07:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1649408824; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=yHLCjlYnnFOLeGoKpgGlpY1aKWwlRcZvbE9KjRYMfXU=; b=MlCbcKTq+/O7ERhaSIrabCUKmYRHjVviOuL8z3rZ6Wn4y+26uosY2yVxMRyfJDLayvyEF3 2lY71+FPga7M4XDQH2X5pU1ElBy3OZLvRy6sj2FaS/jZNcniW4ogZNm2Ixy0HQFTi1GSnz kX5L0YIQFlwu7j+a1kJGAOvj/Rbyo54= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-644-ZUiCTedzO7a7AlXgx5iI0w-1; Fri, 08 Apr 2022 05:07:01 -0400 X-MC-Unique: ZUiCTedzO7a7AlXgx5iI0w-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 74A6B28EA702; Fri, 8 Apr 2022 09:07:00 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-12-202.pek2.redhat.com [10.72.12.202]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0734E40D2962; Fri, 8 Apr 2022 09:06:55 +0000 (UTC) From: Baoquan He To: akpm@linux-foundation.org, willy@infradead.org Cc: linux-kernel@vger.kernel.org, kexec@lists.infradead.org, hch@lst.de, yangtiezhu@loongson.cn, amit.kachhap@arm.com, linux-fsdevel@vger.kernel.org, viro@zeniv.linux.org.uk, bhe@redhat.com Subject: [PATCH v5 RESEND 3/3] vmcore: Convert read_from_oldmem() to take an iov_iter Date: Fri, 8 Apr 2022 17:06:36 +0800 Message-Id: <20220408090636.560886-4-bhe@redhat.com> In-Reply-To: <20220408090636.560886-1-bhe@redhat.com> References: <20220408090636.560886-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.84 on 10.11.54.2 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, 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 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) Signed-off-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 4a721865b5cd..4eaeb645e759 100644 --- a/fs/proc/vmcore.c +++ b/fs/proc/vmcore.c @@ -129,7 +129,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; @@ -178,27 +178,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 */ @@ -218,7 +197,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); } /* @@ -226,7 +210,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)); } /* @@ -402,7 +392,7 @@ static ssize_t __read_vmcore(struct iov_iter *iter, loff_t *fpos) m->offset + m->size - *fpos, iov_iter_count(iter)); 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