From patchwork Thu May 2 08:15:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jon Doron X-Patchwork-Id: 1094076 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="Irxp139Z"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 44vpNQ5Q87z9s55 for ; Thu, 2 May 2019 18:29:58 +1000 (AEST) Received: from localhost ([127.0.0.1]:47359 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hM76K-0006wJ-KO for incoming@patchwork.ozlabs.org; Thu, 02 May 2019 04:29:56 -0400 Received: from eggs.gnu.org ([209.51.188.92]:42829) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hM6th-0003YP-6G for qemu-devel@nongnu.org; Thu, 02 May 2019 04:16:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hM6te-00085x-O9 for qemu-devel@nongnu.org; Thu, 02 May 2019 04:16:53 -0400 Received: from mail-wm1-x343.google.com ([2a00:1450:4864:20::343]:40660) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hM6te-0007ot-F5 for qemu-devel@nongnu.org; Thu, 02 May 2019 04:16:50 -0400 Received: by mail-wm1-x343.google.com with SMTP id h11so1376514wmb.5 for ; Thu, 02 May 2019 01:16:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=DkxdB1SSP3ygac21G5Sl2UZoz/G9CYkw1Wrg+VlI4Ww=; b=Irxp139ZMKljG8THkEBhszOYzo3QX5Z7Y75xFX6M6UqhpBw04QkKvd6jKr8qEn4fpD Ochl4S5GDn1rA3mCphbXAETmJ64sCerkERiZKl71tTGnwTxwvIPfQ33LUjjP9wObzJVa gKsCvzj6r0jils+fbcUTPGgRb8CE2P+jAikp9U6j1Nv7/98FCBpbaC405cIbaOgpbApz Yukn70e1zx7vNUhDDKNiExUx3eMISHGmnDBFpHFtudP7ENVQJkFeRrb836YUUvTOjr9L J8LDR9Wx0Qhd0viY+qJck4DpnPMT9lWyfduFIQGVtS5zh6EYmBWGzwEop9sGEc3NFg+U +wWg== 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=DkxdB1SSP3ygac21G5Sl2UZoz/G9CYkw1Wrg+VlI4Ww=; b=eJo0SyX/hD+zXe27a+FW384bpmhNjfXfK74Yln+g9N9pvlzWQ/c3FdlXhyqLHkwOSB t/qduYKZ027677lQqYDhIl7uUysKgMfRKyI4+MxY7621ODk7Olq4EycSkinhDxuqHysZ voptm9iKmFle+V1fKmSsTsi6fGtix4nZRli3N8efZ22n4v2o7789qnGNcRbQWcfXKR2f tAzGFxSu4jc9CFMewhDJetOTwwPPzZdBafaXDMJ0MVINy1Wzp0EwEtYygAnNCz9Q+s5Q JGKxCKEC9yn+ZSUaLzGgDiMoBbqHBnMi6TLcSKQhIIccsMFl6vciKzhuOi56BnERPRpd Wf+Q== X-Gm-Message-State: APjAAAVpXPkXIefnl6f5y2xAwIhUrBvSEc1q6AZGWvVOZASa7Ea22qCj xZcU/vDKSXYz7d0xdRmYm6SXuJup X-Google-Smtp-Source: APXvYqww2nVnlKoSjNaZp0o8YMmbUNXoDxJroOI04BLexpfBg+24La05NLr35TpssCL0A365sUVC+Q== X-Received: by 2002:a1c:67c1:: with SMTP id b184mr1344235wmc.12.1556785003232; Thu, 02 May 2019 01:16:43 -0700 (PDT) Received: from localhost.localdomain ([176.230.64.186]) by smtp.gmail.com with ESMTPSA id d16sm44698367wra.54.2019.05.02.01.16.41 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 02 May 2019 01:16:42 -0700 (PDT) From: Jon Doron To: qemu-devel@nongnu.org Date: Thu, 2 May 2019 11:15:50 +0300 Message-Id: <20190502081554.5521-24-arilou@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190502081554.5521-1-arilou@gmail.com> References: <20190502081554.5521-1-arilou@gmail.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::343 Subject: [Qemu-devel] [PATCH v9 23/27] gdbstub: Implement qemu physical memory mode 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: alex.bennee@linaro.org, Jon Doron Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Add a new query/set which changes the memory GDB sees to physical memory only. gdb> maint packet qqemu.PhyMemMode will reply the current phy_mem_mode state (1 for enabled, 0 for disabled) gdb> maint packet Qqemu.PhyMemMode:1 Will make GDB read/write only to physical memory, set to 0 to disable Signed-off-by: Jon Doron --- gdbstub.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 55 insertions(+), 3 deletions(-) diff --git a/gdbstub.c b/gdbstub.c index 00c07d6ec0..88ff6224e6 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -46,11 +46,23 @@ #define GDB_ATTACHED "1" #endif +static int phy_memory_mode; + static inline int target_memory_rw_debug(CPUState *cpu, target_ulong addr, uint8_t *buf, int len, bool is_write) { - CPUClass *cc = CPU_GET_CLASS(cpu); + CPUClass *cc; + if (phy_memory_mode) { + if (is_write) { + cpu_physical_memory_write(addr, buf, len); + } else { + cpu_physical_memory_read(addr, buf, len); + } + return 0; + } + + cc = CPU_GET_CLASS(cpu); if (cc->memory_rw_debug) { return cc->memory_rw_debug(cpu, addr, buf, len, is_write); } @@ -2129,7 +2141,29 @@ static void handle_query_attached(GdbCmdContext *gdb_ctx, void *user_ctx) static void handle_query_qemu_supported(GdbCmdContext *gdb_ctx, void *user_ctx) { - put_packet(gdb_ctx->s, "sstepbits;sstep"); + put_packet(gdb_ctx->s, "sstepbits;sstep;PhyMemMode"); +} + +static void handle_query_qemu_phy_mem_mode(GdbCmdContext *gdb_ctx, + void *user_ctx) +{ + snprintf(gdb_ctx->str_buf, sizeof(gdb_ctx->str_buf), "%d", phy_memory_mode); + put_packet(gdb_ctx->s, gdb_ctx->str_buf); +} + +static void handle_set_qemu_phy_mem_mode(GdbCmdContext *gdb_ctx, void *user_ctx) +{ + if (!gdb_ctx->num_params) { + put_packet(gdb_ctx->s, "E22"); + return; + } + + if (!gdb_ctx->params[0].val_ul) { + phy_memory_mode = 0; + } else { + phy_memory_mode = 1; + } + put_packet(gdb_ctx->s, "OK"); } static GdbCmdParseEntry gdb_gen_query_set_common_table[] = { @@ -2212,6 +2246,20 @@ static GdbCmdParseEntry gdb_gen_query_table[] = { .handler = handle_query_qemu_supported, .cmd = "qemu.Supported", }, + { + .handler = handle_query_qemu_phy_mem_mode, + .cmd = "qemu.PhyMemMode", + }, +}; + +static GdbCmdParseEntry gdb_gen_set_table[] = { + /* Order is important if has same prefix */ + { + .handler = handle_set_qemu_phy_mem_mode, + .cmd = "qemu.PhyMemMode:", + .cmd_startswith = 1, + .schema = "l0" + }, }; static void handle_gen_query(GdbCmdContext *gdb_ctx, void *user_ctx) @@ -2245,7 +2293,11 @@ static void handle_gen_set(GdbCmdContext *gdb_ctx, void *user_ctx) return; } - put_packet(gdb_ctx->s, ""); + if (process_string_cmd(gdb_ctx->s, NULL, gdb_ctx->params[0].data, + gdb_gen_set_table, + ARRAY_SIZE(gdb_gen_set_table))) { + put_packet(gdb_ctx->s, ""); + } } static void handle_target_halt(GdbCmdContext *gdb_ctx, void *user_ctx)