From nobody Wed Nov 12 05:24:26 2025 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; 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=ispras.ru ARC-Seal: i=1; a=rsa-sha256; t=1568801728; cv=none; d=zoho.com; s=zohoarc; b=nISsPtAyCJjKZcPoOhRIFMfrS6xQsg3ZXdgXEkxR8/9TnZiEy+7Qy2KV4ex+cazQWlXCXjqeQJ3blFx0pLvCB8xYqzuUqVQD10q0uGP58lG3Oje82CBEbRI3G6jNUWHtWpO3BlI8bqZamBTcaAl8aoUDBvdRriJcZGlqx6Imh4g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1568801728; h=Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:Sender:Subject:To:ARC-Authentication-Results; bh=C0UHExWJoZioIQcuWQgQRV5rLV6cp+Jw/pwBjwecmSw=; b=lKNIlnjXHWQYDOa2rL/LWxm6vdnapnz5EdCmZon96VTXBKPfoAsT8rwz+FfcfRmVEd2NITu8H3mbIA3x0QBYYmANVVuKpBzOvy+IuJmFnSLXbIIGCYNN8fF8+HuAt5P/9NZNPA53D5hH/NYcqDTXu2VxmxFgLpQ+wu45S5pg7T4= ARC-Authentication-Results: i=1; mx.zoho.com; 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 (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1568801728141302.47822110040704; Wed, 18 Sep 2019 03:15:28 -0700 (PDT) Received: from localhost ([::1]:56964 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iAWze-0007SP-9G for importer@patchew.org; Wed, 18 Sep 2019 06:15:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33597) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iAWsW-0007pG-NR for qemu-devel@nongnu.org; Wed, 18 Sep 2019 06:08:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iAWsV-0002Ky-CA for qemu-devel@nongnu.org; Wed, 18 Sep 2019 06:08:04 -0400 Received: from mail.ispras.ru ([83.149.199.45]:33516) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1iAWsV-0002GY-5F for qemu-devel@nongnu.org; Wed, 18 Sep 2019 06:08:03 -0400 Received: from Dimon-PC.lan02.inno (unknown [85.142.117.226]) by mail.ispras.ru (Postfix) with ESMTPSA id 9261E5400FC; Wed, 18 Sep 2019 13:07:58 +0300 (MSK) From: Dmitry Poletaev To: qemu-devel@nongnu.org Date: Wed, 18 Sep 2019 13:07:06 +0300 Message-Id: <20190918100706.19753-1-poletaev@ispras.ru> X-Mailer: git-send-email 2.11.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 83.149.199.45 Subject: [Qemu-devel] [PATCH] Fix wrong behavior of cpu_memory_rw_debug() function in SMM 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: pbonzini@redhat.com, Dmitry Poletaev , ehabkost@redhat.com, rth@twiddle.net Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" There is a problem, that you don't have access to the data using cpu_memory= _rw_debug() function when in SMM. You can't remotely debug SMM mode program= because of that for example. Likely attrs version of get_phys_page_debug should be used to get correct a= sidx at the end to handle access properly. Here the patch to fix it. Signed-off-by: Dmitry Poletaev --- target/i386/cpu.c | 2 +- target/i386/cpu.h | 3 ++- target/i386/helper.c | 5 ++++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 9e0bac31e8..8ade4ed2c6 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -5984,7 +5984,7 @@ static void x86_cpu_common_class_init(ObjectClass *oc= , void *data) #ifndef CONFIG_USER_ONLY cc->asidx_from_attrs =3D x86_asidx_from_attrs; cc->get_memory_mapping =3D x86_cpu_get_memory_mapping; - cc->get_phys_page_debug =3D x86_cpu_get_phys_page_debug; + cc->get_phys_page_attrs_debug =3D x86_cpu_get_phys_page_attrs_debug; cc->write_elf64_note =3D x86_cpu_write_elf64_note; cc->write_elf64_qemunote =3D x86_cpu_write_elf64_qemunote; cc->write_elf32_note =3D x86_cpu_write_elf32_note; diff --git a/target/i386/cpu.h b/target/i386/cpu.h index 5f6e3a029a..bbd00d8deb 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -1549,7 +1549,8 @@ void x86_cpu_get_memory_mapping(CPUState *cpu, Memory= MappingList *list, =20 void x86_cpu_dump_state(CPUState *cs, FILE *f, int flags); =20 -hwaddr x86_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr); +hwaddr x86_cpu_get_phys_page_attrs_debug(CPUState *cpu, vaddr addr, + MemTxAttrs *attrs); =20 int x86_cpu_gdb_read_register(CPUState *cpu, uint8_t *buf, int reg); int x86_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg); diff --git a/target/i386/helper.c b/target/i386/helper.c index 0fa51be646..c3a6e4fabe 100644 --- a/target/i386/helper.c +++ b/target/i386/helper.c @@ -715,7 +715,8 @@ void cpu_x86_update_cr4(CPUX86State *env, uint32_t new_= cr4) } =20 #if !defined(CONFIG_USER_ONLY) -hwaddr x86_cpu_get_phys_page_debug(CPUState *cs, vaddr addr) +hwaddr x86_cpu_get_phys_page_attrs_debug(CPUState *cs, vaddr addr, + MemTxAttrs *attrs) { X86CPU *cpu =3D X86_CPU(cs); CPUX86State *env =3D &cpu->env; @@ -725,6 +726,8 @@ hwaddr x86_cpu_get_phys_page_debug(CPUState *cs, vaddr = addr) uint32_t page_offset; int page_size; =20 + *attrs =3D cpu_get_mem_attrs(env); + a20_mask =3D x86_get_a20_mask(env); if (!(env->cr[0] & CR0_PG_MASK)) { pte =3D addr & a20_mask; --=20 2.11.0