From patchwork Mon Oct 26 08:41:00 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 55524 Delivered-To: patch@linaro.org Received: by 10.112.59.35 with SMTP id w3csp1068639lbq; Mon, 26 Oct 2015 01:43:36 -0700 (PDT) X-Received: by 10.107.3.72 with SMTP id 69mr32988156iod.75.1445849016451; Mon, 26 Oct 2015 01:43:36 -0700 (PDT) Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id b5si11413231igx.100.2015.10.26.01.43.36 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 26 Oct 2015 01:43:36 -0700 (PDT) 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.20150623.gappssmtp.com 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 1ZqdM5-0007o5-Mp; Mon, 26 Oct 2015 08:42:13 +0000 Received: from mail-pa0-x231.google.com ([2607:f8b0:400e:c03::231]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZqdM2-0007m3-FL for linux-arm-kernel@lists.infradead.org; Mon, 26 Oct 2015 08:42:11 +0000 Received: by pacfv9 with SMTP id fv9so190394032pac.3 for ; Mon, 26 Oct 2015 01:41:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro_org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ZTHR5hzSutoN56VGlXep+kX4oS4/3ySYt59l7zYchFE=; b=ZwoO+KMstW1Sb3FygeLZcnRt/CioIOvA6z25ivKK/hwKmdsnwTGV7lSEmU5i2xo4Q5 X4E3rtrdkfgbBAhK7w3EvQoGNRfBg9W26Eqz3BzXyzgD4WcXTevICNvfdWrmJG1IfhSO TUIaW7GagV9IykhD0GSWZap3L/zn7Gx6TTUeZVqGIoSK7LI2kaxidA8hIrOxpDm9jCS2 pbGMKUIP7M6HmXvIkF82QnGHtTQz3eWIyTVuV4ym2ZBywY3vLEFxpNEZiwwML3LUMqVw 6uivIKBeYZ9AakAAzxqesYWlfCOyP+q2Jd7/S0Wjf1OxOZyyZKTCP5hI3UqgcNW6vyY7 Gcyg== 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=ZTHR5hzSutoN56VGlXep+kX4oS4/3ySYt59l7zYchFE=; b=AUlsQzjQd+SR2955CBvkZrbporfYJB4k5q4Lb9Kb7Yexz9awAdlRd8XmdK7ruaSMEn 6bYCi2DtH93yCkDJiE9UBq/gaD7Fa7/dI04Va2rZffEBm9qWQmScUrpeSNzCQl/xE9Qb OMJmgk54fpT8qVvHGyOA1ss3nUgFFC37AVhYyvcK+lzhYHcsIwi5aDfazA/1fmmbq1fu 9AwYoxEzvNCq5wU8kMncYQr+ARbp9ahBfbjSLJmocWdncZtjyxQDCT6QmLu/p2pnN5mw TkglVaXJQ34CqYEcBEvH64FyWPNScatUysSKhg7X7qqnPsiRG5DZBREyVRV9A/8NJpac hkxA== X-Gm-Message-State: ALoCoQly+pWiCXWtcmHsdU5OIc0b6nePa1f+KMSazUfM5GPhbleQ3RzfLYNue/OElMHPKUCpnJDR X-Received: by 10.68.134.39 with SMTP id ph7mr9009996pbb.106.1445848909250; Mon, 26 Oct 2015 01:41:49 -0700 (PDT) Received: from jessie.localdomain ([58.123.138.205]) by smtp.gmail.com with ESMTPSA id n1sm16957860pap.7.2015.10.26.01.41.45 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 26 Oct 2015 01:41:48 -0700 (PDT) From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org, ryan.harkin@linaro.org, leif.lindholm@linaro.org, mark.rutland@arm.com, catalin.marinas@arm.com, linus.walleij@linaro.org, liviu.dudau@arm.com, sudeep.holla@arm.com Subject: [PATCH] arm64/efi: register UEFI runtime mmio regions as iomem resources Date: Mon, 26 Oct 2015 17:41:00 +0900 Message-Id: <1445848860-9547-1-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: References: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20151026_014210_559067_9EA9DE24 X-CRM114-Status: GOOD ( 12.68 ) X-Spam-Score: -2.6 (--) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-2.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [2607:f8b0:400e:c03:0:0:0:231 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_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: lorenzo.pieralisi@arm.com, Ard Biesheuvel MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org In order to prevent kernel drivers from attaching to MMIO regions that are owned by the firmware, register them as iomem resources. Signed-off-by: Ard Biesheuvel --- arch/arm64/kernel/efi.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) -- 2.1.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 a48d1f477b2e..f2c6763d6c37 100644 --- a/arch/arm64/kernel/efi.c +++ b/arch/arm64/kernel/efi.c @@ -229,6 +229,22 @@ void __init efi_init(void) early_memunmap(memmap.map, params.mmap_size); } +static void __init efi_reserve_iomem_resource(efi_memory_desc_t *md) +{ + struct resource *res; + + res = kzalloc(sizeof(*res), GFP_KERNEL); + if (WARN_ON_ONCE(!res)) + return; + + res->start = md->phys_addr & PAGE_MASK; + res->end = PAGE_ALIGN(md->phys_addr + (md->num_pages << EFI_PAGE_SHIFT)) - 1; + res->name = "UEFI Runtime MMIO"; + res->flags = IORESOURCE_MEM | IORESOURCE_BUSY | IORESOURCE_EXCLUSIVE; + + request_resource(&iomem_resource, res); +} + static bool __init efi_virtmap_init(void) { efi_memory_desc_t *md; @@ -239,6 +255,8 @@ static bool __init efi_virtmap_init(void) if (!(md->attribute & EFI_MEMORY_RUNTIME)) continue; + if (md->type == EFI_MEMORY_MAPPED_IO) + efi_reserve_iomem_resource(md); if (md->virt_addr == 0) return false;