Received: by 10.223.185.116 with SMTP id b49csp3208725wrg; Mon, 5 Mar 2018 16:35:05 -0800 (PST) X-Google-Smtp-Source: AG47ELvd2nsTlS7+QuySBnVcRJHFhjTCGGJuXqKWLbL/pBAhfut6JCPcLmcPDpgSdsx/UZyS2kui X-Received: by 10.101.96.142 with SMTP id t14mr13436684pgu.58.1520296505029; Mon, 05 Mar 2018 16:35:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520296504; cv=none; d=google.com; s=arc-20160816; b=kDBmme3O4eC8J2To9K0rHqIMCn5iiY+Etz8tzglWsZ453W+9QtChYwyz3UGDQWwF0S EDpinORSfOc2/1ZSbkvEIJz7qZnygjAjhA04W+B82YypBzo6GgbFROLpJy7RR/al/ZRx wA9OAuba9jNmsTl19AYRLDGsNfYrsO7jjuf/murSLfjpDIemeosAxfyINVskESqN6SvP Jf8sjPCuwnwxreawDdp1ayCYKhC2XrLsynCpWBs8jI+2O7vsCqc0xrY/d6hU+exfaA8h aGwDxPoiS4lyJMyXN5iVV2z42HbdSp0MNxi+FRLhbb28VZJImNZ08Nat7d84DfzDIwhW xDdA== 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:to:from:dkim-signature:arc-authentication-results; bh=2O1xfmJwhi/+CQ7ENmIpGf9ibOdS52oSJ4RPYQeZhQo=; b=vbvptRmxOsDaD8dXIUhnUCXTQdAaTMP64ASNv0jpG9NmzGrt5+xSWD763aJnDu3jwk Cet1QeCAafU8tsbM9Ep+2xKPf5X3kwPMBOfA+cu7clhSPF8aZ+WthSHtUuuBUBbRLw9G qIEabip996Kg6Q8kHUgj1ShRqb7u9uNER1N+yVVmMBXOVdu0b/i5sN9KRvca1pVqRThx 1Dy5GgUks/IDa0BSDvVxOpH5TdSqpqrpQWy9dC2CWdAIiOhEj79kvxemVIdBEaM4+Wol vWTDfJ4oVBaEiaINc7W9yR9EJnCalp4jZMYijekki0E53J6KC36zCdDyW5QaLkTeFhRD NSkg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2017-10-26 header.b=sqTQMKlZ; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p10si9079682pgr.426.2018.03.05.16.34.50; Mon, 05 Mar 2018 16:35:04 -0800 (PST) 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=pass header.i=@oracle.com header.s=corp-2017-10-26 header.b=sqTQMKlZ; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933429AbeCFA0r (ORCPT + 99 others); Mon, 5 Mar 2018 19:26:47 -0500 Received: from aserp2120.oracle.com ([141.146.126.78]:56474 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933325AbeCFA0k (ORCPT ); Mon, 5 Mar 2018 19:26:40 -0500 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w260LXEB034897; Tue, 6 Mar 2018 00:26:29 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references; s=corp-2017-10-26; bh=2O1xfmJwhi/+CQ7ENmIpGf9ibOdS52oSJ4RPYQeZhQo=; b=sqTQMKlZpbtpdlRNVAEyJ4IvJWOYDdIcPRzKIch0YLq4uu1d+CmLP3JHPn60krY+N2+4 u7mp1/lz1Qt8vIoel29oc1ldVy9EKjxL66MiNyhNpD5Vaav48itAtovSBY/jE97/1WD1 5FIXZ2Q77fKPzEPEaJsj65iS3xotuurwCYi1vY0p1iOT1Y5uP8/Z7AvEFqChfvcWx88u zIDntVYcqZF1XM1b+RJznqgKf8mZWR5QXgcbH8XkLhccx16lo51m/lOZma8EtsOR1WyA HMurAMXvN4RJSx7WfSh0domjGwSj6OIr/H2ryEnGWLZi3eLzDithVvSkfjRWQ+OYLJDe 2g== Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by aserp2120.oracle.com with ESMTP id 2ghe3kgg42-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 06 Mar 2018 00:26:29 +0000 Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w260QTPZ023759 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 6 Mar 2018 00:26:29 GMT Received: from abhmp0008.oracle.com (abhmp0008.oracle.com [141.146.116.14]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w260QSFW022189; Tue, 6 Mar 2018 00:26:29 GMT Received: from localhost.localdomain (/98.216.35.41) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 05 Mar 2018 16:26:28 -0800 From: Pavel Tatashin To: steven.sistare@oracle.com, daniel.m.jordan@oracle.com, linux-kernel@vger.kernel.org, Alexander.Levin@microsoft.com, dan.j.williams@intel.com, sathyanarayanan.kuppuswamy@intel.com, pankaj.laxminarayan.bharadiya@intel.com, akuster@mvista.com, cminyard@mvista.com, pasha.tatashin@oracle.com, gregkh@linuxfoundation.org, stable@vger.kernel.org Subject: [PATCH 4.1 34/65] kaiser: ENOMEM if kaiser_pagetable_walk() NULL Date: Mon, 5 Mar 2018 19:25:07 -0500 Message-Id: <20180306002538.1761-35-pasha.tatashin@oracle.com> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180306002538.1761-1-pasha.tatashin@oracle.com> References: <20180306002538.1761-1-pasha.tatashin@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8823 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=835 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1711220000 definitions=main-1803060003 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Hugh Dickins kaiser_add_user_map() took no notice when kaiser_pagetable_walk() failed. And avoid its might_sleep() when atomic (though atomic at present unused). Signed-off-by: Hugh Dickins Acked-by: Jiri Kosina Signed-off-by: Greg Kroah-Hartman (cherry picked from commit 407c3ff6a24c7cb418b77a124d17e282f9622037) Signed-off-by: Pavel Tatashin Conflicts: arch/x86/mm/kaiser.c --- arch/x86/mm/kaiser.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/arch/x86/mm/kaiser.c b/arch/x86/mm/kaiser.c index df7f6591d5aa..058d0886086b 100644 --- a/arch/x86/mm/kaiser.c +++ b/arch/x86/mm/kaiser.c @@ -99,11 +99,11 @@ static pte_t *kaiser_pagetable_walk(unsigned long address, bool is_atomic) pgd_t *pgd = native_get_shadow_pgd(pgd_offset_k(address)); gfp_t gfp = (GFP_KERNEL | __GFP_NOTRACK | __GFP_ZERO); - might_sleep(); if (is_atomic) { gfp &= ~GFP_KERNEL; gfp |= __GFP_HIGH; - } + } else + might_sleep(); if (pgd_none(*pgd)) { WARN_ONCE(1, "All shadow pgds should have been populated"); @@ -160,13 +160,17 @@ int kaiser_add_user_map(const void *__start_addr, unsigned long size, unsigned long end_addr = PAGE_ALIGN(start_addr + size); unsigned long target_address; - for (;address < end_addr; address += PAGE_SIZE) { + for (; address < end_addr; address += PAGE_SIZE) { target_address = get_pa_from_mapping(address); if (target_address == -1) { ret = -EIO; break; } pte = kaiser_pagetable_walk(address, false); + if (!pte) { + ret = -ENOMEM; + break; + } if (pte_none(*pte)) { set_pte(pte, __pte(flags | target_address)); } else { -- 2.16.2