SCSI, build system patches for 2022-07-13
Subsystems (3)
The following changes since commit 8e3d85d36b77f11ad7bded3a2d48c1f0cc334f82:
Merge tag 'for-upstream' of https://gitlab.com/bonzini/qemu into staging (2022-07-12 14:12:15 +0100)
are available in the Git repository at:
https://gitlab.com/bonzini/qemu.git tags/for-upstream
for you to fetch changes up to c0b3607d5938f5ee7fd16ff1e102afe938fd4b39:
pc-bios/s390-ccw: add -Wno-array-bounds (2022-07-13 16:58:58 +0200)
----------------------------------------------------------------
* SCSI fuzzing fix (Mauro)
* pre-install data files in the build directory (Akihiko)
* SCSI fixes for Mac OS (Mark)
----------------------------------------------------------------
Akihiko Odaki (4):
cutils: Introduce bundle mechanism
datadir: Use bundle mechanism
module: Use bundle mechanism
meson: Prefix each element of firmware path
Mark Cave-Ayland (14):
scsi-disk: add new quirks bitmap to SCSIDiskState
scsi-disk: add MODE_PAGE_APPLE_VENDOR quirk for Macintosh
q800: implement compat_props to enable quirk_mode_page_apple_vendor for scsi-cd devices
scsi-disk: add SCSI_DISK_QUIRK_MODE_SENSE_ROM_USE_DBD quirk for Macintosh
q800: implement compat_props to enable quirk_mode_sense_rom_use_dbd for scsi-cd devices
scsi-disk: add SCSI_DISK_QUIRK_MODE_PAGE_VENDOR_SPECIFIC_APPLE quirk for Macintosh
q800: implement compat_props to enable quirk_mode_page_vendor_specific_apple for scsi devices
scsi-disk: add FORMAT UNIT command
scsi-disk: add SCSI_DISK_QUIRK_MODE_PAGE_TRUNCATED quirk for Macintosh
q800: implement compat_props to enable quirk_mode_page_truncated for scsi-cd devices
scsi-disk: allow the MODE_PAGE_R_W_ERROR AWRE bit to be changeable for CDROM drives
scsi-disk: allow MODE SELECT block descriptor to set the block size
q800: add default vendor and product information for scsi-hd devices
q800: add default vendor and product information for scsi-cd devices
Mauro Matteo Cascella (1):
scsi/lsi53c895a: really fix use-after-free in lsi_do_msgout (CVE-2022-0216)
Paolo Bonzini (1):
pc-bios/s390-ccw: add -Wno-array-bounds
.travis.yml | 2 +- Makefile | 2 +- configure | 15 ++++++ docs/about/build-platforms.rst | 2 +- hw/m68k/q800.c | 16 +++++++ hw/scsi/lsi53c895a.c | 3 +- hw/scsi/scsi-disk.c | 96 +++++++++++++++++++++++++++++++++++--- hw/scsi/trace-events | 3 ++ include/hw/scsi/scsi.h | 6 +++ include/qemu/cutils.h | 18 +++++-- include/scsi/constants.h | 2 + meson.build | 15 +++++- meson_options.txt | 2 +- pc-bios/keymaps/meson.build | 21 +++------ pc-bios/meson.build | 13 ++---- pc-bios/s390-ccw/Makefile | 1 + scripts/meson-buildoptions.py | 7 ++- scripts/meson-buildoptions.sh | 4 +- scripts/oss-fuzz/build.sh | 8 ++-- scripts/symlink-install-tree.py | 33 +++++++++++++ softmmu/datadir.c | 30 +++--------- tests/qtest/fuzz-lsi53c895a-test.c | 76 ++++++++++++++++++++++++++++++ tests/qtest/fuzz/fuzz.c | 18 ------- util/cutils.c | 66 ++++++++++++++++++-------- util/meson.build | 1 + util/module.c | 1 - 26 files changed, 348 insertions(+), 113 deletions(-) create mode 100644 scripts/symlink-install-tree.py
Signature · 1 line
2.36.1
[PULL 05/20] meson: Prefix each element of firmware path
From: Akihiko Odaki <[email protected]>
Message-Id: <[email protected]>
--- configure | 15 +++++++++++++++ meson.build | 11 +++++++++-- meson_options.txt | 2 +- scripts/meson-buildoptions.py | 7 +++++-- scripts/meson-buildoptions.sh | 4 ++-- softmmu/datadir.c | 8 +++++--- 6 files changed, 37 insertions(+), 10 deletions(-)
configure +15 -0
@@ -676,6 +676,21 @@ fi werror="" +meson_option_build_array() { + printf '[' + (if test "$targetos" == windows; then + IFS=\; + else + IFS=: + fi + for e in $1; do + e=${e/'\'/'\\'} + e=${e/\"/'\"'} + printf '"""%s""",' "$e" + done) + printf ']\n' +} + . $source_path/scripts/meson-buildoptions.sh meson_options=
meson.build +9 -2
@@ -1718,7 +1718,13 @@ config_host_data.set_quoted('CONFIG_PREFIX', get_option('prefix')) config_host_data.set_quoted('CONFIG_QEMU_CONFDIR', get_option('prefix') / qemu_confdir) config_host_data.set_quoted('CONFIG_QEMU_DATADIR', get_option('prefix') / qemu_datadir) config_host_data.set_quoted('CONFIG_QEMU_DESKTOPDIR', get_option('prefix') / qemu_desktopdir) -config_host_data.set_quoted('CONFIG_QEMU_FIRMWAREPATH', get_option('prefix') / get_option('qemu_firmwarepath')) + +qemu_firmwarepath = '' +foreach k : get_option('qemu_firmwarepath') + qemu_firmwarepath += '"' + get_option('prefix') / k + '", ' +endforeach +config_host_data.set('CONFIG_QEMU_FIRMWAREPATH', qemu_firmwarepath) + config_host_data.set_quoted('CONFIG_QEMU_HELPERDIR', get_option('prefix') / get_option('libexecdir')) config_host_data.set_quoted('CONFIG_QEMU_ICONDIR', get_option('prefix') / qemu_icondir) config_host_data.set_quoted('CONFIG_QEMU_LOCALEDIR', get_option('prefix') / get_option('localedir'))
@@ -3683,7 +3689,8 @@ endif summary_info = {} summary_info += {'Install prefix': get_option('prefix')} summary_info += {'BIOS directory': qemu_datadir} -summary_info += {'firmware path': get_option('prefix') / get_option('qemu_firmwarepath')} +pathsep = targetos == 'windows' ? ';' : ':' +summary_info += {'firmware path': pathsep.join(get_option('qemu_firmwarepath'))} summary_info += {'binary directory': get_option('prefix') / get_option('bindir')} summary_info += {'library directory': get_option('prefix') / get_option('libdir')} summary_info += {'module directory': qemu_moddir}
meson_options.txt +1 -1
@@ -6,7 +6,7 @@ option('qemu_suffix', type : 'string', value: 'qemu', description: 'Suffix for QEMU data/modules/config directories (can be empty)') option('docdir', type : 'string', value : 'share/doc', description: 'Base directory for documentation installation (can be empty)') -option('qemu_firmwarepath', type : 'string', value : 'share/qemu-firmware', +option('qemu_firmwarepath', type : 'array', value : ['share/qemu-firmware'], description: 'search PATH for firmware files') option('pkgversion', type : 'string', value : '', description: 'use specified string as sub-version of the package')
scripts/meson-buildoptions.py +5 -2
@@ -156,7 +156,7 @@ def cli_metavar(opt): if opt["type"] == "string": return "VALUE" if opt["type"] == "array": - return "CHOICES" + return "CHOICES" if "choices" in opt else "VALUES" return "CHOICE"
@@ -199,7 +199,10 @@ def print_parse(options): key = cli_option(opt) name = opt["name"] if require_arg(opt): - print(f' --{key}=*) quote_sh "-D{name}=$2" ;;') + if opt["type"] == "array" and not "choices" in opt: + print(f' --{key}=*) quote_sh "-D{name}=$(meson_option_build_array $2)" ;;') + else: + print(f' --{key}=*) quote_sh "-D{name}=$2" ;;') elif opt["type"] == "boolean": print(f' --enable-{key}) printf "%s" -D{name}=true ;;') print(f' --disable-{key}) printf "%s" -D{name}=false ;;')
scripts/meson-buildoptions.sh +2 -2
@@ -42,7 +42,7 @@ meson_options_help() { printf "%s\n" ' --enable-trace-backends=CHOICES' printf "%s\n" ' Set available tracing backends [log] (choices:' printf "%s\n" ' dtrace/ftrace/log/nop/simple/syslog/ust)' - printf "%s\n" ' --firmwarepath=VALUE search PATH for firmware files [share/qemu-firmware]' + printf "%s\n" ' --firmwarepath=VALUES search PATH for firmware files [share/qemu-firmware]' printf "%s\n" ' --iasl=VALUE Path to ACPI disassembler' printf "%s\n" ' --includedir=VALUE Header file directory [include]' printf "%s\n" ' --interp-prefix=VALUE where to find shared libraries etc., use %M for'
@@ -363,7 +363,7 @@ _meson_option_parse() { --disable-qcow1) printf "%s" -Dqcow1=disabled ;; --enable-qed) printf "%s" -Dqed=enabled ;; --disable-qed) printf "%s" -Dqed=disabled ;; - --firmwarepath=*) quote_sh "-Dqemu_firmwarepath=$2" ;; + --firmwarepath=*) quote_sh "-Dqemu_firmwarepath=$(meson_option_build_array $2)" ;; --enable-qga-vss) printf "%s" -Dqga_vss=enabled ;; --disable-qga-vss) printf "%s" -Dqga_vss=disabled ;; --enable-qom-cast-debug) printf "%s" -Dqom_cast_debug=true ;;
softmmu/datadir.c +5 -3
@@ -85,15 +85,17 @@ void qemu_add_data_dir(char *path)void qemu_add_default_firmwarepath (void ) { -char **dirs; +static const char *const dirs[] = { +CONFIG_QEMU_FIRMWAREPATH + NULL + }; +size_t i;/* add configured firmware directories */ - dirs =g_strsplit (CONFIG_QEMU_FIRMWAREPATH ,G_SEARCHPATH_SEPARATOR_S ,0 );for (i =0 ; dirs[i] !=NULL ; i++) {qemu_add_data_dir (get_relocated_path (dirs[i])); } -g_strfreev (dirs);/* try to find datadir relative to the executable path */ qemu_add_data_dir (get_relocated_path (CONFIG_QEMU_DATADIR ));
Signature · 1 line
2.36.1
Re: [PULL 05/20] meson: Prefix each element of firmware path
Quoted 27 lines · Paolo Bonzini
From: Akihiko Odaki <[email protected]>
Signed-off-by Akihiko Odaki <[email protected]>Message-Id: <[email protected]>
[Rewrite shell function without using Bash extensions. - Paolo]Signed-off-by Paolo Bonzini <[email protected]>--- configure | 15 +++++++++++++++ meson.build | 11 +++++++++-- meson_options.txt | 2 +- scripts/meson-buildoptions.py | 7 +++++-- scripts/meson-buildoptions.sh | 4 ++-- softmmu/datadir.c | 8 +++++--- 6 files changed, 37 insertions(+), 10 deletions(-)configure +4
-0@@ -676,6 +676,21 @@ fi werror="" +meson_option_build_array() { + printf '[' + (if test "$targetos" == windows; then + IFS=\;
configure fi · line 692
Quoted 10 lines
configure +10
-0+ else + IFS=: + fi + for e in $1; do + e=${e/'\'/'\\'} + e=${e/\"/'\"'} + printf '"""%s""",' "$e" + done) + printf ']\n' +}
Hi!
This seems to break the NetBSD VM builds:
$ make vm-build-netbsd J=4 TARGET_LIST=x86_64-softmmu
GIT ui/keycodemapdb meson tests/fp/berkeley-testfloat-3
tests/fp/berkeley-softfloat-3 dtc slirp roms/SLOF
VM-BUILD netbsd
../src/configure: 687: Syntax error: Bad substitutionCould you please have a look?
Thanks,
Thomas
[PULL 01/20] scsi/lsi53c895a: really fix use-after-free in lsi_do_msgout (CVE-2022-0216)
In reply to Paolo BonziniFrom: Mauro Matteo Cascella <[email protected]>
Set current_req to NULL, not current_req->req, to prevent reusing a free'd buffer in case of repeated SCSI cancel requests. Also apply the fix to CLEAR QUEUE and BUS DEVICE RESET messages as well, since they also cancel the request.
Thanks to Alexander Bulekov for providing a reproducer.
Fixes: CVE-2022-0216
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/972
Message-Id: <[email protected]>
--- hw/scsi/lsi53c895a.c | 3 +- tests/qtest/fuzz-lsi53c895a-test.c | 76 ++++++++++++++++++++++++++++++ 2 files changed, 78 insertions(+), 1 deletion(-)
hw/scsi/lsi53c895a.c +2 -1
@@ -1030,7 +1030,7 @@ static void lsi_do_msgout(LSIState *s)trace_lsi_do_msgout_abort (current_tag);if (current_req && current_req->req) {scsi_req_cancel (current_req->req); - current_req->req =NULL ; + current_req =NULL ; }lsi_disconnect (s);break ;
@@ -1056,6 +1056,7 @@ static void lsi_do_msgout(LSIState *s)/* clear the current I/O process */ if (s->current) {scsi_req_cancel (s->current->req); + current_req =NULL ; }/* As the current implemented devices scsi_disk and scsi_generic
tests/qtest/fuzz-lsi53c895a-test.c +76 -0
87 lines not on this page · raw message
Signature · 1 line
2.36.1
[PULL 03/20] datadir: Use bundle mechanism
In reply to Paolo BonziniFrom: Akihiko Odaki <[email protected]>
softmmu/datadir.c had its own implementation to find files in the build tree, but now bundle mechanism provides the unified implementation which works for datadir and the other files.
Message-Id: <[email protected]>
--- .travis.yml | 2 +- pc-bios/keymaps/meson.build | 21 ++++++--------------- pc-bios/meson.build | 13 +++---------- scripts/oss-fuzz/build.sh | 8 ++++---- softmmu/datadir.c | 22 +--------------------- tests/qtest/fuzz/fuzz.c | 18 ------------------ 6 files changed, 15 insertions(+), 69 deletions(-)
.travis.yml +1 -1
@@ -223,7 +223,7 @@ jobs: - BUILD_RC=0 && make -j${JOBS} || BUILD_RC=$? - | if [ "$BUILD_RC" -eq 0 ] ; then - mv pc-bios/s390-ccw/*.img pc-bios/ ; + mv pc-bios/s390-ccw/*.img qemu-bundle/usr/local/share/qemu ; ${TEST_CMD} ; else $(exit $BUILD_RC);
pc-bios/keymaps/meson.build +6 -15
@@ -40,9 +40,9 @@ else endif cp = find_program('cp') -t = [] -foreach km, args: keymaps - if native_qemu_keymap.found() +if native_qemu_keymap.found() + t = [] + foreach km, args: keymaps # generate with qemu-kvm t += custom_target(km, build_by_default: true,
@@ -50,20 +50,11 @@ foreach km, args: keymaps command: [native_qemu_keymap, '-f', '@OUTPUT@', args.split()], install: true, install_dir: qemu_datadir / 'keymaps') - else - # copy from source tree - t += custom_target(km, - build_by_default: true, - input: km, - output: km, - command: [cp, '@INPUT@', '@OUTPUT@'], - install: true, - install_dir: qemu_datadir / 'keymaps') - endif -endforeach + endforeach -if native_qemu_keymap.found() alias_target('update-keymaps', t) +else + install_data(keymaps.keys(), install_dir: qemu_datadir / 'keymaps') endif install_data(['sl', 'sv'], install_dir: qemu_datadir / 'keymaps')
pc-bios/meson.build +3 -10
@@ -85,16 +85,9 @@ blobs = [ 'vof-nvram.bin', ] -ln_s = [find_program('ln', required: true), '-sf'] -foreach f : blobs - roms += custom_target(f, - build_by_default: have_system, - output: f, - input: files('meson.build'), # dummy input - install: get_option('install_blobs'), - install_dir: qemu_datadir, - command: [ ln_s, meson.project_source_root() / 'pc-bios' / f, '@OUTPUT@' ]) -endforeach +if get_option('install_blobs') + install_data(blobs, install_dir: qemu_datadir) +endif subdir('descriptors') subdir('keymaps')
scripts/oss-fuzz/build.sh +4 -4
@@ -64,7 +64,7 @@ mkdir -p "$DEST_DIR/lib/" # Copy the shared libraries here # Build once to get the list of dynamic lib paths, and copy them over ../configure --disable-werror --cc="$CC" --cxx="$CXX" --enable-fuzzing \ - --prefix="$DEST_DIR" --bindir="$DEST_DIR" --datadir="$DEST_DIR/data/" \ + --prefix="/opt/qemu-oss-fuzz" \ --extra-cflags="$EXTRA_CFLAGS" --target-list="i386-softmmu" if ! make "-j$(nproc)" qemu-fuzz-i386; then
@@ -81,14 +81,14 @@ if [ "$GITLAB_CI" != "true" ]; then # Build a second time to build the final binary with correct rpath ../configure --disable-werror --cc="$CC" --cxx="$CXX" --enable-fuzzing \ - --prefix="$DEST_DIR" --bindir="$DEST_DIR" --datadir="$DEST_DIR/data/" \ + --prefix="/opt/qemu-oss-fuzz" \ --extra-cflags="$EXTRA_CFLAGS" --extra-ldflags="-Wl,-rpath,\$ORIGIN/lib" \ --target-list="i386-softmmu" make "-j$(nproc)" qemu-fuzz-i386 V=1 fi -# Copy over the datadir -cp -r ../pc-bios/ "$DEST_DIR/pc-bios" +# Prepare a preinstalled tree +make install DESTDIR=$DEST_DIR/qemu-bundle targets=$(./qemu-fuzz-i386 | awk '$1 ~ /\*/ {print $2}') base_copy="$DEST_DIR/qemu-fuzz-i386-target-$(echo "$targets" | head -n 1)"
softmmu/datadir.c +1 -21
@@ -83,26 +83,6 @@ void qemu_add_data_dir(char *path) data_dir[data_dir_idx++] = path; } -/* -* Find a likely location for support files using the location of the binary. -* When running from the build tree this will be "$bindir/pc-bios". -* Otherwise, this is CONFIG_QEMU_DATADIR (possibly relocated). -* -* The caller must use g_free() to free the returned data when it is -* no longer required. -*/ -static char *find_datadir (void ) -{ - g_autofree char *dir = NULL; - - dir =g_build_filename (qemu_get_exec_dir (),"pc-bios" ,NULL ); -if (g_file_test (dir,G_FILE_TEST_IS_DIR )) { -return g_steal_pointer (&dir); - } - -return get_relocated_path (CONFIG_QEMU_DATADIR ); -} -void qemu_add_default_firmwarepath (void ) {char **dirs;
@@ -116,7 +96,7 @@ void qemu_add_default_firmwarepath(void)g_strfreev (dirs);/* try to find datadir relative to the executable path */ -qemu_add_data_dir (find_datadir ()); +qemu_add_data_dir (get_relocated_path (CONFIG_QEMU_DATADIR )); }void qemu_list_data_dirs (void )
tests/qtest/fuzz/fuzz.c +0 -18
@@ -158,8 +158,6 @@ int LLVMFuzzerInitialize(int *argc, char ***argv, char ***envp) {char *target_name; -const char *bindir; -char *datadir;GString *cmd_line;gchar *pretty_cmd_line;bool serialize = false;
@@ -174,22 +172,6 @@ int LLVMFuzzerInitialize(int *argc, char ***argv, char ***envp) target_name =strstr (**argv,"-target-" );if (target_name) {/* The binary name specifies the target */ target_name +=strlen ("-target-" ); -/* -* With oss-fuzz, the executable is kept in the root of a directory (we -* cannot assume the path). All data (including bios binaries) must be -* in the same dir, or a subdir. Thus, we cannot place the pc-bios so -* that it would be in exec_dir/../pc-bios. -* As a workaround, oss-fuzz allows us to use argv[0] to get the -* location of the executable. Using this we add exec_dir/pc-bios to -* the datadirs. -*/ - bindir =qemu_get_exec_dir (); - datadir =g_build_filename (bindir,"pc-bios" ,NULL ); -if (g_file_test (datadir,G_FILE_TEST_IS_DIR )) { -qemu_add_data_dir (datadir); - }else { -g_free (datadir); - } }else if (*argc >1 ) {/* The target is specified as an argument */ target_name = (*argv)[1 ];if (!strstr (target_name,"--fuzz-target=" )) {
Signature · 1 line
2.36.1
[PULL 02/20] cutils: Introduce bundle mechanism
In reply to Paolo BonziniFrom: Akihiko Odaki <[email protected]>
Developers often run QEMU without installing. The bundle mechanism allows to look up files which should be present in installation even in such a situation.
It is a general mechanism and can find any files in the installation tree. The build tree will have a new directory, qemu-bundle, to represent what files the installation tree would have for reference by the executables.
Note that it abandons compatibility with Windows older than 8. The extended support for the prior version, 7 ended more than 2 years ago, and it is unlikely that someone would like to run the latest QEMU on such an old system.
Message-Id: <[email protected]>
--- Makefile | 2 +- docs/about/build-platforms.rst | 2 +- include/qemu/cutils.h | 18 +++++++-- meson.build | 4 ++ scripts/symlink-install-tree.py | 33 +++++++++++++++++ util/cutils.c | 66 +++++++++++++++++++++++---------- util/meson.build | 1 + 7 files changed, 101 insertions(+), 25 deletions(-) create mode 100644 scripts/symlink-install-tree.py
Makefile +1 -1
@@ -216,7 +216,7 @@ qemu-%.tar.bz2: distclean: clean -$(quiet-@)test -f build.ninja && $(NINJA) $(NINJAFLAGS) -t clean -g || : - rm -f config-host.mak + rm -f config-host.mak qemu-bundle rm -f tests/tcg/config-*.mak rm -f config.status rm -f roms/seabios/config.mak
docs/about/build-platforms.rst +1 -1
@@ -88,7 +88,7 @@ Windows The project aims to support the two most recent versions of Windows that are still supported by the vendor. The minimum Windows API that is currently -targeted is "Windows 7", so theoretically the QEMU binaries can still be run +targeted is "Windows 8", so theoretically the QEMU binaries can still be run on older versions of Windows, too. However, such old versions of Windows are not tested anymore, so it is recommended to use one of the latest versions of Windows instead.
include/qemu/cutils.h +15 -3
@@ -224,9 +224,21 @@ const char *qemu_get_exec_dir(void);* @dir: the directory (typically a `CONFIG_*DIR` variable) to be relocated. * * Returns a path for @dir that uses the directory of the running executable -* as the prefix. For example, if `bindir` is `/usr/bin` and @dir is -* `/usr/share/qemu`, the function will append `../share/qemu` to the -* directory that contains the running executable and return the result. +* as the prefix. +* +* When a directory named `qemu-bundle` exists in the directory of the running +* executable, the path to the directory will be prepended to @dir. For +* example, if the directory of the running executable is `/qemu/build` @dir +* is `/usr/share/qemu`, the result will be +* `/qemu/build/qemu-bundle/usr/share/qemu`. The directory is expected to exist +* in the build tree. +* +* Otherwise, the directory of the running executable will be used as the +* prefix and it appends the relative path from `bindir` to @dir. For example, +* if the directory of the running executable is `/opt/qemu/bin`, `bindir` is +* `/usr/bin` and @dir is `/usr/share/qemu`, the result will be +* `/opt/qemu/bin/../share/qemu`. +* * The returned string should be freed by the caller. */ char *get_relocated_path (const char *dir);
meson.build +4 -0
@@ -7,6 +7,8 @@ add_test_setup('quick', exclude_suites: ['slow', 'thorough'], is_default: true) add_test_setup('slow', exclude_suites: ['thorough'], env: ['G_TEST_SLOW=1', 'SPEED=slow']) add_test_setup('thorough', env: ['G_TEST_SLOW=1', 'SPEED=thorough']) +meson.add_postconf_script(find_program('scripts/symlink-install-tree.py')) + not_found = dependency('', required: false) keyval = import('keyval') ss = import('sourceset')
@@ -356,10 +358,12 @@ nvmm =not_found hvf = not_found midl = not_found widl = not_found +pathcch = not_found host_dsosuf = '.so' if targetos == 'windows' midl = find_program('midl', required: false) widl = find_program('widl', required: false) + pathcch = cc.find_library('pathcch') socket = cc.find_library('ws2_32') winmm = cc.find_library('winmm')
scripts/symlink-install-tree.py new file +33 -0
@@ -0,0 +1,33 @@ +#!/usr/bin/env python3 + +from pathlib import PurePath +import errno +import json +import os +import subprocess +import sys + +def destdir_join(d1: str, d2: str) -> str: + if not d1: + return d2 + # c:\destdir + c:\prefix must produce c:\destdir\prefix + return str(PurePath(d1, *PurePath(d2).parts[1:])) + +introspect = os.environ.get('MESONINTROSPECT') +out = subprocess.run([*introspect.split(' '), '--installed'], + stdout=subprocess.PIPE, check=True).stdout +for source, dest in json.loads(out).items(): + assert os.path.isabs(source) + bundle_dest = destdir_join('qemu-bundle', dest) + path = os.path.dirname(bundle_dest) + try: + os.makedirs(path, exist_ok=True) + except BaseException as e: + print(f'error making directory {path}', file=sys.stderr) + raise e + try: + os.symlink(source, bundle_dest) + except BaseException as e: + if not isinstance(e, OSError) or e.errno != errno.EEXIST: + print(f'error making symbolic link {dest}', file=sys.stderr) + raise e
util/cutils.c +46 -20
83 lines not on this page · raw message
util/meson.build +1 -0
@@ -23,6 +23,7 @@ util_ss.add(when: 'CONFIG_WIN32', if_true: files('event_notifier-win32.c')) util_ss.add(when: 'CONFIG_WIN32', if_true: files('oslib-win32.c')) util_ss.add(when: 'CONFIG_WIN32', if_true: files('qemu-thread-win32.c')) util_ss.add(when: 'CONFIG_WIN32', if_true: winmm) +util_ss.add(when: 'CONFIG_WIN32', if_true: pathcch) util_ss.add(files('envlist.c', 'path.c', 'module.c')) util_ss.add(files('host-utils.c')) util_ss.add(files('bitmap.c', 'bitops.c'))
Signature · 1 line
2.36.1
[PULL 11/20] scsi-disk: add SCSI_DISK_QUIRK_MODE_PAGE_VENDOR_SPECIFIC_APPLE quirk for Macintosh
In reply to Paolo BonziniFrom: Mark Cave-Ayland <[email protected]>
Both MacOS and A/UX make use of vendor-specific MODE SELECT commands with PF=0 to identify SCSI devices:
- MacOS sends a MODE SELECT command with PF=0 for the MODE_PAGE_VENDOR_SPECIFIC (0x0) mode page containing 2 bytes before initialising a disk
- A/UX (installed on disk) sends a MODE SELECT command with PF=0 during SCSI bus enumeration, and gets stuck in an infinite loop if it fails
Add a new SCSI_DISK_QUIRK_MODE_PAGE_VENDOR_SPECIFIC_APPLE quirk to allow both PF=0 MODE SELECT commands and implement a MODE_PAGE_VENDOR_SPECIFIC (0x0) mode page which is compatible with MacOS.
Message-Id: <[email protected]>
--- hw/scsi/scsi-disk.c | 30 ++++++++++++++++++++++++++++-- include/hw/scsi/scsi.h | 1 + include/scsi/constants.h | 1 + 3 files changed, 30 insertions(+), 2 deletions(-)
hw/scsi/scsi-disk.c +28 -2
@@ -1079,6 +1079,7 @@ static int mode_sense_page(SCSIDiskState *s, int page, uint8_t **p_outbuf, int page_control) {static const int mode_sense_valid[0x3f ] = { + [MODE_PAGE_VENDOR_SPECIFIC ] = (1 <<TYPE_DISK ) | (1 <<TYPE_ROM ), [MODE_PAGE_HD_GEOMETRY ] = (1 <<TYPE_DISK ), [MODE_PAGE_FLEXIBLE_DISK_GEOMETRY ] = (1 <<TYPE_DISK ), [MODE_PAGE_CACHING ] = (1 <<TYPE_DISK ) | (1 <<TYPE_ROM ),
@@ -1244,6 +1245,22 @@ static int mode_sense_page(SCSIDiskState *s, int page, uint8_t **p_outbuf,return -1 ; } +case MODE_PAGE_VENDOR_SPECIFIC : +if (s->qdev.type ==TYPE_DISK && (s->quirks & + (1 <<SCSI_DISK_QUIRK_MODE_PAGE_VENDOR_SPECIFIC_APPLE ))) { + length =0x2 ; +if (page_control ==1 ) {/* Changeable Values */ + p[0 ] =0xff ; + p[1 ] =0xff ; +break ; + } + p[0 ] =0 ; + p[1 ] =0 ; +break ; + }else { +return -1 ; + } +default :return -1 ; }
@@ -1570,9 +1587,12 @@ static void scsi_disk_emulate_mode_select(SCSIDiskReq *r, uint8_t *inbuf)int bd_len;int pass; -/* We only support PF=1, SP=0. */ if ((r->req.cmd.buf[1 ] &0x11 ) !=0x10 ) { - goto invalid_field; +if (!(s->quirks & + (1 <<SCSI_DISK_QUIRK_MODE_PAGE_VENDOR_SPECIFIC_APPLE ))) { +/* We only support PF=1, SP=0. */ + goto invalid_field; + } }if (len < hdr_len) {
@@ -3069,6 +3089,9 @@ static Property scsi_hd_properties[] = {DEFINE_PROP_UINT16 ("rotation_rate" , SCSIDiskState, rotation_rate,0 ),DEFINE_PROP_INT32 ("scsi_version" , SCSIDiskState, qdev.default_scsi_version,5 ), +DEFINE_PROP_BIT ("quirk_mode_page_vendor_specific_apple" , SCSIDiskState, + quirks,SCSI_DISK_QUIRK_MODE_PAGE_VENDOR_SPECIFIC_APPLE , +0 ),DEFINE_BLOCK_CHS_PROPERTIES (SCSIDiskState, qdev.conf), DEFINE_PROP_END_OF_LIST(), };
@@ -3121,6 +3144,9 @@ static Property scsi_cd_properties[] = { SCSI_DISK_QUIRK_MODE_PAGE_APPLE_VENDOR, 0),DEFINE_PROP_BIT ("quirk_mode_sense_rom_use_dbd" , SCSIDiskState, quirks,SCSI_DISK_QUIRK_MODE_SENSE_ROM_USE_DBD ,0 ), +DEFINE_PROP_BIT ("quirk_mode_page_vendor_specific_apple" , SCSIDiskState, + quirks,SCSI_DISK_QUIRK_MODE_PAGE_VENDOR_SPECIFIC_APPLE , +0 ), DEFINE_PROP_END_OF_LIST(), };
include/hw/scsi/scsi.h +1 -0
@@ -229,5 +229,6 @@ extern const SCSIReqOps scsi_generic_req_ops;/* scsi-disk.c */ #define SCSI_DISK_QUIRK_MODE_PAGE_APPLE_VENDOR 0#define SCSI_DISK_QUIRK_MODE_SENSE_ROM_USE_DBD 1 +#define SCSI_DISK_QUIRK_MODE_PAGE_VENDOR_SPECIFIC_APPLE 2#endif
include/scsi/constants.h +1 -0
@@ -225,6 +225,7 @@#define TYPE_NO_LUN 0x7f/* Mode page codes for mode sense/set */ +#define MODE_PAGE_VENDOR_SPECIFIC 0x00#define MODE_PAGE_R_W_ERROR 0x01#define MODE_PAGE_HD_GEOMETRY 0x04#define MODE_PAGE_FLEXIBLE_DISK_GEOMETRY 0x05
Signature · 1 line
2.36.1
[PULL 08/20] q800: implement compat_props to enable quirk_mode_page_apple_vendor for scsi-cd devices
In reply to Paolo BonziniFrom: Mark Cave-Ayland <[email protected]>
By default quirk_mode_page_apple_vendor should be enabled for all scsi-cd devices connected to the q800 machine to enable MacOS to detect and use them.
Message-Id: <[email protected]>
--- hw/m68k/q800.c | 6 ++++++ 1 file changed, 6 insertions(+)
hw/m68k/q800.c +6 -0
@@ -686,6 +686,11 @@ static void q800_init(MachineState *machine) } } +static GlobalProperty hw_compat_q800[] = { + {"scsi-cd" ,"quirk_mode_page_apple_vendor" ,"on" }, +}; +static const size_t hw_compat_q800_len =G_N_ELEMENTS (hw_compat_q800); +static void q800_machine_class_init (ObjectClass *oc,void *data) {MachineClass *mc =MACHINE_CLASS (oc);
@@ -695,6 +700,7 @@ static void q800_machine_class_init(ObjectClass *oc, void *data) mc->max_cpus =1 ; mc->block_default_type =IF_SCSI ; mc->default_ram_id ="m68k_mac.ram" ; +compat_props_add (mc->compat_props, hw_compat_q800, hw_compat_q800_len); }static const TypeInfo q800_machine_typeinfo = {
Signature · 1 line
2.36.1
[PULL 07/20] scsi-disk: add MODE_PAGE_APPLE_VENDOR quirk for Macintosh
In reply to Paolo BonziniFrom: Mark Cave-Ayland <[email protected]>
One of the mechanisms MacOS uses to identify CDROM drives compatible with MacOS is to send a custom MODE SELECT command for page 0x30 to the drive. The response to this is a hard-coded manufacturer string which must match in order for the CDROM to be usable within MacOS.
Add an implementation of the MODE SELECT page 0x30 response guarded by a newly defined SCSI_DISK_QUIRK_MODE_PAGE_APPLE_VENDOR quirk bit so that CDROM drives attached to non-Apple machines function exactly as before.
Message-Id: <[email protected]>
--- hw/scsi/scsi-disk.c | 17 +++++++++++++++++ include/hw/scsi/scsi.h | 3 +++ include/scsi/constants.h | 1 + 3 files changed, 21 insertions(+)
hw/scsi/scsi-disk.c +17 -0
@@ -1085,6 +1085,7 @@ static int mode_sense_page(SCSIDiskState *s, int page, uint8_t **p_outbuf, [MODE_PAGE_R_W_ERROR] = (1 << TYPE_DISK) | (1 << TYPE_ROM), [MODE_PAGE_AUDIO_CTL] = (1 << TYPE_ROM), [MODE_PAGE_CAPABILITIES] = (1 << TYPE_ROM), + [MODE_PAGE_APPLE_VENDOR] = (1 << TYPE_ROM), };uint8_t *p = *p_outbuf +2 ;
@@ -1229,6 +1230,20 @@ static int mode_sense_page(SCSIDiskState *s, int page, uint8_t **p_outbuf, p[19 ] = (16 *176 ) &0xff ;break ; +case MODE_PAGE_APPLE_VENDOR : +if (s->quirks & (1 <<SCSI_DISK_QUIRK_MODE_PAGE_APPLE_VENDOR )) { + length =0x1e ; +if (page_control ==1 ) {/* Changeable Values */ +break ; + } + +memset (p,0 , length); +strcpy ((char *)p +8 ,"APPLE COMPUTER, INC " ); +break ; + }else { +return -1 ; + } +default :return -1 ; }
@@ -3085,6 +3100,8 @@ static Property scsi_cd_properties[] = { DEFAULT_MAX_IO_SIZE),DEFINE_PROP_INT32 ("scsi_version" , SCSIDiskState, qdev.default_scsi_version,5 ), +DEFINE_PROP_BIT ("quirk_mode_page_apple_vendor" , SCSIDiskState, quirks, +SCSI_DISK_QUIRK_MODE_PAGE_APPLE_VENDOR ,0 ), DEFINE_PROP_END_OF_LIST(), };
include/hw/scsi/scsi.h +3 -0
@@ -226,4 +226,7 @@ SCSIDevice *scsi_device_get(SCSIBus *bus, int channel, int target, int lun);/* scsi-generic.c. */ extern const SCSIReqOps scsi_generic_req_ops; +/* scsi-disk.c */ +#define SCSI_DISK_QUIRK_MODE_PAGE_APPLE_VENDOR 0 +#endif
include/scsi/constants.h +1 -0
@@ -234,6 +234,7 @@#define MODE_PAGE_FAULT_FAIL 0x1c#define MODE_PAGE_TO_PROTECT 0x1d#define MODE_PAGE_CAPABILITIES 0x2a +#define MODE_PAGE_APPLE_VENDOR 0x30#define MODE_PAGE_ALLS 0x3f/* Not in Mt. Fuji, but in ATAPI 2.6 -- deprecated now in favor * of MODE_PAGE_SENSE_POWER */
Signature · 1 line
2.36.1
[PULL 10/20] q800: implement compat_props to enable quirk_mode_sense_rom_use_dbd for scsi-cd devices
In reply to Paolo BonziniFrom: Mark Cave-Ayland <[email protected]>
By default quirk_mode_sense_rom_use_dbd should be enabled for all scsi-cd devices connected to the q800 machine to correctly report the CDROM block descriptor back to A/UX.
Message-Id: <[email protected]>
--- hw/m68k/q800.c | 1 + 1 file changed, 1 insertion(+)
hw/m68k/q800.c +1 -0
@@ -688,6 +688,7 @@ static void q800_init(MachineState *machine)static GlobalProperty hw_compat_q800[] = { {"scsi-cd" ,"quirk_mode_page_apple_vendor" ,"on" }, + {"scsi-cd" ,"quirk_mode_sense_rom_use_dbd" ,"on" }, };static const size_t hw_compat_q800_len =G_N_ELEMENTS (hw_compat_q800);
Signature · 1 line
2.36.1
[PULL 04/20] module: Use bundle mechanism
In reply to Paolo BonziniFrom: Akihiko Odaki <[email protected]>
Before this change, the directory of the executable was being added to resolve modules in the build tree. However, get_relocated_path() can now resolve them with the new bundle mechanism.
Message-Id: <[email protected]>
--- util/module.c | 1 - 1 file changed, 1 deletion(-)
util/module.c +0 -1
@@ -274,7 +274,6 @@ bool module_load_one(const char *prefix, const char *lib_name, bool mayfail) dirs[n_dirs++] =g_strdup_printf ("%s" , search_dir); } dirs[n_dirs++] =get_relocated_path (CONFIG_QEMU_MODDIR ); - dirs[n_dirs++] =g_strdup (qemu_get_exec_dir ());#ifdef CONFIG_MODULE_UPGRADES version_dir = g_strcanon(g_strdup(QEMU_PKGVERSION),
Signature · 1 line
2.36.1
[PULL 13/20] scsi-disk: add FORMAT UNIT command
In reply to Paolo BonziniFrom: Mark Cave-Ayland <[email protected]>
When initialising a drive ready to install MacOS, Apple HD SC Setup first attempts to format the drive. Add a simple FORMAT UNIT command which simply returns success to allow the format to succeed.
Message-Id: <[email protected]>
--- hw/scsi/scsi-disk.c | 4 ++++ hw/scsi/trace-events | 1 + 2 files changed, 5 insertions(+)
hw/scsi/scsi-disk.c +4 -0
@@ -2180,6 +2180,9 @@ static int32_t scsi_disk_emulate_command(SCSIRequest *req, uint8_t *buf)trace_scsi_disk_emulate_command_WRITE_SAME ( req->cmd.buf[0 ] ==WRITE_SAME_10 ?10 :16 , r->req.cmd.xfer);break ; +case FORMAT_UNIT : +trace_scsi_disk_emulate_command_FORMAT_UNIT (r->req.cmd.xfer); +break ;default :trace_scsi_disk_emulate_command_UNKNOWN (buf[0 ],scsi_command_name (buf[0 ]));
@@ -2585,6 +2588,7 @@ static const SCSIReqOps *const scsi_disk_reqops_dispatch[256] = { [VERIFY_10] = &scsi_disk_emulate_reqops, [VERIFY_12] = &scsi_disk_emulate_reqops, [VERIFY_16] = &scsi_disk_emulate_reqops, + [FORMAT_UNIT] = &scsi_disk_emulate_reqops, [READ_6] = &scsi_disk_dma_reqops, [READ_10] = &scsi_disk_dma_reqops,
hw/scsi/trace-events +1 -0
@@ -334,6 +334,7 @@ scsi_disk_emulate_command_UNMAP(size_t xfer) "Unmap (len %zd)" scsi_disk_emulate_command_VERIFY(int bytchk) "Verify (bytchk %d)" scsi_disk_emulate_command_WRITE_SAME(int cmd, size_t xfer) "WRITE SAME %d (len %zd)" scsi_disk_emulate_command_UNKNOWN(int cmd, const char *name) "Unknown SCSI command (0x%2.2x=%s)" +scsi_disk_emulate_command_FORMAT_UNIT(size_t xfer) "Format Unit (len %zu)" scsi_disk_dma_command_READ(uint64_t lba, uint32_t len) "Read (sector %" PRId64 ", count %u)" scsi_disk_dma_command_WRITE(const char *cmd, uint64_t lba, int len) "Write %s(sector %" PRId64 ", count %u)" scsi_disk_new_request(uint32_t lun, uint32_t tag, const char *line) "Command: lun=%d tag=0x%x data=%s"
Signature · 1 line
2.36.1
[PULL 09/20] scsi-disk: add SCSI_DISK_QUIRK_MODE_SENSE_ROM_USE_DBD quirk for Macintosh
In reply to Paolo BonziniFrom: Mark Cave-Ayland <[email protected]>
During SCSI bus enumeration A/UX sends a MODE SENSE command to the CDROM with the DBD bit unset and expects the response to include a block descriptor. As per the latest SCSI documentation, QEMU currently force-disables the block descriptor for CDROM devices but the A/UX driver expects the requested block descriptor to be returned.
If the block descriptor is not returned in the response then A/UX becomes confused, since the block descriptor returned in the MODE SENSE response is used to generate a subsequent MODE SELECT command which is then invalid.
Add a new SCSI_DISK_QUIRK_MODE_SENSE_ROM_USE_DBD quirk to allow this behaviour to be enabled as required. Note that an additional workaround is required for the previous SCSI_DISK_QUIRK_MODE_PAGE_APPLE_VENDOR quirk which must never return a block descriptor even though the DBD bit is left unset.
Message-Id: <[email protected]>
--- hw/scsi/scsi-disk.c | 27 +++++++++++++++++++++++---- include/hw/scsi/scsi.h | 1 + 2 files changed, 24 insertions(+), 4 deletions(-)
hw/scsi/scsi-disk.c +23 -4
@@ -1279,10 +1279,27 @@ static int scsi_disk_emulate_mode_sense(SCSIDiskReq *r, uint8_t *outbuf) dev_specific_param |=0x80 ;/* Readonly. */ } }else { -/* MMC prescribes that CD/DVD drives have no block descriptors, -* and defines no device-specific parameter. */ - dev_specific_param =0x00 ; - dbd = true; +if (s->quirks & (1 <<SCSI_DISK_QUIRK_MODE_SENSE_ROM_USE_DBD )) { +/* Use DBD from the request... */ + dev_specific_param =0x00 ; + +/* +* ... unless we receive a request for MODE_PAGE_APPLE_VENDOR +* which should never return a block descriptor even though DBD is +* not set, otherwise CDROM detection fails in MacOS +*/ +if (s->quirks & (1 <<SCSI_DISK_QUIRK_MODE_PAGE_APPLE_VENDOR ) && + page ==MODE_PAGE_APPLE_VENDOR ) { + dbd = true; + } + }else { +/* +* MMC prescribes that CD/DVD drives have no block descriptors, +* and defines no device-specific parameter. +*/ + dev_specific_param =0x00 ; + dbd = true; + } }if (r->req.cmd.buf[0 ] ==MODE_SENSE ) {
@@ -3102,6 +3119,8 @@ static Property scsi_cd_properties[] = { 5),DEFINE_PROP_BIT ("quirk_mode_page_apple_vendor" , SCSIDiskState, quirks,SCSI_DISK_QUIRK_MODE_PAGE_APPLE_VENDOR ,0 ), +DEFINE_PROP_BIT ("quirk_mode_sense_rom_use_dbd" , SCSIDiskState, quirks, +SCSI_DISK_QUIRK_MODE_SENSE_ROM_USE_DBD ,0 ), DEFINE_PROP_END_OF_LIST(), };
include/hw/scsi/scsi.h +1 -0
@@ -228,5 +228,6 @@ extern const SCSIReqOps scsi_generic_req_ops;/* scsi-disk.c */ #define SCSI_DISK_QUIRK_MODE_PAGE_APPLE_VENDOR 0 +#define SCSI_DISK_QUIRK_MODE_SENSE_ROM_USE_DBD 1#endif
Signature · 1 line
2.36.1
[PULL 16/20] scsi-disk: allow the MODE_PAGE_R_W_ERROR AWRE bit to be changeable for CDROM drives
In reply to Paolo BonziniFrom: Mark Cave-Ayland <[email protected]>
A/UX sends a MODE_PAGE_R_W_ERROR command with the AWRE bit set to 0 when enumerating CDROM drives. Since the bit is currently hardcoded to 1 then indicate that the AWRE bit can be changed (even though we don't care about the value) so that the MODE_PAGE_R_W_ERROR page can be set successfully.
Message-Id: <[email protected]>
--- hw/scsi/scsi-disk.c | 4 ++++ 1 file changed, 4 insertions(+)
hw/scsi/scsi-disk.c +4 -0
@@ -1188,6 +1188,10 @@ static int mode_sense_page(SCSIDiskState *s, int page, uint8_t **p_outbuf,case MODE_PAGE_R_W_ERROR : length =10 ;if (page_control ==1 ) {/* Changeable Values */ +if (s->qdev.type ==TYPE_ROM ) { +/* Automatic Write Reallocation Enabled */ + p[0 ] =0x80 ; + }break ; } p[0 ] =0x80 ;/* Automatic Write Reallocation Enabled */
Signature · 1 line
2.36.1
[PULL 19/20] q800: add default vendor and product information for scsi-cd devices
In reply to Paolo BonziniFrom: Mark Cave-Ayland <[email protected]>
The MacOS CDROM driver uses a SCSI INQUIRY command to check that any SCSI CDROMs detected match a whitelist of vendors and products before adding them to the list of available devices.
Add known-good default vendor and product information using the existing compat_prop mechanism so the user doesn't have to use long command lines to set the qdev properties manually.
Message-Id: <[email protected]>
--- hw/m68k/q800.c | 3 +++ 1 file changed, 3 insertions(+)
hw/m68k/q800.c +3 -0
@@ -695,6 +695,9 @@ static GlobalProperty hw_compat_q800[] = { { "scsi-cd", "quirk_mode_sense_rom_use_dbd", "on"}, { "scsi-cd", "quirk_mode_page_vendor_specific_apple", "on"}, { "scsi-cd", "quirk_mode_page_truncated", "on"}, + { "scsi-cd", "vendor", "MATSHITA" }, + { "scsi-cd", "product", "CD-ROM CR-8005" }, + { "scsi-cd", "ver", "1.0k" }, };static const size_t hw_compat_q800_len =G_N_ELEMENTS (hw_compat_q800);
Signature · 1 line
2.36.1
[PULL 12/20] q800: implement compat_props to enable quirk_mode_page_vendor_specific_apple for scsi devices
In reply to Paolo BonziniFrom: Mark Cave-Ayland <[email protected]>
By default quirk_mode_page_vendor_specific_apple should be enabled for both scsi-hd and scsi-cd devices to allow MacOS to format SCSI disk devices, and A/UX to enumerate SCSI CDROM devices succesfully without getting stuck in a loop.
Message-Id: <[email protected]>
--- hw/m68k/q800.c | 2 ++ 1 file changed, 2 insertions(+)
hw/m68k/q800.c +2 -0
@@ -687,8 +687,10 @@ static void q800_init(MachineState *machine) }static GlobalProperty hw_compat_q800[] = { + {"scsi-hd" ,"quirk_mode_page_vendor_specific_apple" ,"on" }, {"scsi-cd" ,"quirk_mode_page_apple_vendor" ,"on" }, {"scsi-cd" ,"quirk_mode_sense_rom_use_dbd" ,"on" }, + {"scsi-cd" ,"quirk_mode_page_vendor_specific_apple" ,"on" }, };static const size_t hw_compat_q800_len =G_N_ELEMENTS (hw_compat_q800);
Signature · 1 line
2.36.1
[PULL 06/20] scsi-disk: add new quirks bitmap to SCSIDiskState
In reply to Paolo BonziniFrom: Mark Cave-Ayland <[email protected]>
Since the MacOS SCSI implementation is quite old (and Apple added some firmware customisations to their drives for m68k Macs) there is need to add a mechanism to correctly handle Apple-specific quirks.
Add a new quirks bitmap to SCSIDiskState that can be used to enable these features as required.
Message-Id: <[email protected]>
--- hw/scsi/scsi-disk.c | 1 + 1 file changed, 1 insertion(+)
hw/scsi/scsi-disk.c +1 -0
@@ -94,6 +94,7 @@ struct SCSIDiskState {uint16_t port_index;uint64_t max_unmap_size;uint64_t max_io_size; +uint32_t quirks;QEMUBH *bh;char *version;char *serial;
Signature · 1 line
2.36.1
[PULL 17/20] scsi-disk: allow MODE SELECT block descriptor to set the block size
In reply to Paolo BonziniFrom: Mark Cave-Ayland <[email protected]>
The MODE SELECT command can contain an optional block descriptor that can be used to set the device block size. If the block descriptor is present then update the block size on the SCSI device accordingly.
This allows CDROMs to be used with A/UX which requires a CDROM drive which is capable of switching from a 2048 byte sector size to a 512 byte sector size.
Message-Id: <[email protected]>
--- hw/scsi/scsi-disk.c | 6 ++++++ hw/scsi/trace-events | 1 + 2 files changed, 7 insertions(+)
hw/scsi/scsi-disk.c +6 -0
@@ -1616,6 +1616,12 @@ static void scsi_disk_emulate_mode_select(SCSIDiskReq *r, uint8_t *inbuf) goto invalid_param; } +/* Allow changing the block size */ +if (bd_len && p[6 ] != (s->qdev.blocksize >>8 )) { + s->qdev.blocksize = p[6 ] <<8 ; +trace_scsi_disk_mode_select_set_blocksize (s->qdev.blocksize); + } + len -= bd_len; p += bd_len;
hw/scsi/trace-events +1 -0
@@ -340,6 +340,7 @@ scsi_disk_dma_command_WRITE(const char *cmd, uint64_t lba, int len) "Write %s(se scsi_disk_new_request(uint32_t lun, uint32_t tag, const char *line) "Command: lun=%d tag=0x%x data=%s" scsi_disk_aio_sgio_command(uint32_t tag, uint8_t cmd, uint64_t lba, int len, uint32_t timeout) "disk aio sgio: tag=0x%x cmd=0x%x (sector %" PRId64 ", count %d) timeout=%u" scsi_disk_mode_select_page_truncated(int page, int len, int page_len) "page %d expected length %d but received length %d" +scsi_disk_mode_select_set_blocksize(int blocksize) "set block size to %d" # scsi-generic.c scsi_generic_command_complete_noio(void *req, uint32_t tag, int statuc) "Command complete %p tag=0x%x status=%d"
Signature · 1 line
2.36.1
[PULL 14/20] scsi-disk: add SCSI_DISK_QUIRK_MODE_PAGE_TRUNCATED quirk for Macintosh
In reply to Paolo BonziniFrom: Mark Cave-Ayland <[email protected]>
When A/UX configures the CDROM device it sends a truncated MODE SELECT request for page 1 (MODE_PAGE_R_W_ERROR) which is only 6 bytes in length rather than
10. This seems to be due to bug in Apple's code which calculates the CDB message length incorrectly.
The work at [1] suggests that this truncated request is accepted on real hardware whereas in QEMU it generates an INVALID_PARAM_LEN sense code which causes A/UX to get stuck in a loop retrying the command in an attempt to succeed.
Alter the mode page request length check so that truncated requests are allowed if the SCSI_DISK_QUIRK_MODE_PAGE_TRUNCATED quirk is enabled, whilst also adding a trace event to enable the condition to be detected.
[1] https://68kmla.org/bb/index.php?threads/scsi2sd-project-anyone-interested.29040/page-7#post-316444
Message-Id: <[email protected]>
--- hw/scsi/scsi-disk.c | 7 ++++++- hw/scsi/trace-events | 1 + include/hw/scsi/scsi.h | 1 + 3 files changed, 8 insertions(+), 1 deletion(-)
hw/scsi/scsi-disk.c +6 -1
@@ -1552,7 +1552,10 @@ static int mode_select_pages(SCSIDiskReq *r, uint8_t *p, int len, bool change) goto invalid_param; }if (page_len > len) { - goto invalid_param_len; +if (!(s->quirks &SCSI_DISK_QUIRK_MODE_PAGE_TRUNCATED )) { + goto invalid_param_len; + } +trace_scsi_disk_mode_select_page_truncated (page, page_len, len); }if (!change) {
@@ -3151,6 +3154,8 @@ static Property scsi_cd_properties[] = {DEFINE_PROP_BIT ("quirk_mode_page_vendor_specific_apple" , SCSIDiskState, quirks,SCSI_DISK_QUIRK_MODE_PAGE_VENDOR_SPECIFIC_APPLE ,0 ), +DEFINE_PROP_BIT ("quirk_mode_page_truncated" , SCSIDiskState, quirks, +SCSI_DISK_QUIRK_MODE_PAGE_TRUNCATED ,0 ), DEFINE_PROP_END_OF_LIST(), };
hw/scsi/trace-events +1 -0
@@ -339,6 +339,7 @@ scsi_disk_dma_command_READ(uint64_t lba, uint32_t len) "Read (sector %" PRId64 " scsi_disk_dma_command_WRITE(const char *cmd, uint64_t lba, int len) "Write %s(sector %" PRId64 ", count %u)" scsi_disk_new_request(uint32_t lun, uint32_t tag, const char *line) "Command: lun=%d tag=0x%x data=%s" scsi_disk_aio_sgio_command(uint32_t tag, uint8_t cmd, uint64_t lba, int len, uint32_t timeout) "disk aio sgio: tag=0x%x cmd=0x%x (sector %" PRId64 ", count %d) timeout=%u" +scsi_disk_mode_select_page_truncated(int page, int len, int page_len) "page %d expected length %d but received length %d" # scsi-generic.c scsi_generic_command_complete_noio(void *req, uint32_t tag, int statuc) "Command complete %p tag=0x%x status=%d"
include/hw/scsi/scsi.h +1 -0
@@ -230,5 +230,6 @@ extern const SCSIReqOps scsi_generic_req_ops;#define SCSI_DISK_QUIRK_MODE_PAGE_APPLE_VENDOR 0#define SCSI_DISK_QUIRK_MODE_SENSE_ROM_USE_DBD 1#define SCSI_DISK_QUIRK_MODE_PAGE_VENDOR_SPECIFIC_APPLE 2 +#define SCSI_DISK_QUIRK_MODE_PAGE_TRUNCATED 3#endif
Signature · 1 line
2.36.1
[PULL 20/20] pc-bios/s390-ccw: add -Wno-array-bounds
In reply to Paolo BonziniThe option generates a lot of warnings for integers casted to pointers, for example:
/home/pbonzini/work/upstream/qemu/pc-bios/s390-ccw/dasd-ipl.c:174:19: warning: array subscript 0 is outside array bounds of ‘CcwSeekData[0]’ [-Warray-bounds]
174 | seekData->cyl = 0x00;
| ~~~~~~~~~~~~~~^~~~~~--- pc-bios/s390-ccw/Makefile | 1 + 1 file changed, 1 insertion(+)
pc-bios/s390-ccw/Makefile +1 -0
@@ -35,6 +35,7 @@ EXTRA_CFLAGS += $(call cc-option,-Werror $(EXTRA_CFLAGS),-Wno-stringop-overflow) EXTRA_CFLAGS += -ffreestanding -fno-delete-null-pointer-checks -fno-common -fPIE EXTRA_CFLAGS += -fwrapv -fno-strict-aliasing -fno-asynchronous-unwind-tables EXTRA_CFLAGS += $(call cc-option, $(EXTRA_CFLAGS), -fno-stack-protector) +EXTRA_CFLAGS += $(call cc-option, $(EXTRA_CFLAGS), -Wno-array-bounds) EXTRA_CFLAGS += -msoft-float EXTRA_CFLAGS += $(call cc-option, $(EXTRA_CFLAGS),-march=z900,-march=z10) EXTRA_CFLAGS += -std=gnu99
Signature · 1 line
2.36.1
[PULL 15/20] q800: implement compat_props to enable quirk_mode_page_truncated for scsi-cd devices
In reply to Paolo BonziniFrom: Mark Cave-Ayland <[email protected]>
By default quirk_mode_page_truncated should be enabled for all scsi-cd devices connected to the q800 machine to allow A/UX to enumerate SCSI CDROM devices without hanging.
Message-Id: <[email protected]>
--- hw/m68k/q800.c | 1 + 1 file changed, 1 insertion(+)
hw/m68k/q800.c +1 -0
@@ -691,6 +691,7 @@ static GlobalProperty hw_compat_q800[] = { { "scsi-cd", "quirk_mode_page_apple_vendor", "on"}, { "scsi-cd", "quirk_mode_sense_rom_use_dbd", "on"}, { "scsi-cd", "quirk_mode_page_vendor_specific_apple", "on"}, + { "scsi-cd", "quirk_mode_page_truncated", "on"}, };static const size_t hw_compat_q800_len =G_N_ELEMENTS (hw_compat_q800);
Signature · 1 line
2.36.1
[PULL 18/20] q800: add default vendor and product information for scsi-hd devices
In reply to Paolo BonziniFrom: Mark Cave-Ayland <[email protected]>
The Apple HD SC Setup program uses a SCSI INQUIRY command to check that any SCSI hard disks detected match a whitelist of vendors and products before allowing the "Initialise" button to prepare an empty disk.
Add known-good default vendor and product information using the existing compat_prop mechanism so the user doesn't have to use long command lines to set the qdev properties manually.
Message-Id: <[email protected]>
--- hw/m68k/q800.c | 3 +++ 1 file changed, 3 insertions(+)
hw/m68k/q800.c +3 -0
@@ -688,6 +688,9 @@ static void q800_init(MachineState *machine)static GlobalProperty hw_compat_q800[] = { {"scsi-hd" ,"quirk_mode_page_vendor_specific_apple" ,"on" }, + {"scsi-hd" ,"vendor" ," SEAGATE" }, + {"scsi-hd" ,"product" ," ST225N" }, + {"scsi-hd" ,"ver" ,"1.0 " }, {"scsi-cd" ,"quirk_mode_page_apple_vendor" ,"on" }, {"scsi-cd" ,"quirk_mode_sense_rom_use_dbd" ,"on" }, {"scsi-cd" ,"quirk_mode_page_vendor_specific_apple" ,"on" },
Signature · 1 line
2.36.1
Peter Maydell
AppliedQuoted 9 lines · Paolo Bonzini
The following changes since commit
8e3d85d36b77f11ad7bded3a2d48c1f0cc334f82:Merge tag 'for-upstream' of https://gitlab.com/bonzini/qemu into staging (2022-07-12 14:12:15 +0100)
are available in the Git repository at:
https://gitlab.com/bonzini/qemu.git tags/for-upstream
Quoted 9 lines
for you to fetch changes up to
c0b3607d5938f5ee7fd16ff1e102afe938fd4b39:pc-bios/s390-ccw: add -Wno-array-bounds (2022-07-13 16:58:58 +0200)
----------------------------------------------------------------
* SCSI fuzzing fix (Mauro)
* pre-install data files in the build directory (Akihiko)
* SCSI fixes for Mac OS (Mark)
Applied, thanks.
Please update the changelog at https://wiki.qemu.org/ChangeLog/7.1
for any user-visible changes.
-- PMM