From patchwork Sat Apr 28 13:49:36 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: ronnie sahlberg X-Patchwork-Id: 155658 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id E646BB6FE5 for ; Sat, 28 Apr 2012 23:50:07 +1000 (EST) Received: from localhost ([::1]:45792 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SO82H-0004jd-P2 for incoming@patchwork.ozlabs.org; Sat, 28 Apr 2012 09:50:05 -0400 Received: from eggs.gnu.org ([208.118.235.92]:38227) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SO826-0004ab-Pu for qemu-devel@nongnu.org; Sat, 28 Apr 2012 09:49:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SO825-0002ge-0A for qemu-devel@nongnu.org; Sat, 28 Apr 2012 09:49:54 -0400 Received: from mail-pz0-f46.google.com ([209.85.210.46]:37396) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SO824-0002OX-NS for qemu-devel@nongnu.org; Sat, 28 Apr 2012 09:49:52 -0400 Received: by mail-pz0-f46.google.com with SMTP id z9so2444833dad.33 for ; Sat, 28 Apr 2012 06:49:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=I9g4uEysvyBZnfQIMNtiQNJwYg1i8YGDOAvA6uTBIRE=; b=EdfrDm/A+MybV6PESkQ2EUMuLWyiCrRme6+unQqrpfp6j2iwhXfCuRnpP0RKvcs8CS qpqWbuxcrjQF1U08mtcMz6n1o1GmLcK9KR1Ah/dzaxPAYc0sgPOSfDWgfslSb1TbOSIJ TFXpSvCyZ91S9SwNOeI8q0/gYVm5Zdf6+CAlgN8zyHN/UU0/JvmUdsdJ/VlGqoTjWEwb yKByW37iOYjQeNRqchcK8jE8WnP/Z1W5FMi0HTQqI7/CaSNBQNdoIWiDlGRzLoHgeioF 01LxDjjuXup8lRcee1T85aGE1MERS0D3sb56iVZKkZIXUPjaArdiAihn4lb2cK6pFxuK DM+Q== Received: by 10.68.234.40 with SMTP id ub8mr2854584pbc.57.1335620991789; Sat, 28 Apr 2012 06:49:51 -0700 (PDT) Received: from ronniesahlberg@gmail.com (CPE-58-166-90-251.lnse5.cht.bigpond.net.au. [58.166.90.251]) by mx.google.com with ESMTPS id d4sm9757032pbe.36.2012.04.28.06.49.48 (version=TLSv1/SSLv3 cipher=OTHER); Sat, 28 Apr 2012 06:49:51 -0700 (PDT) Received: by ronniesahlberg@gmail.com (sSMTP sendmail emulation); Sat, 28 Apr 2012 23:49:48 +1000 From: Ronnie Sahlberg To: qemu-devel@nongnu.org, pbonzini@redhat.com Date: Sat, 28 Apr 2012 23:49:36 +1000 Message-Id: <1335620976-29951-2-git-send-email-ronniesahlberg@gmail.com> X-Mailer: git-send-email 1.7.3.1 In-Reply-To: <1335620976-29951-1-git-send-email-ronniesahlberg@gmail.com> References: <1335620976-29951-1-git-send-email-ronniesahlberg@gmail.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.85.210.46 Cc: Ronnie Sahlberg Subject: [Qemu-devel] [PATCH] SCSI-GENERIC: Specify the xfer direction for UNMAP/WRITESAME16/ATAPASSTHROUGH command X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org scsi_cmd_xfer_mode() is used to specify the xfer direction for SCSI commands that come in from the guest. If the direction is set incorrectly this will eventually cause QEMU to kernel-panic the guest. Add UNMAP/WRITESAME16/ATAPASSTHROUGH as commands that send data to the device. Without this change, recent kernels will send both UNMAP as well as ATAPASSTHROUGH commands to any /dev/sg* device, which due to the incorrect xfer direction very quickly causes the guest kernel to crash. Example causing a crash without the patch applied: ./x86_64-softmmu/qemu-system-x86_64 -m 1024 -enable-kvm -cdrom linuxmint-12-gnome-dvd-64bit.iso -drive file=/dev/sg4,if=scsi,bus=0,unit=6 Signed-off-by: Ronnie Sahlberg --- hw/scsi-bus.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diff --git a/hw/scsi-bus.c b/hw/scsi-bus.c index dbdb99c..bca2be8 100644 --- a/hw/scsi-bus.c +++ b/hw/scsi-bus.c @@ -920,6 +920,8 @@ static void scsi_cmd_xfer_mode(SCSICommand *cmd) case UPDATE_BLOCK: case WRITE_LONG_10: case WRITE_SAME_10: + case WRITE_SAME_16: + case UNMAP: case SEARCH_HIGH_12: case SEARCH_EQUAL_12: case SEARCH_LOW_12: @@ -929,6 +931,7 @@ static void scsi_cmd_xfer_mode(SCSICommand *cmd) case SEND_DVD_STRUCTURE: case PERSISTENT_RESERVE_OUT: case MAINTENANCE_OUT: + case ATA_PASSTHROUGH: cmd->mode = SCSI_XFER_TO_DEV; break; default: