Skip to contentSkip to conversation

target/ia64: Add initial CPU state and PC accessors

RFC PATCH In review dev12124 2 participants 2 messages Nov 20

lore
Share & tools
lore

dev12124

author
#0 lore raw

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

---
 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
target/ia64/cpu-qom.h new file +43 -0
new file mode 100644
index 0000000000..4ed395df81
@@ -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 <[email protected]>.
+   *
+   * 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
target/ia64/cpu.c new file +54 -0

55 lines not on this page · raw message

target/ia64/cpu.h new file +83 -0

84 lines not on this page · raw message

Signature · 1 line
2.55.0.windows.3
#1 lore raw
Quoted 5 lines · On 20. Nov 2026, at 03:49, dev12124 <[email protected]> wrote:

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.

Quoted 15 lines

---

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

target/ia64/cpu-qom.h new file +0 -0
new file mode 100644
index 0000000000..4ed395df81

target/ia64/cpu-qom.h line 4

Quoted 4 lines
target/ia64/cpu-qom.h new file +4 -0
@@ -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?

target/ia64/cpu-qom.h line 11

Quoted 7 lines
target/ia64/cpu-qom.h new file +7 -0
+   *
+   * 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 <[email protected]>.
+   *
+   * WARNINGS:

Which LLM harness did you (most likely) use?

Quoted 188 lines
target/ia64/cpu-qom.h new file +32 -0
+   *
+   * 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
target/ia64/cpu.c new file +54 -0
new file mode 100644
index 0000000000..731fd6b8bc
@@ -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 <[email protected]>.
+   *
+   * 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
target/ia64/cpu.h new file +83 -0
new file mode 100644
index 0000000000..f83f508c43
@@ -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 <[email protected]>.
+   *
+   * 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
Signature · 1 line
2.55.0.windows.3