From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B2DFDC44514 for ; Thu, 16 Jul 2026 21:10:40 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wkTLi-0006AZ-Hy; Thu, 16 Jul 2026 17:10:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wkTLh-000695-8V for qemu-arm@nongnu.org; Thu, 16 Jul 2026 17:10:29 -0400 Received: from mail-pl1-x633.google.com ([2607:f8b0:4864:20::633]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wkTLf-0002TW-EP for qemu-arm@nongnu.org; Thu, 16 Jul 2026 17:10:28 -0400 Received: by mail-pl1-x633.google.com with SMTP id d9443c01a7336-2ce7d2adef4so54588895ad.3 for ; Thu, 16 Jul 2026 14:10:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1784236226; x=1784841026; darn=nongnu.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=5Ur2nukUfIP6QGhx5yPbuB/k/ylzfmbXYhSPR5nt4l8=; b=OxIA+fOL1sZqWrPKNyjUsSHSRbUNO1vKUAZeFLkkXouLPMHGEckuVcgjD02E7pX4JM vco6e7OJV55cTPfC/T72QY6+AzNcp8Ohe2itPZ+zU5dDAbZE3TfS36PP6zgNrr8EyuiF CizzBYVeKYAren+CUg5wQzJTG9o0GWjjB/CPWGF3WE6Jxf2Tj8sKD4P2EFr7p5BG0Ttp 3iPg9zW40LkxOTiTTp1FRIbLPmXPZqSQNoUZqO8QDn5S718LulHqwDjvYyDx9w7DPZcI Tcze3xaUU960/1dvvvZuEr/nSqoI49fMTYqj/v3a/X/e4exKoCWucjtHLtEKbEnFGgMt K4tw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784236226; x=1784841026; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=5Ur2nukUfIP6QGhx5yPbuB/k/ylzfmbXYhSPR5nt4l8=; b=Rz87P1oN6mNdnlfE+ueXcyPEUSwYqj2+0cPweAqALVySAwN5TIqIHq9vqV04SSgDJW qeDy7H+JGa+S7CVa14k59Gh+ykuLOYnPfNtw1IdkLdCqDYJfHlLQx+UQcSQ0MgxwQlQ7 PghgYr5WiI9TG6YnNPOymWdKfR+vfz/I9RDkrv/lUyG6bbs5T/SlO/isRLaLvPBdGWvo rIy48TbaSqYP3mE8YZVwr6fwaiIJLko3f0zRBwAWtoIxdYjKmEjoSVZ/7UGxoHga9TUc LRkwXlywqrLs9Zi1WVZTzQ/n71XgiTj/pTKIWYsaxwl/LCrJbL9gtVrHViA6fGfATtP5 Qg0w== X-Forwarded-Encrypted: i=1; AHgh+RoMd1SCgc2baQ7cBHWIDQR7A62prTeTFtV3JxAse6xAFTbAR22jWl3B9aZKmxlKyNsbU2W1rjfyiA==@nongnu.org X-Gm-Message-State: AOJu0YyxURtn6L4Ms0tAnliDres1egyHWHCMGoqfxWluSCQuhhd2k1Bp uMh3WYQdFUNTNtf7Qxu/UZVo+xSrPcO+NC6Oxgplez8cIXpmX9muzikocEuNjdfziKU= X-Gm-Gg: AfdE7clbqQKpss7i3D58l0kDxNYhrPxKcrfl9U7AreycC5Y26g8dBvu2OgkGBjrpT8u 5yjWBkcPB8sAbKBSQQYqr8+cPm0hSDf4Udoxzj/CC3n8Dl0G8jPHtQQEq3jpz+0hpAAvry6qt8A R36HDmg3y1XCyVp0HYA3T9MePQXkwS/A/87C5TTT73GI9alFoiI+D4kZDO/Bz84hPZ8iPxcZJKS 60v5SnqRWAMFhcIB3zshk4IG5l+VOxaStpgdHi6BOcM1y+hGjFXMzfqVz3EcOUUa5Eb98wgykhV Rqi0sGEe2uRVCJNVIk7vM258ozM7s/aMUR8DEuK98rU+oj0QPI3p+w2Yj4RgmwbS3pr9TFv7zpd ugr2RZquHHIIdQpkuz6Mw0233+LsJ+rrvUReQfWgI+kuIiA/l8+0iBKhgVDaQ1c6n8ykdYUV3Un ojTHTkXg== X-Received: by 2002:a17:902:e552:b0:2ca:2073:3119 with SMTP id d9443c01a7336-2cf2eb31d23mr11590055ad.32.1784236225769; Thu, 16 Jul 2026 14:10:25 -0700 (PDT) Received: from p14s ([2604:3d09:148c:c800:bc13:5578:20b0:9bee]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2cf101434aesm25814365ad.28.2026.07.16.14.10.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Jul 2026 14:10:25 -0700 (PDT) Date: Thu, 16 Jul 2026 15:10:22 -0600 From: Mathieu Poirier To: Gavin Shan Cc: berrange@redhat.com, kchamart@redhat.com, pierrick.bouvier@oss.qualcomm.com, peter.maydell@linaro.org, mst@redhat.com, cohuck@redhat.com, pbonzini@redhat.com, eblake@redhat.com, armbru@redhat.com, jpb@kernel.org, lorenzo.pieralisi@linaro.org, qemu-devel@nongnu.org, qemu-arm@nongnu.org, kvm@vger.kernel.org Subject: Re: [RFC v1 10/25] hw/core/loader: Add a ROM loader notifier Message-ID: References: <20260707224306.1202330-1-mathieu.poirier@linaro.org> <20260707224306.1202330-11-mathieu.poirier@linaro.org> <47136344-8e15-498a-a4fb-0dbbb0c71861@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <47136344-8e15-498a-a4fb-0dbbb0c71861@redhat.com> Received-SPF: pass client-ip=2607:f8b0:4864:20::633; envelope-from=mathieu.poirier@linaro.org; helo=mail-pl1-x633.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-arm@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-arm-bounces+qemu-arm=archiver.kernel.org@nongnu.org Sender: qemu-arm-bounces+qemu-arm=archiver.kernel.org@nongnu.org On Tue, Jul 14, 2026 at 08:52:43PM +1000, Gavin Shan wrote: > On 7/8/26 8:42 AM, Mathieu Poirier wrote: > > From: Jean-Philippe Brucker > > > > Add a function to register a notifier that is invoked when ROMs get > > loaded into guest memory. > > > > It will be used by Arm confidential guest support, in order to register > > all blobs loaded into memory with KVM, so that their content is moved > > into Realm state and measured into the initial VM state. > > > > Signed-off-by: Jean-Philippe Brucker > > Signed-off-by: Mathieu Poirier > > --- > > hw/core/loader.c | 15 +++++++++++++++ > > include/hw/core/loader.h | 17 +++++++++++++++++ > > 2 files changed, 32 insertions(+) > > > > diff --git a/hw/core/loader.c b/hw/core/loader.c > > index 5cbfba0a86d2..b3d769bec5cb 100644 > > --- a/hw/core/loader.c > > +++ b/hw/core/loader.c > > @@ -74,6 +74,8 @@ > > #endif > > The (edk2) firmware for the realm guest can be specified by the legacy > '-drive if=pflash' or '-bios'. The memory region corresponding to the > firmware image specified by '-bios' is recorded by the newly added notifier > and populated to TF-RMM properly. > > I don't see how the memory region corresponding to (edk2) firmware image > specified by '-drive if=pflash' is recorded and populated to TF-RMM > accordingly in this series. So I guess '-drive if=pflash' isn't supported > yet? Please give '-drive if=pflash' a try and let me know how you fare. Edk2 is not part of the bootstack I'm currently testing with but I know of configurations where it does work. I'll add it to my list of things to do if it doesn't work, though I may not address it in this patchset. We'll see how busy things get. > > Note that I didn't give '-drive if=pflash' a try yet. > > > static int roms_loaded; > > +static NotifierList rom_loader_notifier = > > + NOTIFIER_LIST_INITIALIZER(rom_loader_notifier); > > /* return the size or -1 if error */ > > int64_t get_image_size(const char *filename, Error **errp) > > @@ -1201,6 +1203,11 @@ MemoryRegion *rom_add_blob(const char *name, const void *blob, size_t len, > > return mr; > > } > > +void rom_add_load_notifier(Notifier *notifier) > > +{ > > + notifier_list_add(&rom_loader_notifier, notifier); > > +} > > + > > /* This function is specific for elf program because we don't need to allocate > > * all the rom. We just allocate the first part and the rest is just zeros. This > > * is why romsize and datasize are different. Also, this function takes its own > > @@ -1242,6 +1249,7 @@ ssize_t rom_add_option(const char *file, int32_t bootindex) > > static void rom_reset(void *unused) > > { > > Rom *rom; > > + RomLoaderNotifyData notify; > > QTAILQ_FOREACH(rom, &roms, next) { > > if (rom->fw_file) { > > @@ -1290,6 +1298,13 @@ static void rom_reset(void *unused) > > address_space_flush_icache_range(rom->as, rom->addr, rom->datasize); > > trace_loader_write_rom(rom->name, rom->addr, rom->datasize, rom->isrom); > > + > > + notify = (RomLoaderNotifyData) { > > + .addr = rom->addr, > > + .len = rom->datasize, > > + .as = rom->as, > > + }; > > + notifier_list_notify(&rom_loader_notifier, ¬ify); > > } > > } > > diff --git a/include/hw/core/loader.h b/include/hw/core/loader.h > > index d9431e8a8d12..94cf6ad2e26b 100644 > > --- a/include/hw/core/loader.h > > +++ b/include/hw/core/loader.h > > @@ -342,6 +342,23 @@ void *rom_ptr_for_as(AddressSpace *as, hwaddr addr, size_t size); > > ssize_t rom_add_vga(const char *file); > > ssize_t rom_add_option(const char *file, int32_t bootindex); > > +typedef struct RomLoaderNotifyData { > > + /* Address of the blob in guest memory */ > > + hwaddr addr; > > + /* Length of the blob */ > > + size_t len; > > + /* Address space of the blob */ > > + AddressSpace *as; > > +} RomLoaderNotifyData; > > + > > +/** > > + * rom_add_load_notifier - Add a notifier for loaded images > > + * > > + * Add a notifier that will be invoked with a RomLoaderNotifyData structure for > > + * each blob loaded into guest memory, after the blob is loaded. > > + */ > > +void rom_add_load_notifier(Notifier *notifier); > > + > > /* This is the usual maximum in uboot, so if a uImage overflows this, it would > > * overflow on real hardware too. */ > > #define UBOOT_MAX_DECOMPRESSED_BYTES (64 << 20) > > Thanks, > Gavin >