From patchwork Wed Mar 1 16:31:42 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 94725 Delivered-To: patch@linaro.org Received: by 10.182.3.34 with SMTP id 2csp1857030obz; Wed, 1 Mar 2017 08:32:03 -0800 (PST) X-Received: by 10.99.115.8 with SMTP id o8mr9693728pgc.36.1488385923101; Wed, 01 Mar 2017 08:32:03 -0800 (PST) Return-Path: Received: from ml01.01.org (ml01.01.org. [198.145.21.10]) by mx.google.com with ESMTPS id l3si4993292pgl.298.2017.03.01.08.32.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 01 Mar 2017 08:32:03 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) client-ip=198.145.21.10; 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 edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id E36DE821E0; Wed, 1 Mar 2017 08:31:59 -0800 (PST) X-Original-To: edk2-devel@lists.01.org Delivered-To: edk2-devel@lists.01.org Received: from mail-wm0-x234.google.com (mail-wm0-x234.google.com [IPv6:2a00:1450:400c:c09::234]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 1238A821DF for ; Wed, 1 Mar 2017 08:31:59 -0800 (PST) Received: by mail-wm0-x234.google.com with SMTP id v186so114699748wmd.0 for ; Wed, 01 Mar 2017 08:31:59 -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:in-reply-to:references; bh=fcoPYGDZW1eh3Su3cCDfh0ExnK0mhtSmuisbusR7zIc=; b=av+33MgrMB09juEz3yXUkaqkChtfetHTu8peqWZqAmk98sFEfNyv/CAo+xBk9GmnDz hsCZlwy+ynW6vzmpUGr4CxpbP9Pa5Qm6PFqbGv3B+X9hEa3ZZo8yH+CurfYVoa3lOGhZ SUkzdrP7bFk3PAmCMb+wXx5IaEzOuWXF4Li9g= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=fcoPYGDZW1eh3Su3cCDfh0ExnK0mhtSmuisbusR7zIc=; b=cKSC7NgozdWGY5Unt49QdxSiKlor0/mKoFeScjkzHdze/J6dJQWMqIs3HkmtTIwVfG VgEzxlxBVLjmS0oj3uWPz3fuUwur1xZuKyucg8yXBjWVFpnCTzhUaop1TP29uIcyVjrA loymj2xMgOnh83h5WTn7mLDMjWIYToZGVGtdtrtuRBmVvxZQc/XKmwVIl5gqCYg54dDp rZnV1XqosA+qWY7l4gk4MPslh795urvItszRlvjua4BMWnRCHJQne+9b7bB7POyW4rFg CX3lDJIQPZei7GNioymv6lZMNvLDOEyQRM/UCbn0M8WK7nkwEJIBoMfGOLU/Y6uOCvkR Xlqg== X-Gm-Message-State: AMke39kN/3Mpheq64M1uYScygTtr8eTogrTXjc7oMn8nZj1QfA0tSrOInrglSinGSZ2aUYr6 X-Received: by 10.28.109.214 with SMTP id b83mr4155916wmi.21.1488385917612; Wed, 01 Mar 2017 08:31:57 -0800 (PST) Received: from localhost.localdomain ([105.147.1.203]) by smtp.gmail.com with ESMTPSA id 11sm7275292wrb.10.2017.03.01.08.31.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 01 Mar 2017 08:31:56 -0800 (PST) From: Ard Biesheuvel To: edk2-devel@lists.01.org, leif.lindholm@linaro.org, lersek@redhat.com Date: Wed, 1 Mar 2017 16:31:42 +0000 Message-Id: <1488385903-30267-5-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1488385903-30267-1-git-send-email-ard.biesheuvel@linaro.org> References: <1488385903-30267-1-git-send-email-ard.biesheuvel@linaro.org> Subject: [edk2] [PATCH 4/5] ArmPkg/ArmMmuLib ARM: implement memory permission control routines X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ard Biesheuvel MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" Now that we have the prerequisite functionality available in ArmMmuLib, wire it up into ArmSetMemoryRegionNoExec, ArmClearMemoryRegionNoExec, ArmSetMemoryRegionReadOnly and ArmClearMemoryRegionReadOnly. This is used by the non-executable stack feature that is configured by DxeIpl. NOTE: The current implementation will not combine RO and XP attributes, i.e., setting/clearing a region no-exec will unconditionally clear the read-only attribute, and vice versa. Currently, we only use ArmSetMemoryRegionNoExec(), so for now, we should be able to live with this. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ard Biesheuvel --- ArmPkg/Library/ArmMmuLib/Arm/ArmMmuLibCore.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) -- 2.7.4 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel diff --git a/ArmPkg/Library/ArmMmuLib/Arm/ArmMmuLibCore.c b/ArmPkg/Library/ArmMmuLib/Arm/ArmMmuLibCore.c index 1112660b434e..55601328d93e 100644 --- a/ArmPkg/Library/ArmMmuLib/Arm/ArmMmuLibCore.c +++ b/ArmPkg/Library/ArmMmuLib/Arm/ArmMmuLibCore.c @@ -761,40 +761,40 @@ ArmSetMemoryAttributes ( return Status; } -RETURN_STATUS +EFI_STATUS ArmSetMemoryRegionNoExec ( IN EFI_PHYSICAL_ADDRESS BaseAddress, IN UINT64 Length ) { - return RETURN_UNSUPPORTED; + return ArmSetMemoryAttributes (BaseAddress, Length, EFI_MEMORY_XP); } -RETURN_STATUS +EFI_STATUS ArmClearMemoryRegionNoExec ( IN EFI_PHYSICAL_ADDRESS BaseAddress, IN UINT64 Length ) { - return RETURN_UNSUPPORTED; + return ArmSetMemoryAttributes (BaseAddress, Length, 0); } -RETURN_STATUS +EFI_STATUS ArmSetMemoryRegionReadOnly ( IN EFI_PHYSICAL_ADDRESS BaseAddress, IN UINT64 Length ) { - return RETURN_UNSUPPORTED; + return ArmSetMemoryAttributes (BaseAddress, Length, EFI_MEMORY_RO); } -RETURN_STATUS +EFI_STATUS ArmClearMemoryRegionReadOnly ( IN EFI_PHYSICAL_ADDRESS BaseAddress, IN UINT64 Length ) { - return RETURN_UNSUPPORTED; + return ArmSetMemoryAttributes (BaseAddress, Length, 0); } RETURN_STATUS