]> git.proxmox.com Git - pve-qemu.git/blob - debian/patches/extra/0003-scsi-megasas-Internal-cdbs-have-16-byte-length.patch
update submodule and patches to QEMU 8.0.0
[pve-qemu.git] / debian / patches / extra / 0003-scsi-megasas-Internal-cdbs-have-16-byte-length.patch
1 From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2 From: Guenter Roeck <linux@roeck-us.net>
3 Date: Tue, 28 Feb 2023 09:11:29 -0800
4 Subject: [PATCH] scsi: megasas: Internal cdbs have 16-byte length
5 MIME-Version: 1.0
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
8
9 Host drivers do not necessarily set cdb_len in megasas io commands.
10 With commits 6d1511cea0 ("scsi: Reject commands if the CDB length
11 exceeds buf_len") and fe9d8927e2 ("scsi: Add buf_len parameter to
12 scsi_req_new()"), this results in failures to boot Linux from affected
13 SCSI drives because cdb_len is set to 0 by the host driver.
14 Set the cdb length to its actual size to solve the problem.
15
16 Signed-off-by: Guenter Roeck <linux@roeck-us.net>
17 Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
18 (picked-up from https://lists.nongnu.org/archive/html/qemu-devel/2023-02/msg08653.html)
19 Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
20 ---
21 hw/scsi/megasas.c | 14 ++------------
22 1 file changed, 2 insertions(+), 12 deletions(-)
23
24 diff --git a/hw/scsi/megasas.c b/hw/scsi/megasas.c
25 index 9cbbb16121..d624866bb6 100644
26 --- a/hw/scsi/megasas.c
27 +++ b/hw/scsi/megasas.c
28 @@ -1780,7 +1780,7 @@ static int megasas_handle_io(MegasasState *s, MegasasCmd *cmd, int frame_cmd)
29 uint8_t cdb[16];
30 int len;
31 struct SCSIDevice *sdev = NULL;
32 - int target_id, lun_id, cdb_len;
33 + int target_id, lun_id;
34
35 lba_count = le32_to_cpu(cmd->frame->io.header.data_len);
36 lba_start_lo = le32_to_cpu(cmd->frame->io.lba_lo);
37 @@ -1789,7 +1789,6 @@ static int megasas_handle_io(MegasasState *s, MegasasCmd *cmd, int frame_cmd)
38
39 target_id = cmd->frame->header.target_id;
40 lun_id = cmd->frame->header.lun_id;
41 - cdb_len = cmd->frame->header.cdb_len;
42
43 if (target_id < MFI_MAX_LD && lun_id == 0) {
44 sdev = scsi_device_find(&s->bus, 0, target_id, lun_id);
45 @@ -1804,15 +1803,6 @@ static int megasas_handle_io(MegasasState *s, MegasasCmd *cmd, int frame_cmd)
46 return MFI_STAT_DEVICE_NOT_FOUND;
47 }
48
49 - if (cdb_len > 16) {
50 - trace_megasas_scsi_invalid_cdb_len(
51 - mfi_frame_desc(frame_cmd), 1, target_id, lun_id, cdb_len);
52 - megasas_write_sense(cmd, SENSE_CODE(INVALID_OPCODE));
53 - cmd->frame->header.scsi_status = CHECK_CONDITION;
54 - s->event_count++;
55 - return MFI_STAT_SCSI_DONE_WITH_ERROR;
56 - }
57 -
58 cmd->iov_size = lba_count * sdev->blocksize;
59 if (megasas_map_sgl(s, cmd, &cmd->frame->io.sgl)) {
60 megasas_write_sense(cmd, SENSE_CODE(TARGET_FAILURE));
61 @@ -1823,7 +1813,7 @@ static int megasas_handle_io(MegasasState *s, MegasasCmd *cmd, int frame_cmd)
62
63 megasas_encode_lba(cdb, lba_start, lba_count, is_write);
64 cmd->req = scsi_req_new(sdev, cmd->index,
65 - lun_id, cdb, cdb_len, cmd);
66 + lun_id, cdb, sizeof(cdb), cmd);
67 if (!cmd->req) {
68 trace_megasas_scsi_req_alloc_failed(
69 mfi_frame_desc(frame_cmd), target_id, lun_id);