From patchwork Tue Aug 28 14:57:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 10578663 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E211C175A for ; Tue, 28 Aug 2018 14:57:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D2BB82A4B8 for ; Tue, 28 Aug 2018 14:57:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C6E712A4C8; Tue, 28 Aug 2018 14:57:52 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4BDE12A4B8 for ; Tue, 28 Aug 2018 14:57:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BC60A6B46E3; Tue, 28 Aug 2018 10:57:41 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id B78726B46E4; Tue, 28 Aug 2018 10:57:41 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A676C6B46E5; Tue, 28 Aug 2018 10:57:41 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg1-f198.google.com (mail-pg1-f198.google.com [209.85.215.198]) by kanga.kvack.org (Postfix) with ESMTP id 61AB46B46E4 for ; Tue, 28 Aug 2018 10:57:41 -0400 (EDT) Received: by mail-pg1-f198.google.com with SMTP id u6-v6so1284880pgn.10 for ; Tue, 28 Aug 2018 07:57:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references; bh=wjUXKpM3aAzUZ+cGrcsbIYHIevH4mUeUXMQGZp2tvbE=; b=Hera40S4Ot2Ze3UGmgM2qj/C+CyUELn5sMYKsDYas5YvPiFcaDI2acI+NjGDQu9BmB cIkdYzQ4NPNW7lfYWnHsrMwQw7xzO7HJqrgwBHLhSVRCJCxQ2nKQJPlVqVmbme9FZIbC Ax4FJ+gWWaVrFRMu2q+KoIElMplreMX2gNIiJrlyBjONH3b/8k3LOGDnQH47OkTzEOlZ fO+9QEF7vXC5QTTbJHAsBHxYnpF1f5kU/bcaKzAyCo7xpliZIU+oJHb6teI4KZeviVDa 0XIoXjchoAGNE1HmUTiPg8KgDhul2Kvm9JhyGI8nrJghLDpaatMTBSI2L12l/FLO+ngD 45Ng== X-Gm-Message-State: APzg51BQhoO8BOLqcoIJ4ZPeEdI07r4oFEvS312KzqnOV2SNF2a0eci1 ui4cvn4ixWgTmktadWA2Q/kcxgdk2YulNIC3hyeGinEORkUzPsswPJKWOqslgjNqSS52i4vg4U8 HhW/vKl9wOhWpsvnaGfPTrhr2uhpzrKGqqR7fT6xa5XIuvu4tcb/nS5oVjH7jAj9iaQ== X-Received: by 2002:a17:902:b78a:: with SMTP id e10-v6mr1957422pls.79.1535468261069; Tue, 28 Aug 2018 07:57:41 -0700 (PDT) X-Google-Smtp-Source: ANB0VdaWZowwJWo1el9MaY2aP8KrMzBBPalqozCx+aN6YbYKZMnqI5440EH2+I/Lu2yUjM7N6sSl X-Received: by 2002:a17:902:b78a:: with SMTP id e10-v6mr1957383pls.79.1535468260266; Tue, 28 Aug 2018 07:57:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535468260; cv=none; d=google.com; s=arc-20160816; b=sRQ+JWHBMHVVVTgR5LN+IudcgitHEqNXQCAp+QC2LfaFMPDv1ZJNU0xymr95PdWKeo kirqGKhGvgI7+DowivYU+UvwuYhcCAWN3p4ocbrIt9UHtmZfSihYxaFCIaItATzMZsaI IfndGmKgbh17gEINIsRA8As9CrGBjy4Mb4+6MpumzgvISAD1H8p4Hpe+IiMR/RCiwSgc qO0rXpzh76dDiOXSDN1HcGrxYxndnR4KEAZ0YO4POfF9uLUWqsIssXZht27t6tW2GR8m jVsQxn85uq184vo0WlmJwr4e6K2U3F1wzFW5cCuG6DQHKTWRYJRVKlKv7yodE/0u7U/X Y4/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=wjUXKpM3aAzUZ+cGrcsbIYHIevH4mUeUXMQGZp2tvbE=; b=lWprtYW/g616YQLhQ2dheHoMNdVIv2oAkPwhUxXpeKI0p9RqjnH1d6cIfaRdUPvXpf ZtCZkEdcLH6lUWYuB0g8Gs87VU31oSfnu9QNPGbpta3wOoOKvlKbWAtR7L4pZcNw7h5O lpCe5713vinRmKTG3l40Y0IOjcwd3PhekpXm3v5+wtSw6juXJak6d1dNleFmkN0/fLkN OGMKTzvTM07oLhz0vIeP899v1/FlgOAx3mFM8cp2a0Ldq63xWPwM7815MRpIhbnJL6c2 tNyqo/9tTrzO5OSTijVR0nXy2CHhCC6Z/z0KOj8gYSWamDxnyy5BUuUTJ+mgXrpeug6W GNyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=MlhXHXbQ; spf=pass (google.com: best guess record for domain of willy@infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=willy@infradead.org Received: from bombadil.infradead.org (bombadil.infradead.org. [2607:7c80:54:e::133]) by mx.google.com with ESMTPS id p14-v6si1103573plo.357.2018.08.28.07.57.40 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 28 Aug 2018 07:57:40 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of willy@infradead.org designates 2607:7c80:54:e::133 as permitted sender) client-ip=2607:7c80:54:e::133; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=MlhXHXbQ; spf=pass (google.com: best guess record for domain of willy@infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=willy@infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=References:In-Reply-To:Message-Id: Date:Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=wjUXKpM3aAzUZ+cGrcsbIYHIevH4mUeUXMQGZp2tvbE=; b=MlhXHXbQ1yVhRHApMUy8I29KV VXzlYu8vxHys6oa7NbpZdSNzLegAaI9Ur6UIXY8+b5kLvbwaLz/8avtBllWksP1Rldm39jWjGpMdr vg+Ih3FhWQMjH5A9ciQy/4luhOyRIuQX/HRdU31sOucg1qQOmhNsBm5hQuIeRSOb9Y0vvIvEd48+2 3/2JjAO7n+4jBsQjc2WzFOndcIyUG5N/pUYZMiHBp3XHHRA2x2dpg7Q9GSIqT374wyCRrY2lrtqtK GnOao8nSZdmF/nwDTEV95bfLP9hNfALfgoiI8LEsTkFjstPZOutvTt7xr8OxbVMVBeZMBe1PQXPbh w+aKeWd+A==; Received: from willy by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1fufR4-0003BA-GK; Tue, 28 Aug 2018 14:57:38 +0000 From: Matthew Wilcox To: Andrew Morton Cc: Matthew Wilcox , Nicolas Pitre , Souptick Joarder , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 04/10] x86: Convert vdso to use vm_fault_t Date: Tue, 28 Aug 2018 07:57:22 -0700 Message-Id: <20180828145728.11873-5-willy@infradead.org> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180828145728.11873-1-willy@infradead.org> References: <20180828145728.11873-1-willy@infradead.org> X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP Return vm_fault_t codes directly from the appropriate mm routines instead of converting from errnos ourselves. Fixes a minor bug where we'd return SIGBUS instead of the correct OOM code if we ran out of memory allocating page tables. Signed-off-by: Matthew Wilcox Reviewed-by: Thomas Gleixner --- arch/x86/entry/vdso/vma.c | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/arch/x86/entry/vdso/vma.c b/arch/x86/entry/vdso/vma.c index 5b8b556dbb12..d1daa53215a4 100644 --- a/arch/x86/entry/vdso/vma.c +++ b/arch/x86/entry/vdso/vma.c @@ -39,7 +39,7 @@ void __init init_vdso_image(const struct vdso_image *image) struct linux_binprm; -static int vdso_fault(const struct vm_special_mapping *sm, +static vm_fault_t vdso_fault(const struct vm_special_mapping *sm, struct vm_area_struct *vma, struct vm_fault *vmf) { const struct vdso_image *image = vma->vm_mm->context.vdso_image; @@ -84,12 +84,11 @@ static int vdso_mremap(const struct vm_special_mapping *sm, return 0; } -static int vvar_fault(const struct vm_special_mapping *sm, +static vm_fault_t vvar_fault(const struct vm_special_mapping *sm, struct vm_area_struct *vma, struct vm_fault *vmf) { const struct vdso_image *image = vma->vm_mm->context.vdso_image; long sym_offset; - int ret = -EFAULT; if (!image) return VM_FAULT_SIGBUS; @@ -108,29 +107,24 @@ static int vvar_fault(const struct vm_special_mapping *sm, return VM_FAULT_SIGBUS; if (sym_offset == image->sym_vvar_page) { - ret = vm_insert_pfn(vma, vmf->address, - __pa_symbol(&__vvar_page) >> PAGE_SHIFT); + return vmf_insert_pfn(vma, vmf->address, + __pa_symbol(&__vvar_page) >> PAGE_SHIFT); } else if (sym_offset == image->sym_pvclock_page) { struct pvclock_vsyscall_time_info *pvti = pvclock_get_pvti_cpu0_va(); if (pvti && vclock_was_used(VCLOCK_PVCLOCK)) { - ret = vm_insert_pfn_prot( - vma, - vmf->address, - __pa(pvti) >> PAGE_SHIFT, - pgprot_decrypted(vma->vm_page_prot)); + return vmf_insert_pfn_prot(vma, vmf->address, + __pa(pvti) >> PAGE_SHIFT, + pgprot_decrypted(vma->vm_page_prot)); } } else if (sym_offset == image->sym_hvclock_page) { struct ms_hyperv_tsc_page *tsc_pg = hv_get_tsc_page(); if (tsc_pg && vclock_was_used(VCLOCK_HVCLOCK)) - ret = vm_insert_pfn(vma, vmf->address, - vmalloc_to_pfn(tsc_pg)); + return vmf_insert_pfn(vma, vmf->address, + vmalloc_to_pfn(tsc_pg)); } - if (ret == 0 || ret == -EBUSY) - return VM_FAULT_NOPAGE; - return VM_FAULT_SIGBUS; }