From patchwork Tue Feb 27 08:39:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 776186 Delivered-To: patch@linaro.org Received: by 2002:adf:a113:0:b0:33d:f458:43ce with SMTP id o19csp53415wro; Tue, 27 Feb 2024 00:48:30 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCWJAihOxsSzUGrA+GdGPgOLSwPoUJ5B0vl9fYCsn+BkU0/xbheUq+8FmJYV9hZJ1SxkX/G1EjOQzycRUpk3/3rX X-Google-Smtp-Source: AGHT+IFVpnCD5FHd1Uxcw6dotT+UYtPF7DiPqJebje/Aai/OAaNI+8C95cA//04YxfiZvdIWZKNn X-Received: by 2002:a05:620a:450f:b0:785:9ed9:b638 with SMTP id t15-20020a05620a450f00b007859ed9b638mr1701854qkp.71.1709023710702; Tue, 27 Feb 2024 00:48:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1709023710; cv=none; d=google.com; s=arc-20160816; b=w3yC5ifUFfPN/eZC1jRUTTsN3v3NNhsEB6S9SoofZlUAcQRL5rmoW3wpdopVH01AtM EoKnu6KpoYe8qb8J0YEAoPW+SInZ3hKrvN/nA8WbvZca49hEiDFwGd/PLbslY9pPmJfN aw+N0N435eEukxc7h97yu01yJC8Fm1a53DRLIBq6UkMkZChlj0n5EAvYMOeimvAQwMr1 pLSZXzxDJ5E87MXqsheU9AwAdlBGQlyLnvxVh0TPtxRxE16JqLZI0ADICKpmp2jyQBpF ko6bFMSlqp4skhqAn3xeSe4tsHEFBNEWsQYFX9HR6ELuPZjCdQ8iH+QnyeHopj+yZR6c eNQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=VFksONIBdqYx5443JbI5pC5i+NSIyfbO3mN1D7EMdV4=; fh=UWsBKeY+UbNZnoXcKfcK9IuZXYZaXHAkv5/tfDi8eN0=; b=Px5dDcoDTpDwoRxACweaMnG+xew+IgJbYbNmFZSbFFC2efn3MoZ1QdT3koIaE2lj9y k935sfeWgP7x7pMi0HSyMc4t+VfonzF1zuuXXwNlBePXvtFcmQM22CBN0pfLRLVHOQWp IHi77pYnRKHXw62E6bY4jNjM2C5sNwkAbI4mLluGX279wrqzyfP8njfLzrwEpGHk0Rds vmqaJAhauYcE82Q31mOZYzi8tIUzki4EcJ2r7UKcFfuykD5PS98HmhWKjPH3nXUFB5sk AOrVtXvcvp1cPxd1/pymTcqyU0tc7I30dPWrlIYO0xnYK8NWBdp1GIq3vozrNR0aTTc1 DQUw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=M9rBA+wk; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id wa26-20020a05620a4d1a00b00787354bed11si7012173qkn.413.2024.02.27.00.48.30 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 27 Feb 2024 00:48:30 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=M9rBA+wk; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ret0x-0006Nr-8L; Tue, 27 Feb 2024 03:40:39 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ret0v-0006Mw-OH for qemu-devel@nongnu.org; Tue, 27 Feb 2024 03:40:37 -0500 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ret0s-0007oG-Kb for qemu-devel@nongnu.org; Tue, 27 Feb 2024 03:40:36 -0500 Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-412af574659so875515e9.2 for ; Tue, 27 Feb 2024 00:40:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1709023232; x=1709628032; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=VFksONIBdqYx5443JbI5pC5i+NSIyfbO3mN1D7EMdV4=; b=M9rBA+wkHQinY9Wx6xSndxiOK6YJ9GlEZsdqoijNFtW3aNGxtKFPuEmeXDIzQKlDCz SQBnmviT8XLh8N3Drff4U2TUIdYpaybaRSTlb0CIx9HNCJvgwkuFDkkiO5jdqmsQmsSQ e8dnNwIyHNPLPX7qQSX4hWtBj6eQhiaHDV9yPSLqsmAYek02eblUpy3Wi99ngG42Q2RV ucw8naiSVz6SyAwdqYDHngfuFGzmEI2rvIqojZaXR5xnRiWNF/irnVyCdCvyRz+B2n9H B3OD/fXU+D1hxVUx+bq9nZMpybJnh8x+g+chBxezQWZu/xducHM0ZEBVM6ZvGmHHWIOc nbOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709023232; x=1709628032; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=VFksONIBdqYx5443JbI5pC5i+NSIyfbO3mN1D7EMdV4=; b=RdnKU7K5bfnNvermtmjLRvnrftvIHDB1fX3oniIv4Kth9mS1YUuHFNKHWXUN2T8vhz mF1TLeMpetF7YANU939hpYq8M0JHRfjDnSFlv3QGZKQ1jkUapgIKBuWwdJgWnXF1sSnp +uC86PRRdLmfEbeTINFmH+Nwt1UuDCbAEJrCqBK3bTxexMx2PY40wbqbjPoO6OXW8fKZ uUrQF5bpGsEGXL/66fMfD6VjQ4puMFPW924psdbWsDimL7qyVrkOm0U9tiY98O1hDXU1 pKMr3hDSy59LmWPTKcPDZYhJ6vSP0Bn6io3KajdOdmD6p4qRrsD9tGwi4FneU9vm2/pY v/0A== X-Gm-Message-State: AOJu0YzSAWDdvkYvt9MsGvP0tVn2HE+0iEr3oDcn1i6hzHFGddiP6MxJ 6biQhSEHOvofvxjIHG6FHdkJHK2N5Wd3zt5peLpK5RkHx9DuKrHDH0e7SjXgBqgW5SYaeeOUZjD J X-Received: by 2002:a05:600c:3b08:b0:412:a0e5:728f with SMTP id m8-20020a05600c3b0800b00412a0e5728fmr5388423wms.21.1709023232617; Tue, 27 Feb 2024 00:40:32 -0800 (PST) Received: from m1x-phil.lan (mic92-h03-176-184-33-214.dsl.sta.abo.bbox.fr. [176.184.33.214]) by smtp.gmail.com with ESMTPSA id e13-20020a05600c4e4d00b00412ad7c8298sm1016497wmq.8.2024.02.27.00.40.31 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 27 Feb 2024 00:40:32 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-ppc@nongnu.org, qemu-block@nongnu.org, qemu-arm@nongnu.org, Mark Cave-Ayland , =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= , Laurent Vivier Subject: [PULL 07/30] hw/nubus-device: round Declaration ROM memory region address to qemu_target_page_size() Date: Tue, 27 Feb 2024 09:39:23 +0100 Message-ID: <20240227083948.5427-8-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240227083948.5427-1-philmd@linaro.org> References: <20240227083948.5427-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::335; envelope-from=philmd@linaro.org; helo=mail-wm1-x335.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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@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-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Mark Cave-Ayland Declaration ROM binary images can be any arbitrary size, however if a host ROM memory region is not aligned to qemu_target_page_size() then we fail the "assert(!(iotlb & ~TARGET_PAGE_MASK))" check in tlb_set_page_full(). Ensure that the host ROM memory region is aligned to qemu_target_page_size() and adjust the offset at which the Declaration ROM image is loaded, since Nubus ROM images are unusual in that they are aligned to the end of the slot address space. Signed-off-by: Mark Cave-Ayland Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Laurent Vivier Message-ID: <20240111102954.449462-2-mark.cave-ayland@ilande.co.uk> Signed-off-by: Philippe Mathieu-Daudé --- hw/nubus/nubus-device.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/hw/nubus/nubus-device.c b/hw/nubus/nubus-device.c index 49008e4938..be4cb24696 100644 --- a/hw/nubus/nubus-device.c +++ b/hw/nubus/nubus-device.c @@ -10,6 +10,7 @@ #include "qemu/osdep.h" #include "qemu/datadir.h" +#include "exec/target_page.h" #include "hw/irq.h" #include "hw/loader.h" #include "hw/nubus/nubus.h" @@ -30,7 +31,8 @@ static void nubus_device_realize(DeviceState *dev, Error **errp) NubusDevice *nd = NUBUS_DEVICE(dev); char *name, *path; hwaddr slot_offset; - int64_t size; + int64_t size, align_size; + uint8_t *rom_ptr; int ret; /* Super */ @@ -76,16 +78,24 @@ static void nubus_device_realize(DeviceState *dev, Error **errp) } name = g_strdup_printf("nubus-slot-%x-declaration-rom", nd->slot); - memory_region_init_rom(&nd->decl_rom, OBJECT(dev), name, size, + + /* + * Ensure ROM memory region is aligned to target page size regardless + * of the size of the Declaration ROM image + */ + align_size = ROUND_UP(size, qemu_target_page_size()); + memory_region_init_rom(&nd->decl_rom, OBJECT(dev), name, align_size, &error_abort); - ret = load_image_mr(path, &nd->decl_rom); + rom_ptr = memory_region_get_ram_ptr(&nd->decl_rom); + ret = load_image_size(path, rom_ptr + (uintptr_t)(align_size - size), + size); g_free(path); g_free(name); if (ret < 0) { error_setg(errp, "could not load romfile \"%s\"", nd->romfile); return; } - memory_region_add_subregion(&nd->slot_mem, NUBUS_SLOT_SIZE - size, + memory_region_add_subregion(&nd->slot_mem, NUBUS_SLOT_SIZE - align_size, &nd->decl_rom); } }