From patchwork Mon Jan 18 14:01:05 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 59925 Delivered-To: patch@linaro.org Received: by 10.112.130.2 with SMTP id oa2csp2013404lbb; Mon, 18 Jan 2016 06:03:23 -0800 (PST) X-Received: by 10.98.42.135 with SMTP id q129mr36340624pfq.13.1453125803412; Mon, 18 Jan 2016 06:03:23 -0800 (PST) Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id u14si39937446pfa.221.2016.01.18.06.03.23 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 18 Jan 2016 06:03:23 -0800 (PST) Received-SPF: pass (google.com: domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) client-ip=2001:1868:205::9; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) smtp.mailfrom=linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org; dkim=neutral (body hash did not verify) header.i=@linaro.org Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1aLANO-0005WR-M3; Mon, 18 Jan 2016 14:01:46 +0000 Received: from mail-wm0-x22a.google.com ([2a00:1450:400c:c09::22a]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aLANH-0005Ij-FQ for linux-arm-kernel@lists.infradead.org; Mon, 18 Jan 2016 14:01:43 +0000 Received: by mail-wm0-x22a.google.com with SMTP id n5so65439076wmn.0 for ; Mon, 18 Jan 2016 06:01:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=jHkc/5xRgBoi1bpK4GowHkCZ1FZQ9uBCT0VxH2pY4Ro=; b=j4x5wPHt+VIPODoubCHxbKiJMj74qPA4IXuH4C+JJ4iDbrjLVAZL0oKD+wyKP+3i/h x+jBXT6AJC6G+qfuccjHnWd4a2gqcRBoMt8U4iQt+bAeBReBxKi4aVvgziKSa0PENB8/ 0VvK0hbYc6jgKr/2BEoWLqh/mxCMXZ7DDXDro= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=jHkc/5xRgBoi1bpK4GowHkCZ1FZQ9uBCT0VxH2pY4Ro=; b=IJW+4v8vQKStNmC9e3jAGUw3Nu+ubHCtcjAgkHxAjup7etA6XA+WnKj/KoZE7ewL3e A2yOLRpPhcDrq2JWLVcD3/jhIkpx7sH38L9YoAd+CTmQOaGvHGr7wvRhMjVr5vBlp03F zRH9To6+SanTYJ5PKlT1wTWyC5fXOS6rzprd5LYkVXgWTJcZ6u8DihHppcrC5AsgIDju rGUwpecBcVPMa5qXyt1amnGyks9nOmOtgVvzG5mSYmOjdMGnB+jSFlWQgUPScoSKBDIa s/8rayUPTbeHNXPO9be0GeK8JdiV9j/P7R0AdFWMNcUj4AsZJ1RMK6QNR6Ooq2hQs46c FK4A== X-Gm-Message-State: AG10YOTgJvXGLe/E3zUchMC/KMRcGZeftneQoZRhRkIcKotoq+jVdyZYBGl0NQXr5l6iLGbG X-Received: by 10.28.54.65 with SMTP id d62mr12924922wma.35.1453125676869; Mon, 18 Jan 2016 06:01:16 -0800 (PST) Received: from localhost.localdomain (cag06-7-83-153-85-71.fbx.proxad.net. [83.153.85.71]) by smtp.gmail.com with ESMTPSA id jo6sm24162102wjb.48.2016.01.18.06.01.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 18 Jan 2016 06:01:15 -0800 (PST) From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org, labbott@fedoraproject.org, mark.rutland@arm.com, catalin.marinas@arm.com, will.deacon@arm.com Subject: [PATCH] arm64: allow vmalloc regions to be set with set_memory_* Date: Mon, 18 Jan 2016 15:01:05 +0100 Message-Id: <1453125665-26627-1-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.5.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160118_060139_673992_1DB71B40 X-CRM114-Status: GOOD ( 14.16 ) X-Spam-Score: -2.7 (--) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-2.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [2a00:1450:400c:c09:0:0:0:22a listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: keescook@chromium.org, Ard Biesheuvel MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org The range of set_memory_* is currently restricted to the module address range because of difficulties in breaking down larger block sizes. vmalloc maps PAGE_SIZE pages so it is safe to use as well. Update the function ranges and add a comment explaining why the range is restricted the way it is. Suggested-by: Laura Abbott Signed-off-by: Ard Biesheuvel --- arch/arm64/mm/pageattr.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) -- 2.5.0 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel Acked-by: Mark Rutland Acked-by: Will Deacon diff --git a/arch/arm64/mm/pageattr.c b/arch/arm64/mm/pageattr.c index 3571c7309c5e..1360a02d88b7 100644 --- a/arch/arm64/mm/pageattr.c +++ b/arch/arm64/mm/pageattr.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include @@ -44,6 +45,7 @@ static int change_memory_common(unsigned long addr, int numpages, unsigned long end = start + size; int ret; struct page_change_data data; + struct vm_struct *area; if (!PAGE_ALIGNED(addr)) { start &= PAGE_MASK; @@ -51,10 +53,23 @@ static int change_memory_common(unsigned long addr, int numpages, WARN_ON_ONCE(1); } - if (start < MODULES_VADDR || start >= MODULES_END) - return -EINVAL; - - if (end < MODULES_VADDR || end >= MODULES_END) + /* + * Kernel VA mappings are always live, and splitting live section + * mappings into page mappings may cause TLB conflicts. This means + * we have to ensure that changing the permission bits of the range + * we are operating on does not result in such splitting. + * + * Let's restrict ourselves to mappings created by vmalloc (or vmap). + * Those are guaranteed to consist entirely of page mappings, and + * splitting is never needed. + * + * So check whether the [addr, addr + size) interval is entirely + * covered by precisely one VM area that has the VM_ALLOC flag set. + */ + area = find_vm_area((void *)addr); + if (!area || + end > (unsigned long)area->addr + area->size || + !(area->flags & VM_ALLOC)) return -EINVAL; data.set_mask = set_mask;