From nobody Sat Jun 29 02:09:58 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.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 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1556782561; cv=none; d=zoho.com; s=zohoarc; b=nmJ4yDUiGgjjmmatsLPTeXZbVYWKSLs7+NtI0Gxxjhy8XiWYxDD3nnIUbRoXQrIPrRHlTJ5l7/oHlrU+dlulVUOhc/bsdn+Rw4JFs5W1wO3CwZouSsPzpRyxNkNS7D/E8HTrBYiQcl3RLurx8ZEvcCicUFw2IBFE1KBiH0ISUyc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1556782561; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=ty2WlLmKhHN0xnYND6EVRTn/Wsczm2UvDdzQfmaxB4Y=; b=EL7KQ+KcecloDtP1vyzO9Kp7j4apnePP+YtPs/hEYhDac0niBGYvjihcwqU3Hod3nSPsnLeWCT5XWvj97SKU4ULziBhHyr+Ho1S8guiN0PawixhZ25IsAkg+x24Phw8kwCrxNP0WSljaZmOCYOWW6ioMm/UTLVAh2ng+2PaNFEE= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1556782561160242.2990926986672; Thu, 2 May 2019 00:36:01 -0700 (PDT) Received: from localhost ([127.0.0.1]:46599 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hM6G3-0001Pc-M1 for importer@patchew.org; Thu, 02 May 2019 03:35:55 -0400 Received: from eggs.gnu.org ([209.51.188.92]:59523) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hM69I-0004B1-EO for qemu-devel@nongnu.org; Thu, 02 May 2019 03:28:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hM694-0002DK-HW for qemu-devel@nongnu.org; Thu, 02 May 2019 03:28:51 -0400 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]:39152) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hM68u-0000sd-IW for qemu-devel@nongnu.org; Thu, 02 May 2019 03:28:36 -0400 Received: by mail-wr1-x442.google.com with SMTP id a9so1794839wrp.6 for ; Thu, 02 May 2019 00:27:41 -0700 (PDT) Received: from localhost.localdomain ([176.230.64.186]) by smtp.gmail.com with ESMTPSA id z5sm8769289wre.70.2019.05.02.00.27.38 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 02 May 2019 00:27:39 -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=ty2WlLmKhHN0xnYND6EVRTn/Wsczm2UvDdzQfmaxB4Y=; b=ux+L8GQgnopXTu3TP26b4++71aIr9NIckByUeOW+wTLaJ56ZSyCfX98ug48WuOCnQz 6EUKdaN+kgRDcJVsNdKpNthGU3iMwvVUioM9AatYEVdHtaRKxLf+rdRYjtoA82G39pDr TpNUTL/v08hxQeA1v8pd77Byv8u2BqG9NFU9+UQonE3cdl/rAU+P0im4vSgjwTVZZsfH Z62ASqBQXsJDjk+zwOa//GFC+WdQsncrBDqXJv4DubGVjWsDVvPxoEUFxKyDmcG+q/43 a2mPrWrX8Ar0QONQy1eS+V9EfHhtNP6xLUdej1/oEUgyf5il1qUfiT+wdP3p6jB1k4U9 4wfg== 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=ty2WlLmKhHN0xnYND6EVRTn/Wsczm2UvDdzQfmaxB4Y=; b=co6FB/8jSS8Q7fVQuXVI9VGBj2QtlY1Ee8LuFFzGd4dCSKry6GJSrX/0boIufxM1fx UR0DsLqse6y0PnI0hvsX31Scn1exDja3anTKpBFkmgnYFhxT7KAUWg7MQTbNG5xm7uRR X/6Jg1+T0r6to5Dq+jnU78lctSlGQCDr6siUjhDAVPZ/9CN0tlpeAZhEqkTah7N1ogQ5 c+/yrE42+forAMRzFwekYrwnH7T9pkiWOWEeODmkhGLx6ux1RKI/+OqxVZbIlKRwx02D J/ai4G0/7QS26h/KRcnzQMYHTJ23UYKwai3vnt4D1AbjLG72iynxa7QZdGHreLsckOKH jqlA== X-Gm-Message-State: APjAAAX6gjHFZtXe7b+Kp5pDXpCyX+YziCyvsGd1n9doZLpWNgkLg7u7 L+7utHrWB/2JTIpi3xUYZTPRzIsb X-Google-Smtp-Source: APXvYqysx6Tbo41fJ4NHVozYIuea8JDuurYREkL+KnbNiqgc9OCmp332RJy1CkYjqXgTSTRbatP7Ow== X-Received: by 2002:adf:b645:: with SMTP id i5mr1590986wre.272.1556782060139; Thu, 02 May 2019 00:27:40 -0700 (PDT) From: Jon Doron To: qemu-devel@nongnu.org Date: Thu, 2 May 2019 10:26:41 +0300 Message-Id: <20190502072641.4667-28-arilou@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190502072641.4667-1-arilou@gmail.com> References: <20190502072641.4667-1-arilou@gmail.com> MIME-Version: 1.0 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::442 Subject: [Qemu-devel] [PATCH v8 27/27] gdbstub: Add support to write a MSR for KVM target 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: liran.alon@oracle.com, alex.bennee@linaro.org, Jon Doron Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" gdb> maint packet Qqemu.kvm.Wrmsr:MsrIndex,Value Signed-off-by: Jon Doron --- gdbstub.c | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/gdbstub.c b/gdbstub.c index d5cdda190a..2d9a8e6942 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -2145,7 +2145,8 @@ static void handle_query_qemu_supported(GdbCmdContext= *gdb_ctx, void *user_ctx) "sstepbits;sstep;PhyMemMode"); =20 if (kvm_enabled()) { - pstrcat(gdb_ctx->str_buf, sizeof(gdb_ctx->str_buf), ";kvm.Rdmsr"); + pstrcat(gdb_ctx->str_buf, sizeof(gdb_ctx->str_buf), + ";kvm.Rdmsr;kvm.Wrmsr"); } =20 put_packet(gdb_ctx->s, gdb_ctx->str_buf); @@ -2196,6 +2197,26 @@ static void handle_query_kvm_read_msr(GdbCmdContext = *gdb_ctx, void *user_ctx) put_packet(gdb_ctx->s, gdb_ctx->str_buf); } =20 +static void handle_set_kvm_write_msr(GdbCmdContext *gdb_ctx, void *user_ct= x) +{ + if (!kvm_enabled()) { + return; + } + + if (gdb_ctx->num_params < 2) { + put_packet(gdb_ctx->s, "E22"); + return; + } + + if (kvm_arch_write_msr(gdbserver_state->c_cpu, gdb_ctx->params[0].val_= ul, + gdb_ctx->params[1].val_ull)) { + put_packet(gdb_ctx->s, "E00"); + return; + } + + put_packet(gdb_ctx->s, "OK"); +} + static GdbCmdParseEntry gdb_gen_query_set_common_table[] =3D { /* Order is important if has same prefix */ { @@ -2302,6 +2323,12 @@ static GdbCmdParseEntry gdb_gen_set_table[] =3D { .cmd_startswith =3D 1, .schema =3D "l0" }, + { + .handler =3D handle_set_kvm_write_msr, + .cmd =3D "qemu.kvm.Wrmsr:", + .cmd_startswith =3D 1, + .schema =3D "l,L0" + }, }; =20 static void handle_gen_query(GdbCmdContext *gdb_ctx, void *user_ctx) --=20 2.20.1