From nobody Sun Nov 16 05:54:41 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1598973043; cv=none; d=zohomail.com; s=zohoarc; b=HojR8Z78/5sbexLzR8NctplXWd/O3UwCJ6jFARjl1eXpLbire3z570dwLWAx7lYeBYT75nhxtT3acE3rgLI25UIs1mHAZ0J4eFQ/ANmM8GH0/OyzrwWgtEQWNwfFhGdJv5UOYfPt3CV5EwkgKhrT2YWpZb5xPO8t5kWNepD1TSM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1598973043; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=euJaN/gf4+eh8HEs7Y0AxRG4hxPSo1ZS1DUgn6b7SL8=; b=M5YcBilJE4fYmaiVNeCdalTeBS687atY6qgrGAEKEu0LQYXEtskXpUazFTCrQFD/lVuAHakn4X+hXlTZkhBbxvx2ERbpbPNBaGwFkSmOZWuwIjCsIGgJT8oiq2S1iuo166VoCvnnM//+/mPjpfVP90OE//zb7UFYdUi+MvD0TiM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1598973043244850.2054958324046; Tue, 1 Sep 2020 08:10:43 -0700 (PDT) Received: from localhost ([::1]:43752 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kD7vm-0004t7-7x for importer@patchew.org; Tue, 01 Sep 2020 11:10:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36728) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kD7T9-0004DD-Mp; Tue, 01 Sep 2020 10:41:07 -0400 Received: from mail-wm1-x343.google.com ([2a00:1450:4864:20::343]:37110) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kD7T8-0008Rc-9U; Tue, 01 Sep 2020 10:41:07 -0400 Received: by mail-wm1-x343.google.com with SMTP id a9so1414041wmm.2; Tue, 01 Sep 2020 07:41:05 -0700 (PDT) Received: from localhost.localdomain (50.red-83-52-54.dynamicip.rima-tde.net. [83.52.54.50]) by smtp.gmail.com with ESMTPSA id a82sm2213204wmc.45.2020.09.01.07.41.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Sep 2020 07:41:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=euJaN/gf4+eh8HEs7Y0AxRG4hxPSo1ZS1DUgn6b7SL8=; b=uxs7mjyLDJPlzC1SMB1NsAN4AjZFqJecdwaXbvbY58lmcKhoNUuSwUCxzaSQW+INOR HOVE/xby/QdhADWlOvZv0IGm8bcgzLAL9ONLecKOXwawuKihItXER8nXo9yM3OZIO/nL +w8oqVwf+iQmuTLdubMGdHbaUQ5rwEJQj6fQMYkhvCl7my/INSdNvFBNbIcJvfzZCwy1 Y5TBrFNhPGIkzqYJQsPuaZ1ePMlNISVjzNrd5b++Q+RzN+NrpKVcl2tdQZ7kbvfrsSfw M4sve7a55NdZlvOiBqHLg83/apAfpHMHwq7P1bbZwDCEeONKXP7kQq7Z55d5L/4pVt2G fmPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=euJaN/gf4+eh8HEs7Y0AxRG4hxPSo1ZS1DUgn6b7SL8=; b=oq3df9gX8vqZz1IlD39MIKjRE7PjUn9xcF8maYONcVSzLo8RtTF7jWP7xuDCm0oVYE 0ahmR89e9zsS/wW15Y5bZu/1aeRwjyFYLU+vrU0AF1//peC7mynGEuvdpp/KYn4ahdmo O1uWKDO3V54Q6iHRXZvmQrIRxftCC095qRkXo2Ms7H6ideEpgR5tmdB71iBdNkCsD86S 1rhHyTBvBAp4AQPbd14FP5k9bLm59L5RdmueU/2Lu+pS0ZE60lNVM/oNe+X0eG8eVoI5 +qUf5tAHnLdxerj4gX+l7ksv5gpZjXRZDGtLzGIaQtqfO3UlMqOZZSUdty14gnnTeXen wnkg== X-Gm-Message-State: AOAM531a+TagHXSlEKD9vjAWY05HlHmCZiTM7t9VqZt1XHoCNJrxz9mI 1ABlNBfQh9Gydi5WRBfoLRfTCWo/2w4= X-Google-Smtp-Source: ABdhPJy4Iqv7ig2e0CWczw1PiG+e5PfVlpB9y++O/kdFr9+NvuaTHnLAbE0fI7quwRodBFRb15HFhg== X-Received: by 2002:a1c:105:: with SMTP id 5mr2227939wmb.83.1598971264123; Tue, 01 Sep 2020 07:41:04 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH 1/4] hw/misc/a9scu: Do not allow invalid CPU count Date: Tue, 1 Sep 2020 16:40:57 +0200 Message-Id: <20200901144100.116742-2-f4bug@amsat.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200901144100.116742-1-f4bug@amsat.org> References: <20200901144100.116742-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::343; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wm1-x343.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.25, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , qemu-arm@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Per the datasheet (DDI0407 r2p0): "The SCU connects one to four Cortex-A9 processors to the memory system through the AXI interfaces." Change the instance_init() handler to a device_realize() one so we can verify the property is in range, and return an error to the caller if not. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson --- hw/misc/a9scu.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/hw/misc/a9scu.c b/hw/misc/a9scu.c index 324371a1c00..915f127761e 100644 --- a/hw/misc/a9scu.c +++ b/hw/misc/a9scu.c @@ -12,8 +12,11 @@ #include "hw/misc/a9scu.h" #include "hw/qdev-properties.h" #include "migration/vmstate.h" +#include "qapi/error.h" #include "qemu/module.h" =20 +#define A9_SCU_CPU_MAX 4 + static uint64_t a9_scu_read(void *opaque, hwaddr offset, unsigned size) { @@ -105,12 +108,17 @@ static void a9_scu_reset(DeviceState *dev) s->control =3D 0; } =20 -static void a9_scu_init(Object *obj) +static void a9_scu_realize(DeviceState *dev, Error **errp) { - A9SCUState *s =3D A9_SCU(obj); - SysBusDevice *sbd =3D SYS_BUS_DEVICE(obj); + A9SCUState *s =3D A9_SCU(dev); + SysBusDevice *sbd =3D SYS_BUS_DEVICE(dev); =20 - memory_region_init_io(&s->iomem, obj, &a9_scu_ops, s, + if (!s->num_cpu || s->num_cpu > A9_SCU_CPU_MAX) { + error_setg(errp, "Illegal CPU count: %u", s->num_cpu); + return; + } + + memory_region_init_io(&s->iomem, OBJECT(s), &a9_scu_ops, s, "a9-scu", 0x100); sysbus_init_mmio(sbd, &s->iomem); } @@ -138,13 +146,13 @@ static void a9_scu_class_init(ObjectClass *klass, voi= d *data) device_class_set_props(dc, a9_scu_properties); dc->vmsd =3D &vmstate_a9_scu; dc->reset =3D a9_scu_reset; + dc->realize =3D a9_scu_realize; } =20 static const TypeInfo a9_scu_info =3D { .name =3D TYPE_A9_SCU, .parent =3D TYPE_SYS_BUS_DEVICE, .instance_size =3D sizeof(A9SCUState), - .instance_init =3D a9_scu_init, .class_init =3D a9_scu_class_init, }; =20 --=20 2.26.2 From nobody Sun Nov 16 05:54:41 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1598973293; cv=none; d=zohomail.com; s=zohoarc; b=afK8QvbyOMEC0gkeBKGawWMHbNX0UhrEo0FAchSKlJghLbUE/eM/Saul7fSdnGVCXfjtgZeoONYMJKVLSZBpzj3l3BstcswfJYBfhmjPOvQzUrRjEwbxVaFzwWr2cs+YbnneHIiTOGUwgzMUexRShGmyd2tXSXz/B2ADubdZlac= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1598973293; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Yw0o3aDHS2ktNtFlFwU+FwiNBr3VIt0o9HwcG9CrL1o=; b=VttnttSOBrDOGDHCQtP8QqmV47hIFXMtMQ0xFwKikri8hFyR+O6F63ZK9jBMx3Ltr1+mzoVP+/VFZ7D/QRSFq4ar2b7pxvZlR4MGVgRGQkOR782Sc0OGJ81gYfAqGVvtCXZRuAC2SP984tALL0T9ypiUYmZp7t+hQIfHI9/wGgc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1598973293934757.7768550127331; Tue, 1 Sep 2020 08:14:53 -0700 (PDT) Received: from localhost ([::1]:57148 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kD7zo-0002Fs-Ug for importer@patchew.org; Tue, 01 Sep 2020 11:14:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36744) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kD7TA-0004EA-Pd; Tue, 01 Sep 2020 10:41:08 -0400 Received: from mail-wm1-x344.google.com ([2a00:1450:4864:20::344]:39144) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kD7T9-0008Rq-7b; Tue, 01 Sep 2020 10:41:08 -0400 Received: by mail-wm1-x344.google.com with SMTP id b79so1404896wmb.4; Tue, 01 Sep 2020 07:41:06 -0700 (PDT) Received: from localhost.localdomain (50.red-83-52-54.dynamicip.rima-tde.net. [83.52.54.50]) by smtp.gmail.com with ESMTPSA id a82sm2213204wmc.45.2020.09.01.07.41.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Sep 2020 07:41:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Yw0o3aDHS2ktNtFlFwU+FwiNBr3VIt0o9HwcG9CrL1o=; b=MhzHMidqhoXGQZqvzWG9dkGG11BwkkaD68W7LIT4q72sUUaBo+YDQ7IKv15oaJ8qla wjbBBrKxZ7yiyq624NNO+zOwMjwmzPXcN2XfdwQ+oICWFbzHQ0KFJ9f/zVkwyez/HU+T GvTLsP5163UUxsd5EPPL+t/mHTehlv9gG1Zf81ee4nbXwYuBLbXyNPwSnde/v0DyxlZ+ IggVGyTeDevj9xbDjXWsYRhmsgT5ejh75A9dM4mJ0ACwWULPoUxJ1Kapfjh1AOa+y82V JupWedHRGCG0FxpOJ5bDJNkKnyfC5PWGfhs4zOthvnYr/oGPtf8S8STl618fa8o8SZps ef7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=Yw0o3aDHS2ktNtFlFwU+FwiNBr3VIt0o9HwcG9CrL1o=; b=SFWcQ86VryJQtpyZ2ZWJHSzC42DbtyEBooQ3KDIEksU/5Qkp6yikxUELU47IR/dz8W IHmD0vN4ER82GncO9jfJX0SgpiyLPhwU1C4FgLtM96ajWA5BC+6a606AwNt3CQb12aiF jrF2F6d+OqAzJVCuellYMf4IBmOF9oAOsQr1TK1rnPZux+wde5qmirKe5FvUXaaHBDtc YN6twdVoH67seK2KTjbelwT1gMYEjRVAPGtfruzf5vp+iQCcss50/uO0lJ5nV81jnCtJ SpUp/wctTWPm7plg8kpUsEF2S5F55ooZtOmSakEkzRzfnAhcgRAliJEB7hBKL0l0Ejyj 9hoQ== X-Gm-Message-State: AOAM530hXEuCjIoNk5SQRtvXDbyuRezUYvGTkasyoSv5/aOG8mGV/q6n k2qk/c0LvPh+m5owgq3AetXpdSkMSQU= X-Google-Smtp-Source: ABdhPJx4JjS4906P0zwy5E9hRQ5IeDMxQktg+ks+CiWeSOvnKXMad5hUY7dLNBrgm9SY6KAvVPOAdA== X-Received: by 2002:a1c:1f42:: with SMTP id f63mr2044061wmf.1.1598971265339; Tue, 01 Sep 2020 07:41:05 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH 2/4] hw/misc/a9scu: Simplify setting MemoryRegionOps::valid fields Date: Tue, 1 Sep 2020 16:40:58 +0200 Message-Id: <20200901144100.116742-3-f4bug@amsat.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200901144100.116742-1-f4bug@amsat.org> References: <20200901144100.116742-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::344; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wm1-x344.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.25, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , qemu-arm@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Per the datasheet (DDI0407 r2p0): "All SCU registers are byte accessible" and are 32-bit aligned. Set MemoryRegionOps::valid min/max fields and simplify the write() handler. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson --- hw/misc/a9scu.c | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/hw/misc/a9scu.c b/hw/misc/a9scu.c index 915f127761e..3f3dcc414fe 100644 --- a/hw/misc/a9scu.c +++ b/hw/misc/a9scu.c @@ -52,23 +52,8 @@ static void a9_scu_write(void *opaque, hwaddr offset, uint64_t value, unsigned size) { A9SCUState *s =3D (A9SCUState *)opaque; - uint32_t mask; + uint32_t mask =3D MAKE_64BIT_MASK(0, size * 8); uint32_t shift; - switch (size) { - case 1: - mask =3D 0xff; - break; - case 2: - mask =3D 0xffff; - break; - case 4: - mask =3D 0xffffffff; - break; - default: - fprintf(stderr, "Invalid size %u in write to a9 scu register %x\n", - size, (unsigned)offset); - return; - } =20 switch (offset) { case 0x00: /* Control */ @@ -99,6 +84,10 @@ static void a9_scu_write(void *opaque, hwaddr offset, static const MemoryRegionOps a9_scu_ops =3D { .read =3D a9_scu_read, .write =3D a9_scu_write, + .valid =3D { + .min_access_size =3D 1, + .max_access_size =3D 4, + }, .endianness =3D DEVICE_NATIVE_ENDIAN, }; =20 --=20 2.26.2 From nobody Sun Nov 16 05:54:41 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1598976064; cv=none; d=zohomail.com; s=zohoarc; b=QuF057ABaMPJ2hwrO3EXo5GXtQ6mcXYVOVD5sx//urYI7/aliGYLoN4mrqDB/5BHtG74v1ClaYrqTA7mNf501/nX06EmHsM+LRy31M9lAJ9A79pehzktUrik3ndGGvQSDFiFyCpZnbO+CcLykaSC2XJ6h3zTU9VNMGOIbmN2918= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1598976064; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=pHNAYrNieu1B/5GPFduULWjxl/G5it3aeYsEpJLKzAg=; b=IcVJ1SdUrUf41oQTmIqygf8TN15/dOLhFKId2ZioXHtLSVBUuTDrTrzI5fRvF97tMHQdggkXu0tNUVMpOczYQO0ybBGvqQ5lKn6eQFZoc8dwGnR9u5D6s+x6j/w2j49a9HXedYSaQXYii55xsSVJSMlJaJtjuQmZkPBD0kvgVh8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1598976064422811.300498514308; Tue, 1 Sep 2020 09:01:04 -0700 (PDT) Received: from localhost ([::1]:47546 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kD7qz-00036f-9s for importer@patchew.org; Tue, 01 Sep 2020 11:05:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36758) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kD7TC-0004Fo-Ot; Tue, 01 Sep 2020 10:41:10 -0400 Received: from mail-wm1-x344.google.com ([2a00:1450:4864:20::344]:51179) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kD7TA-0008S7-E9; Tue, 01 Sep 2020 10:41:09 -0400 Received: by mail-wm1-x344.google.com with SMTP id e17so1425422wme.0; Tue, 01 Sep 2020 07:41:07 -0700 (PDT) Received: from localhost.localdomain (50.red-83-52-54.dynamicip.rima-tde.net. [83.52.54.50]) by smtp.gmail.com with ESMTPSA id a82sm2213204wmc.45.2020.09.01.07.41.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Sep 2020 07:41:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=pHNAYrNieu1B/5GPFduULWjxl/G5it3aeYsEpJLKzAg=; b=u/VemtCjA72ycMPJGwnhrVInkqeGfOL1kePfJtx7FgMOpP245ld2tOqRqkNzz3YSRC q/bzmZipjQP/p3GauRf3IsbEuQj/+9o9z+taZop4xwR29HjByzwPhrrrTtqhBYogeuNX 6i/9nHaJgs81Wi5ILVJ31wMMqcQYVdTlcfmQrFfavl7yJ0H0j6HqvhI8e2yMCgYaEnrM 1JCrL6c64tERQCAor935U5JGUI/hcAkcB0w8c7j+GzNYsBicyG3O0zJ89Lh+kPjUhb7I D0WZaTDwKhqeI9HEmBcMmhLMrrx0w2gsFc5BOVxEvFgHAfQNFrLA+JRMMwuzxHRGUmSG ob2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=pHNAYrNieu1B/5GPFduULWjxl/G5it3aeYsEpJLKzAg=; b=QhcLh9ikpIf1yJcoyw6t5n79Z0sGhG2YWSxSKfsQMnTbXh8jhW2lO4qZFO98e/2njg RCre6kVP+GfulCt0e8qD7445Z8nJVkyaJ3e2D4txMY/b6EHdG+ThLc43WRpmt/mQ1g/g SJkMeO/nggA7BNx1zNBtP2VvpsyAYbjmKDYlkDHsd042IiDYanbY1P4Nr1z3jQgUQk1S qpf6wjcXsu0bpJjF2MlPJ5VjNxCXJr5eGMNCzRmIytpKaOlkwTNMrHsZ773V7C4qA4HS e72H3dJmYhbPaObYZzi+z/GyfdWwqTTbn3E7EYYUthaw072d+6rzAsuAlsvYuV+fx2Nu 0W8w== X-Gm-Message-State: AOAM530DRtqKbG1HM/uCv2paTeQPMFDBa+RZwv3zKk7qLpdL3+ePr2AS n9MR1LMwq46stPjq8SrmKOFPH9g93lg= X-Google-Smtp-Source: ABdhPJw6oWec4iF2ldZ49pXjCurt3QO6RRa5U5qQQZAhrKvuedgTBnuKiU0l/ZO922hg0FHzBB9t0Q== X-Received: by 2002:a1c:2cd7:: with SMTP id s206mr2174171wms.165.1598971266604; Tue, 01 Sep 2020 07:41:06 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH 3/4] hw/misc/a9scu: Simplify setting MemoryRegionOps::impl fields Date: Tue, 1 Sep 2020 16:40:59 +0200 Message-Id: <20200901144100.116742-4-f4bug@amsat.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200901144100.116742-1-f4bug@amsat.org> References: <20200901144100.116742-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::344; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wm1-x344.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.25, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , qemu-arm@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) This model implementation is designed for 32-bit accesses. We can simplify setting the MemoryRegionOps::impl min/max fields to 32-bit (memory::access_with_adjusted_size() will take care of the 8/16-bit accesses). Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson --- hw/misc/a9scu.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/hw/misc/a9scu.c b/hw/misc/a9scu.c index 3f3dcc414fe..47f948341f7 100644 --- a/hw/misc/a9scu.c +++ b/hw/misc/a9scu.c @@ -28,12 +28,6 @@ static uint64_t a9_scu_read(void *opaque, hwaddr offset, return (((1 << s->num_cpu) - 1) << 4) | (s->num_cpu - 1); case 0x08: /* CPU Power Status */ return s->status; - case 0x09: /* CPU status. */ - return s->status >> 8; - case 0x0a: /* CPU status. */ - return s->status >> 16; - case 0x0b: /* CPU status. */ - return s->status >> 24; case 0x0c: /* Invalidate All Registers In Secure State */ return 0; case 0x40: /* Filtering Start Address Register */ @@ -52,8 +46,6 @@ static void a9_scu_write(void *opaque, hwaddr offset, uint64_t value, unsigned size) { A9SCUState *s =3D (A9SCUState *)opaque; - uint32_t mask =3D MAKE_64BIT_MASK(0, size * 8); - uint32_t shift; =20 switch (offset) { case 0x00: /* Control */ @@ -62,9 +54,7 @@ static void a9_scu_write(void *opaque, hwaddr offset, case 0x4: /* Configuration: RO */ break; case 0x08: case 0x09: case 0x0A: case 0x0B: /* Power Control */ - shift =3D (offset - 0x8) * 8; - s->status &=3D ~(mask << shift); - s->status |=3D ((value & mask) << shift); + s->status =3D value; break; case 0x0c: /* Invalidate All Registers In Secure State */ /* no-op as we do not implement caches */ @@ -84,6 +74,10 @@ static void a9_scu_write(void *opaque, hwaddr offset, static const MemoryRegionOps a9_scu_ops =3D { .read =3D a9_scu_read, .write =3D a9_scu_write, + .impl =3D { + .min_access_size =3D 4, + .max_access_size =3D 4, + }, .valid =3D { .min_access_size =3D 1, .max_access_size =3D 4, --=20 2.26.2 From nobody Sun Nov 16 05:54:41 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1598973489; cv=none; d=zohomail.com; s=zohoarc; b=YIyp0GOuDDnaPgvBmXFVbzqLN4DHZiMf+pZJxWtH7+P356dnzm4JT0UI+CL11TgT6xVnpRRA20Ug75SZb8CPG5NtRcK0SakYdojQuiMLKzw+7PlfaKdbnXXHer1SvGupwqiZMj+h8PTazPhTj/FCRN362Ve0333hul8Zl9sqsbU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1598973489; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=/0CItXRpsjbnSZbfizzT7hsK4ATPfYOi35n7IOshX5M=; b=D8sEH6Rfd4FeQXH0kIBIskzzZypimKE00TRREVQWAv5d2QVtCRX3mJ7t+NPC1lNQOb9Uv9GI/nj0DFKYBS2/zrForKsjoZsPx8WUv5Mi2BGLWBA2H1D1B+5lDqSq4/e3dmT3ODZIm2oxZZM3EiOb7NscFS7xPvMX+40xknZaZz8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1598973489822347.91854476031904; Tue, 1 Sep 2020 08:18:09 -0700 (PDT) Received: from localhost ([::1]:56050 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kD7sP-0006fe-O6 for importer@patchew.org; Tue, 01 Sep 2020 11:07:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36772) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kD7TE-0004Kn-MO; Tue, 01 Sep 2020 10:41:12 -0400 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]:34121) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kD7TC-0008SW-QO; Tue, 01 Sep 2020 10:41:12 -0400 Received: by mail-wr1-x443.google.com with SMTP id t10so988030wrv.1; Tue, 01 Sep 2020 07:41:08 -0700 (PDT) Received: from localhost.localdomain (50.red-83-52-54.dynamicip.rima-tde.net. [83.52.54.50]) by smtp.gmail.com with ESMTPSA id a82sm2213204wmc.45.2020.09.01.07.41.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Sep 2020 07:41:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=/0CItXRpsjbnSZbfizzT7hsK4ATPfYOi35n7IOshX5M=; b=o7cuozSmNCtHclFzjtvLc+2uq/AH828HkMYG9Ib4urkGyXXrjBmIC94PEzxRVPFlIc uR8ZhLKi3t039gT4bAzFhwN1pd7UF6RgJoSc6znVg0FQfbLSur3e/NinKIgt/ynG7DOh KfecV5gm4ZfRZ0iUxJ4H4Rl7c0Atv78JJMfpO3DQ+QgFl4EthmGCnZ3++enRWd7120nz uC2WwMHzhHkW+RW4sOLdqjojmxPeNsudKn712JlQMK3sfIQHnt6PHH5RSXg1dh5VasNg zHJ48UJFESDed8Us5pTtinmkOlGsNJ0RSCjKSzq3pEG3McpA1f/afMN7yfbi2K10ZK2T bhIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=/0CItXRpsjbnSZbfizzT7hsK4ATPfYOi35n7IOshX5M=; b=Tu1zFg7b9YhKB2RxoymIizbctVsXRc7vBtR8LNCpI1awXROI7Vt7ps2RcUpFQbWb67 22k5dKMn3irGVfXaaK0HQX7qP6J9TykrDcdzQ1iBchbeeoE7rws2PuPAO7wDmIzkbeZo 2nxxI4l4XLKt9JFt0M5UFg3WyNCN7VZTkFI/Mp/ZVzoca6QLtLQj47uZk7FUKwQ2bdAs LC34iay3PjMT8Fw+H4507pKaYnWZjcB0bGYMCEpF/GzcM3h4nMMmS7nmNJXiwQAKhWM+ qmsWzMJNkJYso3VAupV3iGS9HiHiuBs2hAVkx1UZmb7Z5linitQZkSSOxdbDqzVZII5K F7Kw== X-Gm-Message-State: AOAM531WUlv21WTUanzrGCHI7HhhlxbBz2Sjy7PfB3KH+VT7rFf9HxK3 B22dc73Or0AmJMjhsK0skC9xcJqfd8U= X-Google-Smtp-Source: ABdhPJyu703r5xF86dtH6sAH1kZE6X0yeRaqx/Eyd4WkwcnimUOmnbnFPwY54NonX61jR2xXXHiNtQ== X-Received: by 2002:adf:aad1:: with SMTP id i17mr2433806wrc.360.1598971267766; Tue, 01 Sep 2020 07:41:07 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH 4/4] hw/misc/a9scu: Report unimplemented accesses with qemu_log_mask(UNIMP) Date: Tue, 1 Sep 2020 16:41:00 +0200 Message-Id: <20200901144100.116742-5-f4bug@amsat.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200901144100.116742-1-f4bug@amsat.org> References: <20200901144100.116742-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::443; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wr1-x443.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.25, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , qemu-arm@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Report unimplemented register accesses using qemu_log_mask(UNIMP). Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson --- hw/misc/a9scu.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/hw/misc/a9scu.c b/hw/misc/a9scu.c index 47f948341f7..a375ebc9878 100644 --- a/hw/misc/a9scu.c +++ b/hw/misc/a9scu.c @@ -13,6 +13,7 @@ #include "hw/qdev-properties.h" #include "migration/vmstate.h" #include "qapi/error.h" +#include "qemu/log.h" #include "qemu/module.h" =20 #define A9_SCU_CPU_MAX 4 @@ -38,6 +39,8 @@ static uint64_t a9_scu_read(void *opaque, hwaddr offset, case 0x54: /* SCU Non-secure Access Control Register */ /* unimplemented, fall through */ default: + qemu_log_mask(LOG_UNIMP, "%s: Unsupported offset 0x%"HWADDR_PRIx"\= n", + __func__, offset); return 0; } } @@ -67,6 +70,9 @@ static void a9_scu_write(void *opaque, hwaddr offset, case 0x54: /* SCU Non-secure Access Control Register */ /* unimplemented, fall through */ default: + qemu_log_mask(LOG_UNIMP, "%s: Unsupported offset 0x%"HWADDR_PRIx + " value 0x%"PRIx64"\n", + __func__, offset, value); break; } } --=20 2.26.2