From patchwork Wed May 26 23:47:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 448377 Delivered-To: patch@linaro.org Received: by 2002:a02:7a1b:0:0:0:0:0 with SMTP id a27csp16552jac; Wed, 26 May 2021 17:00:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxsF39tBUXxaUWJADON+VuXc49p5LWZIhBuEY2bVYSh7HUYZu+tSFTtmtgYcV0HUw6Euk5+ X-Received: by 2002:ac8:5d01:: with SMTP id f1mr684705qtx.105.1622073608927; Wed, 26 May 2021 17:00:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622073608; cv=none; d=google.com; s=arc-20160816; b=DOQXlxN0uhCeqHdwkZTRlMSzFWkoHe5SZahuxMwlrfuNa4LLQ6PtziunJQ8rIggFUH 9/XtxWZ05sDzgMH3XwSPZ4qyoctG1Zw1LshKTqFClz40010X+LTpSkVMpGktauRF7dZV 3Sbtpl9UCJFVPS/LWinOnIVOocoqC7GzNMJqCKRfP414NTmBJFNHrRjJ5IVD3p2f1uKa dyBQeAfRNa5GDGFHk6cRdaaCx+Qtm8OmkJXRSfOUcpfT0fxJNoer9PeusIPxQvn60c9k 6goVbPBlxNHTG4rCPJzz4DcfZhHsh32r8PuzV5YjY6Y//gkkuuebX/TOk3hr7ZHiqmt4 B6Jw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc: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:to:from :dkim-signature; bh=q34u+TqxTDTJkPHH4qaEih5rVqpqwrjejSIKV+3eh1g=; b=XqUBkCTuWIdalcbgm8aiImyKH+HsVg7AP18374Kmzw77jJHDfI3QLfiWeXKvA7PUBp WSm8TvdJ9oB4Mj1OVcLQMlAAhxBDca/KV0wxnmi1DbpTod8rzSmTtKXV3vMp0JL69cez vqlMvYMs/c6av4MZtbA5ly2XV+7M+/yc0R+O5s0W/5iSE4hm6vGWAoqQWBw/5Jz+EJJe ZUXUrvEFyfnm/qcwh07tRHmxI5Z+G1ke6sHZbeqgZ9Hxp+FC5wV65l/BcTme0kl7wCuV KmjVSKNrupdPLegz7Si2uYrAZRkJmUMtWOVdW38FCbwihT96dQzgiw0VL1keA+IZbyQx tPTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LzzoIrV6; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 8si285731qkd.100.2021.05.26.17.00.08 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 26 May 2021 17:00:08 -0700 (PDT) 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=LzzoIrV6; 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 Received: from localhost ([::1]:33716 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lm3RY-0004D5-7e for patch@linaro.org; Wed, 26 May 2021 20:00:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35070) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lm3Fg-00068l-Q3 for qemu-devel@nongnu.org; Wed, 26 May 2021 19:47:56 -0400 Received: from mail-pf1-x436.google.com ([2607:f8b0:4864:20::436]:35807) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lm3FU-0004dG-Or for qemu-devel@nongnu.org; Wed, 26 May 2021 19:47:51 -0400 Received: by mail-pf1-x436.google.com with SMTP id g18so2220810pfr.2 for ; Wed, 26 May 2021 16:47:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=q34u+TqxTDTJkPHH4qaEih5rVqpqwrjejSIKV+3eh1g=; b=LzzoIrV6ZHodTidA9Ylnb1WWt4YBoVZL1dJD3P2oWgiUTfbVxcxlS/ONg0pJmpOkxU uzRyrsN3wQb7Y97cNExrHzp1SbGbbKUVuQRZv0bvWP0vTRykg2rzILW6fodvAQBGjVu/ fRTqRQzTv+c9HaGSAqNb11OOJCN7UAKbNYIjrnkMfKvjR7aLukKYLOodS09y1TnwgBqK ElGD4EjTjyoG6fy9NiWoVaHiAX0KolPhpbRqwvW5JbbmUoQFK+7wk6QhpmpMCBgOt7g5 42JVrsu39YddcA3qDX6GA0ow9bh/+Y44S12MzNhmnKahq+tHZKThN6THRBkmG9tNbcpR c3bA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=q34u+TqxTDTJkPHH4qaEih5rVqpqwrjejSIKV+3eh1g=; b=BiCQLKlcQu6/7Haj43+R6FKUAq1qnP4kw51bDApXet9U2fe1MyqduOpOK5lXdxAh+j 06vH4G7kOmLeWJx36sSS1q9HnBNEvSHR0ERJwaXBhWzL3upKwY8KP6MoypfyvJWKV2eC cP02/Rsy/N3l8Vm4dYR+M49ifRw0Zk/dmuq1ctiGgzKEWq8ogXamIPvPwxkcKTTIX4gK 0f9nfaWeXzAfqgLKuO3kdjN18mBOrHKQW+PPR1/S001O6vmCnl4O06gkQE4OqQYCflmo nj98bqS+a1VbZCEA1/q+8EDIRrapcP7ZC2MNFfmq5FdpaFx1wpUtuUXsOYLXdBrDE8ZW 8fqg== X-Gm-Message-State: AOAM530NZnhVdIS0IJL8Shsihm1pHiCkfQ638XrxZ2Zv7pVvPuZ4EtSc jhoa4e4j6DESiuPzbkfBa8zVuyg2Y83MDQ== X-Received: by 2002:a63:617:: with SMTP id 23mr976042pgg.409.1622072855861; Wed, 26 May 2021 16:47:35 -0700 (PDT) Received: from localhost.localdomain (174-21-70-228.tukw.qwest.net. [174.21.70.228]) by smtp.gmail.com with ESMTPSA id g13sm285355pfi.18.2021.05.26.16.47.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 May 2021 16:47:35 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 29/31] cpu: Move CPUClass::get_paging_enabled to SysemuCPUOps Date: Wed, 26 May 2021 16:47:08 -0700 Message-Id: <20210526234710.125396-30-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210526234710.125396-1-richard.henderson@linaro.org> References: <20210526234710.125396-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::436; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x436.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=unavailable 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@linaro.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Philippe Mathieu-Daudé Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson Message-Id: <20210517105140.1062037-23-f4bug@amsat.org> Signed-off-by: Richard Henderson --- include/hw/core/cpu.h | 2 -- include/hw/core/sysemu-cpu-ops.h | 4 ++++ hw/core/cpu-sysemu.c | 4 ++-- target/i386/cpu.c | 4 +++- 4 files changed, 9 insertions(+), 5 deletions(-) -- 2.25.1 diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h index 4f6dd24112..e4328de8d4 100644 --- a/include/hw/core/cpu.h +++ b/include/hw/core/cpu.h @@ -94,7 +94,6 @@ struct SysemuCPUOps; * @dump_state: Callback for dumping state. * @dump_statistics: Callback for dumping statistics. * @get_arch_id: Callback for getting architecture-dependent CPU ID. - * @get_paging_enabled: Callback for inquiring whether paging is enabled. * @set_pc: Callback for setting the Program Counter register. This * should have the semantics used by the target architecture when * setting the PC from a source such as an ELF file entry point; @@ -137,7 +136,6 @@ struct CPUClass { void (*dump_state)(CPUState *cpu, FILE *, int flags); void (*dump_statistics)(CPUState *cpu, int flags); int64_t (*get_arch_id)(CPUState *cpu); - bool (*get_paging_enabled)(const CPUState *cpu); void (*set_pc)(CPUState *cpu, vaddr value); int (*gdb_read_register)(CPUState *cpu, GByteArray *buf, int reg); int (*gdb_write_register)(CPUState *cpu, uint8_t *buf, int reg); diff --git a/include/hw/core/sysemu-cpu-ops.h b/include/hw/core/sysemu-cpu-ops.h index 213e5287ab..a9ba39e5f2 100644 --- a/include/hw/core/sysemu-cpu-ops.h +++ b/include/hw/core/sysemu-cpu-ops.h @@ -21,6 +21,10 @@ typedef struct SysemuCPUOps { */ void (*get_memory_mapping)(CPUState *cpu, MemoryMappingList *list, Error **errp); + /** + * @get_paging_enabled: Callback for inquiring whether paging is enabled. + */ + bool (*get_paging_enabled)(const CPUState *cpu); /** * @get_phys_page_debug: Callback for obtaining a physical address. */ diff --git a/hw/core/cpu-sysemu.c b/hw/core/cpu-sysemu.c index 3850fcb27f..00253f8929 100644 --- a/hw/core/cpu-sysemu.c +++ b/hw/core/cpu-sysemu.c @@ -27,8 +27,8 @@ bool cpu_paging_enabled(const CPUState *cpu) { CPUClass *cc = CPU_GET_CLASS(cpu); - if (cc->get_paging_enabled) { - return cc->get_paging_enabled(cpu); + if (cc->sysemu_ops->get_paging_enabled) { + return cc->sysemu_ops->get_paging_enabled(cpu); } return false; diff --git a/target/i386/cpu.c b/target/i386/cpu.c index d400feec8f..744afc0ff2 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -6485,12 +6485,14 @@ static int64_t x86_cpu_get_arch_id(CPUState *cs) return cpu->apic_id; } +#if !defined(CONFIG_USER_ONLY) static bool x86_cpu_get_paging_enabled(const CPUState *cs) { X86CPU *cpu = X86_CPU(cs); return cpu->env.cr[0] & CR0_PG_MASK; } +#endif /* !CONFIG_USER_ONLY */ static void x86_cpu_set_pc(CPUState *cs, vaddr value) { @@ -6719,6 +6721,7 @@ static Property x86_cpu_properties[] = { static const struct SysemuCPUOps i386_sysemu_ops = { .get_memory_mapping = x86_cpu_get_memory_mapping, + .get_paging_enabled = x86_cpu_get_paging_enabled, .get_phys_page_attrs_debug = x86_cpu_get_phys_page_attrs_debug, .asidx_from_attrs = x86_asidx_from_attrs, .get_crash_info = x86_cpu_get_crash_info, @@ -6754,7 +6757,6 @@ static void x86_cpu_common_class_init(ObjectClass *oc, void *data) cc->gdb_read_register = x86_cpu_gdb_read_register; cc->gdb_write_register = x86_cpu_gdb_write_register; cc->get_arch_id = x86_cpu_get_arch_id; - cc->get_paging_enabled = x86_cpu_get_paging_enabled; #ifndef CONFIG_USER_ONLY cc->sysemu_ops = &i386_sysemu_ops;