OpenBSD CVS

CVS log for src/usr.sbin/vmd/vioscsi.c


[BACK] Up to [local] / src / usr.sbin / vmd

Request diff between arbitrary revisions


Default branch: MAIN


Revision 1.24 / (download) - annotate - [select for diffs], Wed Sep 6 19:26:39 2023 UTC (8 months, 3 weeks ago) by dv
Branch: MAIN
CVS Tags: OPENBSD_7_5_BASE, OPENBSD_7_5, OPENBSD_7_4_BASE, OPENBSD_7_4, HEAD
Changes since 1.23: +5 -8 lines
Diff to previous 1.23 (colored)

vmd(8): clean up struct ioinfo.

In prep for fixing some vioblk device issues, simplify the ioinfo
struct by dropping members that aren't needed.

ok mlarkin@

Revision 1.23 / (download) - annotate - [select for diffs], Sat Apr 1 06:39:03 2023 UTC (14 months ago) by jsg
Branch: MAIN
Changes since 1.22: +2 -1 lines
Diff to previous 1.22 (colored)

avoid use of uninitialised memory
ok mlarkin@

Revision 1.22 / (download) - annotate - [select for diffs], Fri Dec 23 19:25:22 2022 UTC (17 months, 1 week ago) by dv
Branch: MAIN
CVS Tags: OPENBSD_7_3_BASE, OPENBSD_7_3
Changes since 1.21: +38 -133 lines
Diff to previous 1.21 (colored)

vmd(8): implement zero-copy operations on virtqueues.

The original virtio device implementation relied on allocating a
buffer on heap, copying the virtqueue from the guest, mutating the
copy, and then overwriting the virtqueue in the guest.

While the approach worked, it was both complex and added extra
overhead. On older hardware, switching to the zero-copy approach
can show a noticeable performance improvement for vionet devices.
An added benefit is this diff also reduces the amount of code in
vmd, which is always a welcome change.

In addition, change to talking about the queue pfn and not "address"
as the virtio-pci spec has drivers provide a 32-bit value representing
the physical page number of the location in guest memory, not the
linear address.

Original idea from dlg@ while working on re-adding async task queues.

ok dlg@, tested by many

Revision 1.21 / (download) - annotate - [select for diffs], Tue Nov 8 12:41:00 2022 UTC (18 months, 3 weeks ago) by dv
Branch: MAIN
Changes since 1.20: +2 -2 lines
Diff to previous 1.20 (colored)

whitespace fix in debug printf, no functional change.

Revision 1.20 / (download) - annotate - [select for diffs], Mon Mar 7 14:17:47 2022 UTC (2 years, 2 months ago) by dv
Branch: MAIN
CVS Tags: OPENBSD_7_2_BASE, OPENBSD_7_2, OPENBSD_7_1_BASE, OPENBSD_7_1
Changes since 1.19: +41 -55 lines
Diff to previous 1.19 (colored)

Resolve clang unused-but-set warnings in vmd's vioscsi.c.

A few of the vioscsi functions have debug logging in DPRINTF's and
are the only use of some declared variables. This tucks any debug-only
variables into the DPRINTF or behind an #if DEBUG.

ok from deraadt@ caveated I don't add code before any declarations.

Revision 1.19 / (download) - annotate - [select for diffs], Wed Jun 16 16:55:02 2021 UTC (2 years, 11 months ago) by dv
Branch: MAIN
CVS Tags: OPENBSD_7_0_BASE, OPENBSD_7_0
Changes since 1.18: +2 -1 lines
Diff to previous 1.18 (colored)

cleanup vmd(8) includes and header files

Lots of organic growth other the years lead to unnecessary includes
(proc.h everywhere) and odd dependencies between header files. This
cleans things up a bit to help with upcoming cleanup around dhcp
code.

No functional change.

"go for it" mlarkin@

Revision 1.14.4.1 / (download) - annotate - [select for diffs], Tue May 18 14:40:47 2021 UTC (3 years ago) by bluhm
Branch: OPENBSD_6_8
Changes since 1.14: +84 -71 lines
Diff to previous 1.14 (colored) next main 1.15 (colored)

vmd(8): guest virtio drivers can cause stack & buffer overflows

A vmd guest can craft invalid virtio descriptor lengths resulting
in reading and writing beyond stack-allocated buffer lengths providing
an escape vector to the host.

Instead of allowing the guest to dictate read/write lengths, this
commit has vmd just use compile-time lengths based on the source
or destination object sizes. For instances where vmd's virtio
implementation can't use this method, such as reading packets from
the vionet device, cap each read with a pre-computed max chunk size.

Reported by Maxime Villard.

Tested with help from Mischa Peters, OK mlarkin@
from dv@

this is errata/6.8/020_vmd.patch.sig

Revision 1.15.2.1 / (download) - annotate - [select for diffs], Tue May 18 14:39:23 2021 UTC (3 years ago) by bluhm
Branch: OPENBSD_6_9
Changes since 1.15: +84 -71 lines
Diff to previous 1.15 (colored) next main 1.16 (colored)

vmd(8): guest virtio drivers can cause stack & buffer overflows

A vmd guest can craft invalid virtio descriptor lengths resulting
in reading and writing beyond stack-allocated buffer lengths providing
an escape vector to the host.

Instead of allowing the guest to dictate read/write lengths, this
commit has vmd just use compile-time lengths based on the source
or destination object sizes. For instances where vmd's virtio
implementation can't use this method, such as reading packets from
the vionet device, cap each read with a pre-computed max chunk size.

Reported by Maxime Villard.

Tested with help from Mischa Peters, OK mlarkin@
from dv@

this is errata/6.9/003_vmd.patch.sig

Revision 1.18 / (download) - annotate - [select for diffs], Tue May 18 11:06:43 2021 UTC (3 years ago) by dv
Branch: MAIN
Changes since 1.17: +76 -70 lines
Diff to previous 1.17 (colored)

vmd(8): guest virtio drivers can cause stack & buffer overflows

A vmd guest can craft invalid virtio descriptor lengths resulting
in reading and writing beyond stack-allocated buffer lengths providing
an escape vector to the host.

Instead of allowing the guest to dictate read/write lengths, this
commit has vmd just use compile-time lengths based on the source
or destination object sizes. For instances where vmd's virtio
implementation can't use this method, such as reading packets from
the vionet device, cap each read with a pre-computed max chunk size.

Reported by Maxime Villard.

Tested with help from Mischa Peters, OK mlarkin@

Revision 1.17 / (download) - annotate - [select for diffs], Thu Apr 22 18:40:21 2021 UTC (3 years, 1 month ago) by dv
Branch: MAIN
Changes since 1.16: +9 -2 lines
Diff to previous 1.16 (colored)

vmd(8): guard against bad virtio drivers

Add protections against guests with bad virtio-{blk,net,scsi}
drivers, specifically avoiding invalid descriptor chains and
invalid vionet packet sizes. This helps prevent possible lockup
of the host vm process due to a spinning device event loop thread.

Also fix an unneeded cast in the vioblk handling in case of invalid
buffer lengths.

OK mlarkin@

Revision 1.16 / (download) - annotate - [select for diffs], Thu Apr 22 10:45:21 2021 UTC (3 years, 1 month ago) by dv
Branch: MAIN
Changes since 1.15: +10 -10 lines
Diff to previous 1.15 (colored)

Remove trailing whitespace in comment blocks.

Revision 1.15 / (download) - annotate - [select for diffs], Wed Mar 3 01:27:54 2021 UTC (3 years, 3 months ago) by jsg
Branch: MAIN
CVS Tags: OPENBSD_6_9_BASE
Branch point for: OPENBSD_6_9
Changes since 1.14: +4 -4 lines
Diff to previous 1.14 (colored)

off by one in array bounds tests
ok mlarkin@

Revision 1.14 / (download) - annotate - [select for diffs], Thu Sep 3 13:11:49 2020 UTC (3 years, 8 months ago) by krw
Branch: MAIN
CVS Tags: OPENBSD_6_8_BASE
Branch point for: OPENBSD_6_8
Changes since 1.13: +2 -2 lines
Diff to previous 1.13 (colored)

No need for a private #define for the INQUIRY response_format value '2'. Just
use the new SID_SCSI2_RESPONSE.

Revision 1.13 / (download) - annotate - [select for diffs], Tue Sep 1 12:17:54 2020 UTC (3 years, 9 months ago) by krw
Branch: MAIN
Changes since 1.12: +6 -6 lines
Diff to previous 1.12 (colored)

Rename [READ|WRITE]_BIG to [READ|WRITE]_10. Rename struct scsi_rw_big to
struct scsi_rw_10.

ok gnezdo@ jmatthew@ (who also did sparc64 compile test)

Revision 1.12 / (download) - annotate - [select for diffs], Thu Jan 10 18:59:56 2019 UTC (5 years, 4 months ago) by sf
Branch: MAIN
CVS Tags: OPENBSD_6_7_BASE, OPENBSD_6_7, OPENBSD_6_6_BASE, OPENBSD_6_6, OPENBSD_6_5_BASE, OPENBSD_6_5
Changes since 1.11: +2 -1 lines
Diff to previous 1.11 (colored)

unbreak vmd build

include new virtio_pcireg.h header

Revision 1.11 / (download) - annotate - [select for diffs], Sat Aug 25 04:16:09 2018 UTC (5 years, 9 months ago) by ccardenas
Branch: MAIN
CVS Tags: OPENBSD_6_4_BASE, OPENBSD_6_4
Changes since 1.10: +6 -3 lines
Diff to previous 1.10 (colored)

Rework disks to have pluggable backends.

This is prep work for adding qcow2 image support.

From Ori Bernstein.  Many thanks!

Tested by many.

OK ccardenas@

Revision 1.10 / (download) - annotate - [select for diffs], Sun Jul 15 20:25:52 2018 UTC (5 years, 10 months ago) by ccardenas
Branch: MAIN
Changes since 1.9: +27 -27 lines
Diff to previous 1.9 (colored)

vioscsi driver has been stable enough so we can move a good portion of these
log_debug messages to be DPRINTF (compile time).

Prompted by reyk@.

Ok reyk@.

Revision 1.9 / (download) - annotate - [select for diffs], Sun Jul 15 14:42:04 2018 UTC (5 years, 10 months ago) by reyk
Branch: MAIN
Changes since 1.8: +27 -27 lines
Diff to previous 1.8 (colored)

Revert unrelated change to vioscsi.c

(I had this in my tree to silence vioscsi.c log_debug, but Carlos
already has a better diff for that)

Revision 1.8 / (download) - annotate - [select for diffs], Sun Jul 15 14:36:54 2018 UTC (5 years, 10 months ago) by reyk
Branch: MAIN
Changes since 1.7: +28 -28 lines
Diff to previous 1.7 (colored)

Track resources and enforce cpu/memory/interface limits for non-root users.

The limits are currently hard-coded and undocumented (4 CPUs/VMs, 2G
memory, 8 interfaces) but will be configurable in an upcoming diff.
These limits are tracked in total usage; for example, a user will be
able to run up to 4 VMs with 512M of memory or a single VM with 2G.

OK ccardenas@ mlarkin@

Revision 1.7 / (download) - annotate - [select for diffs], Tue Jul 10 20:43:15 2018 UTC (5 years, 10 months ago) by reyk
Branch: MAIN
Changes since 1.6: +23 -23 lines
Diff to previous 1.6 (colored)

vmd already had DEBUG/DPRINTF, there is no need for VMD_DEBUG/dprintf

Replace all occurences of dprintf with DPRINTF (defined in proc.h).

Revision 1.6 / (download) - annotate - [select for diffs], Tue Jun 19 17:12:34 2018 UTC (5 years, 11 months ago) by reyk
Branch: MAIN
Changes since 1.5: +24 -21 lines
Diff to previous 1.5 (colored)

knf

Revision 1.5 / (download) - annotate - [select for diffs], Thu Apr 26 01:10:10 2018 UTC (6 years, 1 month ago) by ccardenas
Branch: MAIN
Changes since 1.4: +2 -2 lines
Diff to previous 1.4 (colored)

spelling error in log message

Revision 1.4 / (download) - annotate - [select for diffs], Fri Jan 19 14:23:52 2018 UTC (6 years, 4 months ago) by ccardenas
Branch: MAIN
CVS Tags: OPENBSD_6_3_BASE, OPENBSD_6_3
Changes since 1.3: +4 -4 lines
Diff to previous 1.3 (colored)

VMD: vioscsi - fix large ISO support in Linux

Check if n_blocks is less than UINT32_MAX and not the image size
in various places (READ_CAPACITY_* and GET_CONFIGURATION).

ok mlarkin@ and dlg@

Revision 1.3 / (download) - annotate - [select for diffs], Tue Jan 16 06:10:45 2018 UTC (6 years, 4 months ago) by ccardenas
Branch: MAIN
Changes since 1.2: +109 -1 lines
Diff to previous 1.2 (colored)

VMD: vioscsi - add support for REPORT_LUNS opcode

ok mlarkin@

Revision 1.2 / (download) - annotate - [select for diffs], Mon Jan 15 04:26:58 2018 UTC (6 years, 4 months ago) by ccardenas
Branch: MAIN
Changes since 1.1: +1437 -1417 lines
Diff to previous 1.1 (colored)

VMD: vioscsi refactor

Each opcode is now handled in the respective function (vioscsi_handle_xxx)
which allows more functionality to be added easier.

No functional changes confirmed by guest testing.

ok mlarkin@

Revision 1.1 / (download) - annotate - [select for diffs], Wed Jan 3 05:39:56 2018 UTC (6 years, 4 months ago) by ccardenas
Branch: MAIN

Add initial CD-ROM support to VMD via vioscsi.

* Adds 'cdrom' keyword to vm.conf(5) and '-r' to vmctl(8)
* Support various sized ISOs (Limitation of 4G ISOs on Linux guests)
* Known working guests: OpenBSD (primary), Alpine Linux (primary),
  CentOS 6 (secondary), Ubuntu 17.10 (secondary).
  NOTE: Secondary indicates some issue(s) preventing full/reliable
  functionality outside the scope of the vioscsi work.
* If the attached disks are non-bootable (i.e. empty), SeaBIOS (vmd's
  default BIOS) will boot from CD-ROM.

ok mlarkin@, jca@

This form allows you to request diff's between any two revisions of a file. You may select a symbolic revision name using the selection box or you may type in a numeric name using the type-in text box.