* [Qemu-devel] [RFC v6 0/2] monitor: add memory search commands s, sp @ 2015-05-18 11:22 hw.claudio 2015-05-18 11:22 ` [Qemu-devel] [RFC v6 1/2] util: add memmem replacement function hw.claudio ` (2 more replies) 0 siblings, 3 replies; 11+ messages in thread From: hw.claudio @ 2015-05-18 11:22 UTC (permalink / raw) To: Luiz Capitulino, Paolo Bonzini Cc: Claudio Fontana, Peter Maydell, Gonglei, qemu-devel From: Claudio Fontana <claudio.fontana@huawei.com> This is the latest iteration of the memory search patch, including a trivial replacement for the memmem function for systems which don't provide one (notably Windows). It detects the presence of memmem in configure and sets CONFIG_MEMMEM, providing a trivial implementation for the !CONFIG_MEMMEM case. The new code is MIT licensed, following usage of other files in the same directory dealing with replacement functions (osdep, oslib, getauxval etc), and to maximize reusability. I have tested this in both CONFIG_MEMMEM defined/undefined scenarios, but more feedback and testing is welcome of course. changes from v5: dropped the import from gnulib and implemented a trivial replacement. changes from v4: made into a series of two patches. Introduced a memmem replacement function (import from gnulib) and detection code in configure. changes from v3: initialize pointer variable to NULL to finally get rid of spurious warning changes from v2: move code to try to address spurious warning changes from v1: make checkpatch happy by adding braces here and there. Claudio Fontana (2): util: add memmem replacement function monitor: add memory search commands s, sp configure | 15 ++++++ hmp-commands.hx | 28 +++++++++++ include/qemu/osdep.h | 4 ++ monitor.c | 140 +++++++++++++++++++++++++++++++++++++++++++++++++++ util/Makefile.objs | 1 + util/memmem.c | 62 +++++++++++++++++++++++ 6 files changed, 250 insertions(+) create mode 100644 util/memmem.c -- 1.8.5.3 ^ permalink raw reply [flat|nested] 11+ messages in thread
* [Qemu-devel] [RFC v6 1/2] util: add memmem replacement function 2015-05-18 11:22 [Qemu-devel] [RFC v6 0/2] monitor: add memory search commands s, sp hw.claudio @ 2015-05-18 11:22 ` hw.claudio 2015-05-18 14:47 ` Eric Blake 2015-05-18 11:22 ` [Qemu-devel] [RFC v6 2/2] monitor: add memory search commands s, sp hw.claudio 2015-05-28 20:18 ` [Qemu-devel] [RFC v6 0/2] " Luiz Capitulino 2 siblings, 1 reply; 11+ messages in thread From: hw.claudio @ 2015-05-18 11:22 UTC (permalink / raw) To: Luiz Capitulino, Paolo Bonzini Cc: Claudio Fontana, Peter Maydell, Gonglei, qemu-devel From: Claudio Fontana <claudio.fontana@huawei.com> if the memmem function is missing, provide a trivial replacement. Signed-off-by: Claudio Fontana <claudio.fontana@huawei.com> --- configure | 15 +++++++++++++ include/qemu/osdep.h | 4 ++++ util/Makefile.objs | 1 + util/memmem.c | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 82 insertions(+) create mode 100644 util/memmem.c diff --git a/configure b/configure index 1f0f485..feb55b1 100755 --- a/configure +++ b/configure @@ -3078,6 +3078,17 @@ if compile_prog "" "" ; then fi ########################################## +# memmem probe +cat > $TMPC <<EOF +#include <string.h> +int main(int argc, char *argv[]) { return memmem(argv[0], 0, argv[0], 0) != argv[0]; } +EOF +memmem=no +if compile_prog "" "" ; then + memmem=yes +fi + +########################################## # fdt probe # fdt support is mandatory for at least some target architectures, # so insist on it if we're building those system emulators. @@ -4431,6 +4442,7 @@ echo "RDMA support $rdma" echo "TCG interpreter $tcg_interpreter" echo "fdt support $fdt" echo "preadv support $preadv" +echo "memmem support $memmem" echo "fdatasync $fdatasync" echo "madvise $madvise" echo "posix_madvise $posix_madvise" @@ -4780,6 +4792,9 @@ fi if test "$preadv" = "yes" ; then echo "CONFIG_PREADV=y" >> $config_host_mak fi +if test "$memmem" = "yes" ; then + echo "CONFIG_MEMMEM=y" >> $config_host_mak +fi if test "$fdt" = "yes" ; then echo "CONFIG_FDT=y" >> $config_host_mak fi diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h index b3300cc..d74ddff 100644 --- a/include/qemu/osdep.h +++ b/include/qemu/osdep.h @@ -201,6 +201,10 @@ ssize_t writev(int fd, const struct iovec *iov, int iov_cnt); #include <sys/uio.h> #endif +#ifndef CONFIG_MEMMEM +void *memmem(const void *hay, size_t hay_len, const void *s, size_t s_len); +#endif /* !CONFIG_MEMMEM */ + #ifdef _WIN32 static inline void qemu_timersub(const struct timeval *val1, const struct timeval *val2, diff --git a/util/Makefile.objs b/util/Makefile.objs index ceaba30..628242f 100644 --- a/util/Makefile.objs +++ b/util/Makefile.objs @@ -1,6 +1,7 @@ util-obj-y = osdep.o cutils.o unicode.o qemu-timer-common.o util-obj-$(CONFIG_WIN32) += oslib-win32.o qemu-thread-win32.o event_notifier-win32.o util-obj-$(CONFIG_POSIX) += oslib-posix.o qemu-thread-posix.o event_notifier-posix.o qemu-openpty.o +util-obj-$(call lnot,$(CONFIG_MEMMEM)) += memmem.o util-obj-y += envlist.o path.o module.o util-obj-$(call lnot,$(CONFIG_INT128)) += host-utils.o util-obj-y += bitmap.o bitops.o hbitmap.o diff --git a/util/memmem.c b/util/memmem.c new file mode 100644 index 0000000..32b58ba --- /dev/null +++ b/util/memmem.c @@ -0,0 +1,62 @@ +/* + * memmem replacement function + * + * Copyright (C) 2015 Huawei Technologies Duesseldorf GmbH + * Written by Claudio Fontana <claudio.fontana@huawei.com> + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include <qemu-common.h> + +/* + * Search for the first occurrence of a binary string ("needle") + * in a memory region ("haystack"). + * + * If needle length is 0, it returns the pointer to the haystack. + * Otherwise it returns the pointer to the first character of the first + * occurrence of the needle in the haystack, or NULL if none are found. + * + */ +void *memmem(const void *haystack, size_t hay_len, const void *needle, size_t s_len) +{ + const unsigned char *hay = (const unsigned char *)haystack; + const unsigned char *s = (const unsigned char *)needle; + const unsigned char *last = hay + (hay_len - s_len); + + if (s_len == 0) { + return (void *)hay; + } + + if (hay_len < s_len) { + return NULL; + } + + if (s_len == 1) { + return memchr(hay, s[0], hay_len); + } + + for (; hay <= last; hay++) { + if (hay[0] == s[0] && memcmp(hay, s, s_len) == 0) { + return (void *)hay; + } + } + + return NULL; +} -- 1.8.5.3 ^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [Qemu-devel] [RFC v6 1/2] util: add memmem replacement function 2015-05-18 11:22 ` [Qemu-devel] [RFC v6 1/2] util: add memmem replacement function hw.claudio @ 2015-05-18 14:47 ` Eric Blake 0 siblings, 0 replies; 11+ messages in thread From: Eric Blake @ 2015-05-18 14:47 UTC (permalink / raw) To: hw.claudio, Luiz Capitulino, Paolo Bonzini Cc: Peter Maydell, Gonglei, Claudio Fontana, qemu-devel [-- Attachment #1: Type: text/plain, Size: 1151 bytes --] On 05/18/2015 05:22 AM, hw.claudio@gmail.com wrote: > From: Claudio Fontana <claudio.fontana@huawei.com> > > if the memmem function is missing, provide a trivial replacement. > > Signed-off-by: Claudio Fontana <claudio.fontana@huawei.com> > --- > configure | 15 +++++++++++++ > include/qemu/osdep.h | 4 ++++ > util/Makefile.objs | 1 + > util/memmem.c | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++ > 4 files changed, 82 insertions(+) > create mode 100644 util/memmem.c > > + if (s_len == 1) { > + return memchr(hay, s[0], hay_len); > + } > + > + for (; hay <= last; hay++) { > + if (hay[0] == s[0] && memcmp(hay, s, s_len) == 0) { An obvious optimization would be: if (hay[0] == s[0] && memcmp(hay + 1, s + 1, s_len - 1) == 0) since you already compared the first byte and know that the needle is more than one byte. But it's not worth the churn; this version is sufficient for the job as-is. Reviewed-by: Eric Blake <eblake@redhat.com> -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org [-- Attachment #2: OpenPGP digital signature --] [-- Type: application/pgp-signature, Size: 604 bytes --] ^ permalink raw reply [flat|nested] 11+ messages in thread
* [Qemu-devel] [RFC v6 2/2] monitor: add memory search commands s, sp 2015-05-18 11:22 [Qemu-devel] [RFC v6 0/2] monitor: add memory search commands s, sp hw.claudio 2015-05-18 11:22 ` [Qemu-devel] [RFC v6 1/2] util: add memmem replacement function hw.claudio @ 2015-05-18 11:22 ` hw.claudio 2015-05-28 20:18 ` [Qemu-devel] [RFC v6 0/2] " Luiz Capitulino 2 siblings, 0 replies; 11+ messages in thread From: hw.claudio @ 2015-05-18 11:22 UTC (permalink / raw) To: Luiz Capitulino, Paolo Bonzini Cc: Claudio Fontana, Peter Maydell, Gonglei, qemu-devel From: Claudio Fontana <claudio.fontana@huawei.com> usage is similar to the commands x, xp. Example with string: looking for "ELF" header in memory: (qemu) s/1000000cb 0x40001000 "ELF" searching memory area [0000000040001000-00000000400f5240] 0000000040090001 (qemu) x/20b 0x40090000 0000000040090000: '\x7f' 'E' 'L' 'F' '\x02' '\x01' '\x01' '\x03' 0000000040090008: '\x00' '\x00' '\x00' '\x00' '\x00' '\x00' '\x00' '\x00' 0000000040090010: '\x02' '\x00' '\xb7' '\x00' Example with value: looking for 64bit variable value 0x990088 (qemu) s/1000000xg 0xffff900042000000 0x990088 searching memory area [ffff900042000000-ffff9000427a1200] ffff9000424b3000 ffff9000424c1000 Signed-off-by: Claudio Fontana <claudio.fontana@huawei.com> --- hmp-commands.hx | 28 ++++++++++++ monitor.c | 140 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 168 insertions(+) diff --git a/hmp-commands.hx b/hmp-commands.hx index e864a6c..badf1f5 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -430,6 +430,34 @@ Start gdbserver session (default @var{port}=1234) ETEXI { + .name = "s", + .args_type = "fmt:/,addr:l,data:s", + .params = "/fmt addr data", + .help = "search virtual memory starting at 'addr' for 'data'", + .mhandler.cmd = hmp_memory_search, + }, + +STEXI +@item s/fmt @var{addr} @var{data} +@findex s +Virtual memory search starting at @var{addr} for data described by @var{data}. +ETEXI + + { + .name = "sp", + .args_type = "fmt:/,addr:l,data:s", + .params = "/fmt addr data", + .help = "search physical memory starting at 'addr' for 'data'", + .mhandler.cmd = hmp_physical_memory_search, + }, + +STEXI +@item sp/fmt @var{addr} @var{data} +@findex sp +Physical memory search starting at @var{addr} for data described by @var{data}. +ETEXI + + { .name = "x", .args_type = "fmt:/,addr:l", .params = "/fmt addr", diff --git a/monitor.c b/monitor.c index b2561e1..fde383e 100644 --- a/monitor.c +++ b/monitor.c @@ -1205,6 +1205,124 @@ static void monitor_printc(Monitor *mon, int c) monitor_printf(mon, "'"); } +static void monitor_print_addr(Monitor *mon, hwaddr addr, bool is_physical) +{ + if (is_physical) { + monitor_printf(mon, TARGET_FMT_plx "\n", addr); + } else { + monitor_printf(mon, TARGET_FMT_lx "\n", (target_ulong)addr); + } +} + +/* simple memory search for a byte sequence. The sequence is generated from + * a numeric value to look for in guest memory, or from a string. + */ +static void memory_search(Monitor *mon, int count, int format, int wsize, + hwaddr addr, const char *data_str, bool is_physical) +{ + int pos, len; /* pos in the search area, len of area */ + char *hay; /* buffer for haystack */ + int hay_size; /* haystack size. Needle size is wsize. */ + const char *needle = NULL; /* needle to search in the haystack */ + const char *format_str; /* numeric input format string */ + char value_raw[8]; /* numeric input converted to raw data */ +#define MONITOR_S_CHUNK_SIZE 16000 + + len = wsize * count; + if (len < 1) { + monitor_printf(mon, "invalid search area length.\n"); + return; + } + switch (format) { + case 'i': + monitor_printf(mon, "format '%c' not supported.\n", format); + return; + case 'c': + needle = data_str; + wsize = strlen(data_str); + if (wsize > MONITOR_S_CHUNK_SIZE) { + monitor_printf(mon, "search string too long [max %d].\n", + MONITOR_S_CHUNK_SIZE); + return; + } + break; + case 'o': + format_str = "%" SCNo64; + break; + default: + case 'x': + format_str = "%" SCNx64; + break; + case 'u': + format_str = "%" SCNu64; + break; + case 'd': + format_str = "%" SCNd64; + break; + } + if (format != 'c') { + uint64_t value; /* numeric input value */ + void *from = &value; + if (sscanf(data_str, format_str, &value) != 1) { + monitor_printf(mon, "could not parse search string " + "\"%s\" as format '%c'.\n", data_str, format); + return; + } +#if defined(HOST_WORDS_BIGENDIAN) != defined(TARGET_WORDS_BIGENDIAN) + value = bswap64(value); +#endif +#if defined(TARGET_WORDS_BIGENDIAN) + from += 8 - wsize; +#endif + memcpy(value_raw, from, wsize); + needle = value_raw; + } + monitor_printf(mon, "searching memory area "); + if (is_physical) { + monitor_printf(mon, "[" TARGET_FMT_plx "-" TARGET_FMT_plx "]\n", + addr, addr + len); + } else { + monitor_printf(mon, "[" TARGET_FMT_lx "-" TARGET_FMT_lx "]\n", + (target_ulong)addr, (target_ulong)addr + len); + } + hay_size = len < MONITOR_S_CHUNK_SIZE ? len : MONITOR_S_CHUNK_SIZE; + hay = g_malloc0(hay_size); + + for (pos = 0; pos < len;) { + char *mark, *match; /* mark new starting position, eventual match */ + int l, todo; /* total length to be processed in current chunk */ + l = len - pos; + if (l > hay_size) { + l = hay_size; + } + if (is_physical) { + cpu_physical_memory_read(addr, hay, l); + } else if (cpu_memory_rw_debug(ENV_GET_CPU(mon_get_cpu()), addr, + (uint8_t *)hay, l, 0) < 0) { + monitor_printf(mon, " Cannot access memory\n"); + break; + } + for (mark = hay, todo = l; todo >= wsize;) { + match = memmem(mark, todo, needle, wsize); + if (!match) { + break; + } + monitor_print_addr(mon, addr + (match - hay), is_physical); + mark = match + 1; + todo = mark - hay; + } + if (pos + l < len) { + /* catch potential matches across chunks. */ + pos += l - (wsize - 1); + addr += l - (wsize - 1); + } else { + pos += l; + addr += l; + } + } + g_free(hay); +} + static void memory_dump(Monitor *mon, int count, int format, int wsize, hwaddr addr, int is_physical) { @@ -1329,6 +1447,28 @@ static void memory_dump(Monitor *mon, int count, int format, int wsize, } } +static void hmp_memory_search(Monitor *mon, const QDict *qdict) +{ + int count = qdict_get_int(qdict, "count"); + int format = qdict_get_int(qdict, "format"); + int size = qdict_get_int(qdict, "size"); + target_long addr = qdict_get_int(qdict, "addr"); + const char *data_str = qdict_get_str(qdict, "data"); + + memory_search(mon, count, format, size, addr, data_str, false); +} + +static void hmp_physical_memory_search(Monitor *mon, const QDict *qdict) +{ + int count = qdict_get_int(qdict, "count"); + int format = qdict_get_int(qdict, "format"); + int size = qdict_get_int(qdict, "size"); + hwaddr addr = qdict_get_int(qdict, "addr"); + const char *data_str = qdict_get_str(qdict, "data"); + + memory_search(mon, count, format, size, addr, data_str, true); +} + static void hmp_memory_dump(Monitor *mon, const QDict *qdict) { int count = qdict_get_int(qdict, "count"); -- 1.8.5.3 ^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [Qemu-devel] [RFC v6 0/2] monitor: add memory search commands s, sp 2015-05-18 11:22 [Qemu-devel] [RFC v6 0/2] monitor: add memory search commands s, sp hw.claudio 2015-05-18 11:22 ` [Qemu-devel] [RFC v6 1/2] util: add memmem replacement function hw.claudio 2015-05-18 11:22 ` [Qemu-devel] [RFC v6 2/2] monitor: add memory search commands s, sp hw.claudio @ 2015-05-28 20:18 ` Luiz Capitulino 2015-06-11 17:53 ` Luiz Capitulino 2 siblings, 1 reply; 11+ messages in thread From: Luiz Capitulino @ 2015-05-28 20:18 UTC (permalink / raw) To: hw.claudio Cc: Peter Maydell, Claudio Fontana, qemu-devel, Gonglei, Paolo Bonzini On Mon, 18 May 2015 13:22:16 +0200 hw.claudio@gmail.com wrote: > From: Claudio Fontana <claudio.fontana@huawei.com> > > This is the latest iteration of the memory search patch, > including a trivial replacement for the memmem function for systems > which don't provide one (notably Windows). > > It detects the presence of memmem in configure and sets CONFIG_MEMMEM, > providing a trivial implementation for the !CONFIG_MEMMEM case. > > The new code is MIT licensed, following usage of other files in the same > directory dealing with replacement functions (osdep, oslib, getauxval etc), > and to maximize reusability. > > I have tested this in both CONFIG_MEMMEM defined/undefined scenarios, > but more feedback and testing is welcome of course. > > changes from v5: > dropped the import from gnulib and implemented a trivial replacement. > > changes from v4: > made into a series of two patches. > Introduced a memmem replacement function (import from gnulib) > and detection code in configure. > > changes from v3: > initialize pointer variable to NULL to finally get rid of spurious warning > > changes from v2: > move code to try to address spurious warning > > changes from v1: > make checkpatch happy by adding braces here and there. > > > Claudio Fontana (2): > util: add memmem replacement function > monitor: add memory search commands s, sp Applied to the qmp branch, thanks. > > configure | 15 ++++++ > hmp-commands.hx | 28 +++++++++++ > include/qemu/osdep.h | 4 ++ > monitor.c | 140 +++++++++++++++++++++++++++++++++++++++++++++++++++ > util/Makefile.objs | 1 + > util/memmem.c | 62 +++++++++++++++++++++++ > 6 files changed, 250 insertions(+) > create mode 100644 util/memmem.c > ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [Qemu-devel] [RFC v6 0/2] monitor: add memory search commands s, sp 2015-05-28 20:18 ` [Qemu-devel] [RFC v6 0/2] " Luiz Capitulino @ 2015-06-11 17:53 ` Luiz Capitulino 2015-06-12 6:21 ` Markus Armbruster 0 siblings, 1 reply; 11+ messages in thread From: Luiz Capitulino @ 2015-06-11 17:53 UTC (permalink / raw) To: hw.claudio Cc: Peter Maydell, Claudio Fontana, qemu-devel, Markus Armbruster, Gonglei, Paolo Bonzini On Thu, 28 May 2015 16:18:41 -0400 Luiz Capitulino <lcapitulino@redhat.com> wrote: > On Mon, 18 May 2015 13:22:16 +0200 > hw.claudio@gmail.com wrote: > > > From: Claudio Fontana <claudio.fontana@huawei.com> > > > > This is the latest iteration of the memory search patch, > > including a trivial replacement for the memmem function for systems > > which don't provide one (notably Windows). > > > > It detects the presence of memmem in configure and sets CONFIG_MEMMEM, > > providing a trivial implementation for the !CONFIG_MEMMEM case. > > > > The new code is MIT licensed, following usage of other files in the same > > directory dealing with replacement functions (osdep, oslib, getauxval etc), > > and to maximize reusability. > > > > I have tested this in both CONFIG_MEMMEM defined/undefined scenarios, > > but more feedback and testing is welcome of course. > > > > changes from v5: > > dropped the import from gnulib and implemented a trivial replacement. > > > > changes from v4: > > made into a series of two patches. > > Introduced a memmem replacement function (import from gnulib) > > and detection code in configure. > > > > changes from v3: > > initialize pointer variable to NULL to finally get rid of spurious warning > > > > changes from v2: > > move code to try to address spurious warning > > > > changes from v1: > > make checkpatch happy by adding braces here and there. > > > > > > Claudio Fontana (2): > > util: add memmem replacement function > > monitor: add memory search commands s, sp > > Applied to the qmp branch, thanks. Unfortunately, I'm quite busy and won't have time to push this through my tree. Markus is going to pick up this series soon. Acked-by: Luiz Capitulino <lcapitulino@redhat.com> > > > > > configure | 15 ++++++ > > hmp-commands.hx | 28 +++++++++++ > > include/qemu/osdep.h | 4 ++ > > monitor.c | 140 +++++++++++++++++++++++++++++++++++++++++++++++++++ > > util/Makefile.objs | 1 + > > util/memmem.c | 62 +++++++++++++++++++++++ > > 6 files changed, 250 insertions(+) > > create mode 100644 util/memmem.c > > > ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [Qemu-devel] [RFC v6 0/2] monitor: add memory search commands s, sp 2015-06-11 17:53 ` Luiz Capitulino @ 2015-06-12 6:21 ` Markus Armbruster 2015-06-12 8:35 ` Claudio Fontana 0 siblings, 1 reply; 11+ messages in thread From: Markus Armbruster @ 2015-06-12 6:21 UTC (permalink / raw) To: Luiz Capitulino Cc: Peter Maydell, Claudio Fontana, qemu-devel, Gonglei, Paolo Bonzini, hw.claudio Luiz Capitulino <lcapitulino@redhat.com> writes: > On Thu, 28 May 2015 16:18:41 -0400 > Luiz Capitulino <lcapitulino@redhat.com> wrote: > >> On Mon, 18 May 2015 13:22:16 +0200 >> hw.claudio@gmail.com wrote: >> >> > From: Claudio Fontana <claudio.fontana@huawei.com> >> > >> > This is the latest iteration of the memory search patch, >> > including a trivial replacement for the memmem function for systems >> > which don't provide one (notably Windows). >> > >> > It detects the presence of memmem in configure and sets CONFIG_MEMMEM, >> > providing a trivial implementation for the !CONFIG_MEMMEM case. >> > >> > The new code is MIT licensed, following usage of other files in the same >> > directory dealing with replacement functions (osdep, oslib, getauxval etc), >> > and to maximize reusability. >> > >> > I have tested this in both CONFIG_MEMMEM defined/undefined scenarios, >> > but more feedback and testing is welcome of course. >> > >> > changes from v5: >> > dropped the import from gnulib and implemented a trivial replacement. >> > >> > changes from v4: >> > made into a series of two patches. >> > Introduced a memmem replacement function (import from gnulib) >> > and detection code in configure. >> > >> > changes from v3: >> > initialize pointer variable to NULL to finally get rid of spurious warning >> > >> > changes from v2: >> > move code to try to address spurious warning >> > >> > changes from v1: >> > make checkpatch happy by adding braces here and there. >> > >> > >> > Claudio Fontana (2): >> > util: add memmem replacement function >> > monitor: add memory search commands s, sp >> >> Applied to the qmp branch, thanks. > > > Unfortunately, I'm quite busy and won't have time to push this > through my tree. Markus is going to pick up this series soon. > > Acked-by: Luiz Capitulino <lcapitulino@redhat.com> This series is marked RFC. Is it intended for merging anyway? Semantic conflict with [PATCH v2 0/2] monitor+disas: Remove uses of ENV_GET_CPU needs to be resolved: CC x86_64-softmmu/monitor.o /work/armbru/qemu/monitor.c: In function ‘memory_search’: /work/armbru/qemu/monitor.c:1222:9: warning: passing argument 1 of ‘x86_env_get_cpu’ from incompatible pointer type [enabled by default] } else if (cpu_memory_rw_debug(ENV_GET_CPU(mon_get_cpu()), addr, ^ In file included from /work/armbru/qemu/target-i386/cpu.h:982:0, from /work/armbru/qemu/include/qemu-common.h:124, from /work/armbru/qemu/include/hw/hw.h:5, from /work/armbru/qemu/monitor.c:25: /work/armbru/qemu/target-i386/cpu-qom.h:119:23: note: expected ‘struct CPUX86State *’ but argument is of type ‘struct CPUState *’ static inline X86CPU *x86_env_get_cpu(CPUX86State *env) ^ ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [Qemu-devel] [RFC v6 0/2] monitor: add memory search commands s, sp 2015-06-12 6:21 ` Markus Armbruster @ 2015-06-12 8:35 ` Claudio Fontana 2015-06-12 12:57 ` Markus Armbruster 0 siblings, 1 reply; 11+ messages in thread From: Claudio Fontana @ 2015-06-12 8:35 UTC (permalink / raw) To: Markus Armbruster, Luiz Capitulino Cc: Peter Maydell, Gonglei, hw.claudio, qemu-devel, Paolo Bonzini On 12.06.2015 08:21, Markus Armbruster wrote: > Luiz Capitulino <lcapitulino@redhat.com> writes: > >> On Thu, 28 May 2015 16:18:41 -0400 >> Luiz Capitulino <lcapitulino@redhat.com> wrote: >> >>> On Mon, 18 May 2015 13:22:16 +0200 >>> hw.claudio@gmail.com wrote: >>> >>>> From: Claudio Fontana <claudio.fontana@huawei.com> >>>> >>>> This is the latest iteration of the memory search patch, >>>> including a trivial replacement for the memmem function for systems >>>> which don't provide one (notably Windows). >>>> >>>> It detects the presence of memmem in configure and sets CONFIG_MEMMEM, >>>> providing a trivial implementation for the !CONFIG_MEMMEM case. >>>> >>>> The new code is MIT licensed, following usage of other files in the same >>>> directory dealing with replacement functions (osdep, oslib, getauxval etc), >>>> and to maximize reusability. >>>> >>>> I have tested this in both CONFIG_MEMMEM defined/undefined scenarios, >>>> but more feedback and testing is welcome of course. >>>> >>>> changes from v5: >>>> dropped the import from gnulib and implemented a trivial replacement. >>>> >>>> changes from v4: >>>> made into a series of two patches. >>>> Introduced a memmem replacement function (import from gnulib) >>>> and detection code in configure. >>>> >>>> changes from v3: >>>> initialize pointer variable to NULL to finally get rid of spurious warning >>>> >>>> changes from v2: >>>> move code to try to address spurious warning >>>> >>>> changes from v1: >>>> make checkpatch happy by adding braces here and there. >>>> >>>> >>>> Claudio Fontana (2): >>>> util: add memmem replacement function >>>> monitor: add memory search commands s, sp >>> >>> Applied to the qmp branch, thanks. >> >> >> Unfortunately, I'm quite busy and won't have time to push this >> through my tree. Markus is going to pick up this series soon. >> >> Acked-by: Luiz Capitulino <lcapitulino@redhat.com> > > This series is marked RFC. Is it intended for merging anyway? > > Semantic conflict with > [PATCH v2 0/2] monitor+disas: Remove uses of ENV_GET_CPU > needs to be resolved: Hello Markus, the two series conflict, but the resolution is quite simple. I would suggest applying the "Remove uses of ENV_GET_CPU" stuff first, and then fixing up my patch, I can do it for you if you need. Thanks! Claudio > > CC x86_64-softmmu/monitor.o > /work/armbru/qemu/monitor.c: In function ‘memory_search’: > /work/armbru/qemu/monitor.c:1222:9: warning: passing argument 1 of ‘x86_env_get_cpu’ from incompatible pointer type [enabled by default] > } else if (cpu_memory_rw_debug(ENV_GET_CPU(mon_get_cpu()), addr, > ^ > In file included from /work/armbru/qemu/target-i386/cpu.h:982:0, > from /work/armbru/qemu/include/qemu-common.h:124, > from /work/armbru/qemu/include/hw/hw.h:5, > from /work/armbru/qemu/monitor.c:25: > /work/armbru/qemu/target-i386/cpu-qom.h:119:23: note: expected ‘struct CPUX86State *’ but argument is of type ‘struct CPUState *’ > static inline X86CPU *x86_env_get_cpu(CPUX86State *env) > ^ > -- Claudio Fontana Server Virtualization Architect Huawei Technologies Duesseldorf GmbH Riesstraße 25 - 80992 München ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [Qemu-devel] [RFC v6 0/2] monitor: add memory search commands s, sp 2015-06-12 8:35 ` Claudio Fontana @ 2015-06-12 12:57 ` Markus Armbruster 2015-06-12 13:31 ` Claudio Fontana 0 siblings, 1 reply; 11+ messages in thread From: Markus Armbruster @ 2015-06-12 12:57 UTC (permalink / raw) To: Claudio Fontana Cc: Peter Maydell, qemu-devel, Luiz Capitulino, Gonglei, Paolo Bonzini, hw.claudio Claudio Fontana <claudio.fontana@huawei.com> writes: > On 12.06.2015 08:21, Markus Armbruster wrote: >> This series is marked RFC. Is it intended for merging anyway? >> >> Semantic conflict with >> [PATCH v2 0/2] monitor+disas: Remove uses of ENV_GET_CPU >> needs to be resolved: > > Hello Markus, > > the two series conflict, but the resolution is quite simple. > I would suggest applying the "Remove uses of ENV_GET_CPU" stuff first, > and then fixing up my patch, I can do it for you if you need. Please do, and make sure to drop the RFC on your respin if you want it merged. ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [Qemu-devel] [RFC v6 0/2] monitor: add memory search commands s, sp 2015-06-12 12:57 ` Markus Armbruster @ 2015-06-12 13:31 ` Claudio Fontana 2015-06-12 22:31 ` Eric Blake 0 siblings, 1 reply; 11+ messages in thread From: Claudio Fontana @ 2015-06-12 13:31 UTC (permalink / raw) To: Markus Armbruster Cc: Peter Maydell, Claudio Fontana, QEMU Developers, Luiz Capitulino, Gonglei, Paolo Bonzini Hello Markus, the merge conflict resolution is the following: ----- diff --git a/monitor.c b/monitor.c index 4a5ac4e..fc6e15b 100644 --- a/monitor.c +++ b/monitor.c @@ -1219,7 +1219,7 @@ static void memory_search(Monitor *mon, int count, int format, int wsize, } if (is_physical) { cpu_physical_memory_read(addr, hay, l); - } else if (cpu_memory_rw_debug(ENV_GET_CPU(mon_get_cpu()), addr, + } else if (cpu_memory_rw_debug(mon_get_cpu(), addr, (uint8_t *)hay, l, 0) < 0) { monitor_printf(mon, " Cannot access memory\n"); break; ----- You can also fetch this from the following repo and branch: https://github.com/hw-claudio/qemu-aarch64-queue "memsearch_merge_conflict" Or do you want me to respin based on an uncommited state of master + "remove ENV_GET_CPU" series? Thanks, Claudio On 12 June 2015 at 14:57, Markus Armbruster <armbru@redhat.com> wrote: > Claudio Fontana <claudio.fontana@huawei.com> writes: > >> On 12.06.2015 08:21, Markus Armbruster wrote: >>> This series is marked RFC. Is it intended for merging anyway? >>> >>> Semantic conflict with >>> [PATCH v2 0/2] monitor+disas: Remove uses of ENV_GET_CPU >>> needs to be resolved: >> >> Hello Markus, >> >> the two series conflict, but the resolution is quite simple. >> I would suggest applying the "Remove uses of ENV_GET_CPU" stuff first, >> and then fixing up my patch, I can do it for you if you need. > > Please do, and make sure to drop the RFC on your respin if you want it > merged. ^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [Qemu-devel] [RFC v6 0/2] monitor: add memory search commands s, sp 2015-06-12 13:31 ` Claudio Fontana @ 2015-06-12 22:31 ` Eric Blake 0 siblings, 0 replies; 11+ messages in thread From: Eric Blake @ 2015-06-12 22:31 UTC (permalink / raw) To: Claudio Fontana, Markus Armbruster Cc: Peter Maydell, Claudio Fontana, QEMU Developers, Luiz Capitulino, Gonglei, Paolo Bonzini [-- Attachment #1: Type: text/plain, Size: 431 bytes --] On 06/12/2015 07:31 AM, Claudio Fontana wrote: > Hello Markus, > > the merge conflict resolution is the following: > > > Or do you want me to respin based on an uncommited state of master + > "remove ENV_GET_CPU" series? Probably easiest to just post a v7 with RFC dropped and all resolution performed. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org [-- Attachment #2: OpenPGP digital signature --] [-- Type: application/pgp-signature, Size: 604 bytes --] ^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2015-06-12 22:31 UTC | newest] Thread overview: 11+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2015-05-18 11:22 [Qemu-devel] [RFC v6 0/2] monitor: add memory search commands s, sp hw.claudio 2015-05-18 11:22 ` [Qemu-devel] [RFC v6 1/2] util: add memmem replacement function hw.claudio 2015-05-18 14:47 ` Eric Blake 2015-05-18 11:22 ` [Qemu-devel] [RFC v6 2/2] monitor: add memory search commands s, sp hw.claudio 2015-05-28 20:18 ` [Qemu-devel] [RFC v6 0/2] " Luiz Capitulino 2015-06-11 17:53 ` Luiz Capitulino 2015-06-12 6:21 ` Markus Armbruster 2015-06-12 8:35 ` Claudio Fontana 2015-06-12 12:57 ` Markus Armbruster 2015-06-12 13:31 ` Claudio Fontana 2015-06-12 22:31 ` Eric Blake
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).