From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 Cc: lersek@redhat.com, Ard Biesheuvel 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: [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: , X-List-Received-Date: Tue, 07 Mar 2017 08:42:16 -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 | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) 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 -- 2.7.4