From 7572ec0727663d4491323fc1719b71951826fa41 Mon Sep 17 00:00:00 2001 From: Chris Fernald Date: Wed, 19 Jun 2024 15:09:54 -0700 Subject: [PATCH] Do not treat RP memory as valid for access (#40) ## Description When accessing memory, treat read protected memory the same as non-resident VAs. There shouldn't be a need to read or write to these addresses and if so in the future they should be sup[ported through physical read/write instructions. - [x] Impacts functionality? - [ ] Impacts security? - [ ] Breaking change? - [ ] Includes tests? - [ ] Includes documentation? ## How This Was Tested Tested in SBSA ## Integration Instructions N/A --- .../Library/DebugAgent/DebugAgentDxe.c | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/DebuggerFeaturePkg/Library/DebugAgent/DebugAgentDxe.c b/DebuggerFeaturePkg/Library/DebugAgent/DebugAgentDxe.c index 11e1a8d..89fd09e 100644 --- a/DebuggerFeaturePkg/Library/DebugAgent/DebugAgentDxe.c +++ b/DebuggerFeaturePkg/Library/DebugAgent/DebugAgentDxe.c @@ -459,24 +459,17 @@ AccessMemory ( return FALSE; } - if (Write && (Attributes & EFI_MEMORY_RO)) { - Status = mMemoryAttributeProtocol->ClearMemoryAttributes ( - mMemoryAttributeProtocol, - Address & ~EFI_PAGE_MASK, - EFI_PAGE_SIZE, - EFI_MEMORY_RO | EFI_MEMORY_RP - ); - if (EFI_ERROR (Status)) { - return FALSE; - } + if (Attributes & EFI_MEMORY_RP) { + // Treat RP memory as non-valid. + return FALSE; + } - AttributesChanged = TRUE; - } else if (Attributes & EFI_MEMORY_RP) { + if (Write && (Attributes & EFI_MEMORY_RO)) { Status = mMemoryAttributeProtocol->ClearMemoryAttributes ( mMemoryAttributeProtocol, Address & ~EFI_PAGE_MASK, EFI_PAGE_SIZE, - EFI_MEMORY_RP + EFI_MEMORY_RO ); if (EFI_ERROR (Status)) { return FALSE;