[RFC PATCH] target/ia64: Add initial CPU state and PC accessors

dev12124 posted 1 patch 3 days, 1 hour ago
target/ia64/cpu-qom.h | 43 ++++++++++++++++++++++
target/ia64/cpu.c     | 54 ++++++++++++++++++++++++++++
target/ia64/cpu.h     | 83 +++++++++++++++++++++++++++++++++++++++++++
3 files changed, 180 insertions(+)
create mode 100644 target/ia64/cpu-qom.h
create mode 100644 target/ia64/cpu.c
create mode 100644 target/ia64/cpu.h
[RFC PATCH] target/ia64: Add initial CPU state and PC accessors
Posted by dev12124 3 days, 1 hour ago
Signed-off-by: dev12124 <joaoanandalima@gmail.com>
---
 target/ia64/cpu-qom.h | 43 ++++++++++++++++++++++
 target/ia64/cpu.c     | 54 ++++++++++++++++++++++++++++
 target/ia64/cpu.h     | 83 +++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 180 insertions(+)
 create mode 100644 target/ia64/cpu-qom.h
 create mode 100644 target/ia64/cpu.c
 create mode 100644 target/ia64/cpu.h

diff --git a/target/ia64/cpu-qom.h b/target/ia64/cpu-qom.h
new file mode 100644
index 0000000000..4ed395df81
--- /dev/null
+++ b/target/ia64/cpu-qom.h
@@ -0,0 +1,43 @@
+/* SPDX-License-Identifier: MIT */
+
+/*
+   * QEMU Project for Intel Itanium (IA-64) emulation by 'Software Developer'.
+   *
+   * Copyright (c) 2026-2028 João (@dev12124 GitHub, @dev GitLab).
+   *
+   * This file is the CPU Header sign QEMU Models.
+   * Author: João Guilherme da Silva Freitas Lima <joaoanandalima@gmail.com>.
+   *
+   * WARNINGS:
+   *
+   * Permission is hereby granted, free of charge, to any person obtaining a copy
+   * of this software and associated documentation files (the "Software"), to deal
+   * in the Software without restriction, including without limitation the rights
+   * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+   * copies of the Software, and to permit persons to whom the Software is
+   * furnished to do so, subject to the following conditions:
+   *
+   * The above copyright notice and this permission notice shall be included in
+   * all copies or substantial portions of the Software.
+   * 
+   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+   * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+   * THE SOFTWARE.
+   */
+
+#ifndef __CPu_CLASS_HID
+#define __CPu_CLASS_HID
+
+#include "hw/core/cpu.h"
+
+struct IA64CPUClass {
+    CPUClass parent_class;
+    DeviceRealize parent_realize; 
+    ResettablePhases parent_phases;
+} __attribute__((aligned(64))); /* Optimization in first local */
+
+#endif
\ No newline at end of file
diff --git a/target/ia64/cpu.c b/target/ia64/cpu.c
new file mode 100644
index 0000000000..731fd6b8bc
--- /dev/null
+++ b/target/ia64/cpu.c
@@ -0,0 +1,54 @@
+/* SPDX-License-Identifier: MIT */
+
+/*
+   * QEMU Project for Intel Itanium (IA-64) emulation by 'Software Developer'.
+   *
+   * Copyright (c) 2026-2028 João (@dev12124 GitHub, @dev GitLab).
+   *
+   * This file is Implementation CPU Emulated of IA64 Arch.
+   * Author: João Guilherme da Silva Freitas Lima <joaoanandalima@gmail.com>.
+   *
+   * WARNINGS:
+   *
+   * Permission is hereby granted, free of charge, to any person obtaining a copy
+   * of this software and associated documentation files (the "Software"), to deal
+   * in the Software without restriction, including without limitation the rights
+   * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+   * copies of the Software, and to permit persons to whom the Software is
+   * furnished to do so, subject to the following conditions:
+   *
+   * The above copyright notice and this permission notice shall be included in
+   * all copies or substantial portions of the Software.
+   * 
+   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+   * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+   * THE SOFTWARE.
+   */
+
+#include "qemu/osdep.h" 
+#include "cpu-qom.h" /* target/ia64/ */
+#include "cpu.h" /* target/ia64/ */
+
+static void ia64_set_pc(CPUState *cs, vaddr value)
+{
+    if(unlikely(!cs)) /* Pure Optimizatiom */
+        return;
+
+    CPUIA64State *env = cpu_env(cs); /* Extract */
+    env->ip = env->ip | value & ~0xFULL;
+    env->slot = value & 0x3;
+}
+
+static vaddr ia64_get_pc(CPUState *cs)
+{
+    if(unlikely(!cs))
+        return 0;
+
+    CPUIA64State *env = cpu_env(cs);
+    vaddr result = env->ip | (env->slot & 0x3);
+    return result;
+}
\ No newline at end of file
diff --git a/target/ia64/cpu.h b/target/ia64/cpu.h
new file mode 100644
index 0000000000..f83f508c43
--- /dev/null
+++ b/target/ia64/cpu.h
@@ -0,0 +1,83 @@
+/* SPDX-License-Identifier: MIT */
+
+/*
+   * QEMU Project for Intel Itanium (IA-64) emulation by 'Software Developer'.
+   *
+   * Copyright (c) 2026-2028 João (@dev12124 GitHub, @dev GitLab).
+   *
+   * This file is the CPU Header sign QEMU Models.
+   * Author: João Guilherme da Silva Freitas Lima <joaoanandalima@gmail.com>.
+   *
+   * WARNINGS:
+   *
+   * Permission is hereby granted, free of charge, to any person obtaining a copy
+   * of this software and associated documentation files (the "Software"), to deal
+   * in the Software without restriction, including without limitation the rights
+   * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+   * copies of the Software, and to permit persons to whom the Software is
+   * furnished to do so, subject to the following conditions:
+   *
+   * The above copyright notice and this permission notice shall be included in
+   * all copies or substantial portions of the Software.
+   * 
+   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+   * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+   * THE SOFTWARE.
+   */
+
+#ifndef __CPU_HEADER_MODEL__
+#define __CPU_HEADER_MODEL__
+
+#include "cpu-qom.h"
+#include "exec/cpu-defs.h"
+
+#ifndef unlikely
+#define unlikely(x) __builtin_expect(!!(x), 0)
+#endif
+
+typedef struct CPUArchState {
+      uint64_t gr[128];
+
+      uint64_t nat_lo;
+      uint64_t nat_hi;
+
+      uint64_t pr;
+
+      uint64_t br[8];
+
+      uint64_t ar[128];
+
+      uint64_t cr[128];
+
+      uint64_t ip;
+      uint64_t slot;
+
+      uint64_t cfm;
+
+      uint64_t psr;
+} __attribute__((aligned(64))) CPUIA64State; /* Aligned in a Cache Line (I love optimization) */
+
+struct ArchCPU {
+    CPUState parent_obj;
+    CPUIA64State env;
+} __attribute__((aligned(64)));
+
+#define TYPE_IA64_CPU "ia64-cpu"
+OBJECT_DECLARE_CPU_TYPE(IA64CPU, IA64CPUClass, IA64_CPU)
+
+static inline void cpu_get_tb_cpu_state(CPUIA64State *env, vaddr *pc,
+                                 uint64_t *cs_base, uint32_t *flags)
+{
+    if(unlikely(!env)||unlikely(!pc)||unlikely(!cs_base)||unlikely(!flags))
+        return;
+
+    *pc = env->ip | (env->slot & 0x3);
+    *cs_base = 0;
+    *flags = 0;
+}
+
+#endif
\ No newline at end of file
-- 
2.55.0.windows.3


Re: [RFC PATCH] target/ia64: Add initial CPU state and PC accessors
Posted by Mohamed Mediouni 2 days, 23 hours ago

> On 20. Nov 2026, at 03:49, dev12124 <joaoanandalima@gmail.com> wrote:
> 
> Signed-off-by: dev12124 <joaoanandalima@gmail.com>

Hi,

No. This alone without a series around it doesn’t make a whole lot of sense
if any.

For context: there’s AI-assisted QEMU forks with IA-64 system emulation
around, that are functional. But this patch is not that.

> ---
> target/ia64/cpu-qom.h | 43 ++++++++++++++++++++++
> target/ia64/cpu.c     | 54 ++++++++++++++++++++++++++++
> target/ia64/cpu.h     | 83 +++++++++++++++++++++++++++++++++++++++++++
> 3 files changed, 180 insertions(+)
> create mode 100644 target/ia64/cpu-qom.h
> create mode 100644 target/ia64/cpu.c
> create mode 100644 target/ia64/cpu.h
> 
> diff --git a/target/ia64/cpu-qom.h b/target/ia64/cpu-qom.h
> new file mode 100644
> index 0000000000..4ed395df81
> --- /dev/null
> +++ b/target/ia64/cpu-qom.h
> @@ -0,0 +1,43 @@
> +/* SPDX-License-Identifier: MIT */
> +
> +/*
> +   * QEMU Project for Intel Itanium (IA-64) emulation by 'Software Developer'.

This looks like output from a machine learning model.

Did you happen to review the QEMU LLM patches policy? Both the current one and what’s
on the list?

> +   *
> +   * Copyright (c) 2026-2028 João (@dev12124 GitHub, @dev GitLab).
> +   *
> +   * This file is the CPU Header sign QEMU Models.
> +   * Author: João Guilherme da Silva Freitas Lima <joaoanandalima@gmail.com>.
> +   *
> +   * WARNINGS:

Which LLM harness did you (most likely) use?
> +   *
> +   * Permission is hereby granted, free of charge, to any person obtaining a copy
> +   * of this software and associated documentation files (the "Software"), to deal
> +   * in the Software without restriction, including without limitation the rights
> +   * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
> +   * copies of the Software, and to permit persons to whom the Software is
> +   * furnished to do so, subject to the following conditions:
> +   *
> +   * The above copyright notice and this permission notice shall be included in
> +   * all copies or substantial portions of the Software.
> +   * 
> +   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> +   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> +   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
> +   * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
> +   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
> +   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
> +   * THE SOFTWARE.
> +   */
> +
> +#ifndef __CPu_CLASS_HID
> +#define __CPu_CLASS_HID
> +
> +#include "hw/core/cpu.h"
> +
> +struct IA64CPUClass {
> +    CPUClass parent_class;
> +    DeviceRealize parent_realize; 
> +    ResettablePhases parent_phases;
> +} __attribute__((aligned(64))); /* Optimization in first local */
> +
> +#endif
> \ No newline at end of file
> diff --git a/target/ia64/cpu.c b/target/ia64/cpu.c
> new file mode 100644
> index 0000000000..731fd6b8bc
> --- /dev/null
> +++ b/target/ia64/cpu.c
> @@ -0,0 +1,54 @@
> +/* SPDX-License-Identifier: MIT */
> +
> +/*
> +   * QEMU Project for Intel Itanium (IA-64) emulation by 'Software Developer'.
> +   *
> +   * Copyright (c) 2026-2028 João (@dev12124 GitHub, @dev GitLab).
> +   *
> +   * This file is Implementation CPU Emulated of IA64 Arch.
> +   * Author: João Guilherme da Silva Freitas Lima <joaoanandalima@gmail.com>.
> +   *
> +   * WARNINGS:
> +   *
> +   * Permission is hereby granted, free of charge, to any person obtaining a copy
> +   * of this software and associated documentation files (the "Software"), to deal
> +   * in the Software without restriction, including without limitation the rights
> +   * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
> +   * copies of the Software, and to permit persons to whom the Software is
> +   * furnished to do so, subject to the following conditions:
> +   *
> +   * The above copyright notice and this permission notice shall be included in
> +   * all copies or substantial portions of the Software.
> +   * 
> +   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> +   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> +   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
> +   * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
> +   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
> +   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
> +   * THE SOFTWARE.
> +   */
> +
> +#include "qemu/osdep.h" 
> +#include "cpu-qom.h" /* target/ia64/ */
> +#include "cpu.h" /* target/ia64/ */
> +
> +static void ia64_set_pc(CPUState *cs, vaddr value)
> +{
> +    if(unlikely(!cs)) /* Pure Optimizatiom */
> +        return;
> +
> +    CPUIA64State *env = cpu_env(cs); /* Extract */
> +    env->ip = env->ip | value & ~0xFULL;
> +    env->slot = value & 0x3;
> +}
> +
> +static vaddr ia64_get_pc(CPUState *cs)
> +{
> +    if(unlikely(!cs))
> +        return 0;
> +
> +    CPUIA64State *env = cpu_env(cs);
> +    vaddr result = env->ip | (env->slot & 0x3);
> +    return result;
> +}
> \ No newline at end of file
> diff --git a/target/ia64/cpu.h b/target/ia64/cpu.h
> new file mode 100644
> index 0000000000..f83f508c43
> --- /dev/null
> +++ b/target/ia64/cpu.h
> @@ -0,0 +1,83 @@
> +/* SPDX-License-Identifier: MIT */
> +
> +/*
> +   * QEMU Project for Intel Itanium (IA-64) emulation by 'Software Developer'.
> +   *
> +   * Copyright (c) 2026-2028 João (@dev12124 GitHub, @dev GitLab).
> +   *
> +   * This file is the CPU Header sign QEMU Models.
> +   * Author: João Guilherme da Silva Freitas Lima <joaoanandalima@gmail.com>.
> +   *
> +   * WARNINGS:
> +   *
> +   * Permission is hereby granted, free of charge, to any person obtaining a copy
> +   * of this software and associated documentation files (the "Software"), to deal
> +   * in the Software without restriction, including without limitation the rights
> +   * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
> +   * copies of the Software, and to permit persons to whom the Software is
> +   * furnished to do so, subject to the following conditions:
> +   *
> +   * The above copyright notice and this permission notice shall be included in
> +   * all copies or substantial portions of the Software.
> +   * 
> +   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> +   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> +   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
> +   * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
> +   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
> +   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
> +   * THE SOFTWARE.
> +   */
> +
> +#ifndef __CPU_HEADER_MODEL__
> +#define __CPU_HEADER_MODEL__
> +
> +#include "cpu-qom.h"
> +#include "exec/cpu-defs.h"
> +
> +#ifndef unlikely
> +#define unlikely(x) __builtin_expect(!!(x), 0)
> +#endif
> +
> +typedef struct CPUArchState {
> +      uint64_t gr[128];
> +
> +      uint64_t nat_lo;
> +      uint64_t nat_hi;
> +
> +      uint64_t pr;
> +
> +      uint64_t br[8];
> +
> +      uint64_t ar[128];
> +
> +      uint64_t cr[128];
> +
> +      uint64_t ip;
> +      uint64_t slot;
> +
> +      uint64_t cfm;
> +
> +      uint64_t psr;
> +} __attribute__((aligned(64))) CPUIA64State; /* Aligned in a Cache Line (I love optimization) */
> +
> +struct ArchCPU {
> +    CPUState parent_obj;
> +    CPUIA64State env;
> +} __attribute__((aligned(64)));
> +
> +#define TYPE_IA64_CPU "ia64-cpu"
> +OBJECT_DECLARE_CPU_TYPE(IA64CPU, IA64CPUClass, IA64_CPU)
> +
> +static inline void cpu_get_tb_cpu_state(CPUIA64State *env, vaddr *pc,
> +                                 uint64_t *cs_base, uint32_t *flags)
> +{
> +    if(unlikely(!env)||unlikely(!pc)||unlikely(!cs_base)||unlikely(!flags))
> +        return;
> +
> +    *pc = env->ip | (env->slot & 0x3);
> +    *cs_base = 0;
> +    *flags = 0;
> +}
> +
> +#endif
> \ No newline at end of file
> -- 
> 2.55.0.windows.3
> 
>