Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp2438361imj; Mon, 18 Feb 2019 06:05:45 -0800 (PST) X-Google-Smtp-Source: AHgI3IY/rbiAjXiKozTIpMzCf3eNaEc4chmoVNriO0PaTrWKc+DRk4BRY370VT5RdlUYaxpim7MA X-Received: by 2002:a65:41c2:: with SMTP id b2mr18936977pgq.67.1550498745445; Mon, 18 Feb 2019 06:05:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550498745; cv=none; d=google.com; s=arc-20160816; b=GsNK5q4bk83ujqDG9JHDFY0LlngVtMPX7skhfQ90ZQuyjHLMLUIxoD+C/nZ9HnkWdV cl0rUQ3ISmzHXswG6pscmLrvkUxMYAuoCSnzVY047k7mGZGc9Xr10r8q0sCCT8UwXTvL hfHx5eNgq0CmIfZkmefnSqTJU70FzA8kyjAg0B7lO/EA07M0gzbvKvGrJldJ5caYI5xj bs6tZvNQflD/EUU4YcjoojNLodXvHGhHQZwu2Fg/1T5BHXZZ+ZpxYEf+XNYNK8XxsD0K 31PK6VLa8AElPoMLMHe8w1Wf6saPysYKWlAeZ8dJDWjP84mC8jTw6xPwzIwZ1thUnX1w drhA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=JMsMDvNaO5/B8qr06UQ25aLExvgz4/RKK1U5tKv8kVo=; b=xSLLkjzRMstS4Xlfr1oZSDQ7l5NAuu9P5Lsye4t0wdtZGOlnNv0zFdfrtJdAUwC1uj FQMYq7kUBHqKGR+dANLnuq5gHuJuq8bwaHv6yeOM6lalwYg6o07TdbozkSP3qRDu7s7C +c/X03azQT6MC6FXxQT3EPm1Cq9sHtdjBYAU3whewLwfALxr6qsVAsUXuHHQ6o/XVI+4 PLj3P5oclcoorLHHbChqZl6++mMYq4lsndBrP56/eHWsmQmLINvJxE5TWEllNwFxzLUH Ddu3fFqpUo+hIFLF4fEJI/EEIhc8keXXWWnWqEXuK5uOV7RTgB9gDxb9QayFZrJc7frs xadA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="a/0QG9CR"; 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 30si13775170ple.287.2019.02.18.06.05.30; Mon, 18 Feb 2019 06:05:45 -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=@kernel.org header.s=default header.b="a/0QG9CR"; 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 S2389697AbfBRODa (ORCPT + 99 others); Mon, 18 Feb 2019 09:03:30 -0500 Received: from mail.kernel.org ([198.145.29.99]:45386 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389691AbfBROD1 (ORCPT ); Mon, 18 Feb 2019 09:03:27 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 4F3B62070D; Mon, 18 Feb 2019 14:03:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1550498606; bh=9lFSmPBTLREf+u/IAkmAImviphgRRXcC8LwIqAfEDHI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=a/0QG9CRkZdV6uB796HoU+89vw+AtXjwmxgTwlM6NL6KtNAbF2bdzCOLrr5wz7qzl aE1zbEpU530dDF9OL07a+IIGScBrZ5SysXuc8aYauH/Yzt9uULeML02OT0YuH2CTLM sI0vDr5M8jfgAZViGS9OL8ulSGtLCqICQLgWJ4x0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Anton Ivanov , Richard Weinberger , Sasha Levin Subject: [PATCH 4.4 062/143] um: Avoid marking pages with "changed protection" Date: Mon, 18 Feb 2019 14:43:10 +0100 Message-Id: <20190218133531.371720729@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190218133529.099444112@linuxfoundation.org> References: <20190218133529.099444112@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ [ Upstream commit 8892d8545f2d0342b9c550defbfb165db237044b ] Changing protection is a very high cost operation in UML because in addition to an extra syscall it also interrupts mmap merge sequences generated by the tlb. While the condition is not particularly common it is worth avoiding. Signed-off-by: Anton Ivanov Signed-off-by: Richard Weinberger Signed-off-by: Sasha Levin --- arch/um/include/asm/pgtable.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/arch/um/include/asm/pgtable.h b/arch/um/include/asm/pgtable.h index 18eb9924dda3..aeb430212947 100644 --- a/arch/um/include/asm/pgtable.h +++ b/arch/um/include/asm/pgtable.h @@ -197,12 +197,17 @@ static inline pte_t pte_mkold(pte_t pte) static inline pte_t pte_wrprotect(pte_t pte) { - pte_clear_bits(pte, _PAGE_RW); + if (likely(pte_get_bits(pte, _PAGE_RW))) + pte_clear_bits(pte, _PAGE_RW); + else + return pte; return(pte_mknewprot(pte)); } static inline pte_t pte_mkread(pte_t pte) { + if (unlikely(pte_get_bits(pte, _PAGE_USER))) + return pte; pte_set_bits(pte, _PAGE_USER); return(pte_mknewprot(pte)); } @@ -221,6 +226,8 @@ static inline pte_t pte_mkyoung(pte_t pte) static inline pte_t pte_mkwrite(pte_t pte) { + if (unlikely(pte_get_bits(pte, _PAGE_RW))) + return pte; pte_set_bits(pte, _PAGE_RW); return(pte_mknewprot(pte)); } -- 2.19.1