From nobody Fri Nov 7 00:41:11 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1544702328265726.922602673731; Thu, 13 Dec 2018 03:58:48 -0800 (PST) Received: from localhost ([::1]:51931 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gXPde-00027e-QT for importer@patchew.org; Thu, 13 Dec 2018 06:58:46 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55928) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gXPaB-0007dV-TW for qemu-devel@nongnu.org; Thu, 13 Dec 2018 06:55:12 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gXPa8-00008H-6B for qemu-devel@nongnu.org; Thu, 13 Dec 2018 06:55:11 -0500 Received: from mail-wm1-x342.google.com ([2a00:1450:4864:20::342]:37550) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gXPa7-00007N-6q for qemu-devel@nongnu.org; Thu, 13 Dec 2018 06:55:07 -0500 Received: by mail-wm1-x342.google.com with SMTP id g67so2091756wmd.2 for ; Thu, 13 Dec 2018 03:55:07 -0800 (PST) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id g201sm1255645wme.43.2018.12.13.03.55.03 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Dec 2018 03:55:04 -0800 (PST) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 9997A3E0363; Thu, 13 Dec 2018 11:55:03 +0000 (GMT) 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=ekMfKo3ZA6YOlbMnD8F8r3Cf15l5nuMJM++IxWwQXiA=; b=LHqBUJQpc+kgMPo+3cbVB81x78OGSqdD07GFNZDNxvZ7yh+Q+J09iCAgETHjVD0bOo RU04Y0n1rRWKMeogvvv+4qIO1bdClFqI1hltmZdVVCnM4hyTDZ0kPkWyMQFb7qXbdm3Q U4bI+B0jgwjZ7aExf7rg7A1uOxdpF+wTBrApw= 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=ekMfKo3ZA6YOlbMnD8F8r3Cf15l5nuMJM++IxWwQXiA=; b=i9D/Iayt+3XNcoWLA8yPoDPmxdwi/1mpEd+zOjhi5K7dOQZYNHIJqfNQRsf67KhUio ha10+5JlI3j9VkaSxejoXU1DuqLmWORrMN/4gABLvi8ksuk+EqVl+A3L3rr2HL94K3im VKce6TU1fdvloGIGBHt6aCJjJOyqQwFxccaf7qqdNH2lYzYZm8zU4cq//XhIwDNw66oC qsY3hOq1r9F/ZshTr+E4vrrBP9w6nuOLYq3AtPrra7Fip6sEW5JfDjEU4v0o/BSAAdnP SqhahW02MoElpbspKFJsoWrysHqBmQUz6wPljRGdwMBFfUBdh8i1B0SM1FJTScjNxYQ2 bILw== X-Gm-Message-State: AA+aEWYhzdVN7KlbizPNHm1UxU9va7ZXp+l/CytLjKR9Ui3Z4ymSWn/T PdoXR/OG/zu/K5WQ6qWZsWpQAQ== X-Google-Smtp-Source: AFSGD/WlkpxkAjKqfteavzzytdKTUu2+NeeUiAJxDGW/C5zsuq1CyA8mZXrqaQQnFbd/AY5XTZRfsA== X-Received: by 2002:a1c:35ca:: with SMTP id c193mr9697688wma.146.1544702106109; Thu, 13 Dec 2018 03:55:06 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Date: Thu, 13 Dec 2018 11:55:03 +0000 Message-Id: <20181213115503.24188-3-alex.bennee@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181213115503.24188-1-alex.bennee@linaro.org> References: <20181213115503.24188-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::342 Subject: [Qemu-devel] [PATCH v1 2/2] target/arm: defer setting up of aarch64 gdb until arm_cpu_realize X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mark.rutland@arm.com, Peter Maydell , Omair Javaid , ard.biesheuvel@linaro.org, qemu-arm@nongnu.org, =?UTF-8?q?Alex=20Benn=C3=A9e?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) If we setup earlier we miss the parsing of the aarch64 state of the CPU. If the user has booted up with: qemu-system-aarch64 -cpu host,aarch64=3Doff -enable-kvm we end up presenting an aarch64 view of the world via the gdbstub and hilarity ensues. Reported-by: Ard Biesheuvel Signed-off-by: Alex Benn=C3=A9e Cc: Omair Javaid Reviewed-by: Richard Henderson --- include/hw/arm/arm.h | 2 ++ target/arm/cpu.c | 4 ++++ target/arm/cpu64.c | 20 +++++++++++++++----- 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/include/hw/arm/arm.h b/include/hw/arm/arm.h index ffed39252d..f9a7a6e2fb 100644 --- a/include/hw/arm/arm.h +++ b/include/hw/arm/arm.h @@ -171,4 +171,6 @@ void arm_write_secure_board_setup_dummy_smc(ARMCPU *cpu, ticks. */ extern int system_clock_scale; =20 +void arm_cpu_enable_aarch64_gdbstub(CPUClass *cc); + #endif /* HW_ARM_H */ diff --git a/target/arm/cpu.c b/target/arm/cpu.c index 60411f6bfe..100a72ff81 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -890,9 +890,13 @@ static void arm_cpu_realizefn(DeviceState *dev, Error = **errp) * queries ID_ISAR0_EL1 on such a host, the value is UNKNOWN. * Similarly, we cannot check ID_AA64PFR0 without AArch64 support. */ +#ifdef TARGET_AARCH64 if (arm_feature(&cpu->env, ARM_FEATURE_AARCH64)) { + CPUClass *cc =3D CPU_GET_CLASS(cs); no_aa32 =3D !cpu_isar_feature(aa64_aa32, cpu); + arm_cpu_enable_aarch64_gdbstub(cc); } +#endif =20 if (arm_feature(env, ARM_FEATURE_V7VE)) { /* v7 Virtualization Extensions. In real hardware this implies diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c index 873f059bf2..53cde60557 100644 --- a/target/arm/cpu64.c +++ b/target/arm/cpu64.c @@ -434,12 +434,14 @@ static gchar *aarch64_gdb_arch_name(CPUState *cs) return g_strdup("aarch64"); } =20 -static void aarch64_cpu_class_init(ObjectClass *oc, void *data) -{ - CPUClass *cc =3D CPU_CLASS(oc); +/* + * We can only setup aarch64 gdb support once we realize the CPU + * object and know what mode it has been booted in. This is called + * from arm_cpu_realize. + */ =20 - cc->cpu_exec_interrupt =3D arm_cpu_exec_interrupt; - cc->set_pc =3D aarch64_cpu_set_pc; +void arm_cpu_enable_aarch64_gdbstub(CPUClass *cc) +{ cc->gdb_read_register =3D aarch64_cpu_gdb_read_register; cc->gdb_write_register =3D aarch64_cpu_gdb_write_register; cc->gdb_num_core_regs =3D 34; @@ -447,6 +449,14 @@ static void aarch64_cpu_class_init(ObjectClass *oc, vo= id *data) cc->gdb_arch_name =3D aarch64_gdb_arch_name; } =20 +static void aarch64_cpu_class_init(ObjectClass *oc, void *data) +{ + CPUClass *cc =3D CPU_CLASS(oc); + + cc->cpu_exec_interrupt =3D arm_cpu_exec_interrupt; + cc->set_pc =3D aarch64_cpu_set_pc; +} + static void aarch64_cpu_register(const ARMCPUInfo *info) { TypeInfo type_info =3D { --=20 2.17.1