From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 Cc: Ard Biesheuvel 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: [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: , X-List-Received-Date: Wed, 01 Mar 2017 16:31:59 -0000 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(-) 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 -- 2.7.4