From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by mx.groups.io with SMTP id smtpd.web11.164587.1673869823765050680 for ; Mon, 16 Jan 2023 03:50:24 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ScorjuVM; spf=pass (domain: kernel.org, ip: 145.40.68.75, mailfrom: ardb@kernel.org) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 0F757B80E37 for ; Mon, 16 Jan 2023 11:50:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BCFA4C433F0 for ; Mon, 16 Jan 2023 11:50:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1673869819; bh=IHIK8nc4DNk4By5aWeEb1lrLuPQ555/HwNKWgeQs2o0=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=ScorjuVMdO2jUWUjrue1MK2rhr7UtXa/Re097aFlhiiymKesPc7wAmX+Liaknu8Go 7BBJWS0+Gw5Xk2OCVmFBSEAHI/5T/wNY1V3xQ0imb//xMn+OFL2sP4Yqgp7ht8/jyB w5R5AsURnB9CazsZMwmtaJlj/yrfjlpH9ouCJ5i1rZsFkO8V+UtOCbpE5yq/ipoPFR uLOq/BeGDkJbGlcBDqaD+V4SzQaSUrV7K6qT//76OzjxvtAkt0GUycnyfV1sIpQPD0 6sjEHGOScnFCOu+fEFEaZlHeqcM6Ts+b64XPqX5VUHyaGZFZLAMKZa2UCuvPOZRtnF QwJXxGVy/2IXg== Received: by mail-lj1-f171.google.com with SMTP id g14so29676530ljh.10 for ; Mon, 16 Jan 2023 03:50:19 -0800 (PST) X-Gm-Message-State: AFqh2kpYjAMAdreYOY50sMD/sUlgq7oo489bPf4vc63v6xVlXVQhzH6d GUE6x9YWYvsooajCBI1dqXKM2ePniE2hc9x6JJw= X-Google-Smtp-Source: AMrXdXvyigYgL9Ma0CybBx408/LFuy4YFN13KE9V16WQeVK7JQd/10I9xJl0g1fGEVPR1/rhOcktO+gK0lmlA1zMfSc= X-Received: by 2002:a05:651c:238e:b0:28b:814d:7087 with SMTP id bk14-20020a05651c238e00b0028b814d7087mr376122ljb.516.1673869817713; Mon, 16 Jan 2023 03:50:17 -0800 (PST) MIME-Version: 1.0 References: <20230116094639.255314-1-kraxel@redhat.com> In-Reply-To: From: "Ard Biesheuvel" Date: Mon, 16 Jan 2023 12:50:06 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [edk2-devel] [PATCH 1/1] ArmVirt: don't use unaligned CopyMem () on NOR flash To: devel@edk2.groups.io, kraxel@redhat.com Cc: Oliver Steffen , Leif Lindholm , Pawel Polawski , Ard Biesheuvel , Sami Mujawar Content-Type: text/plain; charset="UTF-8" On Mon, 16 Jan 2023 at 12:10, Ard Biesheuvel wrote: > > On Mon, 16 Jan 2023 at 10:46, Gerd Hoffmann wrote: > > > > Fixes: e5ec3ba409b5 ("OvmfPkg/VirtNorFlashDxe: map flash memory as uncacheable") > > Signed-off-by: Gerd Hoffmann > > Thanks Gerd. > > I'll tweak the fixes line and the commit log a bit: > > Commit 789a72328553 reclassified the NOR flash region as EFI_MEMORY_WC > in the OS visible EFI memory map, and dropped the explicit aligned > CopyMem() implementation, in the assumption that EFI_MEMORY_WC will be > honored by the OS, and that the region will be mapped in a way that > tolerates misaligned accesses. However, Linux today uses device > attributes for all EFI MMIO regions, in spite of the memory type > attributes, and so using misaligned accesses is never safe. > > So instead, switch to the generic CopyMem() implementation entirely, > just like we already did for VariableRuntimeDxe. > > Fixes: 789a72328553 ("OvmfPkg/VirtNorFlashDxe: use EFI_MEMORY_WC and > drop AlignedCopyMem()") > Merged as #3903. > > --- > > ArmVirtPkg/ArmVirtKvmTool.dsc | 6 +++++- > > ArmVirtPkg/ArmVirtQemu.dsc | 6 +++++- > > ArmVirtPkg/ArmVirtQemuKernel.dsc | 6 +++++- > > 3 files changed, 15 insertions(+), 3 deletions(-) > > > > diff --git a/ArmVirtPkg/ArmVirtKvmTool.dsc b/ArmVirtPkg/ArmVirtKvmTool.dsc > > index 2ba00bd08ff1..d0afe1b49e25 100644 > > --- a/ArmVirtPkg/ArmVirtKvmTool.dsc > > +++ b/ArmVirtPkg/ArmVirtKvmTool.dsc > > @@ -296,7 +296,11 @@ [Components.common] > > NULL|ArmVirtPkg/Library/ArmVirtTimerFdtClientLib/ArmVirtTimerFdtClientLib.inf > > } > > > > - OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.inf > > + OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.inf { > > + > > + # don't use unaligned CopyMem () on the UEFI varstore NOR flash region > > + BaseMemoryLib|MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf > > + } > > > > MdeModulePkg/Universal/WatchdogTimerDxe/WatchdogTimer.inf > > > > diff --git a/ArmVirtPkg/ArmVirtQemu.dsc b/ArmVirtPkg/ArmVirtQemu.dsc > > index 5dd8b6104cca..0f1c6395488a 100644 > > --- a/ArmVirtPkg/ArmVirtQemu.dsc > > +++ b/ArmVirtPkg/ArmVirtQemu.dsc > > @@ -428,7 +428,11 @@ [Components.common] > > > > NULL|ArmVirtPkg/Library/ArmVirtTimerFdtClientLib/ArmVirtTimerFdtClientLib.inf > > } > > - OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.inf > > + OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.inf { > > + > > + # don't use unaligned CopyMem () on the UEFI varstore NOR flash region > > + BaseMemoryLib|MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf > > + } > > MdeModulePkg/Universal/WatchdogTimerDxe/WatchdogTimer.inf > > > > # > > diff --git a/ArmVirtPkg/ArmVirtQemuKernel.dsc b/ArmVirtPkg/ArmVirtQemuKernel.dsc > > index f5db3ac432f3..807c85d48285 100644 > > --- a/ArmVirtPkg/ArmVirtQemuKernel.dsc > > +++ b/ArmVirtPkg/ArmVirtQemuKernel.dsc > > @@ -331,7 +331,11 @@ [Components.common] > > > > NULL|ArmVirtPkg/Library/ArmVirtTimerFdtClientLib/ArmVirtTimerFdtClientLib.inf > > } > > - OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.inf > > + OvmfPkg/VirtNorFlashDxe/VirtNorFlashDxe.inf { > > + > > + # don't use unaligned CopyMem () on the UEFI varstore NOR flash region > > + BaseMemoryLib|MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf > > + } > > MdeModulePkg/Universal/WatchdogTimerDxe/WatchdogTimer.inf > > > > # > > -- > > 2.39.0 > > > > > > > > > > > >