From: Cornelia Huck <cornelia.huck@de.ibm.com>
To: qemu-devel@nongnu.org
Cc: peter.maydell@linaro.org, borntraeger@de.ibm.com, agraf@suse.de,
David Hildenbrand <dahi@linux.vnet.ibm.com>,
Jens Freimann <jfrei@linux.vnet.ibm.com>,
aliguori@amazon.com, Cornelia Huck <cornelia.huck@de.ibm.com>
Subject: [Qemu-devel] [PULL 7/9] s390x: remove duplicate definitions of DIAG 501
Date: Tue, 20 May 2014 13:45:00 +0200 [thread overview]
Message-ID: <1400586302-3253-8-git-send-email-cornelia.huck@de.ibm.com> (raw)
In-Reply-To: <1400586302-3253-1-git-send-email-cornelia.huck@de.ibm.com>
From: David Hildenbrand <dahi@linux.vnet.ibm.com>
When restoring the previously saved instruction in
kvm_arch_remove_sw_breakpoint(), we only restored one byte. Let's use
the sizeof() operator to make sure we restore the entire instruction.
While we are at it, let's remove the duplicate definitions of DIAG 501
and replace its size (used when reading/writing the instruction) with
a sizeof() operator to make the code self explaining and less error-prone.
Signed-off-by: David Hildenbrand <dahi@linux.vnet.ibm.com>
Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Signed-off-by: Jens Freimann <jfrei@linux.vnet.ibm.com>
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
---
target-s390x/kvm.c | 20 ++++++++++++--------
1 file changed, 12 insertions(+), 8 deletions(-)
diff --git a/target-s390x/kvm.c b/target-s390x/kvm.c
index bb731a0..4d12f70 100644
--- a/target-s390x/kvm.c
+++ b/target-s390x/kvm.c
@@ -320,12 +320,16 @@ static void *legacy_s390_alloc(size_t size)
return mem == MAP_FAILED ? NULL : mem;
}
+/* DIAG 501 is used for sw breakpoints */
+static const uint8_t diag_501[] = {0x83, 0x24, 0x05, 0x01};
+
int kvm_arch_insert_sw_breakpoint(CPUState *cs, struct kvm_sw_breakpoint *bp)
{
- static const uint8_t diag_501[] = {0x83, 0x24, 0x05, 0x01};
- if (cpu_memory_rw_debug(cs, bp->pc, (uint8_t *)&bp->saved_insn, 4, 0) ||
- cpu_memory_rw_debug(cs, bp->pc, (uint8_t *)diag_501, 4, 1)) {
+ if (cpu_memory_rw_debug(cs, bp->pc, (uint8_t *)&bp->saved_insn,
+ sizeof(diag_501), 0) ||
+ cpu_memory_rw_debug(cs, bp->pc, (uint8_t *)diag_501,
+ sizeof(diag_501), 1)) {
return -EINVAL;
}
return 0;
@@ -333,14 +337,14 @@ int kvm_arch_insert_sw_breakpoint(CPUState *cs, struct kvm_sw_breakpoint *bp)
int kvm_arch_remove_sw_breakpoint(CPUState *cs, struct kvm_sw_breakpoint *bp)
{
- uint8_t t[4];
- static const uint8_t diag_501[] = {0x83, 0x24, 0x05, 0x01};
+ uint8_t t[sizeof(diag_501)];
- if (cpu_memory_rw_debug(cs, bp->pc, t, 4, 0)) {
+ if (cpu_memory_rw_debug(cs, bp->pc, t, sizeof(diag_501), 0)) {
return -EINVAL;
- } else if (memcmp(t, diag_501, 4)) {
+ } else if (memcmp(t, diag_501, sizeof(diag_501))) {
return -EINVAL;
- } else if (cpu_memory_rw_debug(cs, bp->pc, (uint8_t *)&bp->saved_insn, 1, 1)) {
+ } else if (cpu_memory_rw_debug(cs, bp->pc, (uint8_t *)&bp->saved_insn,
+ sizeof(diag_501), 1)) {
return -EINVAL;
}
--
1.7.9.5
next prev parent reply other threads:[~2014-05-20 11:45 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-20 11:44 [Qemu-devel] [PULL 0/9] s390 patches for 2014/05/20 Cornelia Huck
2014-05-20 11:44 ` [Qemu-devel] [PULL 1/9] kvm: Fix enable_cap helpers on older gcc Cornelia Huck
2014-05-20 11:44 ` [Qemu-devel] [PULL 2/9] s390x: split flic into kvm and non-kvm parts Cornelia Huck
2014-05-20 11:44 ` [Qemu-devel] [PULL 3/9] s390x: add I/O adapter registration Cornelia Huck
2014-05-20 11:44 ` [Qemu-devel] [PULL 4/9] s390x/virtio-ccw: reference-counted indicators Cornelia Huck
2014-05-20 11:44 ` [Qemu-devel] [PULL 5/9] s390x/virtio-ccw: wire up irq routing and irqfds Cornelia Huck
2014-05-20 11:44 ` [Qemu-devel] [PULL 6/9] linux-headers: update Cornelia Huck
2014-05-20 11:45 ` Cornelia Huck [this message]
2014-05-20 11:45 ` [Qemu-devel] [PULL 8/9] s390x/kvm: software breakpoint support Cornelia Huck
2014-05-20 11:45 ` [Qemu-devel] [PULL 9/9] s390x/kvm: hw debugging support via guest PER facility Cornelia Huck
2014-05-22 16:05 ` [Qemu-devel] [PULL 0/9] s390 patches for 2014/05/20 Peter Maydell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1400586302-3253-8-git-send-email-cornelia.huck@de.ibm.com \
--to=cornelia.huck@de.ibm.com \
--cc=agraf@suse.de \
--cc=aliguori@amazon.com \
--cc=borntraeger@de.ibm.com \
--cc=dahi@linux.vnet.ibm.com \
--cc=jfrei@linux.vnet.ibm.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).