Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp7200092imm; Tue, 28 Aug 2018 08:00:26 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZapNjjOItdXd9KjVVbY27Pdfvdk67nkwG7o/+Qt50bqvGCAqRmC7+5xTLGOTv4ZCDzR0nc X-Received: by 2002:a63:d645:: with SMTP id d5-v6mr1923587pgj.450.1535468426680; Tue, 28 Aug 2018 08:00:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535468426; cv=none; d=google.com; s=arc-20160816; b=qWRGEAe7j1eOXuamtfo7zNMhfOMuQ4JOMADNMXPPngN3e2IigVwPSOQXwtsFL1cCzO kmvDo7ae5UbPyAjxRNuP0o6kTPQaK4VoXl6tYEdCLMAQ2/5PR8fjm5Qr/NqT9hsSRZIk z6QV4gbUveK5l37k6rEYTourmUWYv3OJViJYqEG+nX/W7vD0KLrnj5UbwHkmLF7hcvMY tv/YIaae0v4jHaxWyKmxuc1YBQsJm6AP9UHEWc7fYVmso76CbEKseZcrqc1LSQh3mf6i Umtv0hxVhGrpRhIOExks2sfu8IM14uIiKyYWX/Zg/HpLOExz5zt4PIPyY4EGxcEYRCFo oIwg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=wjUXKpM3aAzUZ+cGrcsbIYHIevH4mUeUXMQGZp2tvbE=; b=JvwYO2gw35FOJjgtc9VnRjuH+I32zymVkn4zk9/jzxEQyDnewsyDozwWwuA6yRssNA s7DBpLLLkt6tGJ2NWBi7bhMpWlE/lDbhUOK0SfEYpU6jJMwcxcrpjWWMIv5AE0lP1pVx UTPAMjcMmA0PNuhlJpMUGkPpYzU7WVLdRTk0c4DJ+RI0k9R0ULd/TXGu3xHM5dsUSoXy OdjeD4OIuiocdMP7QnqHK+XPW2+fpP9G7Zmt61Hic4Wpvtt9tRW+iMQ8KmpN7Y6/xPPB u94HVvdpJCQDe+NBudO1tvDXrncV4jtn50TKSutkNe0uXT439hCI1jRuOhXdifVwtxTe ag2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=MlhXHXbQ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v21-v6si1194355plo.397.2018.08.28.08.00.11; Tue, 28 Aug 2018 08:00:26 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=MlhXHXbQ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728588AbeH1SuY (ORCPT + 99 others); Tue, 28 Aug 2018 14:50:24 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:57600 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727827AbeH1Stn (ORCPT ); Tue, 28 Aug 2018 14:49:43 -0400 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> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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; } -- 2.18.0