From patchwork Fri Dec 6 19:11:21 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: 847855 Delivered-To: patch@linaro.org Received: by 2002:a5d:50c2:0:b0:385:e875:8a9e with SMTP id f2csp952533wrt; Fri, 6 Dec 2024 11:12:24 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCVNesjEj8EOwp/9mfoF/lZwk+OGm+ZtyTu3/hr/1WJfJfzS6uPNGvlseeQ5Rt/CqbUxF3x8gA==@linaro.org X-Google-Smtp-Source: AGHT+IGA5tAZ9OgXCOw5M3fGPkqlhM/Y9fmNzKR8M0BJNngllp6DBBI+7kQVff1gWTsdvQyNNsf5 X-Received: by 2002:a05:620a:394e:b0:7b6:753b:9b78 with SMTP id af79cd13be357-7b6bcaf6fadmr437769885a.29.1733512344538; Fri, 06 Dec 2024 11:12:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1733512344; cv=none; d=google.com; s=arc-20240605; b=MldGoFvugtvcgkLhH/2r5IfNqS7jbrZHtMfdDcEgnHEGz+SauMexyzxiWk8zwxAeft nOSmgu273DXj3gy182xz0Qw3Ad8L1ndU/ocCcGuk3Lw/PQ2Ai1y5KkcCZLCDz7BxhpHz Nvhnc0syBdOOFAfI9WlaVakJYodFJaaDN/5xqDHM8EJNcpyhJQbY8U+XEvkZBOnDVC8O 5lzpK4eZOAf3WqEQ/g87Y7NI7OBEY52Cs0IH391KfvGjqiqqdmTb3NHvodXbim+QA27u PjJ1rQHTCVOUpLloGGvQFTWcFJlVU7RRcdetZntAFLELDQJAIBUuGs2rwF+j8gRTwc/5 htFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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=YgcNNQUYfz24Ofcaa3/V/dRBkc53lWEecigpnwJFnlA=; fh=nor25M+9+H107JlZXKJGdGrH0Gd1Bpyuyq5I9vqTo+I=; b=fg/nsJ6lXgt1CiUVYs8o08v29XKc/7NIZkWkqCPC5do+hILsbsoDBEbSpqIb7CYJbW As2oeKk/16j7EXfvtspSS0EBhUGLSZjY/PwfAQOC0WNtT8HT/8oKj3ke1X5AQdc9CQAZ YSkphnEqdZewfEUAX0Xr0zTZKkdva8milvTMTZGv1aflVu61/SS5xSOfw+U6iz8iITcT nTyITNwyfi+CalncdU41OYbg7Dxso3V9fZHo+2dMoQ9MRRv32Cl9la54NMA0S2k+jtte eHEEf5ShrBsXeukQPCDyqj2rqsr5IirJqIRunGbtdFEWd7A8zLQqbCeR3vCW3f/l791w HliA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dCdvq1DM; 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; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-7b6b5aaac3csi493059185a.480.2024.12.06.11.12.24 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 06 Dec 2024 11:12:24 -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=dCdvq1DM; 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; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tJdjp-0005uG-NR; Fri, 06 Dec 2024 14:11:41 -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 1tJdjo-0005tu-77 for qemu-devel@nongnu.org; Fri, 06 Dec 2024 14:11:40 -0500 Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tJdjm-0001dz-Mt for qemu-devel@nongnu.org; Fri, 06 Dec 2024 14:11:39 -0500 Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-434a83c6b01so16450605e9.0 for ; Fri, 06 Dec 2024 11:11:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1733512297; x=1734117097; 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=YgcNNQUYfz24Ofcaa3/V/dRBkc53lWEecigpnwJFnlA=; b=dCdvq1DM0BTfnWliKjfgqLw7lJZmwV4sHC5KQy1OhGGCbJlEw7BbMdl+PeOtcHpBpb /9pyyuOjVmNI/MTAzmgw8oTDJy56oKHdZikt3NGB7qw65vyWA3kbh0hhoVw4XF74JfWN GEV8v2fZ0hs0/nUONKqTz2uA47n3Pehj8Wkf+jGXyVlFsS50k7gIaLqYcM4h7krh1rQS 6hotQNpf59TCdUmfEHlzQoY/vhvpdUOzBmJ23vSjrCYWv9SRj9gT6kwOmUslcGJcK6Dz zicDySbniUB3nxt/5sNp9rq+UStcBKtGdXbUMVJn18nei7yh8R/Jx6WR1Gu4lRHQ5ujv rnEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733512297; x=1734117097; 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=YgcNNQUYfz24Ofcaa3/V/dRBkc53lWEecigpnwJFnlA=; b=XnO5nCwUQSB1SzKL5Il7btRsnja1Fno7pI/9M4/FFRWJ/CqtNNNoSDgRKEQbgzL4d5 NXwWtaDKIhE64a2vQJuPTEn5E5VmwhnR7e/KJvuKJhs71EjT94CGNR8+ILB0Cbv5y5KV Jw7/lIjsPGi10lIuSM83+XWUrkPOXgtp/k82Z06QRYNjJf/MF2bdCmJHZmfIg0sRnXDU 5IB33VXHzhYKyqBZbOQE1bapLmL0zIlhgfE8jWXh9hkVmQHMwDazv133nsokNXCJ+aYU /lF3LowDpQP4pCYjE9VB7LIxiSuFRPwsjCSUZh7mq1PcuEJb0AyqsjkenJj/ZVag3rqF im5w== X-Gm-Message-State: AOJu0YzbLMQTa+PDpxO04bbQbs6MvvbSvYbeBsAeAkb6Z0OAPtWFdoiH wmtEBWiRA1xM3//ruYfxcfTpWWzrPIphjg3TRflxcuYjMQRnAg0I3efQcDW56sWvHI3qHy48L6d tNsQ= X-Gm-Gg: ASbGncu1OnzDdKMMPx6gbrHqgqr/cfBlt+ilE3X1829ndxaasQHHBP3pBqHhNU2DEko BRtRZ6FS6Na1dhDsiARZOw3TcDGTBHioCCQ+vdVHaapWpIgXcV+UpLiC3droGjx6iE05/UsnUgM IEpbTX8t8hgk5C9CaGgCKp6E+r4XF41C131NibroLZPcEH32947x2aqjVWKqidU5Fzd8Y0Mjs32 kzftEDKIE8T1AQFAltQ737JxdIV9hPUXQ0+K1lsaGKBWYuC+GTi+tYgDD9YKvkuIDw= X-Received: by 2002:a05:6000:1846:b0:385:e8b0:df13 with SMTP id ffacd0b85a97d-3862b3d5c9amr3188655f8f.40.1733512296763; Fri, 06 Dec 2024 11:11:36 -0800 (PST) Received: from localhost.localdomain ([95.127.41.180]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-434da0d26b0sm66778295e9.9.2024.12.06.11.11.33 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 06 Dec 2024 11:11:35 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: "Michael S. Tsirkin" , Richard Henderson , Eduardo Habkost , Marcel Apfelbaum , Zhao Liu , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH 1/4] hw/timer/hpet: Introduce hpet_add_fw_cfg_bytes() Date: Fri, 6 Dec 2024 20:11:21 +0100 Message-ID: <20241206191124.9195-2-philmd@linaro.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241206191124.9195-1-philmd@linaro.org> References: <20241206191124.9195-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32c; envelope-from=philmd@linaro.org; helo=mail-wm1-x32c.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-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 Introduce hpet_add_fw_cfg_bytes() to restrict accesses to hpet_cfg[] within hw/timer/hpet.c. Signed-off-by: Philippe Mathieu-Daudé --- include/hw/timer/hpet.h | 2 ++ hw/i386/fw_cfg.c | 5 ++--- hw/timer/hpet.c | 10 ++++++++++ 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/include/hw/timer/hpet.h b/include/hw/timer/hpet.h index d17a8d43199..d361ab9e931 100644 --- a/include/hw/timer/hpet.h +++ b/include/hw/timer/hpet.h @@ -85,4 +85,6 @@ static inline bool hpet_find(void) return object_resolve_path_type("", TYPE_HPET, NULL); } +bool hpet_add_fw_cfg_bytes(FWCfgState *fw_cfg, Error **errp); + #endif diff --git a/hw/i386/fw_cfg.c b/hw/i386/fw_cfg.c index 0e4494627c2..16f806e76b1 100644 --- a/hw/i386/fw_cfg.c +++ b/hw/i386/fw_cfg.c @@ -26,8 +26,6 @@ #include CONFIG_DEVICES #include "target/i386/cpu.h" -struct hpet_fw_config hpet_cfg = {.count = UINT8_MAX}; - const char *fw_cfg_arch_key_name(uint16_t key) { static const struct { @@ -149,7 +147,8 @@ FWCfgState *fw_cfg_arch_create(MachineState *ms, #endif fw_cfg_add_i32(fw_cfg, FW_CFG_IRQ0_OVERRIDE, 1); - fw_cfg_add_bytes(fw_cfg, FW_CFG_HPET, &hpet_cfg, sizeof(hpet_cfg)); + hpet_add_fw_cfg_bytes(fw_cfg, &error_fatal); + /* allocate memory for the NUMA channel: one (64bit) word for the number * of nodes, one word for each VCPU->node and one word for each node to * hold the amount of memory. diff --git a/hw/timer/hpet.c b/hw/timer/hpet.c index 5399f1b2a3f..9ca1424565f 100644 --- a/hw/timer/hpet.c +++ b/hw/timer/hpet.c @@ -36,6 +36,7 @@ #include "hw/rtc/mc146818rtc_regs.h" #include "migration/vmstate.h" #include "hw/timer/i8254.h" +#include "hw/i386/fw_cfg.h" #include "exec/address-spaces.h" #include "qom/object.h" #include "trace.h" @@ -86,6 +87,8 @@ struct HPETState { uint8_t hpet_id; /* instance id */ }; +struct hpet_fw_config hpet_cfg = {.count = UINT8_MAX}; + static uint32_t hpet_in_legacy_mode(HPETState *s) { return s->config & HPET_CFG_LEGACY; @@ -777,3 +780,10 @@ static void hpet_register_types(void) } type_init(hpet_register_types) + +bool hpet_add_fw_cfg_bytes(FWCfgState *fw_cfg, Error **errp) +{ + fw_cfg_add_bytes(fw_cfg, FW_CFG_HPET, &hpet_cfg, sizeof(hpet_cfg)); + + return true; +} From patchwork Fri Dec 6 19:11:22 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: 847858 Delivered-To: patch@linaro.org Received: by 2002:a5d:50c2:0:b0:385:e875:8a9e with SMTP id f2csp952877wrt; Fri, 6 Dec 2024 11:13:09 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCWyXA/STHwLwVp/H/gDPIp3EZmDDyg6epH9a1kJptXQGHM+8rH5j1JJu2q9G278stxiOsI3pA==@linaro.org X-Google-Smtp-Source: AGHT+IHmnFimYTP3gXdAYz3r6pNoLPfnlHVlfoJIZf9C023BQPf/0wFqXgpV0LUkHCeQsdTX4Lic X-Received: by 2002:a05:6214:2028:b0:6d8:8f14:2f5c with SMTP id 6a1803df08f44-6d8e717de65mr87018396d6.23.1733512389272; Fri, 06 Dec 2024 11:13:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1733512389; cv=none; d=google.com; s=arc-20240605; b=Mw52wFFUOR8D2ILX5tyewDejZEl4+XtJ7nZnaUUVJ662h2Md2ggpHCZh7cdQGiiZAS UiC+a9vHZj+WEQkT40JWk/u2Exdiv3S+O7litwxqYBhnNjLFvFKzKTQS4BnfBZ3Ckv+g TWNeN54L22TaeJZQpqRT1Up4IXjGYZOxIG0SJNKVV2URy5EB2NP7L5dtsuZ5bLt4lRgL k+kmlXB7JM/+QG4Jyz/nkKL9qlAOQQxNH/qQaqrHjA+c3YkOaLW7/g1JzQj3BswAQyuv 7u7YsL8q+SLCcxDcC/J080Xcpqud2WnUOUI4fTuNLNXxzCETJOqEl71USevyODD26DE4 gVFg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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=inpxKK/bSOw7wpkiYaFHlIXdNffEZkImnMWDkwESKJk=; fh=nor25M+9+H107JlZXKJGdGrH0Gd1Bpyuyq5I9vqTo+I=; b=Jjv5KWgrbWo4UueYUGHa0uhpyVfgEGX1LqDEef3s2L9H9K8a+TDmGSYsiMRQotm7K6 znYuNbOya4VF1weCBhF9P2LcBt+oWvje7milisYi51Qrt+Cyz4p6XKPy/IAhnfQDFX19 LjVk8XXxEMES4Eehw4trFoMgw/LJbxohqvDO1PGz+67LdAtR2Jt52SxhqqMadBnMq7pU T0ih5dj3aeMg7nNqK6xngE/Oomfc89dshfhVoF/9l15NGsN35XjqYmC5cTSkL+gQbCy9 n6Jxy1ckihzcxbq1I/9A2r+YoMeAeWY9xz3jVlpAipqys54y69pMSlBv9ZTQ0Aj7nNcJ xs2A==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=OwemHclZ; 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; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-7b6b5a4844asi454677785a.96.2024.12.06.11.13.09 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 06 Dec 2024 11:13:09 -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=OwemHclZ; 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; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tJdjy-0005vD-1Q; Fri, 06 Dec 2024 14:11:50 -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 1tJdjv-0005ut-7P for qemu-devel@nongnu.org; Fri, 06 Dec 2024 14:11:47 -0500 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tJdjt-0001ea-M9 for qemu-devel@nongnu.org; Fri, 06 Dec 2024 14:11:46 -0500 Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-434aafd68e9so17027245e9.0 for ; Fri, 06 Dec 2024 11:11:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1733512304; x=1734117104; 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=inpxKK/bSOw7wpkiYaFHlIXdNffEZkImnMWDkwESKJk=; b=OwemHclZSo9xwe1p0E0SEKFPyoaMRjsFhrQkJmkPDK+rhR0m/0Jfhws960RfCd8pnx /u7M3/JOhg0Q6z0tzigyRpXzdXi9BWZXgdKIT951YiPnSMgsUnin36QoisOd1IMwCXlA BXqs9U1kE/b7K/XTez4YQkn2zyG5tkzTot85W4Hf+yrHY6VDABD+oT1y61aRwId+egjL BELriPNNFei7cCvWSdNFfFp7uPbVgY/8WsJ0g4gxECXokFJrfOKT7CfoFIMpual6aDsU C0oF2jOvW00f7p7ebRkclZr5RnVZc/7lCJyhckeTbrffHnTwzXUlmwpSgFV5UafmMdKb /X7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733512304; x=1734117104; 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=inpxKK/bSOw7wpkiYaFHlIXdNffEZkImnMWDkwESKJk=; b=ZpzaH2OcQZ2OKlcZIACMlyylbjOp/jcFTBflP4G2VjKrfrHHJTOj62OIZT8/W5x9Ed BmyaELyfyaEQNj/pY77zCeoN50S6x38w4p5Ay/vvhol+eAy6GTnRH8Xl9oeshveTFpb+ mUs4+glzPbtJzqO/yTzvKzfWCurO4GydDGA0CLkneGJJEKL+SDuZrNjq9ZR1SX5dGuy/ wg19iW2tsEbnOeJ/Z6cE5ohueskqTXSS680zKCoF++rpI72XaFAXSupG6akb0kczl9No T3fivP/hffQcYV0pPgo/hv6BTB+DnJQzWV+bfftEUrnTrAR+yUtbo0ReNHlKA7KPlMi/ cUTQ== X-Gm-Message-State: AOJu0Yz2aZqzMXxAzjtw4giDC7B2EsAG/ABBerPlOpqD+qXY/kJnYHi+ 11eXN8gJnRyAKJuVlb7/U6rueWNaSLQc0KOVhvkpEmQObTnVLXoieMeXFvO82nIwmYhx2OOmGml HfbY= X-Gm-Gg: ASbGncuoZW+hyDkgce7NJV+Jwg99An7AWoYUKzQP9HXBbQTQbdCEobpTYlxao+WNrFm su+YNavz0rmDrU94yM4XE2qL6eKDJW1Mg1YOHdfC10BpMSJAwoh3RYy3TMGr7VLeX4yg0T58ORv KiztGOIaiYmopCoATq0kyFSLKJ80zz9Yk+GTjl5/+6roIuiwrqI6WNtG0H0ZjylPWtzu101fSZl E7IIodEes343OXXev//sK6SC2CiXBHYOrRtulj5nEiyRkoCVAo5k0fY80wvw6Ko9Mc= X-Received: by 2002:a05:600c:4eca:b0:431:6060:8b16 with SMTP id 5b1f17b1804b1-434ddedbb3bmr43086355e9.30.1733512303951; Fri, 06 Dec 2024 11:11:43 -0800 (PST) Received: from localhost.localdomain ([95.127.41.180]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-434d526b312sm104463915e9.6.2024.12.06.11.11.41 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 06 Dec 2024 11:11:43 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: "Michael S. Tsirkin" , Richard Henderson , Eduardo Habkost , Marcel Apfelbaum , Zhao Liu , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH 2/4] hw/timer/hpet: Reduce hpet_cfg[] scope Date: Fri, 6 Dec 2024 20:11:22 +0100 Message-ID: <20241206191124.9195-3-philmd@linaro.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241206191124.9195-1-philmd@linaro.org> References: <20241206191124.9195-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::332; envelope-from=philmd@linaro.org; helo=mail-wm1-x332.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-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 Now than hpet_cfg[] is only accessed within hpet.c, make it static. No need to expose the hpet_fw_entry/hpet_fw_config structure declarations outside of it, so move them in the source too. Signed-off-by: Philippe Mathieu-Daudé --- include/hw/timer/hpet.h | 16 ---------------- hw/timer/hpet.c | 16 +++++++++++++++- 2 files changed, 15 insertions(+), 17 deletions(-) diff --git a/include/hw/timer/hpet.h b/include/hw/timer/hpet.h index d361ab9e931..2a95799a679 100644 --- a/include/hw/timer/hpet.h +++ b/include/hw/timer/hpet.h @@ -60,22 +60,6 @@ #define HPET_TN_INT_ROUTE_CAP_SHIFT 32 #define HPET_TN_CFG_BITS_READONLY_OR_RESERVED 0xffff80b1U -struct hpet_fw_entry -{ - uint32_t event_timer_block_id; - uint64_t address; - uint16_t min_tick; - uint8_t page_prot; -} QEMU_PACKED; - -struct hpet_fw_config -{ - uint8_t count; - struct hpet_fw_entry hpet[8]; -} QEMU_PACKED; - -extern struct hpet_fw_config hpet_cfg; - #define TYPE_HPET "hpet" #define HPET_INTCAP "hpet-intcap" diff --git a/hw/timer/hpet.c b/hw/timer/hpet.c index 9ca1424565f..849cb3e669b 100644 --- a/hw/timer/hpet.c +++ b/hw/timer/hpet.c @@ -41,6 +41,20 @@ #include "qom/object.h" #include "trace.h" +struct hpet_fw_entry +{ + uint32_t event_timer_block_id; + uint64_t address; + uint16_t min_tick; + uint8_t page_prot; +} QEMU_PACKED; + +struct hpet_fw_config +{ + uint8_t count; + struct hpet_fw_entry hpet[8]; +} QEMU_PACKED; + #define HPET_MSI_SUPPORT 0 OBJECT_DECLARE_SIMPLE_TYPE(HPETState, HPET) @@ -87,7 +101,7 @@ struct HPETState { uint8_t hpet_id; /* instance id */ }; -struct hpet_fw_config hpet_cfg = {.count = UINT8_MAX}; +static struct hpet_fw_config hpet_cfg = {.count = UINT8_MAX}; static uint32_t hpet_in_legacy_mode(HPETState *s) { From patchwork Fri Dec 6 19:11: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: 847857 Delivered-To: patch@linaro.org Received: by 2002:a5d:50c2:0:b0:385:e875:8a9e with SMTP id f2csp952773wrt; Fri, 6 Dec 2024 11:12:57 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCVU+Z/oMLnRDl1Yfxq+J6T1PuqESZ/zOtjLyYn64pzj6q+jBG5uNG61ehEIFHDqQ3oYILOfhw==@linaro.org X-Google-Smtp-Source: AGHT+IEPiRtbEWqLUBcWTMg2SZ0kqjfWo60TzsLIKriNWwCxhvPv7ydUYpRzlpYF/NbLlJgazLYs X-Received: by 2002:a05:690c:7082:b0:6ef:4cb2:8b4c with SMTP id 00721157ae682-6efe3c0da40mr52161667b3.23.1733512376792; Fri, 06 Dec 2024 11:12:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1733512376; cv=none; d=google.com; s=arc-20240605; b=jSh+cju4Ug6BlVW6lxdWMG5erznYte0E/adNd1/4J0ywSG8WGVfHfqrTWvmLH/4w6z e6d0j8GSirIrYn+sqvVHQAv6xoyPraHjfjH9wzlvQLdpBGyHz91i8Bd7OlxvG6yk2OdB ZifL5LTbrEA6SsD/lDGbcZ8n6nWWbiZUNfycc5dpwPeeLsqD4k68ZAksNUuYN7JT/rDH 471cHxckKfEeAJSyM83RAi7UeSrMuuuLx3zEsdS9IL/tOARf2SEaG9NaS+HHhq/pgm0i a1Cl6yjVjBWQmGm9A8HmlmBPUBmS7tjO1lXlIVPfxN6wDaB88YgRWePRYRAJGshw/SoF hpSA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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=Dd/n06KQPsRfxFeQobyHwXgQczMYXIkFQbqkcOigBrk=; fh=nor25M+9+H107JlZXKJGdGrH0Gd1Bpyuyq5I9vqTo+I=; b=bjSQUFSri9jdQ8esYng8OigdpO74p10S69rqJOCXwm8fTk6+XWU/G+wmOJW1GurmTT N+UVLtr2tR8xLJIVhSv4wbfq3UTxcUu58XNJz00Zx+dpyYe/GYcgoQM2JXTbqTEf5jpX oxE1RlkHz8r/EVYM43H2jU25igd/jX+iTGXIffLFGYPzBtJHWxtaA8s82MopJzfis15g +uJZ5g24Kt63Lu9K70BwJ/Y2XWsv2Ou0nr7bE0G3W3/FAPzHy/UNyfDTdl1SwfTqB/p3 hxdYOpn+tnYbkEr/mt7WDvB8nhps9rPeSmChiPSMaXXzhOtVi8ScmajgvrgfS486znC3 2RkQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=yB6I9kHD; 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; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d75a77b69052e-46729860db5si25398951cf.643.2024.12.06.11.12.56 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 06 Dec 2024 11:12:56 -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=yB6I9kHD; 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; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tJdk4-0005wY-2U; Fri, 06 Dec 2024 14:11:56 -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 1tJdk2-0005w9-TT for qemu-devel@nongnu.org; Fri, 06 Dec 2024 14:11:54 -0500 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tJdk1-0001f7-DN for qemu-devel@nongnu.org; Fri, 06 Dec 2024 14:11:54 -0500 Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-434a2033562so22877105e9.1 for ; Fri, 06 Dec 2024 11:11:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1733512311; x=1734117111; 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=Dd/n06KQPsRfxFeQobyHwXgQczMYXIkFQbqkcOigBrk=; b=yB6I9kHDEnNlOQhz6Q+ukyMhfwXLMeS19PZGJ5DP18qSxy2L2ovtPp13XuD7ekWujf 5Z9GaOuIT2LK0Pk+k8fVFKY0hJXer7PH+XcpKlUXO3dMLwoVvBRXsGgAnQ/UD3eabufC P+Lo2pvwMC4qzdXl+mPmmIzDSzEW55IjHvNbA52tFf2kfEcnNVHOwSUH34ifOjp+JCmv 4B25V0LINBDLfLr/zqo24c7+0K53edCCZ0dXUDWmWTxH/54iiZng/1DSi4eO4HGtSNYj 2O618ac7cPgUbFg6NqUFfg8KhhRroiY0itL1HJYM1dS41JgScaMm5JfuZ1KaAoL2ZSOR SUSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733512311; x=1734117111; 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=Dd/n06KQPsRfxFeQobyHwXgQczMYXIkFQbqkcOigBrk=; b=VyT9poYYusMynkHhrpTxr5UYFiYx6j2O9JlKZPp4QLMjS/d+8oJjriqMNDFr9ku/RQ 3hqcmYJow2Zf3BNN7QuBgL5n8Lfv0obdxpoEIRGFZsQ4Himky1G7VxD6ZslnH79R5k6P nB2y0+NntQoXmnTKM+KyqhZb/i8024wgdHOyG6T0TeBrg8nhRI7X4bxI3kT7S6IRhbxm cPwCZ3MlykAQt/djO7Oivvoa6LxmAhi/mOp6ZkXaMkiZlXwG9zN73oeE8EAtGlH7qSID 1PofwIJlBk2I4LETM2uZqMpd7QKWpb1ilEffMyl6w3nN5Z6lJRrwhIzL+u6ZpsP31j4C 2k8w== X-Gm-Message-State: AOJu0YxiKVcrtOKiXosAv88Li03/O00VXd3288PPTa2tFim3rKKXlM3l pJasJNMgOP0kFz44Qe4FKtEWNd7QsYx5czkS0HIv1iU5XZMFF8OYqIkItbr55MxPtrKtTYSTbuS Bleo= X-Gm-Gg: ASbGncunhNU5kSFQAn0+vxOXQdiOSDw+nqXxvqihY6R2fAblW8/L4By/MWsb87DfuFt H6gbhVyjf78JxizwocPWl/jK4hB6w1vahgrjyTIg6Isv6fQwcjyeKanfM/8YXyUidaajWFdeJHf eYbGWOLufygyvcrY9agJVpEnH8a8fB7R0wckRgQ7OwKEJXA8uwee537QK77xZ28ktpAYbpsoait ZFTBQuZYE6lS6j8bMBlPpACBhmXpJPQoDnYy+cFsvyKq2HqHrAKBmPDCmf3RjTXW/c= X-Received: by 2002:a05:600c:1e1e:b0:434:a5bc:70fc with SMTP id 5b1f17b1804b1-434ddeb51c4mr35959325e9.8.1733512311712; Fri, 06 Dec 2024 11:11:51 -0800 (PST) Received: from localhost.localdomain ([95.127.41.180]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-434d5281229sm102098015e9.26.2024.12.06.11.11.48 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 06 Dec 2024 11:11:51 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: "Michael S. Tsirkin" , Richard Henderson , Eduardo Habkost , Marcel Apfelbaum , Zhao Liu , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH 3/4] hw/timer/hpet: Have hpet_find() return an Object Date: Fri, 6 Dec 2024 20:11:23 +0100 Message-ID: <20241206191124.9195-4-philmd@linaro.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241206191124.9195-1-philmd@linaro.org> References: <20241206191124.9195-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::333; envelope-from=philmd@linaro.org; helo=mail-wm1-x333.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-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 Signed-off-by: Philippe Mathieu-Daudé --- include/hw/timer/hpet.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/hw/timer/hpet.h b/include/hw/timer/hpet.h index 2a95799a679..d11cdff0347 100644 --- a/include/hw/timer/hpet.h +++ b/include/hw/timer/hpet.h @@ -64,7 +64,7 @@ #define HPET_INTCAP "hpet-intcap" -static inline bool hpet_find(void) +static inline Object *hpet_find(void) { return object_resolve_path_type("", TYPE_HPET, NULL); } From patchwork Fri Dec 6 19:11:24 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: 847856 Delivered-To: patch@linaro.org Received: by 2002:a5d:50c2:0:b0:385:e875:8a9e with SMTP id f2csp952594wrt; Fri, 6 Dec 2024 11:12:33 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCVXdTaJCShwEHLaJZgTOV2s4PNlscyFYPVSsZpzPKFW2BkwYRUiDpmL41GMcLLVOa3tZizrkA==@linaro.org X-Google-Smtp-Source: AGHT+IHDIALIuIeDQE4/qzVg5O07SglWnGUfun6g6yElNIfOxCxUehqrEBesy4Fw4LaIto65bGgh X-Received: by 2002:a05:622a:1995:b0:466:9bf7:13e7 with SMTP id d75a77b69052e-46734cc53e4mr73129761cf.20.1733512353032; Fri, 06 Dec 2024 11:12:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1733512353; cv=none; d=google.com; s=arc-20240605; b=XdDv7sZg6lXoga0weSEXRDQvQOEAm1zNWQ3NwaMrqUT5sdVRoycXIoWgMzaIqnzOl9 UPs4kWDacl7xERm5y2K9YaGq+fl5luqL8ZFVjRB3pb1pU48mJN1w0/m20wZrhNO5jJGt kiVcYB+u7iD+lVoOaF/M9O6TvkLiqLCj6+AQarP8ruYzm05U+e9/klwlV1nnk9+AOcbx AJmVRhE+zS7m6JNkhXss7JecGyBxZ7WrpbD+NZX+qi6X6lPb+1nxptcg/B3t1CQkrRtU AUIF0Y2EueiArboyrMT86PBul96knLcvDE1fU5drnlHFjDkm+fdrxdaNdnTXa7Appjn+ sIgA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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=usuUWxdQ8ewKippAge2X3v0Dk+bE+NLkyVAycBl0ZOQ=; fh=nor25M+9+H107JlZXKJGdGrH0Gd1Bpyuyq5I9vqTo+I=; b=VKeWHmvZj5ENNYZKe35nPZytVm7UT93aAcK84HyR6yUIx2qYElJPwEquOL8+o3hDvG bRBwAI8ojUZ+W7cs8N5cvQUOTNd4pabZo5sCAF4M1yi5tGQlmz52RUC6Hzo17oyfhAJ8 aKM44K9aiNAExJMXg/3Bk/wZW+MIIZX0YnSe9qnIxL7k7BkGSjmJncH1aw+1CjGj0WaZ dVdbq3+y5qkSVhIUN3Bs5WisE6fAfYdsQ2Q4FjtRCH93Bym4ki9EHY/GizLkbNZf4bR/ BP58cJunJz08V1SYERj+rFDhxIhYGyfJ3xDniMvoOr6Iy8XJeAE/s21TX9z/1Vzrdfoq srMA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="rxmsR1l/"; 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; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d75a77b69052e-467297b99eesi58007891cf.298.2024.12.06.11.12.32 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 06 Dec 2024 11:12:33 -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="rxmsR1l/"; 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; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tJdkB-0005xe-Va; Fri, 06 Dec 2024 14:12:04 -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 1tJdkA-0005xV-Vt for qemu-devel@nongnu.org; Fri, 06 Dec 2024 14:12:03 -0500 Received: from mail-wr1-x431.google.com ([2a00:1450:4864:20::431]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tJdk9-0001fS-6k for qemu-devel@nongnu.org; Fri, 06 Dec 2024 14:12:02 -0500 Received: by mail-wr1-x431.google.com with SMTP id ffacd0b85a97d-385e2880606so2074950f8f.3 for ; Fri, 06 Dec 2024 11:12:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1733512319; x=1734117119; 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=usuUWxdQ8ewKippAge2X3v0Dk+bE+NLkyVAycBl0ZOQ=; b=rxmsR1l/a4FkHH7rqqPFaJ55XtXrBfFk3Vv57OqjHE5U6BUP2syAZy4vVjhx/dX+TE w2fwLFZPp6eJn+H62wM9FvnMauDHKpf2YiiB/TWeUQNnPLNObowTE2YYw2lqRW1gwoLl FMyWxZ5yjH6XFZd/Fil4KE70kOBE2N9LoXyHC8cSeaVj0gk2LSjimhEoJ9d9BwZYInQt q0DdrA69d0PvMFmKLnF99ojm2X7YT/cj179q0MOjuaAQfQ7h7vnIMxLA9gjDMAJ1Y9eO AJ3aJ6Zvv6xEBsBt2u78MRGltcya6Fm8Dw5w8/rLg3kOiODtVdcCUmO3J/HRhTk6OLUD U8Qg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733512319; x=1734117119; 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=usuUWxdQ8ewKippAge2X3v0Dk+bE+NLkyVAycBl0ZOQ=; b=EuI0aPwZrmTUWFTqJhSDom3qjpC2aOP4UQ2FGnWbhvpOn4LZJDTZdn5dhdF5ZTp3xH w6VfluoAh+SHMtjczk+zav2Xe2Pp6WoJvAyzlMKebLWut141Ez4sswBFwSl0gIXg2FNE dAcri6rXULf7Sji0AsErEMJsk11sjVpj8Fk9jCxcdzQM0eorv6zz8Fyf0X3z7P2uc+Qa x7rCO7qei8Y8Yvho3OH2D446A4NNJhLyiAp6YkygNAo9ElAK7Gza2o5bMslTYrkedIXm o7+Gkvy0YbHQb+CaJdkC4otVbvJhAlu8GaLG1Pi6VuIE88fQ8ww5c090oyrsXYfhsgaM R8nA== X-Gm-Message-State: AOJu0YxME0vs9WyxKXpHvsQRhNLFIKlGvoU+vctnAfaMCr7hB0ElmOG9 QbdwLJLQcub6TKqAUKc64SHULliGWwT9a/QcJ81eiftJ6LPlKSvucnj55NNohy7Ah1GuDDW94fj V6X4= X-Gm-Gg: ASbGncsd61Hw2pJ5K5kmFC/0YWXq2YDhrgv5yK+GA5rOAEQea21VnHjlNUkRjcdD7cu gGwNrL3zuoT6h3RHY0MRXmctS9kK9q4iLoXfiEJe/afz9ykMbZKTRLQilwpb25lIjlAVM9fIEBt KXiY/Kld9pWT1kfYvp9tQxHt46MLzS3vgkqlraDGUVDqO71r7jK0je+ux/MfRg6riEanm1nAhJX y8ixYHifdnzerKjGlTe1sZyTdB3UXf7UFcdtlPLfig8Uc00z7f4GaD0Ya+qNkaHkgA= X-Received: by 2002:a05:6000:401e:b0:385:e4a7:df09 with SMTP id ffacd0b85a97d-3862b3cdcd3mr3352553f8f.44.1733512319429; Fri, 06 Dec 2024 11:11:59 -0800 (PST) Received: from localhost.localdomain ([95.127.41.180]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-386219095easm5400867f8f.83.2024.12.06.11.11.56 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 06 Dec 2024 11:11:58 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: "Michael S. Tsirkin" , Richard Henderson , Eduardo Habkost , Marcel Apfelbaum , Zhao Liu , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH 4/4] hw/timer/hpet: Hold fw_cfg state within HPET class Date: Fri, 6 Dec 2024 20:11:24 +0100 Message-ID: <20241206191124.9195-5-philmd@linaro.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241206191124.9195-1-philmd@linaro.org> References: <20241206191124.9195-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::431; envelope-from=philmd@linaro.org; helo=mail-wr1-x431.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-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 We maintain one hpet_cfg[] state for all HPET instances. Move it to a new HPET class. Signed-off-by: Philippe Mathieu-Daudé --- hw/timer/hpet.c | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/hw/timer/hpet.c b/hw/timer/hpet.c index 849cb3e669b..c5aeac860b4 100644 --- a/hw/timer/hpet.c +++ b/hw/timer/hpet.c @@ -57,7 +57,7 @@ struct hpet_fw_config #define HPET_MSI_SUPPORT 0 -OBJECT_DECLARE_SIMPLE_TYPE(HPETState, HPET) +OBJECT_DECLARE_TYPE(HPETState, HPETClass, HPET) struct HPETState; typedef struct HPETTimer { /* timers */ @@ -101,7 +101,11 @@ struct HPETState { uint8_t hpet_id; /* instance id */ }; -static struct hpet_fw_config hpet_cfg = {.count = UINT8_MAX}; +struct HPETClass { + SysBusDeviceClass parent_class; + + struct hpet_fw_config fw_cfg; +}; static uint32_t hpet_in_legacy_mode(HPETState *s) { @@ -279,6 +283,7 @@ static bool hpet_validate_num_timers(void *opaque, int version_id) static int hpet_post_load(void *opaque, int version_id) { HPETState *s = opaque; + HPETClass *hc = HPET_GET_CLASS(s); int i; for (i = 0; i < s->num_timers; i++) { @@ -295,7 +300,7 @@ static int hpet_post_load(void *opaque, int version_id) /* Push number of timers into capability returned via HPET_ID */ s->capability &= ~HPET_ID_NUM_TIM_MASK; s->capability |= (s->num_timers - 1) << HPET_ID_NUM_TIM_SHIFT; - hpet_cfg.hpet[s->hpet_id].event_timer_block_id = (uint32_t)s->capability; + hc->fw_cfg.hpet[s->hpet_id].event_timer_block_id = (uint32_t)s->capability; /* Derive HPET_MSI_SUPPORT from the capability of the first timer. */ s->flags &= ~(1 << HPET_MSI_SUPPORT); @@ -660,6 +665,7 @@ static const MemoryRegionOps hpet_ram_ops = { static void hpet_reset(DeviceState *d) { HPETState *s = HPET(d); + HPETClass *hc = HPET_GET_CLASS(d); SysBusDevice *sbd = SYS_BUS_DEVICE(d); int i; @@ -682,8 +688,8 @@ static void hpet_reset(DeviceState *d) s->hpet_counter = 0ULL; s->hpet_offset = 0ULL; s->config = 0ULL; - hpet_cfg.hpet[s->hpet_id].event_timer_block_id = (uint32_t)s->capability; - hpet_cfg.hpet[s->hpet_id].address = sbd->mmio[0].addr; + hc->fw_cfg.hpet[s->hpet_id].event_timer_block_id = (uint32_t)s->capability; + hc->fw_cfg.hpet[s->hpet_id].address = sbd->mmio[0].addr; /* to document that the RTC lowers its output on reset as well */ s->rtc_irq_level = 0; @@ -719,23 +725,24 @@ static void hpet_realize(DeviceState *dev, Error **errp) { SysBusDevice *sbd = SYS_BUS_DEVICE(dev); HPETState *s = HPET(dev); + HPETClass *hc = HPET_GET_CLASS(dev); int i; HPETTimer *timer; if (!s->intcap) { warn_report("Hpet's intcap not initialized"); } - if (hpet_cfg.count == UINT8_MAX) { + if (hc->fw_cfg.count == UINT8_MAX) { /* first instance */ - hpet_cfg.count = 0; + hc->fw_cfg.count = 0; } - if (hpet_cfg.count == 8) { + if (hc->fw_cfg.count == 8) { error_setg(errp, "Only 8 instances of HPET is allowed"); return; } - s->hpet_id = hpet_cfg.count++; + s->hpet_id = hc->fw_cfg.count++; for (i = 0; i < HPET_NUM_IRQ_ROUTES; i++) { sysbus_init_irq(sbd, &s->irqs[i]); @@ -773,11 +780,14 @@ static Property hpet_device_properties[] = { static void hpet_device_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); + HPETClass *hc = HPET_CLASS(klass); dc->realize = hpet_realize; device_class_set_legacy_reset(dc, hpet_reset); dc->vmsd = &vmstate_hpet; device_class_set_props(dc, hpet_device_properties); + + hc->fw_cfg.count = UINT8_MAX; } static const TypeInfo hpet_device_info = { @@ -797,7 +807,9 @@ type_init(hpet_register_types) bool hpet_add_fw_cfg_bytes(FWCfgState *fw_cfg, Error **errp) { - fw_cfg_add_bytes(fw_cfg, FW_CFG_HPET, &hpet_cfg, sizeof(hpet_cfg)); + HPETClass *hc = HPET_GET_CLASS(hpet_find()); + + fw_cfg_add_bytes(fw_cfg, FW_CFG_HPET, &hc->fw_cfg, sizeof(hc->fw_cfg)); return true; }