From patchwork Sat Nov 5 13:32:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Frysinger X-Patchwork-Id: 60020 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 35E1A3857C76 for ; Sat, 5 Nov 2022 13:38:39 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 35E1A3857C76 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1667655519; bh=2wwAymssv2FxGOfhR3O5ne2tu0G4ZZ8g7RFi1pqE/xI=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=XTbjKcoBz/Rz8n7W9kyVIFvi1Yf7NCCaGfCYZsI7hIDSV5OaTTEJMjUGyfaxHi72Z kxP7lYPm5tstew1uQz8TIW+xWKR1t30jWoHkhtt6a9E0fek0UkXEhz4FnBqR+yAD2d qq2N7n1xLrvRw5ljKgwJI/0SeOiDicA2IWWUL5SA= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from smtp.gentoo.org (dev.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) by sourceware.org (Postfix) with ESMTP id 2371138582A0 for ; Sat, 5 Nov 2022 13:33:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 2371138582A0 Received: by smtp.gentoo.org (Postfix, from userid 559) id C8F693412D2; Sat, 5 Nov 2022 13:33:44 +0000 (UTC) To: gdb-patches@sourceware.org Subject: [PATCH 18/26] sim: bpf: invert sim_cpu storage Date: Sat, 5 Nov 2022 20:32:50 +0700 Message-Id: <20221105133258.23409-19-vapier@gentoo.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221105133258.23409-1-vapier@gentoo.org> References: <20221101151158.24916-1-vapier@gentoo.org> <20221105133258.23409-1-vapier@gentoo.org> MIME-Version: 1.0 X-Spam-Status: No, score=-11.1 required=5.0 tests=BAYES_00, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Mike Frysinger via Gdb-patches From: Mike Frysinger Reply-To: Mike Frysinger Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" The cpu.h change is in generated cgen code, but that has been sent upstream too, so the next regen should include it automatically. --- sim/bpf/cpu.h | 2 +- sim/bpf/sim-if.c | 2 +- sim/bpf/sim-main.h | 16 +++++++++++----- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/sim/bpf/cpu.h b/sim/bpf/cpu.h index 5dd42de6a756..fb5344e0b767 100644 --- a/sim/bpf/cpu.h +++ b/sim/bpf/cpu.h @@ -54,7 +54,7 @@ do { \ CPU (h_pc) = (x);\ ;} while (0) } hardware; -#define CPU_CGEN_HW(cpu) (& (cpu)->cpu_data.hardware) +#define CPU_CGEN_HW(cpu) (& BPF_SIM_CPU (cpu)->cpu_data.hardware) } BPFBF_CPU_DATA; /* Cover fns for register access. */ diff --git a/sim/bpf/sim-if.c b/sim/bpf/sim-if.c index 1501b42ff372..25ea76346ec1 100644 --- a/sim/bpf/sim-if.c +++ b/sim/bpf/sim-if.c @@ -132,7 +132,7 @@ sim_open (SIM_OPEN_KIND kind, STATE_MACHS (sd) = bpf_sim_machs; STATE_MODEL_NAME (sd) = "bpf-def"; - if (sim_cpu_alloc_all (sd, 1) != SIM_RC_OK) + if (sim_cpu_alloc_all_extra (sd, 1, sizeof (struct bpf_sim_cpu)) != SIM_RC_OK) goto error; if (sim_pre_argv_init (sd, argv[0]) != SIM_RC_OK) diff --git a/sim/bpf/sim-main.h b/sim/bpf/sim-main.h index 80538840886e..5a29360e389e 100644 --- a/sim/bpf/sim-main.h +++ b/sim/bpf/sim-main.h @@ -19,6 +19,8 @@ #ifndef SIM_MAIN_H #define SIM_MAIN_H +#define SIM_HAVE_COMMON_SIM_CPU + #include "sim-basics.h" #include "cgen-types.h" #include "bpf-desc.h" @@ -29,15 +31,19 @@ #include "bpf-sim.h" #include "bpf-helpers.h" - -struct _sim_cpu +struct bpf_sim_cpu { - sim_cpu_base base; - CGEN_CPU cgen_cpu; - + /* CPU-model specific parts go here. + Note that in files that don't need to access these pieces WANT_CPU_FOO + won't be defined and thus these parts won't appear. This is ok in the + sense that things work. It is a source of bugs though. + One has to of course be careful to not take the size of this + struct and no structure members accessed in non-cpu specific files can + go after here. */ #if defined (WANT_CPU_BPFBF) BPFBF_CPU_DATA cpu_data; #endif }; +#define BPF_SIM_CPU(cpu) ((struct bpf_sim_cpu *) CPU_ARCH_DATA (cpu)) #endif /* ! SIM_MAIN_H */