From patchwork Thu Nov 22 17:26:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 151806 Delivered-To: patches@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp1018642ljp; Thu, 22 Nov 2018 09:26:57 -0800 (PST) X-Google-Smtp-Source: AFSGD/VfLC+jW+uHW7eNK2SU/fo75zGai8W5Wdo16Q1aFd/sjI1zbGWqcKdJqhmSY5edgjVZzp+E X-Received: by 2002:a5d:410e:: with SMTP id l14mr10435076wrp.61.1542907617898; Thu, 22 Nov 2018 09:26:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542907617; cv=none; d=google.com; s=arc-20160816; b=Sni46drixQzFWUZXkQH4bGtXgainVkZzJ4AB4b77vWqIwpgELCAPdP+OWoBbEN/j2Y +HRcOKGhDiJFDgb599T5pMVZB8QcJiqEDsQ+m/fb0KYWnlrY8pPl3Vh2RC9tyCmXrgz8 x06spBpGzv15EkbInE5VrgHHhiabVDb9gTcvyZCl8SvehAafh6l6R1vCVqmOAxpqJocT ox7wl18hbkNe0taiefETitJAbdq0mda9HHoKmwS7UhFXFB0z7W5P9JFVkRx0nPpBFTcZ 1XH6e3F/7Rvi2xjt7pyt74+C4kSoq92apfzMig9vGNPkzVmY+UvUAreJT3iHwR72KKas rkBw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=88TccMLuTY3QJvVCI49ok8kEckLrFHxNTR2Wxo3x4No=; b=S7z0BznQfGeNWZ8JdIKMdnSakTfSTMxWrOnyJ53yNCSCJJiVXrkVfkSQB96k/IjtIX +10GbMvyxzhTmrB0iuOQ2g9VtLgVb+dFUDcoHGVdUy2IVVooQwZv2Uvmgpq09QUwuqYP 7qqpjxTXNoSU/ppLn/9V25w+kN99z1rU6SqaRH0bGRzcbz2ySvmX5nBZaGNrnOKtPPZn cnvTto1tUny1U217iJ2dXucLRI9Oc32iLfYL6kA2dqpQ1MGrX+zRTBQAKjKS87LdBLHe ZT/lwYdrEw2qTqdylc1icidhjcb2WQs34AtDMiCyL6AU6oT0tzEsyEsjHwMViKnAClpu wSxA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 2001:8b0:1d0::2 as permitted sender) smtp.mailfrom=pm215@archaic.org.uk; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by mx.google.com with ESMTPS id e72si4091637wmg.125.2018.11.22.09.26.57 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 22 Nov 2018 09:26:57 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 2001:8b0:1d0::2 as permitted sender) client-ip=2001:8b0:1d0::2; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 2001:8b0:1d0::2 as permitted sender) smtp.mailfrom=pm215@archaic.org.uk; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from pm215 by orth.archaic.org.uk with local (Exim 4.89) (envelope-from ) id 1gPskj-0005ee-BI; Thu, 22 Nov 2018 17:26:57 +0000 From: Peter Maydell To: qemu-devel@nongnu.org Cc: patches@linaro.org, "Dr. David Alan Gilbert" , Markus Armbruster , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH v2 for-4.0 1/3] disas.c: Use address_space_read() to read memory Date: Thu, 22 Nov 2018 17:26:51 +0000 Message-Id: <20181122172653.3413-2-peter.maydell@linaro.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181122172653.3413-1-peter.maydell@linaro.org> References: <20181122172653.3413-1-peter.maydell@linaro.org> MIME-Version: 1.0 Currently disas.c reads physical memory using cpu_physical_memory_read(). This effectively hard-codes assuming that all CPUs have the same view of physical memory. Switch to address_space_read() instead, which lets us use the AddressSpace for the CPU we're disassembling for. Signed-off-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daudé --- disas.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) -- 2.19.1 diff --git a/disas.c b/disas.c index 5325b7e6be6..f9c517b3588 100644 --- a/disas.c +++ b/disas.c @@ -588,7 +588,10 @@ static int physical_read_memory(bfd_vma memaddr, bfd_byte *myaddr, int length, struct disassemble_info *info) { - cpu_physical_memory_read(memaddr, myaddr, length); + CPUDebug *s = container_of(info, CPUDebug, info); + + address_space_read(s->cpu->as, memaddr, MEMTXATTRS_UNSPECIFIED, + myaddr, length); return 0; } From patchwork Thu Nov 22 17:26:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 151808 Delivered-To: patches@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp1018658ljp; Thu, 22 Nov 2018 09:26:58 -0800 (PST) X-Google-Smtp-Source: AJdET5dbPxyUqhI/vW+/kmXyDI5MMCGOo4L92mnq1Joy7QP5f9S7sB4q69fwvYWLmmLEuiKBNuX5 X-Received: by 2002:a1c:ef08:: with SMTP id n8mr11150356wmh.114.1542907618742; Thu, 22 Nov 2018 09:26:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542907618; cv=none; d=google.com; s=arc-20160816; b=bwSG/XuBSWU+3K1vnfhhzbvIj0wh+ZszIC63yD8YLxvWGmr/Kfa7D1B1t42xIL/9Wf 11zSlfvT6z9DC34KIkyZrOO6CGythZHregJX3VnW7FKwH71XkX2MPRNrsVh0n8sh2cXQ 9OJmbIX7zI2cZJll3Tomapv5SXFEV5ld4nAsPczTECF/thBjs+fPKV1yZRdlE6VDrQLg aGDKtVNpybAeEn04nAIG8v4XxMIZxHBesKd2xdT6jAdDNso3gQsPRfJKrNFEw2yqY1Sy 1MPiq1gdDPTOuMnUqcJnRr/2ks/pS8kOk4ECPZ61NxOaPfYDENR+s6G9mu/hJA3UmhLq J/5A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=dNx4zTVXMvMtAogQ7W24AJpC6g2e+hWzKEj9KgYy7vE=; b=ea709RYl1L2GIomzO46DmKc/wxsPvyggKb3Xd9aF4zFbE8CJj+0jMun8M7GgUCgV5M zwkeIhUQtB6+Y1vOF9T4EE3W6pPx3LVWVJde1JQWXwQPbZmy+u61wny7lEmsK782UAPN rweOsPI7AtGQLtFVTP/A55vF7fwZoatlR5sAb2m4azQ1H7c3hf6CjEa/KPFc9MYxUN58 dkxt6jmo94FSAMj38yHqgumRwBMFhWI7yLVe/y/isA0VDJxT9Y/zNITIGmGGXTxdRoje hlFaa2gzy37TaN90N4NTA56ZAmQm54WobnT8JC+Shca17TeLxmYmmw+rnM5ENaLB3Q+J IuBA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 2001:8b0:1d0::2 as permitted sender) smtp.mailfrom=pm215@archaic.org.uk; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by mx.google.com with ESMTPS id a140si3848967wme.181.2018.11.22.09.26.58 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 22 Nov 2018 09:26:58 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 2001:8b0:1d0::2 as permitted sender) client-ip=2001:8b0:1d0::2; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 2001:8b0:1d0::2 as permitted sender) smtp.mailfrom=pm215@archaic.org.uk; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from pm215 by orth.archaic.org.uk with local (Exim 4.89) (envelope-from ) id 1gPskk-0005ev-8W; Thu, 22 Nov 2018 17:26:58 +0000 From: Peter Maydell To: qemu-devel@nongnu.org Cc: patches@linaro.org, "Dr. David Alan Gilbert" , Markus Armbruster , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH v2 for-4.0 2/3] monitor: Use address_space_read() to read memory Date: Thu, 22 Nov 2018 17:26:52 +0000 Message-Id: <20181122172653.3413-3-peter.maydell@linaro.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181122172653.3413-1-peter.maydell@linaro.org> References: <20181122172653.3413-1-peter.maydell@linaro.org> MIME-Version: 1.0 Currently monitor.c reads physical memory using cpu_physical_memory_read(). This effectively hard-codes assuming that all CPUs have the same view of physical memory. Switch to address_space_read() instead, which lets us use the AddressSpace for the CPU we're reading memory for (falling back to address_space_memory if there is no CPU, as happens with the "none" board). As a bonus, this allows us to detect failures to read memory. Signed-off-by: Peter Maydell Reviewed-by: Dr. David Alan Gilbert --- monitor.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) -- 2.19.1 Reviewed-by: Philippe Mathieu-Daudé diff --git a/monitor.c b/monitor.c index d39390c2f2f..b0e8f2c490a 100644 --- a/monitor.c +++ b/monitor.c @@ -1604,7 +1604,13 @@ static void memory_dump(Monitor *mon, int count, int format, int wsize, if (l > line_size) l = line_size; if (is_physical) { - cpu_physical_memory_read(addr, buf, l); + AddressSpace *as = cs ? cs->as : &address_space_memory; + MemTxResult r = address_space_read(as, addr, + MEMTXATTRS_UNSPECIFIED, buf, l); + if (r != MEMTX_OK) { + monitor_printf(mon, " Cannot access memory\n"); + break; + } } else { if (cpu_memory_rw_debug(cs, addr, buf, l, 0) < 0) { monitor_printf(mon, " Cannot access memory\n"); From patchwork Thu Nov 22 17:26:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 151809 Delivered-To: patches@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp1018669ljp; Thu, 22 Nov 2018 09:26:59 -0800 (PST) X-Google-Smtp-Source: AJdET5cspkzO1hZ47EAYZN4qpsub6z9xw4hzQiJT/LtS9Gtr5o2MTuRIP1qA1hb9jE9eXfLn272J X-Received: by 2002:a1c:950f:: with SMTP id x15-v6mr10867748wmd.3.1542907619645; Thu, 22 Nov 2018 09:26:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542907619; cv=none; d=google.com; s=arc-20160816; b=y9SHLcEEOgOWrSIMhbJnumgzlx0GF6dR0MqJgm3FnS4imxNXQxkr+nF1mnbP4ZbUUQ Dki/aSQLW+88y8EndfJi+JnNhEbYxiuXKvP2w45BTJzkVfPG+SQqoY1MmnedTzDuuY0I GsssrXj6W9BKLqYlsPHZhVWg8Vr2kYJUJiGNuiC5KzEcHhOuOsN4ppPKDzzmJzlBxzUE eW2HZOIPGjH/ia0AAAK6ZwW6AEwlEJIVHCApqMxmt2sLOw9JUWKOtthrpJarAD4EDFNw O0eH5ee0o7+0JJZ86HXfemk2Wihxg3Frt8Vo+x+WT+TdMkAccXq2kwAP6cLQxRnAymvZ vhXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=XGEW7nyDacq1HwaQphwG+1IzZu6IuS4CTxik4WzDDbg=; b=dJU8e33Dt3YCV6Zv+EkUYDp7s+ECtfXrLxwraqSY6sFzTNZ7RxmpVa8BOZdV8NQXoF /5W73JqmCjWPg02nPOtOkR+XZrssouDgsytRaPsPWOnPIff8LmQnl6vNYCFxRENtEMgs DU3S0ATUsgUopv4I//38npVHiv9X0ZS/omSEyIDNeUPuxZnaN7URDU1teYQbL2GA+ASN TD2Jvw3CZOFfQX8WtjSZVBKnnpwmuUBtiQ85C9wt2sDr1Ac7+nYTOMIeCXTpYvagjLWM pBppGwe3xBYmArYhewQ7fAEp1GAkdYFGMKfkv85kRr/04h8odt/IiYZzbhjh8PPqXhND a/1A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 2001:8b0:1d0::2 as permitted sender) smtp.mailfrom=pm215@archaic.org.uk; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by mx.google.com with ESMTPS id s82si3907487wmf.82.2018.11.22.09.26.59 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 22 Nov 2018 09:26:59 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 2001:8b0:1d0::2 as permitted sender) client-ip=2001:8b0:1d0::2; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 2001:8b0:1d0::2 as permitted sender) smtp.mailfrom=pm215@archaic.org.uk; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from pm215 by orth.archaic.org.uk with local (Exim 4.89) (envelope-from ) id 1gPskl-0005fB-6E; Thu, 22 Nov 2018 17:26:59 +0000 From: Peter Maydell To: qemu-devel@nongnu.org Cc: patches@linaro.org, "Dr. David Alan Gilbert" , Markus Armbruster , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH v2 for-4.0 3/3] elf_ops.h: Use address_space_write() to write memory Date: Thu, 22 Nov 2018 17:26:53 +0000 Message-Id: <20181122172653.3413-4-peter.maydell@linaro.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181122172653.3413-1-peter.maydell@linaro.org> References: <20181122172653.3413-1-peter.maydell@linaro.org> MIME-Version: 1.0 Currently the load_elf function in elf_ops.h uses cpu_physical_memory_write() to write the ELF file to memory if it is not handling it as a ROM blob. This means we ignore the AddressSpace that the function is passed to define where it should be loaded. Use address_space_write() instead. Signed-off-by: Peter Maydell --- v1->v2: handle NULL as --- include/hw/elf_ops.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) -- 2.19.1 Reviewed-by: Philippe Mathieu-Daudé diff --git a/include/hw/elf_ops.h b/include/hw/elf_ops.h index 81cecaf27e2..74679ff8da3 100644 --- a/include/hw/elf_ops.h +++ b/include/hw/elf_ops.h @@ -482,7 +482,9 @@ static int glue(load_elf, SZ)(const char *name, int fd, rom_add_elf_program(label, data, file_size, mem_size, addr, as); } else { - cpu_physical_memory_write(addr, data, file_size); + address_space_write(as ? as : &address_space_memory, + addr, MEMTXATTRS_UNSPECIFIED, + data, file_size); g_free(data); } }