From patchwork Wed Jun 29 12:51:28 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 71190 Delivered-To: patch@linaro.org Received: by 10.140.28.4 with SMTP id 4csp2134558qgy; Wed, 29 Jun 2016 05:53:36 -0700 (PDT) X-Received: by 10.98.62.15 with SMTP id l15mr11466703pfa.24.1467204816432; Wed, 29 Jun 2016 05:53:36 -0700 (PDT) Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id i186si4375997pfe.3.2016.06.29.05.53.36 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 29 Jun 2016 05:53:36 -0700 (PDT) Received-SPF: pass (google.com: best guess record for 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; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for 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; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1bIEyx-0006BN-CI; Wed, 29 Jun 2016 12:52:43 +0000 Received: from mail-wm0-x234.google.com ([2a00:1450:400c:c09::234]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bIEyJ-0005Wl-0Y for linux-arm-kernel@lists.infradead.org; Wed, 29 Jun 2016 12:52:04 +0000 Received: by mail-wm0-x234.google.com with SMTP id r201so72329275wme.1 for ; Wed, 29 Jun 2016 05:51:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=NSA4pog7YjW6R4dv3iqkeongv4IMGuEap3XjJ0fQW8M=; b=D6YCR2aGA5qUdpJObRy8+g7sbwoF1I+9vNkR2iLGHxS/aBh6uCcmhOPhPG8C854z9l fhyy9vxQlq/190RfD9bs103u+9Kn6rI+Opgl10lbLg25X/rXLzK1JM8+++lKSlhAEQFv /niPxVzVRzZ0AIiC/tQdOj0gYjzCIaoyTVFR8= 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:in-reply-to :references; bh=NSA4pog7YjW6R4dv3iqkeongv4IMGuEap3XjJ0fQW8M=; b=f2dkyvIR2A0j1hBt0kM8MNiJP+Ov5puz277XAjxZNNWB6frGVhhhQ64oTm8LcmhbEv MH1tCuTKFwv51O0eU5S1E6GV/9XTP64kXZ8ZVzEsPXezjw0nXYTdqtZ/dI6hm82m+5b2 rUXfYwuzN0fOW9RK+0c0B7Md/ySvTuCo8CBX4wY7bMA3lQC22Y+AQiiAUWuIQ7AzLPax subFxtzwyTNmbSOc0ghpm9+AKfnWnt5f1Cf1WPoUFbfrhrkBAh+0+4oUXBWdNCJGm86A bwpH/NPjbivdd8fL6YC4rqeiXOi5LpU81gDvB/JbUuCQPtTmj63skKjQawRYXjY2GTQR JoXA== X-Gm-Message-State: ALyK8tKG0/TlOYojINefhRW/R2RzAJDtUEDjPsl+5Xrcdq2lwO4NLc+ZQnXLWWLcfrYovu58 X-Received: by 10.28.210.83 with SMTP id j80mr9225243wmg.54.1467204701290; Wed, 29 Jun 2016 05:51:41 -0700 (PDT) Received: from localhost.localdomain ([188.203.148.129]) by smtp.gmail.com with ESMTPSA id bh7sm3592433wjb.22.2016.06.29.05.51.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 29 Jun 2016 05:51:40 -0700 (PDT) From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org, linux-efi@vger.kernel.org, catalin.marinas@arm.com, mark.rutland@arm.com, matt@codeblueprint.co.uk Subject: [PATCH 3/5] arm64: efi: avoid block mappings for unaligned UEFI memory regions Date: Wed, 29 Jun 2016 14:51:28 +0200 Message-Id: <1467204690-10790-4-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1467204690-10790-1-git-send-email-ard.biesheuvel@linaro.org> References: <1467204690-10790-1-git-send-email-ard.biesheuvel@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160629_055203_267306_8075698D X-CRM114-Status: GOOD ( 14.33 ) 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:234 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 Message has at least one valid DKIM or DK signature -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 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: leif.lindholm@linaro.org, Ard Biesheuvel MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org When running the OS with a page size > 4 KB, we need to round up mappings for regions that are not aligned to the OS's page size. We already avoid block mappings for EfiRuntimeServicesCode/Data regions for other reasons, but in the unlikely event that other unaliged regions exists that have the EFI_MEMORY_RUNTIME attribute set, ensure that unaligned regions are always mapped down to pages. This way, the overlapping page is guaranteed not to be covered by a block mapping that needs to be split. Signed-off-by: Ard Biesheuvel --- arch/arm64/kernel/efi.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) -- 2.7.4 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel diff --git a/arch/arm64/kernel/efi.c b/arch/arm64/kernel/efi.c index 4aef89f37049..ba9bee389fd5 100644 --- a/arch/arm64/kernel/efi.c +++ b/arch/arm64/kernel/efi.c @@ -65,6 +65,20 @@ int __init efi_create_mapping(struct mm_struct *mm, efi_memory_desc_t *md) bool allow_block_mappings = (md->type != EFI_RUNTIME_SERVICES_CODE && md->type != EFI_RUNTIME_SERVICES_DATA); + if (!PAGE_ALIGNED(md->phys_addr) || + !PAGE_ALIGNED(md->num_pages << EFI_PAGE_SHIFT)) { + /* + * If the end address of this region is not aligned to page + * size, the mapping is rounded up, and may end up sharing a + * page frame with the next UEFI memory region. If we create + * a block entry now, we may need to split it again when mapping + * the next region, and support for that is going to be removed + * from the MMU routines. So avoid block mappings altogether in + * that case. + */ + allow_block_mappings = false; + } + create_pgd_mapping(mm, md->phys_addr, md->virt_addr, md->num_pages << EFI_PAGE_SHIFT, __pgprot(prot_val | PTE_NG), allow_block_mappings);