From patchwork Wed Nov 29 17:21:17 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Levin, Alexander \(Sasha Levin\)" X-Patchwork-Id: 120040 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp3358184qgn; Wed, 29 Nov 2017 09:53:29 -0800 (PST) X-Google-Smtp-Source: AGs4zMYH7gbZrToN5E5FkQ6xqId8EdlFZXQaDLO3vCcwNWxDUJl7VdUmeDHbxiUIkOn0wxI/pu6Q X-Received: by 10.84.177.129 with SMTP id x1mr3693599plb.217.1511978009192; Wed, 29 Nov 2017 09:53:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511978009; cv=none; d=google.com; s=arc-20160816; b=EXtqmal0Aj+ALqRgsmLvlfgiC82WgVYot4AApwY/huoXq4+TryrfB2VKDOQk/r0UJT J+EQAo3FuszFbam3h7OAHJeSp+QpBg2myGxTHyB5m5aWoTDpLdy1BopXy1zTVlLaOlxZ 6GFMzY81/127CT8HeG5d5vCRGBZbGsrNMJRGUlr8FUwZ3qtF1v4FrNFMnB0iVlMA//vD lTlXP25DRA8RSRNRV1j8nf7BCMd3bKSaSHpaISOc36wE44Zvrepesjc58LKYhMbBy61j 1O9vnwdmqj41CWlteW9wffPvukWbsfxlmWNUChq2XcRaR1JrUPlWDUpuHGnH31cw+mXM 3R0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :content-language:accept-language:in-reply-to:references:message-id :date:thread-index:thread-topic:subject:to:cc:from:dkim-signature :dkim-signature:dkim-signature:arc-authentication-results; bh=rXyxLFiKHCJs7DbqhiX9IYM6hCSfc3LVrSyR1JDFnY4=; b=j22PJGqsqcxk99+t+pLFYYKex2teeXtHExZjryj1ut1Ppey+0USVr8TT32jA20ITOn y6mjRa8Uz78AtiOyUx73nCYAoG/zj+92qWC/4ilTEDwC13sM/ZLiDIQuG5gH8Dj5k3Ax g0obRFRea5NrPkJ3OKre7Ea0jN8nyGrZAxnG6pkECdGjJCZNqkVlVlkKQXGundK1/Rdg KfhQplLphVGQHnZqZKQxeWU+lCoc+6cU29qp0vNDlMwnEi74Q+E5LYq6x+02Bn0BT6yY 5158rWcjB4PDTv7OjYKx918xaGaffgiW4FcJbp0H0q1cphQWUXFVxFDamNhFyXER95Ie xg8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@verizon.com header.s=corp header.b=ViGo4pbm; dkim=fail header.i=@verizon.com header.s=corp header.b=PluBNB78; dkim=fail header.i=@verizon.com header.s=corp header.b=u2NW+Iel; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=NONE dis=NONE) header.from=verizon.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z6si1598704pgz.111.2017.11.29.09.53.28; Wed, 29 Nov 2017 09:53:29 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@verizon.com header.s=corp header.b=ViGo4pbm; dkim=fail header.i=@verizon.com header.s=corp header.b=PluBNB78; dkim=fail header.i=@verizon.com header.s=corp header.b=u2NW+Iel; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=NONE dis=NONE) header.from=verizon.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934990AbdK2Rx1 (ORCPT + 28 others); Wed, 29 Nov 2017 12:53:27 -0500 Received: from omzsmtpe02.verizonbusiness.com ([199.249.25.209]:55873 "EHLO omzsmtpe02.verizonbusiness.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933922AbdK2RWN (ORCPT ); Wed, 29 Nov 2017 12:22:13 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=verizon.com; i=@verizon.com; q=dns/txt; s=corp; t=1511976133; x=1543512133; h=from:cc:to:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=G/P0gdRh/4DpMLPX1+x8XII/ZdXHCqQ0qP4m/VfyJFw=; b=ViGo4pbmvuC+nVQQzqLGDFbVqQeP10lnWxLpKw7ANs+xnJCwe0VoamsZ M5zqiWQzKK3gRzWp1H3bOi4vC9wkwRcmzIOaeLm57HaUqElamq1WupE37 hROiV64mGGjdEDAVx6w6IgqxZgQ0eZqDCRKZnnalo/yEkChT+Vk4RLH9c U=; Received: from unknown (HELO fldsmtpi02.verizon.com) ([166.68.71.144]) by omzsmtpe02.verizonbusiness.com with ESMTP; 29 Nov 2017 17:22:04 +0000 Received: from rogue-10-255-192-101.rogue.vzwcorp.com (HELO apollo.verizonwireless.com) ([10.255.192.101]) by fldsmtpi02.verizon.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 29 Nov 2017 17:21:28 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=verizon.com; i=@verizon.com; q=dns/txt; s=corp; t=1511976089; x=1543512089; h=from:cc:to:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=G/P0gdRh/4DpMLPX1+x8XII/ZdXHCqQ0qP4m/VfyJFw=; b=PluBNB78/8kEvapNGIdduQ9XTCOEku8OmQ4h1P0L1t5ya355Z8lHCycL Sfgw4wahJHovMajJTd6RhpFrPX5+Faelw0Zf7YFmcYOYSkj9V5NwXbjVg LC2T6/NkCSd9JTuF3Ls/4AFTBuvCOeNW5uHc1XbzcDKMEBkyCvmjG2ybS c=; Received: from pioneer.tdc.vzwcorp.com (HELO eris.verizonwireless.com) ([10.254.88.34]) by apollo.verizonwireless.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 29 Nov 2017 12:21:26 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=verizon.com; i=@verizon.com; q=dns/txt; s=corp; t=1511976086; x=1543512086; h=to:subject:date:message-id:references:in-reply-to: content-transfer-encoding:mime-version:from:cc; bh=G/P0gdRh/4DpMLPX1+x8XII/ZdXHCqQ0qP4m/VfyJFw=; b=u2NW+Ielx4tW42YLPCW5SfEExL0unJVOlakflIldRzViQS5JcqtwSgOv TttZLDJ8qnd/ktdXiMPR7YzyR40V38jtRbbL71zl/nDDk7fCipwOkhKCa AfCEpHWASuOV35DqqSoG3IBGJmZF0Ee+0ZCMgDKKX0Rcm4o7bhHFG7+gY Y=; From: alexander.levin@verizon.com Cc: Roger Quadros , Felipe Balbi , alexander.levin@verizon.com X-Host: pioneer.tdc.vzwcorp.com Received: from ohtwi1exh003.uswin.ad.vzwcorp.com ([10.144.218.45]) by eris.verizonwireless.com with ESMTP/TLS/AES128-SHA256; 29 Nov 2017 17:21:26 +0000 Received: from tbwexch16apd.uswin.ad.vzwcorp.com (153.114.162.40) by OHTWI1EXH003.uswin.ad.vzwcorp.com (10.144.218.45) with Microsoft SMTP Server (TLS) id 14.3.248.2; Wed, 29 Nov 2017 12:21:26 -0500 Received: from OMZP1LUMXCA17.uswin.ad.vzwcorp.com (144.8.22.195) by tbwexch16apd.uswin.ad.vzwcorp.com (153.114.162.40) with Microsoft SMTP Server (TLS) id 15.0.1263.5; Wed, 29 Nov 2017 12:21:25 -0500 Received: from OMZP1LUMXCA17.uswin.ad.vzwcorp.com (144.8.22.195) by OMZP1LUMXCA17.uswin.ad.vzwcorp.com (144.8.22.195) with Microsoft SMTP Server (TLS) id 15.0.1263.5; Wed, 29 Nov 2017 11:21:25 -0600 Received: from OMZP1LUMXCA17.uswin.ad.vzwcorp.com ([144.8.22.195]) by OMZP1LUMXCA17.uswin.ad.vzwcorp.com ([144.8.22.195]) with mapi id 15.00.1263.000; Wed, 29 Nov 2017 11:21:25 -0600 To: "linux-kernel@vger.kernel.org" , "stable@vger.kernel.org" Subject: [PATCH AUTOSEL for 4.9 21/52] usb: dwc3: gadget: Fix system suspend/resume on TI platforms Thread-Topic: [PATCH AUTOSEL for 4.9 21/52] usb: dwc3: gadget: Fix system suspend/resume on TI platforms Thread-Index: AQHTaTZ3pN6y70RiAUiEwkJJmtXkew== Date: Wed, 29 Nov 2017 17:21:17 +0000 Message-ID: <20171129172100.28819-21-alexander.levin@verizon.com> References: <20171129172100.28819-1-alexander.levin@verizon.com> In-Reply-To: <20171129172100.28819-1-alexander.levin@verizon.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-messagesentrepresentingtype: 1 x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.144.60.250] MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Roger Quadros [ Upstream commit 1551e35ea4189c1f7199fe278395fc94196715f2 ] On TI platforms (dra7, am437x), the DWC3_DSTS_DEVCTRLHLT bit is not set after the device controller is stopped via DWC3_DCTL_RUN_STOP. If we don't disconnect and stop the gadget, it stops working after a system resume with the trace below. There is no point in preventing gadget disconnect and gadget stop during system suspend/resume as we're going to suspend in any case, whether DEVCTRLHLT timed out or not. [ 141.727480] ------------[ cut here ]------------ [ 141.732349] WARNING: CPU: 1 PID: 2135 at drivers/usb/dwc3/gadget.c:2384 dwc3_stop_active_transfer.constprop.4+0xc4/0xe4 [dwc3] [ 141.744299] Modules linked in: usb_f_ss_lb g_zero libcomposite xhci_plat_hcd xhci_hcd usbcore dwc3 evdev udc_core m25p80 usb_common spi_nor snd_soc_davinci_mcasp snd_soc_simple_card snd_soc_edma snd_soc_tlv3e [ 141.792163] CPU: 1 PID: 2135 Comm: irq/456-dwc3 Not tainted 4.10.0-rc8 #1138 [ 141.799547] Hardware name: Generic DRA74X (Flattened Device Tree) [ 141.805940] [] (unwind_backtrace) from [] (show_stack+0x10/0x14) [ 141.814066] [] (show_stack) from [] (dump_stack+0xac/0xe0) [ 141.821648] [] (dump_stack) from [] (__warn+0xd8/0x104) [ 141.828955] [] (__warn) from [] (warn_slowpath_null+0x20/0x28) [ 141.836902] [] (warn_slowpath_null) from [] (dwc3_stop_active_transfer.constprop.4+0xc4/0xe4 [dwc3]) [ 141.848329] [] (dwc3_stop_active_transfer.constprop.4 [dwc3]) from [] (__dwc3_gadget_ep_disable+0x64/0x528 [dwc3]) [ 141.861034] [] (__dwc3_gadget_ep_disable [dwc3]) from [] (dwc3_gadget_ep_disable+0x3c/0xc8 [dwc3]) [ 141.872280] [] (dwc3_gadget_ep_disable [dwc3]) from [] (usb_ep_disable+0x11c/0x18c [udc_core]) [ 141.883160] [] (usb_ep_disable [udc_core]) from [] (disable_ep+0x18/0x54 [usb_f_ss_lb]) [ 141.893408] [] (disable_ep [usb_f_ss_lb]) from [] (disable_endpoints+0x18/0x50 [usb_f_ss_lb]) [ 141.904168] [] (disable_endpoints [usb_f_ss_lb]) from [] (disable_source_sink+0x2c/0x34 [usb_f_ss_lb]) [ 141.915771] [] (disable_source_sink [usb_f_ss_lb]) from [] (reset_config+0x48/0x7c [libcomposite]) [ 141.927012] [] (reset_config [libcomposite]) from [] (composite_disconnect+0x2c/0x54 [libcomposite]) [ 141.938444] [] (composite_disconnect [libcomposite]) from [] (usb_gadget_udc_reset+0x10/0x34 [udc_core]) [ 141.950237] [] (usb_gadget_udc_reset [udc_core]) from [] (dwc3_gadget_reset_interrupt+0x64/0x698 [dwc3]) [ 141.962022] [] (dwc3_gadget_reset_interrupt [dwc3]) from [] (dwc3_thread_interrupt+0x618/0x1a3c [dwc3]) [ 141.973723] [] (dwc3_thread_interrupt [dwc3]) from [] (irq_thread_fn+0x1c/0x54) [ 141.983215] [] (irq_thread_fn) from [] (irq_thread+0x120/0x1f0) [ 141.991247] [] (irq_thread) from [] (kthread+0xf8/0x138) [ 141.998641] [] (kthread) from [] (ret_from_fork+0x14/0x24) [ 142.006213] ---[ end trace b4ecfe9f175b9a9c ]--- Signed-off-by: Roger Quadros Signed-off-by: Felipe Balbi Signed-off-by: Sasha Levin --- drivers/usb/dwc3/gadget.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) -- 2.11.0 diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c index c61ddbf94bc7..16c67120d72b 100644 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c @@ -3092,15 +3092,10 @@ void dwc3_gadget_exit(struct dwc3 *dwc) int dwc3_gadget_suspend(struct dwc3 *dwc) { - int ret; - if (!dwc->gadget_driver) return 0; - ret = dwc3_gadget_run_stop(dwc, false, false); - if (ret < 0) - return ret; - + dwc3_gadget_run_stop(dwc, false, false); dwc3_disconnect_gadget(dwc); __dwc3_gadget_stop(dwc); From patchwork Wed Nov 29 17:21:20 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Levin, Alexander \(Sasha Levin\)" X-Patchwork-Id: 120037 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp3346179qgn; Wed, 29 Nov 2017 09:42:06 -0800 (PST) X-Google-Smtp-Source: AGs4zMYoaqbllAwsr2RVncGmjIsIFN4Qp0baXsMsZQNJoc/gYLk0ae6UlrzGhzjoMm+Cv4SYLm8k X-Received: by 10.98.215.19 with SMTP id b19mr3742820pfh.94.1511977325925; Wed, 29 Nov 2017 09:42:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511977325; cv=none; d=google.com; s=arc-20160816; b=SEYbXT/iVpHU7zUgyiDPEu4wNOkrbIDmu97/PpoXubGudsdx31QglhvjOjg3OG41Ar baVJ4PmfquUOjA6FUTQIE2XQQf8KmwAg8EUbow/ggzf3zog7BqLaQ46TEElu1hLu7Y/F 4IJIcz2JUl/qTZuYb8+9a47Dah0BuOMjUCRdVRfwWTuUTgVYL6pO2VCAFyn2q+J2BaSx e0qOgqNRCnNZ45AyIzA8j4iGmwQzAwVr1O3MshzT+uJVl8l2UU0OA+yT88NhzaB0/M8u jo2xQLrTjtLJ5R5BZT1ANzO0p8+F7SH5PBDeJvkyK1axZ55+xo/NBUmP23pN4OMWvUe/ lnNw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :content-language:accept-language:in-reply-to:references:message-id :date:thread-index:thread-topic:subject:to:cc:from:dkim-signature :dkim-signature:dkim-signature:arc-authentication-results; bh=Ahxgf2Ps2JgVHoRHc06HehYssx4Rh4bk2jdV/3nDV5o=; b=HOPabtKIXUvnjH/Yl+eyoUajsCguIgrEOFh5ONwLbM9PT8hkjk8WvMaK4/suFbfnvz A8nUgl7P3OkSId0HiiFTEooskffLDmrBQEbbTW8WsUE3YBdpiyUKkW6oJkThJk9FXYAl 5GS6lkxEeCnm0sh8davgXz5s9Il6o8rDEuJynlEPUAZ9Bfqou88oSQby4097RfEAgqFj vXiQkHq4TPqRzp4KikVbzoH0BIYo4gwaQi23ka/1uF3qvAEM4gU3rX6VZoehWnryk93R P/J7nkP9RBxFobGYaXMDHE3DG0z3s8Mi3gN2+9kLko/3vk8Z0xVPkP9CfLo+saNMH7sP WsQw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@verizon.com header.s=corp header.b=SNMQeufO; dkim=fail header.i=@verizon.com header.s=corp header.b=dLTubST1; dkim=fail header.i=@verizon.com header.s=corp header.b=d3PnrMjq; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=NONE dis=NONE) header.from=verizon.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q62si1705231pfd.99.2017.11.29.09.42.05; Wed, 29 Nov 2017 09:42:05 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@verizon.com header.s=corp header.b=SNMQeufO; dkim=fail header.i=@verizon.com header.s=corp header.b=dLTubST1; dkim=fail header.i=@verizon.com header.s=corp header.b=d3PnrMjq; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=NONE dis=NONE) header.from=verizon.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934842AbdK2RmD (ORCPT + 28 others); Wed, 29 Nov 2017 12:42:03 -0500 Received: from fldsmtpe03.verizon.com ([140.108.26.142]:46306 "EHLO fldsmtpe03.verizon.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754100AbdK2RWx (ORCPT ); Wed, 29 Nov 2017 12:22:53 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=verizon.com; i=@verizon.com; q=dns/txt; s=corp; t=1511976173; x=1543512173; h=from:cc:to:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=0jzyeUxil33jrO0VR4r0Yu68z377VtxAFwAVISkQZXY=; b=SNMQeufO1IyP1ug+25dA4GGUh8PTkrAY2KKyoCAgk6wkr7L6Dig008Xc JE2LBjaMIfEjFWfcJP2foDO9IDE74bpDwWekRZrSDwGKIHz3KwPRegfps D8CDkvr0AZL7HfVJmWwXmwtxobleFTm5xqN63IBWIFFuZL5f9vtkbGmh1 g=; Received: from unknown (HELO fldsmtpi03.verizon.com) ([166.68.71.145]) by fldsmtpe03.verizon.com with ESMTP; 29 Nov 2017 17:22:50 +0000 Received: from rogue-10-255-192-101.rogue.vzwcorp.com (HELO apollo.verizonwireless.com) ([10.255.192.101]) by fldsmtpi03.verizon.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 29 Nov 2017 17:22:04 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=verizon.com; i=@verizon.com; q=dns/txt; s=corp; t=1511976141; x=1543512141; h=from:cc:to:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=0jzyeUxil33jrO0VR4r0Yu68z377VtxAFwAVISkQZXY=; b=dLTubST1FMPdIMYgxtYIoHjCsedeyvczPkDJKGqjCApdjB2dzsVdKB9X ZAfEGjgVNL367UoaeI63FUG/GZo6yCPTkMOu7W/IvBWU1d3swlnnJJXDh qu/iKHTN5U5Z36C/1ET5sOdffPWSMxK1Uqz0lcpnHJEhlM6kBG/+j7q73 I=; Received: from mariner.tdc.vzwcorp.com (HELO eris.verizonwireless.com) ([10.254.88.84]) by apollo.verizonwireless.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 29 Nov 2017 12:22:02 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=verizon.com; i=@verizon.com; q=dns/txt; s=corp; t=1511976122; x=1543512122; h=to:subject:date:message-id:references:in-reply-to: content-transfer-encoding:mime-version:from:cc; bh=0jzyeUxil33jrO0VR4r0Yu68z377VtxAFwAVISkQZXY=; b=d3PnrMjq7u1T4RJguDyY2eSaTxMMjhzaABi7PmDSmn0+ffJNtJrcgODp nvavgafcwyDASnihuhqS2oQ5YhHDM7S6cW2aRURmuiqAD2a7wbPpU6Pk2 SpLGisn6oBBXUuAXVOhy57Oal9X6sVInjLpJ5aKcA3YrjCaPiZXI7AWM+ c=; From: alexander.levin@verizon.com Cc: Mark Rutland , Dave Martin , Suzuki K Poulose , Marc Zyngier , alexander.levin@verizon.com X-Host: mariner.tdc.vzwcorp.com Received: from ohtwi1exh003.uswin.ad.vzwcorp.com ([10.144.218.45]) by eris.verizonwireless.com with ESMTP/TLS/AES128-SHA256; 29 Nov 2017 17:22:02 +0000 Received: from OMZP1LUMXCA14.uswin.ad.vzwcorp.com (144.8.22.189) by OHTWI1EXH003.uswin.ad.vzwcorp.com (10.144.218.45) with Microsoft SMTP Server (TLS) id 14.3.248.2; Wed, 29 Nov 2017 12:22:02 -0500 Received: from OMZP1LUMXCA17.uswin.ad.vzwcorp.com (144.8.22.195) by OMZP1LUMXCA14.uswin.ad.vzwcorp.com (144.8.22.189) with Microsoft SMTP Server (TLS) id 15.0.1263.5; Wed, 29 Nov 2017 11:22:01 -0600 Received: from OMZP1LUMXCA17.uswin.ad.vzwcorp.com ([144.8.22.195]) by OMZP1LUMXCA17.uswin.ad.vzwcorp.com ([144.8.22.195]) with mapi id 15.00.1263.000; Wed, 29 Nov 2017 11:22:01 -0600 To: "linux-kernel@vger.kernel.org" , "stable@vger.kernel.org" Subject: [PATCH AUTOSEL for 4.9 31/52] arm: KVM: Survive unknown traps from guests Thread-Topic: [PATCH AUTOSEL for 4.9 31/52] arm: KVM: Survive unknown traps from guests Thread-Index: AQHTaTZ4GSkLFM5URE29Zwi+I0meVg== Date: Wed, 29 Nov 2017 17:21:20 +0000 Message-ID: <20171129172100.28819-31-alexander.levin@verizon.com> References: <20171129172100.28819-1-alexander.levin@verizon.com> In-Reply-To: <20171129172100.28819-1-alexander.levin@verizon.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-messagesentrepresentingtype: 1 x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.144.60.250] MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Mark Rutland [ Upstream commit f050fe7a9164945dd1c28be05bf00e8cfb082ccf ] Currently we BUG() if we see a HSR.EC value we don't recognise. As configurable disables/enables are added to the architecture (controlled by RES1/RES0 bits respectively), with associated synchronous exceptions, it may be possible for a guest to trigger exceptions with classes that we don't recognise. While we can't service these exceptions in a manner useful to the guest, we can avoid bringing down the host. Per ARM DDI 0406C.c, all currently unallocated HSR EC encodings are reserved, and per ARM DDI 0487A.k_iss10775, page G6-4395, EC values within the range 0x00 - 0x2c are reserved for future use with synchronous exceptions, and EC values within the range 0x2d - 0x3f may be used for either synchronous or asynchronous exceptions. The patch makes KVM handle any unknown EC by injecting an UNDEFINED exception into the guest, with a corresponding (ratelimited) warning in the host dmesg. We could later improve on this with with a new (opt-in) exit to the host userspace. Cc: Dave Martin Cc: Suzuki K Poulose Reviewed-by: Christoffer Dall Signed-off-by: Mark Rutland Signed-off-by: Marc Zyngier Signed-off-by: Sasha Levin --- arch/arm/include/asm/kvm_arm.h | 1 + arch/arm/kvm/handle_exit.c | 19 ++++++++++++------- 2 files changed, 13 insertions(+), 7 deletions(-) -- 2.11.0 diff --git a/arch/arm/include/asm/kvm_arm.h b/arch/arm/include/asm/kvm_arm.h index e22089fb44dc..a3f0b3d50089 100644 --- a/arch/arm/include/asm/kvm_arm.h +++ b/arch/arm/include/asm/kvm_arm.h @@ -209,6 +209,7 @@ #define HSR_EC_IABT_HYP (0x21) #define HSR_EC_DABT (0x24) #define HSR_EC_DABT_HYP (0x25) +#define HSR_EC_MAX (0x3f) #define HSR_WFI_IS_WFE (_AC(1, UL) << 0) diff --git a/arch/arm/kvm/handle_exit.c b/arch/arm/kvm/handle_exit.c index 066b6d4508ce..42f5daf715d0 100644 --- a/arch/arm/kvm/handle_exit.c +++ b/arch/arm/kvm/handle_exit.c @@ -79,7 +79,19 @@ static int kvm_handle_wfx(struct kvm_vcpu *vcpu, struct kvm_run *run) return 1; } +static int kvm_handle_unknown_ec(struct kvm_vcpu *vcpu, struct kvm_run *run) +{ + u32 hsr = kvm_vcpu_get_hsr(vcpu); + + kvm_pr_unimpl("Unknown exception class: hsr: %#08x\n", + hsr); + + kvm_inject_undefined(vcpu); + return 1; +} + static exit_handle_fn arm_exit_handlers[] = { + [0 ... HSR_EC_MAX] = kvm_handle_unknown_ec, [HSR_EC_WFI] = kvm_handle_wfx, [HSR_EC_CP15_32] = kvm_handle_cp15_32, [HSR_EC_CP15_64] = kvm_handle_cp15_64, @@ -98,13 +110,6 @@ static exit_handle_fn kvm_get_exit_handler(struct kvm_vcpu *vcpu) { u8 hsr_ec = kvm_vcpu_trap_get_class(vcpu); - if (hsr_ec >= ARRAY_SIZE(arm_exit_handlers) || - !arm_exit_handlers[hsr_ec]) { - kvm_err("Unknown exception class: hsr: %#08x\n", - (unsigned int)kvm_vcpu_get_hsr(vcpu)); - BUG(); - } - return arm_exit_handlers[hsr_ec]; } From patchwork Wed Nov 29 17:21:20 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Levin, Alexander \(Sasha Levin\)" X-Patchwork-Id: 120039 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp3355602qgn; Wed, 29 Nov 2017 09:51:10 -0800 (PST) X-Google-Smtp-Source: AGs4zMaMP/gZbS3dMjaH0azvnNf3G8RQOLdWKgTIABaDrV9inH49nVOOO1YhnIE8KxMbm/KneeM5 X-Received: by 10.84.198.67 with SMTP id o61mr3552453pld.261.1511977870427; Wed, 29 Nov 2017 09:51:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511977870; cv=none; d=google.com; s=arc-20160816; b=Y2F0zlKlJ7Bjd+69YNjBIFqO6SEHyqJSOyFbuGN/KeTDHQTGQdg0tLfteZED704Pd3 ifej4xf+jkIYghUomu4wQ2PAnmXKnz4rmqU1+p57//lZxS+s1ItkN4l9v4Z7NNwePDpO Bex1PD3ltuegvJyaGGbCHtAgiG1Ktr9/X15xVmA/Ebu1T8sTQa2AvZn8vEH67TuiHNeH IcWfoc5MsqBobIiUM/KssDYTTYlaraIPghU1CR2y1oSNDaDtXKJMjhC/hOgK4kEteLXA absxHMvUOiD7vWuAwfrqfLT7DVVUsqN9pKOF8RGowG3wKmFxIoxeAl//T9l5muBadzfu rBJg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :content-language:accept-language:in-reply-to:references:message-id :date:thread-index:thread-topic:subject:to:cc:from:dkim-signature :dkim-signature:dkim-signature:arc-authentication-results; bh=HPwc+TjdPqQl0S0RjTxxxW04J+A8j9v6hdsISWYcv6g=; b=MR2BL845tczJwQPG6cB0p54x14PQhmIRUC4IbqUlTywVR0wBRuj6xwN6HMfaO2/pbN FsJFuGGtsZCZh+Bfq9Db7cSyTgodesAOD2hwwZ0NGGXQKs8YpATHZozKSkN+SMuDP8V2 RhJgyRC8lBFQvCvBN23vHE/wpiQY2BJ0rgJpqq1VI3H5YkO66CRnTMxqLBDn/sdeAt7R FgqB28xBqbelGV/EPTa/CMslmagoDVr1oaM/MsyCoBECpqhyM+eK/H7YapOA3NqH5yo+ WzJgXWjQ4hs6xOm1VDBmLDDRca/0dZa9QaR8SS/RmEoIbREAUXokRtQp9Ro8CSj8Nhy1 zjHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@verizon.com header.s=corp header.b=WVqJgcMv; dkim=fail header.i=@verizon.com header.s=corp header.b=hDh7BJi1; dkim=fail header.i=@verizon.com header.s=corp header.b=BsKBkmzq; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=NONE dis=NONE) header.from=verizon.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w2si1580058pgc.754.2017.11.29.09.51.10; Wed, 29 Nov 2017 09:51:10 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@verizon.com header.s=corp header.b=WVqJgcMv; dkim=fail header.i=@verizon.com header.s=corp header.b=hDh7BJi1; dkim=fail header.i=@verizon.com header.s=corp header.b=BsKBkmzq; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=NONE dis=NONE) header.from=verizon.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934778AbdK2RvI (ORCPT + 28 others); Wed, 29 Nov 2017 12:51:08 -0500 Received: from omzsmtpe02.verizonbusiness.com ([199.249.25.209]:10293 "EHLO omzsmtpe02.verizonbusiness.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933971AbdK2RWT (ORCPT ); Wed, 29 Nov 2017 12:22:19 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=verizon.com; i=@verizon.com; q=dns/txt; s=corp; t=1511976139; x=1543512139; h=from:cc:to:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=x+kKlI912bvlmDmAzhO0NiBbLUIDtg6Tw3U3fm0VKXk=; b=WVqJgcMvzy4dEaod1i2XGe/+tS+Cg3oW8rkxI1aaWz7mZmTXUXbrav5x vVCydG9QE3IM/r43FxNJ0+uNqT6XV4BhnH1/VgO6dF+K1kRcbdknbzmNa AwJWlvco8zNye94NZfoNEeypXwMPNe4gpDRO0tbnhMA+NCF7K6xpMF4yC Y=; Received: from unknown (HELO fldsmtpi02.verizon.com) ([166.68.71.144]) by omzsmtpe02.verizonbusiness.com with ESMTP; 29 Nov 2017 17:22:06 +0000 Received: from rogue-10-255-192-101.rogue.vzwcorp.com (HELO apollo.verizonwireless.com) ([10.255.192.101]) by fldsmtpi02.verizon.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 29 Nov 2017 17:22:04 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=verizon.com; i=@verizon.com; q=dns/txt; s=corp; t=1511976124; x=1543512124; h=from:cc:to:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=x+kKlI912bvlmDmAzhO0NiBbLUIDtg6Tw3U3fm0VKXk=; b=hDh7BJi1GJTG6BoZs2Uk3I0kH0aK/GUDjPOw5FKJiBG79SVLmJMr6dfz HmEa2u3bNRk2wkxL4Kb12RwKmbPROWQXX0LqcbGlzC8CuLBp/498E1VrA 3IkMwAaYfuVIIdiBJkf78A/y9YuYOb7dnMNVJQnMHG/xPX7MLMeWzQAse E=; Received: from mariner.tdc.vzwcorp.com (HELO eris.verizonwireless.com) ([10.254.88.84]) by apollo.verizonwireless.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 29 Nov 2017 12:22:03 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=verizon.com; i=@verizon.com; q=dns/txt; s=corp; t=1511976123; x=1543512123; h=to:subject:date:message-id:references:in-reply-to: content-transfer-encoding:mime-version:from:cc; bh=x+kKlI912bvlmDmAzhO0NiBbLUIDtg6Tw3U3fm0VKXk=; b=BsKBkmzquh/4hwuT9VUNbEm20cuKocS6SA+57amUD7lv/oyUTb0DD9Hb Wp+Pk9QkTEnDx87BDK+RDK/jp1ryyzIOdXHkxGzA7+xqdTt8WH2sRrCUq 8zlgnHFJqJ0Iy+Ae02yfmQ2SgMWGqCFIl/0wW/UuKEJuPds36KyiFgFAk w=; From: alexander.levin@verizon.com Cc: Mark Rutland , Dave Martin , Suzuki K Poulose , Marc Zyngier , alexander.levin@verizon.com X-Host: mariner.tdc.vzwcorp.com Received: from ohtwi1exh003.uswin.ad.vzwcorp.com ([10.144.218.45]) by eris.verizonwireless.com with ESMTP/TLS/AES128-SHA256; 29 Nov 2017 17:22:03 +0000 Received: from tbwexch25apd.uswin.ad.vzwcorp.com (153.114.162.49) by OHTWI1EXH003.uswin.ad.vzwcorp.com (10.144.218.45) with Microsoft SMTP Server (TLS) id 14.3.248.2; Wed, 29 Nov 2017 12:22:03 -0500 Received: from OMZP1LUMXCA17.uswin.ad.vzwcorp.com (144.8.22.195) by tbwexch25apd.uswin.ad.vzwcorp.com (153.114.162.49) with Microsoft SMTP Server (TLS) id 15.0.1263.5; Wed, 29 Nov 2017 12:22:02 -0500 Received: from OMZP1LUMXCA17.uswin.ad.vzwcorp.com (144.8.22.195) by OMZP1LUMXCA17.uswin.ad.vzwcorp.com (144.8.22.195) with Microsoft SMTP Server (TLS) id 15.0.1263.5; Wed, 29 Nov 2017 11:22:02 -0600 Received: from OMZP1LUMXCA17.uswin.ad.vzwcorp.com ([144.8.22.195]) by OMZP1LUMXCA17.uswin.ad.vzwcorp.com ([144.8.22.195]) with mapi id 15.00.1263.000; Wed, 29 Nov 2017 11:22:02 -0600 To: "linux-kernel@vger.kernel.org" , "stable@vger.kernel.org" Subject: [PATCH AUTOSEL for 4.9 32/52] arm64: KVM: Survive unknown traps from guests Thread-Topic: [PATCH AUTOSEL for 4.9 32/52] arm64: KVM: Survive unknown traps from guests Thread-Index: AQHTaTZ5wtew0EzS3k2bOZLUJW0wzw== Date: Wed, 29 Nov 2017 17:21:20 +0000 Message-ID: <20171129172100.28819-32-alexander.levin@verizon.com> References: <20171129172100.28819-1-alexander.levin@verizon.com> In-Reply-To: <20171129172100.28819-1-alexander.levin@verizon.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-messagesentrepresentingtype: 1 x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.144.60.250] MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Mark Rutland [ Upstream commit ba4dd156eabdca93501d92a980ba27fa5f4bbd27 ] Currently we BUG() if we see an ESR_EL2.EC value we don't recognise. As configurable disables/enables are added to the architecture (controlled by RES1/RES0 bits respectively), with associated synchronous exceptions, it may be possible for a guest to trigger exceptions with classes that we don't recognise. While we can't service these exceptions in a manner useful to the guest, we can avoid bringing down the host. Per ARM DDI 0487A.k_iss10775, page D7-1937, EC values within the range 0x00 - 0x2c are reserved for future use with synchronous exceptions, and EC values within the range 0x2d - 0x3f may be used for either synchronous or asynchronous exceptions. The patch makes KVM handle any unknown EC by injecting an UNDEFINED exception into the guest, with a corresponding (ratelimited) warning in the host dmesg. We could later improve on this with with a new (opt-in) exit to the host userspace. Cc: Dave Martin Cc: Suzuki K Poulose Reviewed-by: Christoffer Dall Signed-off-by: Mark Rutland Signed-off-by: Marc Zyngier Signed-off-by: Sasha Levin --- arch/arm64/kvm/handle_exit.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) -- 2.11.0 diff --git a/arch/arm64/kvm/handle_exit.c b/arch/arm64/kvm/handle_exit.c index a204adf29f0a..85baadab02d3 100644 --- a/arch/arm64/kvm/handle_exit.c +++ b/arch/arm64/kvm/handle_exit.c @@ -125,7 +125,19 @@ static int kvm_handle_guest_debug(struct kvm_vcpu *vcpu, struct kvm_run *run) return ret; } +static int kvm_handle_unknown_ec(struct kvm_vcpu *vcpu, struct kvm_run *run) +{ + u32 hsr = kvm_vcpu_get_hsr(vcpu); + + kvm_pr_unimpl("Unknown exception class: hsr: %#08x -- %s\n", + hsr, esr_get_class_string(hsr)); + + kvm_inject_undefined(vcpu); + return 1; +} + static exit_handle_fn arm_exit_handlers[] = { + [0 ... ESR_ELx_EC_MAX] = kvm_handle_unknown_ec, [ESR_ELx_EC_WFx] = kvm_handle_wfx, [ESR_ELx_EC_CP15_32] = kvm_handle_cp15_32, [ESR_ELx_EC_CP15_64] = kvm_handle_cp15_64, @@ -151,13 +163,6 @@ static exit_handle_fn kvm_get_exit_handler(struct kvm_vcpu *vcpu) u32 hsr = kvm_vcpu_get_hsr(vcpu); u8 hsr_ec = ESR_ELx_EC(hsr); - if (hsr_ec >= ARRAY_SIZE(arm_exit_handlers) || - !arm_exit_handlers[hsr_ec]) { - kvm_err("Unknown exception class: hsr: %#08x -- %s\n", - hsr, esr_get_class_string(hsr)); - BUG(); - } - return arm_exit_handlers[hsr_ec]; }