From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-x232.google.com (mail-wm0-x232.google.com [IPv6:2a00:1450:400c:c09::232]) (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 AB6EA1A1F52 for ; Thu, 8 Sep 2016 00:50:36 -0700 (PDT) Received: by mail-wm0-x232.google.com with SMTP id 1so72741339wmz.1 for ; Thu, 08 Sep 2016 00:50:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=SBsbfTc5ECU2cQzyGwX+QytNC+JQlMGTMFtO8Lp2iuM=; b=cRvlM2vhW7rgPGmeRaF4nabp5Z4uw+HoOzEpqXIjQ4C9WQsquThsyd3oZWvTtbDeqI wQnrNFjplLUP7FnYkP4MYFJ3f68Jdgji3qu6AtwoEo0LKGpNw0KIQA5G67rnW3D4O3MH VR1ilXbPXpOuFSY6xEu8M5MEwf50oGWprtTWo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=SBsbfTc5ECU2cQzyGwX+QytNC+JQlMGTMFtO8Lp2iuM=; b=DWqNqjIFU3owj0M+9VyczxcXuW98hLlqT8HmOJQM+RFZVOgdOkhj2CdmyQeF8RstY3 B8d23HIQLyzpZMP01gPOHCfWqUvr/fQAHtQ3jTMAJCjWACNKRrT1An7t8GQ90zDC7Yyw Fc9XX4xy9UjaDcpjEyv9X5oFtXXAjf6co91YfbpfzD4t7qgKrFeRbebSHvEw0DecBxqh WLMy/9wH2eNeYGIV8fMuuc7phFtyxZF/NnJmurr/cYZYKue57gAPi7+q1sg02ftLIgrY jOFkW8phMaayfJteLUuPKv+lck0jbUC4cApeD0NBMop/wKsD+YGYNW7h2TC4QEiskpMn CRrg== X-Gm-Message-State: AE9vXwO+BGdwApYqBHugkVENvlbRVr2IvVUB+MdM+N0ljWx9oB/MV4E4hdx0WlIsIHJCOGIK X-Received: by 10.28.229.205 with SMTP id c196mr7848303wmh.35.1473321035283; Thu, 08 Sep 2016 00:50:35 -0700 (PDT) Received: from localhost.localdomain ([197.130.133.164]) by smtp.gmail.com with ESMTPSA id b128sm8211859wmb.21.2016.09.08.00.50.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 08 Sep 2016 00:50:34 -0700 (PDT) From: Ard Biesheuvel To: edk2-devel@lists.01.org, leif.lindholm@linaro.org, lersek@redhat.com Cc: Ard Biesheuvel Date: Thu, 8 Sep 2016 08:50:27 +0100 Message-Id: <1473321027-31091-1-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.7.4 Subject: [PATCH] ArmVirtPkg: restrict mapping attributes of normal memory to EFI_MEMORY_WB 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: Thu, 08 Sep 2016 07:50:37 -0000 In general, on an ARM system, mapping normal memory as device memory may have unintended side effects, given that unaligned accesses or loads and stores with special semantics (e.g., load/store exclusive) may fault or may not work as expected. Under KVM, the situation is even worse, since the host may not expect the guest to perform uncached accesses, and so writes to such an uncached region may get lost completely. Since the only safe mapping type under KVM is EFI_MEMORY_WB, remove all other memory type attributes. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ard Biesheuvel --- ArmVirtPkg/HighMemDxe/HighMemDxe.c | 3 +-- ArmVirtPkg/Library/ArmVirtMemoryInitPeiLib/ArmVirtMemoryInitPeiLib.c | 3 --- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/ArmVirtPkg/HighMemDxe/HighMemDxe.c b/ArmVirtPkg/HighMemDxe/HighMemDxe.c index 7fd7e8e9a539..4d56e6236b54 100644 --- a/ArmVirtPkg/HighMemDxe/HighMemDxe.c +++ b/ArmVirtPkg/HighMemDxe/HighMemDxe.c @@ -78,8 +78,7 @@ InitializeHighMemDxe ( Status = gDS->AddMemorySpace ( EfiGcdMemoryTypeSystemMemory, CurBase, CurSize, - EFI_MEMORY_WB | EFI_MEMORY_WC | - EFI_MEMORY_WT | EFI_MEMORY_UC); + EFI_MEMORY_WB); if (EFI_ERROR (Status)) { DEBUG ((EFI_D_ERROR, diff --git a/ArmVirtPkg/Library/ArmVirtMemoryInitPeiLib/ArmVirtMemoryInitPeiLib.c b/ArmVirtPkg/Library/ArmVirtMemoryInitPeiLib/ArmVirtMemoryInitPeiLib.c index 251e5314e61d..6f3e54b7afcb 100644 --- a/ArmVirtPkg/Library/ArmVirtMemoryInitPeiLib/ArmVirtMemoryInitPeiLib.c +++ b/ArmVirtPkg/Library/ArmVirtMemoryInitPeiLib/ArmVirtMemoryInitPeiLib.c @@ -68,9 +68,6 @@ MemoryPeim ( ResourceAttributes = ( EFI_RESOURCE_ATTRIBUTE_PRESENT | EFI_RESOURCE_ATTRIBUTE_INITIALIZED | - EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE | - EFI_RESOURCE_ATTRIBUTE_WRITE_COMBINEABLE | - EFI_RESOURCE_ATTRIBUTE_WRITE_THROUGH_CACHEABLE | EFI_RESOURCE_ATTRIBUTE_WRITE_BACK_CACHEABLE | EFI_RESOURCE_ATTRIBUTE_TESTED ); -- 2.7.4