From patchwork Tue Mar 7 08:42:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 94957 Delivered-To: patch@linaro.org Received: by 10.140.82.71 with SMTP id g65csp1788803qgd; Tue, 7 Mar 2017 00:42:19 -0800 (PST) X-Received: by 10.84.139.195 with SMTP id 61mr33796555plr.109.1488876139839; Tue, 07 Mar 2017 00:42:19 -0800 (PST) Return-Path: Received: from ml01.01.org (ml01.01.org. [198.145.21.10]) by mx.google.com with ESMTPS id f12si21799612pgn.102.2017.03.07.00.42.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 07 Mar 2017 00:42:19 -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 0A0DA80354; Tue, 7 Mar 2017 00:42:18 -0800 (PST) X-Original-To: edk2-devel@lists.01.org Delivered-To: edk2-devel@lists.01.org Received: from mail-wr0-x22e.google.com (mail-wr0-x22e.google.com [IPv6:2a00:1450:400c:c0c::22e]) (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 E8EB580350 for ; Tue, 7 Mar 2017 00:42:15 -0800 (PST) Received: by mail-wr0-x22e.google.com with SMTP id l37so133865339wrc.1 for ; Tue, 07 Mar 2017 00:42:15 -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=ZJpVYrph+YZLStcGlcNs07zqB4hj07Q8mNmuYD796W8=; b=eRm+eQADcjAg/LrRaJEG/9k4ryGmTlJ9LHGXNNmqrgaTX/ZNK9XKP6H9H96ULz7UOX LC/pCVQ3L+L6zl+B6zcb7O2IEeCWHgOZpEcx+tFpJGQxfBMW6uqZYrXWScULn8fhaXAJ DrOvoE+qQeu0ifJTPkT/GV+sAkIcdUnM1nW0s= 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=ZJpVYrph+YZLStcGlcNs07zqB4hj07Q8mNmuYD796W8=; b=Y0J9GIfo87lqH0/iLWSW9dpaARpS+rMAZSQfah6x3/OhrS4G+cbFgDyN1tFJHaFLsI 3yl5XehZ51wUjckAHF7ACWGGol+xYAovBm5qHjdxBQN4GY9Dv8Yfmwl+TJOn2Fj9B8Xs LZrPEGSI59gC0x0UyP/lRUUiENBRG7ksk1d9L/Ul3y/AfwppyEcHHIDVVQd6I+rjwqmY tWxeUAo91445KlgOaHF8x21dXd/ibkKdltGE++OaM3VRDa2d0beEfQJdNW3eQBuu0u17 73+QYp+UT0MAk0O/QtSeLaD9pO1PexQuiL8u8BpyhUYfA9CFkNuuc9cozN28e4WfPEuV GEmQ== X-Gm-Message-State: AMke39my4upxfepbod2pN/IImrXTQmyBV2QTWBxbSA/B+kRql1UK/sQtmbcCDCCh8WSEjCyy X-Received: by 10.223.129.74 with SMTP id 68mr16764949wrm.183.1488876134573; Tue, 07 Mar 2017 00:42:14 -0800 (PST) Received: from ards-macbook-pro.c.hoisthospitality.com ([109.74.56.122]) by smtp.gmail.com with ESMTPSA id u41sm30097838wrc.24.2017.03.07.00.42.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 07 Mar 2017 00:42:13 -0800 (PST) From: Ard Biesheuvel To: edk2-devel@lists.01.org, leif.lindholm@linaro.org Date: Tue, 7 Mar 2017 09:42:04 +0100 Message-Id: <1488876125-24396-4-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1488876125-24396-1-git-send-email-ard.biesheuvel@linaro.org> References: <1488876125-24396-1-git-send-email-ard.biesheuvel@linaro.org> Subject: [edk2] [PATCH v2 3/4] 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: lersek@redhat.com, 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 | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) -- 2.7.4 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel Reviewed-by: Leif Lindholm diff --git a/ArmPkg/Library/ArmMmuLib/Arm/ArmMmuLibCore.c b/ArmPkg/Library/ArmMmuLib/Arm/ArmMmuLibCore.c index 351b6c03a42c..b02f6d7fc590 100644 --- a/ArmPkg/Library/ArmMmuLib/Arm/ArmMmuLibCore.c +++ b/ArmPkg/Library/ArmMmuLib/Arm/ArmMmuLibCore.c @@ -37,6 +37,8 @@ #define ID_MMFR0_SHR_IMP_HW_COHERENT 1 #define ID_MMFR0_SHR_IGNORED 0xf +#define __EFI_MEMORY_RWX 0 // no restrictions + #define CACHE_ATTRIBUTE_MASK (EFI_MEMORY_UC | \ EFI_MEMORY_WC | \ EFI_MEMORY_WT | \ @@ -797,7 +799,7 @@ ArmSetMemoryRegionNoExec ( IN UINT64 Length ) { - return EFI_UNSUPPORTED; + return ArmSetMemoryAttributes (BaseAddress, Length, EFI_MEMORY_XP); } EFI_STATUS @@ -806,7 +808,7 @@ ArmClearMemoryRegionNoExec ( IN UINT64 Length ) { - return EFI_UNSUPPORTED; + return ArmSetMemoryAttributes (BaseAddress, Length, __EFI_MEMORY_RWX); } EFI_STATUS @@ -815,7 +817,7 @@ ArmSetMemoryRegionReadOnly ( IN UINT64 Length ) { - return EFI_UNSUPPORTED; + return ArmSetMemoryAttributes (BaseAddress, Length, EFI_MEMORY_RO); } EFI_STATUS @@ -824,7 +826,7 @@ ArmClearMemoryRegionReadOnly ( IN UINT64 Length ) { - return EFI_UNSUPPORTED; + return ArmSetMemoryAttributes (BaseAddress, Length, __EFI_MEMORY_RWX); } RETURN_STATUS