gxemul-devel Mailing List for GXemul
Status: Alpha
Brought to you by:
gavare
You can subscribe to this list here.
2008 |
Jan
|
Feb
|
Mar
(3) |
Apr
|
May
|
Jun
(1) |
Jul
(2) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
---|---|---|---|---|---|---|---|---|---|---|---|---|
2009 |
Jan
(2) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(1) |
Sep
|
Oct
|
Nov
|
Dec
|
2010 |
Jan
(2) |
Feb
(1) |
Mar
|
Apr
|
May
(2) |
Jun
|
Jul
|
Aug
(3) |
Sep
|
Oct
|
Nov
|
Dec
|
2011 |
Jan
|
Feb
|
Mar
|
Apr
(2) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2012 |
Jan
|
Feb
|
Mar
|
Apr
(1) |
May
|
Jun
(4) |
Jul
|
Aug
|
Sep
(4) |
Oct
|
Nov
|
Dec
|
2013 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(1) |
Nov
|
Dec
|
2014 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(1) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2015 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(1) |
Nov
|
Dec
|
2016 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(1) |
Oct
|
Nov
|
Dec
|
2018 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(2) |
Sep
(1) |
Oct
|
Nov
(1) |
Dec
(1) |
2019 |
Jan
|
Feb
|
Mar
(4) |
Apr
|
May
(1) |
Jun
(14) |
Jul
(1) |
Aug
|
Sep
(1) |
Oct
|
Nov
|
Dec
|
2023 |
Jan
|
Feb
|
Mar
(7) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Jan-Benedict G. <jb...@lu...> - 2023-03-30 16:13:53
|
Hi! I feel a bit silly, but ... I've now integrated GXemul into my scripts to allow transparently to start either Qemu, GXemul or SIMH, either with in foreground (with active stdio) or in background (stdin < /dev/null, stdout+stderr > logfile) for having emulated systems around as temporary builders. It seems to start up well with: gxemul -E decstation -e 3max -L tap_1 -l 08:00:2b:29:3b:01 -d R:disk.img However, with < /dev/null, I just get the config dump and it stops generating output with "NetBSD/pmax 10.99.2 FFSv1 Primary Bootstrap", and it seems to try to get input: (gdb) bt #0 0x00007fd1f3ea4794 in __GI___select (nfds=nfds@entry=1, readfds=readfds@entry=0x7ffd2dc1a700, writefds=writefds@entry=0x0, exceptfds=exceptfds@entry=0x0, timeout=timeout@entry=0x7ffd2dc1a6f0) at ../sysdeps/unix/sysv/linux/select.c:69 #1 0x000055f709d23151 in d_avail (d=d@entry=0) at ./src/console/console.c:291 #2 0x000055f709d23ae7 in console_stdin_avail (handle=<optimized out>) at ./src/console/console.c:329 #3 console_charavail (handle=<optimized out>) at ./src/console/console.c:357 #4 0x000055f709f1ea4b in lk201_tick (machine=<optimized out>, d=d@entry=0x55f70ac10b20) at ./src/devices/lk201.c:254 #5 0x000055f709ed8607 in dev_dc7085_tick (cpu=0x7fd1ef7ff000, extra=0x55f70ac102c0) at ./src/devices/dev_dc7085.c:153 #6 0x000055f709f2c8ad in machine_run (machine=0x55f70abf21b0) at ./src/machines/machine.c:686 #7 0x000055f709f3d6a1 in emul_run (emul=emul@entry=0x55f70abf1f70) at ./src/core/emul.c:975 #8 0x000055f709d22c36 in main (argc=11, argv=0x7ffd2dc1aae8) at ./src/core/main.c:773 Any chance I can shutdown its stdin? Would be awesome to be able to start it in background. If nothing works, I'd still try to put it into a `screen` or the like, but I'd prefer to not wrap it once more... Thanks, Jan-Benedict -- |
From: Jan-Benedict G. <jb...@lu...> - 2023-03-28 08:38:59
|
Hi! There is probably already a (to-be-pushed-to-upstream-SVN) patch available to enable TAP networking unter Linux, but nonetheless, here's what I have locally for the time being. I'm using it this way (here as an example for a DECstation booting the NetBSD installer: There are CI builds for NetBSD HEAD running, storing the ISO and sets (along with the kernel) in tarballs. This is extracted and GXemul started with it, on a local TAP interface bridged with a physical wired NIC: tar xzf /var/cache/laminar/netbsd-rel-pmax-mipsel.tar.gz dd bs=1M count=1024 if=/dev/zero of=netbsd.img ISO="$(ls images/*.iso | head -1)" TAP=threemax tunctl -t "${TAP}" || true ip link set "${TAP}" up || true brctl addif br0 "${TAP}" || true # gxemul @3maxconfig gxemul -E decstation -e 3max \ -L threemax \ -l 10:11:12:13:14:16 \ -d netbsd.img \ -d "6c:${ISO}" \ -o "-a" \ -j netbsd pmax/binary/kernel/netbsd-INSTALL.gz The plan is to prepare as many simulated systems as possible to exercise as many NetBSD variants as possible. DECstations are just one example, SIMH is already running (VAX), as well as Qemu (amd64). Seems that more archs are reachable (alpha with a small Qemu patch, aarch64, ...) These simulators are used to just do test installations (and throw away the resulting disk images), but my goal is to also install "master" disk images and run these with overlays. All three simulators (Qemu, SIMH, GXemul) support this type of configuration, so that's ideal to start a nice farm of build hosts. The only difference is that they're getting a fresh overlay and a different MAC address. Oh, and here's the Linux TAP patch. There are others around that also set the IFF_ONE_QUEUE if available (cf. http://svn.exactcode.de/t2/trunk/package/emulators/gxemul/linux-tap.patch for example), but I'm not sure if that's needed or really beneficial. diff --git a/src/net/net_tap.c b/src/net/net_tap.c index 188276e..d920695 100644 --- a/src/net/net_tap.c +++ b/src/net/net_tap.c @@ -48,6 +48,11 @@ #include "misc.h" #include "net.h" +#ifdef __linux__ +# include <linux/if.h> +# include <linux/if_tun.h> +#endif + /* * net_tap_rx_for_nic(): * @@ -166,7 +171,11 @@ bool net_tap_init(struct net *net, const char *tapdev) int fd; int one = 1; +#ifdef __linux__ + fd = open("/dev/net/tun", O_RDWR); +#else fd = open(tapdev, O_RDWR); +#endif if (fd < 0) { debugmsg(SUBSYS_NET, "tap", VERBOSITY_ERROR, "unable to open tap device '%s': %s", @@ -174,6 +183,22 @@ bool net_tap_init(struct net *net, const char *tapdev) return false; } +#ifdef __linux__ + struct ifreq ifr; + + memset(&ifr, 0, sizeof(ifr)); + ifr.ifr_flags = IFF_TAP | IFF_NO_PI; + strncpy(ifr.ifr_name, tapdev, IFNAMSIZ); + + if (ioctl(fd, TUNSETIFF, &ifr) < 0) { + debugmsg(SUBSYS_NET, "tap", VERBOSITY_ERROR, + "unable to attach to " + "tap device '%s': %s", tapdev, strerror(errno)); + close(fd); + return false; + } +#endif + if (ioctl(fd, FIONBIO, &one) < 0) { debugmsg(SUBSYS_NET, "tap", VERBOSITY_ERROR, "unable to set non-blocking mode on " MfG, JBG -- |
From: Jan-Benedict G. <jb...@lu...> - 2023-03-28 08:20:19
|
Hi! On Mon, 2023-03-27 22:49:31 +0200, Jan-Benedict Glaw <jb...@lu...> wrote: > On Sat, 2023-03-25 20:39:37 +0100, Jan-Benedict Glaw <jb...@lu...> wrote: > > @Anders: Do you already have private patches to allow for > > configurable MAC addresses? Or maybe I'd cook up something? > > I had a closer look. One quite simple way to have configurable MAC > addresses could be to add a command line option (as well as a "mac()" > option in the config file) to supply a list of comma-separated MAC > addresses to be stored in struct machine. > > A helper function could be used to to parse that string and return > (if available) the n'th MAC address (or an error.) This could be > called by net_generate_unique_mac() to either pick a configured MAC > address or place one (as before.) > > @Anders: Would you accept a patch like that? Or have a different idea > for supplying / parsing MAC addresses? No docs yet, but use it either with `-l 10:11:12:13:14:15,10:12:14:16:18:20` on the command line or with `mac_list("10:11:12:13:14:15")` within a `machine(...)` context inside the config file. No docs yet. Works for me as far as tested (with just one NIC on a simulated DECstation, so supplying multiple MAC addresses wasn't actually tested yet.) diff --git a/src/core/emul_parse.c b/src/core/emul_parse.c index a16d80b..6e31465 100644 --- a/src/core/emul_parse.c +++ b/src/core/emul_parse.c @@ -224,6 +224,8 @@ static char cur_machine_start_paused[10]; static char cur_machine_ncpus[10]; static char cur_machine_n_gfx_cards[10]; static char cur_machine_serial_nr[10]; +#define MAX_MAC_LIST_LEN (8*20) +static char cur_machine_mac_list[MAX_MAC_LIST_LEN]; static char cur_machine_emulated_hz[10]; static char cur_machine_memory[10]; #define MAX_N_LOAD 15 @@ -357,6 +359,7 @@ static void parse__emul(struct emul *e, FILE *f, int *in_emul, int *line, cur_machine_serial_nr[0] = '\0'; cur_machine_emulated_hz[0] = '\0'; cur_machine_memory[0] = '\0'; + cur_machine_mac_list[0] = '\0'; return; } @@ -528,6 +531,10 @@ static void parse__machine(struct emul *e, FILE *f, int *in_emul, int *line, e->next_serial_nr = m->serial_nr+1; } + if (cur_machine_mac_list[0]) { + m->mac_list = strdup (cur_machine_mac_list); + } + if (cur_machine_emulated_hz[0]) { m->emulated_hz = mystrtoull(cur_machine_emulated_hz, NULL, 0); @@ -617,6 +624,7 @@ static void parse__machine(struct emul *e, FILE *f, int *in_emul, int *line, WORD("force_netboot", cur_machine_force_netboot); WORD("ncpus", cur_machine_ncpus); WORD("serial_nr", cur_machine_serial_nr); + WORD("mac_list", cur_machine_mac_list); WORD("n_gfx_cards", cur_machine_n_gfx_cards); WORD("emulated_hz", cur_machine_emulated_hz); WORD("memory", cur_machine_memory); diff --git a/src/include/machine.h b/src/include/machine.h index 02ee1f7..67b314b 100644 --- a/src/include/machine.h +++ b/src/include/machine.h @@ -119,6 +119,7 @@ struct machine { is useful when emulating multiple cards in one machine: */ int serial_nr; int nr_of_nics; + char *mac_list; /* Main memory: */ struct memory *memory; diff --git a/src/net/net_misc.c b/src/net/net_misc.c index f2826b8..fd96559 100644 --- a/src/net/net_misc.c +++ b/src/net/net_misc.c @@ -76,6 +76,48 @@ void net_debugaddr(void *addr, int type) } +static int net_get_configured_mac(struct machine *m, unsigned int n, unsigned char *macbuf) +{ + char *start; + unsigned int mac[6]; + + fprintf (stderr, "Trying to find MAC address %u from \"%s\"\n", n, m->mac_list); + + if (m == NULL || m->mac_list == NULL || macbuf == NULL) + return -1; + + /* Find n'th MAC address. */ + start = m->mac_list; + while (*start != '\0' && n > 0) { + if (*start == ',') { + n--; + } + start++; + } + + /* Reached end-of-string. */ + if (*start == '\0' || n > 0) + return -1; + + /* Try to parse MAC address, copy to output buffer. */ + fprintf (stderr, "MAC starts with %s\n", start); + if (sscanf(start, "%x:%x:%x:%x:%x:%x", + &mac[0], &mac[1], &mac[2], + &mac[3], &mac[4], &mac[5]) == 6) { + + macbuf[0] = mac[0]; + macbuf[1] = mac[1]; + macbuf[2] = mac[2]; + macbuf[3] = mac[3]; + macbuf[4] = mac[4]; + macbuf[5] = mac[5]; + + return 0; + } else { + return -1; + } +} + /* * net_generate_unique_mac(): * @@ -92,19 +134,23 @@ void net_generate_unique_mac(struct machine *machine, unsigned char *macbuf) return; } - // Special case: real SGI machines have 0x08 as their first - // byte, so let's mimic that. - macbuf[0] = machine->machine_type == MACHINE_SGI ? 0x08 : 0x10; - macbuf[1] = 0x20; - macbuf[2] = 0x30; - macbuf[3] = 0; - macbuf[4] = 0; - /* NOTE/TODO: This only allows 8 nics per machine! */ - macbuf[5] = (machine->serial_nr << 4) + (machine->nr_of_nics << 1); - - if (macbuf[0] & 1 || macbuf[5] & 1) { - fatal("Internal error in net_generate_unique_mac().\n"); - exit(1); + /* Use a configured MAC address if available, or generate + something that seems to be reasonable. */ + if (net_get_configured_mac (machine, machine->nr_of_nics, macbuf) != 0) { + // Special case: real SGI machines have 0x08 as their first + // byte, so let's mimic that. + macbuf[0] = machine->machine_type == MACHINE_SGI ? 0x08 : 0x10; + macbuf[1] = 0x20; + macbuf[2] = 0x30; + macbuf[3] = 0; + macbuf[4] = 0; + /* NOTE/TODO: This only allows 8 nics per machine! */ + macbuf[5] = (machine->serial_nr << 4) + (machine->nr_of_nics << 1); + + if (macbuf[0] & 1 || macbuf[5] & 1) { + fatal("Internal error in net_generate_unique_mac().\n"); + exit(1); + } } /* TODO: Remember the mac addresses somewhere? */ diff --git a/src/core/main.c b/src/core/main.c index f08f68c..0730dba 100644 --- a/src/core/main.c +++ b/src/core/main.c @@ -180,6 +180,7 @@ static void usage(bool longusage) " ISO9660\n filesystem, -j sets the name of the" " kernel to load.\n"); printf(" -L tapdev enable tap networking using device 'tapdev'\n"); + printf(" -l mac,,, Comma-separated list of MAC addresses for all network adapters\n"); printf(" -M m emulate m MBs of physical RAM\n"); printf(" -N display nr of instructions/second average, at" " regular intervals\n"); @@ -267,7 +268,8 @@ static void usage(bool longusage) * Reads command line arguments. */ int get_cmd_args(int argc, char *argv[], struct emul *emul, - char ***diskimagesp, int *n_diskimagesp, char **tap_devname) + char ***diskimagesp, int *n_diskimagesp, char **tap_devname, + char **mac_list) { int using_switch_e = 0, using_switch_E = 0; bool using_switch_Z = false; @@ -280,7 +282,7 @@ int get_cmd_args(int argc, char *argv[], struct emul *emul, struct machine *m = emul_add_machine(emul, NULL); const char *opts = - "AC:c:Dd:E:e:GHhI:iJj:k:KL:M:Nn:Oo:p:QqRrSs:TtVvW:" + "AC:c:Dd:E:e:GHhI:iJj:k:KL:l:M:Nn:Oo:p:QqRrSs:TtVvW:" #ifdef WITH_X11 "XxY:" #endif @@ -369,6 +371,9 @@ int get_cmd_args(int argc, char *argv[], struct emul *emul, case 'K': debugger_enter_at_end_of_run = true; break; + case 'l': + *mac_list = strdup(optarg); + break; case 'L': *tap_devname = strdup(optarg); break; @@ -592,6 +597,7 @@ int main(int argc, char *argv[]) struct emul *emul; bool using_config_file = false; char *tap_devname = NULL; + char *mac_list = NULL; char **diskimages = NULL; int n_diskimages = 0; int i; @@ -640,7 +646,7 @@ int main(int argc, char *argv[]) settings_add(global_settings, "emul", 1, SETTINGS_TYPE_SUBSETTINGS, 0, emul->settings); - get_cmd_args(argc, argv, emul, &diskimages, &n_diskimages, &tap_devname); + get_cmd_args(argc, argv, emul, &diskimages, &n_diskimages, &tap_devname, &mac_list); if (!skip_srandom_call) { struct timeval tv; @@ -678,6 +684,9 @@ int main(int argc, char *argv[]) return 1; } + /* Add MAC address list to machine. */ + emul->machines[0]->mac_list = strdup(mac_list); + /* Initialize one emul: */ if (!emul_simple_init(emul, tap_devname)) { fprintf(stderr, "Could not initialize the emulation.\n"); I'd very much appreciate comments on the approach, or hints when there's a better way. Thanks, Jan-Benedict -- |
From: Jan-Benedict G. <jb...@lu...> - 2023-03-27 20:49:44
|
Hi! On Sat, 2023-03-25 20:39:37 +0100, Jan-Benedict Glaw <jb...@lu...> wrote: > I just tried to find a way to configure specific MAC addresses for an > emulated machine. Couldn't find something in the docs and a quick look > at the sources seems to indicate that, for all emulated NICs, > net_generate_unique_mac() is called to calculate a MAC address. It > seems that for two "VMs" run as separate processes, the same MAC would > be used? [...] > @Anders: Do you already have private patches to allow for > configurable MAC addresses? Or maybe I'd cook up something? I had a closer look. One quite simple way to have configurable MAC addresses could be to add a command line option (as well as a "mac()" option in the config file) to supply a list of comma-separated MAC addresses to be stored in struct machine. A helper function could be used to to parse that string and return (if available) the n'th MAC address (or an error.) This could be called by net_generate_unique_mac() to either pick a configured MAC address or place one (as before.) @Anders: Would you accept a patch like that? Or have a different idea for supplying / parsing MAC addresses? MfG, JBG -- |
From: Jan-Benedict G. <jb...@lu...> - 2023-03-25 20:18:21
|
On Sat, 2023-03-25 20:39:37 +0100, Jan-Benedict Glaw <jb...@lu...> wrote: > I just tried to find a way to configure specific MAC addresses for an > emulated machine. Couldn't find something in the docs and a quick look > at the sources seems to indicate that, for all emulated NICs, > net_generate_unique_mac() is called to calculate a MAC address. It > seems that for two "VMs" run as separate processes, the same MAC would > be used? net_generate_unique_mac() uses the machine->serial_nr to be encoded into four bits of the MAC address. That would basically allow for 16 predictable emulated systems. I'd probaby start with that, but in the end, there'd be good use for more gxemul systems on a network. So the serial_nr eases my issue a bit, but doesn't solve the general case. MfG, JBG -- |
From: Jan-Benedict G. <jb...@lu...> - 2023-03-25 19:39:51
|
Hi! I just tried to find a way to configure specific MAC addresses for an emulated machine. Couldn't find something in the docs and a quick look at the sources seems to indicate that, for all emulated NICs, net_generate_unique_mac() is called to calculate a MAC address. It seems that for two "VMs" run as separate processes, the same MAC would be used? That would not be working well with TAP devices. And the generated MAC addresses don't work too well for setting up an external DHCP server. (Some background: I'd like to setup quite a herd of emulated hosts, based on Qemu, SIMH and gxemul. They'll usually use an overlay to a static base disk image and the operating systems on the individual emulated machines will just be different wrt. their MAC address, thus get different IP addresses. That however implies that I can actually _supply_ a MAC address.) @Anders: Do you already have private patches to allow for configurable MAC addresses? Or maybe I'd cook up something? Thanks, Jan-Benedict -- |
From: Jan-Benedict G. <jb...@lu...> - 2023-03-15 19:07:34
|
Hi! Not too long ago, I came across GXemul with the intend to use it for automated testing (NetBSD installation.) As it didn't work right out of the box running on Linux (issues with TAP devices for proper networking), I already sent a preliminary patch to the author. After having found the SVN repo on Sourceforge, I cloned it locally (git svn), but realized that the last commit is from about one and a half year ago. As the HISTORY file suggests more frequent changes, I suppose I cloned an outdated repository? OTOH, the mailing lists here seem to be also quite ... silent. I hope GXemul didn't face its end? Thanks, Jan-Benedict -- |
From: Andreas G. <gs...@gs...> - 2019-09-16 09:02:25
|
Hi gxemul-devel, Running the NetBSD test suite on NetBSD-current/landisk under gxemul 0.6.2 on a NetBSD/amd64 host, after a few minutes, time stops advancing in the virtual machine. For example, in the console log at http://www.gson.org/netbsd/bugs/build/landisk/2019/2019.09.13.08.09.24/test.log the first hundred or so testcases show a nonzero execution time as expected: file_return_while: [2.409073s] Passed. for_break_case: [2.290891s] Passed. for_break_compound: [0.336354s] Passed. but all the ones after that show an execution time of zero: for_break_file: [0.000000s] Passed. for_break_for: [0.000000s] Passed. for_break_func: [0.000000s] Passed. for_break_subshell: [0.000000s] Passed. When the guest has entered this state, a "sleep" command still takes about the expected amount of real time, but the clock does not advance during it: # date; sleep 10; date Mon Sep 16 08:04:47 UTC 2019 [ten second pause] Mon Sep 16 08:04:47 UTC 2019 This does not appear to happen on real hardware, based on the logs at http://www.netbsd.org/~martin/landisk-atf/ . -- Andreas Gustafsson, gs...@gs... |
From: Chris H. <cmh...@es...> - 2019-07-05 19:25:30
|
I’ve encountered a similar issue with DECstation 5000/200 (3max) emulation with Ultrix 4.5 on my little GPD Pocket running Ubuntu 19.04 (and preciously 18.10). I’ll see if I can attach with GDB when it happens and figure out what’s going on. — Chris |
From: Andreas G. <gs...@gs...> - 2019-06-27 16:29:22
|
Hi gxemul-devel, I'm having a strange problem trying to boot NetBSD/hpcmips 8.1 on gxemul-trunk on Linux. When the install ramdisk kernel boots, the serial terminal output unexpectedly stops somewhere in the middle of the boot messages, before showing the sysinst installation menu. However, if I then press a key, the output continues. Sometimes it stops again and I have to press a key again multiple times before it gets all the way to sysinst. This is of course easy to work around when installing manually, but it makes automated installs using anita impossible. I have reproduced this behavior on two different Linux systems: "gumbo" which runs Debian 9, and an Amazon EC2 t2.micro instance running Amazon Linux 2 (ami-0b898040803850657). This problem does not happen when running gxemul on NetBSD 8.0 or macOS 10.14.5. I have not tested other gxemul versions nor other guests with respect to this particular problem. gxemul-trunk.tar.gz was retrieved today and has a sha1 checksum 8bfd6c81e28b0cc182758fc8803490a0e3462af2. To reproduce the problem, run the following shell script on a Linux system. If the guest boots all the way to sysinst, exit gxemul (control-c quit enter) and run the script again; you may need a few tries, but sooner or later the console output will stop before sysinst starts. #!/bin/sh set -xe test -f gxemul-trunk.tar.gz || wget http://gavare.se/gxemul/src/gxemul-trunk.tar.gz test -f netbsd.gz || wget http://ftp.netbsd.org/pub/NetBSD/NetBSD-8.1/hpcmips/installation/netbsd.gz ls -al gxemul-trunk.tar.gz shasum gxemul-trunk.tar.gz || true test -f gxemul-trunk/gxemul || ( gunzip <gxemul-trunk.tar.gz | tar xfv - cd gxemul-trunk sh configure make -j4 ) test -f wd0.img || dd if=/dev/zero of=wd0.img bs=1024k count=1536 gxemul-trunk/gxemul -M 48 -d wd0.img -emobilepro880 netbsd.gz -- Andreas Gustafsson, gs...@gs... |
From: Andreas G. <gs...@gs...> - 2019-06-06 13:53:55
|
Anders Gavare wrote: > > Looks like the code has undefined behavior: init_bootpath is set to > > point to the local variable bootpath[], but by the time init_bootpath > > is used as the source in strlcpy(), bootpath[] has already gone out of > > scope. > > Horrible and embarrassing. :-| > > But interesting at the same time. It feels like the compiler took the > opportunity to optimize away the undefined code. Yes, that's what it looks like to me, too. > It would have been nice to > get a warning from the compiler though, something like "taking the address > to a temporary stack variable and using it after it has gone out of scope" > etc. Indeed. > Moving bootpath to the top of the function should work then: > https://pastebin.com/FXMKvCQC Yes, that works. -- Andreas Gustafsson, gs...@gs... |
From: Anders G. <ga...@gm...> - 2019-06-06 12:23:07
|
> Looks like the code has undefined behavior: init_bootpath is set to > point to the local variable bootpath[], but by the time init_bootpath > is used as the source in strlcpy(), bootpath[] has already gone out of > scope. Horrible and embarrassing. :-| But interesting at the same time. It feels like the compiler took the opportunity to optimize away the undefined code. It would have been nice to get a warning from the compiler though, something like "taking the address to a temporary stack variable and using it after it has gone out of scope" etc. Moving bootpath to the top of the function should work then: https://pastebin.com/FXMKvCQC Anders |
From: Andreas G. <gs...@gs...> - 2019-06-06 09:28:25
|
Anders Gavare wrote: > Can you add a printf statement next to that code and see what value > machine->bootdev_id has when you run your scenario? 0 or 1? I added this patch: --- machine_pmax.cc~ 2019-04-17 20:26:19.000000000 +0300 +++ machine_pmax.cc 2019-06-05 18:02:44.839025490 +0300 @@ -806,6 +806,8 @@ #endif strlcpy(bootpath, "5/rz1/", sizeof(bootpath)); + printf("** bootdev_id=%d force_netboot=%d\n", + machine->bootdev_id, machine->force_netboot); if (machine->bootdev_id < 0 || machine->force_netboot) { /* tftp boot: */ strlcpy(bootpath, "5/tftp/", sizeof(bootpath)); and it printed: ** bootdev_id=0 force_netboot=0 machine: DECstation 5000/200 (3MAX, KN02) (25.00 MHz) bootstring(+bootarg): boot 5/rz1/netbsd-INSTALL.gz -a Looks like the code has undefined behavior: init_bootpath is set to point to the local variable bootpath[], but by the time init_bootpath is used as the source in strlcpy(), bootpath[] has already gone out of scope. -- Andreas Gustafsson, gs...@gs... |
From: Anders G. <ga...@gm...> - 2019-06-06 09:01:04
|
The patch which was applied from http://cvsweb.netbsd.org/bsdweb.cgi/pkgsrc/emulators/gxemul/patches/patch-src_cpus_cpu_mips.cc?rev=1.1&content-type=text/x-cvsweb-markup&only_with_tag=MAIN ("implement trap with immediate instructions present in MIPS32.") for the MIPS TGEIU instruction recently is wrong; it decodes the trap instructions similar to BGEZALL etc. which are branches, not traps. The disassembly has now been fixed, and the instructions have been actually implemented too (but not that well tested in the Trapping case). This finally allows the NetBSD/evbmips installation instructions to be updated from 7.1.2 to 8.0, since 8.0 used one of those instructions during bootup. http://gavare.se/gxemul/gxemul-trunk/doc/machine_evbmips.html#netbsdevbmipsinstall Anders |
From: Anders G. <ga...@gm...> - 2019-06-05 07:21:19
|
> Comparing the two, I see the bootstring has changed from "boot 5/rz0/ -a" to "boot 5/rz1/ -a". Yes, that's strange. The two patches that I did not apply from NetBSD's pkgsrc were a) the NOFPU stuff, and b) the patch at http://cvsweb.netbsd.org/bsdweb.cgi/pkgsrc/emulators/gxemul/patches/patch-src_machines_machine__pmax.cc?rev=1.3&content-type=text/x-cvsweb-markup&only_with_tag=MAIN which essentially does this: - strlcpy(bootpath, "5/rz1/", sizeof(bootpath)); + strlcpy(bootpath, "5/rz0/", sizeof(bootpath)); However, the lines immediately below that in src/machines/machine_pmax.cc say: if (machine->bootdev_id < 0 || machine->force_netboot) { /* tftp boot: */ strlcpy(bootpath, "5/tftp/", sizeof(bootpath)); bootpath[0] = '0' + boot_net_boardnumber; } else { /* disk boot: */ bootpath[0] = '0' + boot_scsi_boardnumber; if (diskimage_is_a_tape(machine, machine->bootdev_id, machine->bootdev_type)) bootpath[2] = 't'; bootpath[4] = '0' + machine->bootdev_id; } so if you are not netbooting, it should overwrite bootpath[4] with the device ID of the boot device. I am confused as to what has happened. Can you add a printf statement next to that code and see what value machine->bootdev_id has when you run your scenario? 0 or 1? Anders |
From: Andreas G. <gs...@gs...> - 2019-06-05 06:45:05
|
Anders Gavare wrote: > Yes, the testmips failures are known issues -- I am removing everything > MIPS related from the "new" framework, concentrating on the old framework > where MIPS things actually work. Some unit tests remain to be rewritten to > use some other architecture for testing. I removed the "test" dependency from the "install" target in the Makefile, and "make install" then worked. > The important thing now is that a full install of NetBSD/hocmips can be > done and that you can run something meaningful non-trivial in it, such as > compile programs. I have now successfully done a full hpcmips install and ATF test run. The console log output from the tests is at: http://www.gson.org/netbsd/bugs/build/hpcmips/2019/2019.06.03.15.49.04/test.log There are some 181 failing test cases, and lots of "warning: LOW reference" and "pmap_tlb_update_addr(...) returned 0" messages, but that was already the case with 0.6.0.1. I also tested pmax, and it now fails to boot after the install as it tries to mount the wrong disk as the root. A console log from 0.6.0.1 is at http://www.gson.org/netbsd/bugs/build/pmax/2019/2019.05.02.00.34.06/test.log and from trunk: http://www.gson.org/netbsd/bugs/build/pmax/2019/2019.06.03.15.49.04/test.log Comparing the two, I see the bootstring has changed from "boot 5/rz0/ -a" to "boot 5/rz1/ -a". > As for the NetBSD patches, almost all of them were applied 20190417: see > http://gavare.se/gxemul/gxemul-trunk/HISTORY.html Great, thanks. -- Andreas Gustafsson, gs...@gs... |
From: Anders G. <ga...@gm...> - 2019-06-03 18:36:08
|
Yes, the testmips failures are known issues -- I am removing everything MIPS related from the "new" framework, concentrating on the old framework where MIPS things actually work. Some unit tests remain to be rewritten to use some other architecture for testing. The important thing now is that a full install of NetBSD/hocmips can be done and that you can run something meaningful non-trivial in it, such as compile programs. As for the NetBSD patches, almost all of them were applied 20190417: see http://gavare.se/gxemul/gxemul-trunk/HISTORY.html One which I did not apply due to lack of spare time for testing was the patch regarding which CPU models that lack an FPU. Anders Den mån 3 juni 2019 11:21Andreas Gustafsson <gs...@gs...> skrev: > Anders Gavare wrote: > > Andreas: Can you also try the latest > > http://gavare.se/gxemul/src/gxemul-trunk.tar.gz ? > > I tried building it without using pkgsrc, using "./configure" and > "make", and it built, but "make install" reports errors: > > ### Test_BackwardStepCommand_NotWhenSnapshotsAreDisabled > testmips is not a known template machine name. > Use gxemul -H to get a list of valid machine templates. > Failed to create configuration from template: testmips > Aborting. > > ### Test_BackwardStepCommand_NotWhenSnapshotsAreDisabled > (BackwardStepCommand.cc line 271) failed! > > root.step should initially be 3 > Expected: 0x3 > but was: 0 > ### Test_BackwardStepCommand_Basic > testmips is not a known template machine name. > Use gxemul -H to get a list of valid machine templates. > Failed to create configuration from template: testmips > Aborting. > > ### Test_BackwardStepCommand_Basic (BackwardStepCommand.cc line 272) > failed! > > root.step should initially be 3 > Expected: 0x3 > but was: 0 > ### Test_BackwardStepCommand_ManualAddAndLoad > > ### Test_BackwardStepCommand_ManualAddAndLoad (BackwardStepCommand.cc > line 273) failed! > > apa > [...] > > 3 TESTS FAILED! > *** Error code 1 > > Stop. > > The pkgsrc package has a number of patches, many of which no longer > apply to -trunk; I wonder if they have been or should be upstreamed. > -- > Andreas Gustafsson, gs...@gs... > |
From: Andreas G. <gs...@gs...> - 2019-06-03 09:21:38
|
Anders Gavare wrote: > Andreas: Can you also try the latest > http://gavare.se/gxemul/src/gxemul-trunk.tar.gz ? I tried building it without using pkgsrc, using "./configure" and "make", and it built, but "make install" reports errors: ### Test_BackwardStepCommand_NotWhenSnapshotsAreDisabled testmips is not a known template machine name. Use gxemul -H to get a list of valid machine templates. Failed to create configuration from template: testmips Aborting. ### Test_BackwardStepCommand_NotWhenSnapshotsAreDisabled (BackwardStepCommand.cc line 271) failed! > root.step should initially be 3 Expected: 0x3 but was: 0 ### Test_BackwardStepCommand_Basic testmips is not a known template machine name. Use gxemul -H to get a list of valid machine templates. Failed to create configuration from template: testmips Aborting. ### Test_BackwardStepCommand_Basic (BackwardStepCommand.cc line 272) failed! > root.step should initially be 3 Expected: 0x3 but was: 0 ### Test_BackwardStepCommand_ManualAddAndLoad ### Test_BackwardStepCommand_ManualAddAndLoad (BackwardStepCommand.cc line 273) failed! > apa [...] 3 TESTS FAILED! *** Error code 1 Stop. The pkgsrc package has a number of patches, many of which no longer apply to -trunk; I wonder if they have been or should be upstreamed. -- Andreas Gustafsson, gs...@gs... |
From: Anders G. <ga...@gm...> - 2019-06-03 05:33:40
|
Andreas: Can you also try the latest http://gavare.se/gxemul/src/gxemul-trunk.tar.gz ? I cleaned up the code a bit just above where the "if" hack was placed, and now it seems to work well with both HelenOS with non-4KB pages, and VR* CPUs with 1 KB pages, again. No need for the non-sensical "if" hack. Also, I updated http://gavare.se/gxemul/gxemul-trunk/doc/machine_hpcmips.html to NetBSD version 8.0, with comments about which modes work and which modes don't. Anders On Sat, Jun 1, 2019 at 5:06 PM Andreas Gustafsson <gs...@gs...> wrote: > Anders Gavare wrote: > > Andreas: Can you try changing the if statement in this block in > > src/cpus/cpu_mips_coproc.cc in 0.6.1: > [...] > > and see if that works as a short-term hack? I tried it here, and it > seemed > > to work. > > Yes, it works for me, too. > -- > Andreas Gustafsson, gs...@gs... > |
From: Anders G. <ga...@gm...> - 2019-06-01 20:05:54
|
> Ok, I think I found the problem in cpu_arm_instr_dpi.cc. I have changed the code to: > #if defined(A__SBC) || defined(A__RSC) > c64 = a - b - (cpu->cd.arm.flags & ARM_F_C? 0 : 1); > #endif > > Best regards, > Joergen Thanks Joergen, nice catch! The patch looks reasonable and has been applied. Included in the latest http://gavare.se/gxemul/src/gxemul-trunk.tar.gz Anders |
From: Andreas G. <gs...@gs...> - 2019-06-01 15:06:55
|
Anders Gavare wrote: > Andreas: Can you try changing the if statement in this block in > src/cpus/cpu_mips_coproc.cc in 0.6.1: [...] > and see if that works as a short-term hack? I tried it here, and it seemed > to work. Yes, it works for me, too. -- Andreas Gustafsson, gs...@gs... |
From: Anders G. <ga...@gm...> - 2019-06-01 12:18:20
|
Andreas: Can you try changing the if statement in this block in src/cpus/cpu_mips_coproc.cc in 0.6.1: ... /* * If we have a memblock (host page) for the physical page, * then add a translation for it immediately, to save some * time. (It would otherwise be added later on anyway, * because of a translation miss.) * * NOTE/TODO: This is only for 4KB pages so far. It would * be too expensive to add e.g. 16MB pages like * this. */ if (psize == 0x1000) { memblock = memory_paddr_to_hostaddr(cpu->mem, paddr0, 0); if (memblock != NULL && cp->reg[COP0_ENTRYLO0] & ENTRYLO_V) cpu->update_translation_table(cpu, vaddr0, memblock, wf0, paddr0); memblock = memory_paddr_to_hostaddr(cpu->mem, paddr1, 0); if (memblock != NULL && cp->reg[COP0_ENTRYLO1] & ENTRYLO_V) cpu->update_translation_table(cpu, vaddr1, memblock, wf1, paddr1); } to if (psize == 0x1000 && cpu->cd.mips.cpu_type.rev != MIPS_R4100) { and see if that works as a short-term hack? I tried it here, and it seemed to work. I have no idea why. I assumed that page size 1 KB would be problematic, not 4 KB. So perhaps this just hides the bug... Anders On Sat, Jun 1, 2019 at 11:03 AM Anders Gavare <ga...@gm...> wrote: > > Hi, > > GXemul 0.6.1 is having trouble installing NetBSD/hpcmips. > > More details here: > > http://gnats.netbsd.org/54252 > > Hi Andreas, > > I think I may have found the revision where this broke. > > ------------------------------------------------------------------------ > r5906 | debug | 2018-06-13 15:13:23 +0200 (Wed, 13 Jun 2018) | 1 line > > Fixing an old TODO for invalidating translation caches when using non-4KB > pages for MIPS. This makes HelenOS 0.7.1/malta boot further than before. > ------------------------------------------------------------------------ > > At least on my machine, installing NetBSD 8.0 and booting after install to > a working login as root worked fine up to revision 5905, but not with 5906 > and forward. > > (Except for the usual problem of /dev/ttyE0 not being enabled by default, > so login via serial console doesn't work "out of the box".) > > I will investigate that fix, and see if it can be done some other way. > > A wild guess as to the cause of the bug: The VR4121 has 1 KB pages which I > guess are buggy in GXemul. I don't know how much of that NetBSD uses in > practice, perhaps it mostly uses 4 KB pages. > > Also, this is a good opportunity to clean up the GXemul documentation and > create up-to-date regression testing scripts for hpcmips; many of the modes > (MobilePro 770, 800, and 880) seem to have bit-rotted over time when > booting NetBSD with -X. Most likely due to incompleteness of emulation. > These modes only seem to work with serial console these days. Luckily, > MobilePro 780 emulation still works with both serial and graphical console. > :-) > > > Anders > > |
From: Anders G. <ga...@gm...> - 2019-06-01 09:03:25
|
> Hi, > GXemul 0.6.1 is having trouble installing NetBSD/hpcmips. > More details here: > http://gnats.netbsd.org/54252 Hi Andreas, I think I may have found the revision where this broke. ------------------------------------------------------------------------ r5906 | debug | 2018-06-13 15:13:23 +0200 (Wed, 13 Jun 2018) | 1 line Fixing an old TODO for invalidating translation caches when using non-4KB pages for MIPS. This makes HelenOS 0.7.1/malta boot further than before. ------------------------------------------------------------------------ At least on my machine, installing NetBSD 8.0 and booting after install to a working login as root worked fine up to revision 5905, but not with 5906 and forward. (Except for the usual problem of /dev/ttyE0 not being enabled by default, so login via serial console doesn't work "out of the box".) I will investigate that fix, and see if it can be done some other way. A wild guess as to the cause of the bug: The VR4121 has 1 KB pages which I guess are buggy in GXemul. I don't know how much of that NetBSD uses in practice, perhaps it mostly uses 4 KB pages. Also, this is a good opportunity to clean up the GXemul documentation and create up-to-date regression testing scripts for hpcmips; many of the modes (MobilePro 770, 800, and 880) seem to have bit-rotted over time when booting NetBSD with -X. Most likely due to incompleteness of emulation. These modes only seem to work with serial console these days. Luckily, MobilePro 780 emulation still works with both serial and graphical console. :-) Anders |
From: Andreas G. <gs...@gs...> - 2019-05-31 11:57:30
|
Hi, GXemul 0.6.1 is having trouble installing NetBSD/hpcmips. More details here: http://gnats.netbsd.org/54252 -- Andreas Gustafsson, gs...@gs... |
From: Nilsson J. (ETAS-SEC/ENG-IDS) <Joe...@se...> - 2019-03-21 13:39:06
|
Ok, I think I found the problem in cpu_arm_instr_dpi.cc. I have changed the code to: #if defined(A__SBC) || defined(A__RSC) c64 = a - b - (cpu->cd.arm.flags & ARM_F_C? 0 : 1); #endif Best regards, Joergen From: Nilsson Joergen (ETAS-SEC/ENG-IDS) Sent: den 21 mars 2019 10:54 To: 'gxe...@li...' <gxe...@li...> Subject: ARM SBC instruction emulation does not set CPSR oVerflow bit Hello gxemul developers, I have recently come across an anomaly in the emulation of the ARM SBC instruction. The case is as below. GXEMUL VERSION: 0.6.1 ENVIRONMENT: Debian COMMAND: gxemul -E 'testarm' mysimpleapp CODE: #include <inttypes.h> int main(void) { int ret = 0; int64_t min_signed = INT64_MIN; int64_t max_signed = INT64_MAX; if (max_signed > min_signed) { ret = 0; } else { ret = -1; } return ret; } COMPILER: gcc-arm-non-eabi RESULT: Main returned nonzero! DEBUG INFO (BEFORE): 0001023c: e0d23004 sbcs r3,r2,r4 BREAKPOINT: pc = 0x1023c (The instruction has not yet executed.) GXemul> reg cpu0: cpsr = nzcvqjeaIFt pc = 0x0001023c <main+0x68> cpu0: r0 = 0x00000000 r1 = 0x00000000 r2 = 0x80000000 r3 = 0xfffffffe cpu0: r4 = 0x7fffffff r5 = 0x00000000 r6 = 0x00000000 r7 = 0x00000000 cpu0: r8 = 0x00000000 r9 = 0x00000000 sl = 0x00000000 fp = 0x0001c9cc cpu0: ip = 0x00000000 sp = 0x0001c9a0 lr = 0x00010028 cpu0: cpsr = 0x000000d3 (SVC32) DEBUG INFO (AFTER): GXemul> step 0001023c: e0d23004 sbcs r3,r2,r4 GXemul> reg cpu0: cpsr = nZCvqjeaIFt pc = 0x00010240 <main+0x6c> cpu0: r0 = 0x00000000 r1 = 0x00000000 r2 = 0x80000000 r3 = 0x00000000 cpu0: r4 = 0x7fffffff r5 = 0x00000000 r6 = 0x00000000 r7 = 0x00000000 cpu0: r8 = 0x00000000 r9 = 0x00000000 sl = 0x00000000 fp = 0x0001c9cc cpu0: ip = 0x00000000 sp = 0x0001c9a0 lr = 0x00010028 cpu0: cpsr = 0x600000d3 (SVC32) The expected is that the oVerflow bit of the CPSR is set, i.e. that CPSR is 0x700000d3. Could anyone guide me as how to resolve this problem in the correct manner? I guess there is an update of the cpu_arm_instr_dpi.cc needed. Best regards, Joergen |