Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp7614671rwn; Wed, 14 Sep 2022 01:19:22 -0700 (PDT) X-Google-Smtp-Source: AA6agR6iZuXQ5jGxBePMooGJM1wHbqmup7bXgoy0lf+wxG1N3edDpfeFfwv8vgz4vALnlKLOE9Z6 X-Received: by 2002:a17:907:eaa:b0:772:b571:bd7c with SMTP id ho42-20020a1709070eaa00b00772b571bd7cmr21218986ejc.563.1663143562179; Wed, 14 Sep 2022 01:19:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663143562; cv=none; d=google.com; s=arc-20160816; b=wx/GpV0vQpkSQ0zjRLVg4+OplLj5+2IDZ0yUtOnaVE+hHkRSlF6jlwVaxl2lOglRdQ +0E4dnJFBAoLZPpK9qv62GzzYAZ5OhvgFH3ns/WBl3Njv0fx08ocFgguetm0FswDmyOt MLbmMjUbH+xhZuJi6vzH/2qsXcAo/rxtipzAIhSJXSlazw5RX5wJm8fcmt+T21d++TPD yZNzF5fWZDOF5duajxC/2XP3SJI2eXyAUV5AjbrFciCFTb36X2lPtW7Z7vEUvggLCUpv JZlg5GMczpalrkfxPTkFEqUoGxBp8pB3t4rDe04GtwKXp35IbQ00Z3W3lSN+Xke7ZLEG 8bUQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-disposition:mime-version:message-id :subject:cc:to:from:date; bh=KGMak7+tPhK/SxKFG7I+1a9kwONyucBvx/VXcFgVICA=; b=f8HxekdW1HLu41UBqITmotAYw5d5In7q26OyPPRvOYsF5geua+8+4F1Nwa72Ooqw10 F2l/ZvIQUg4Y1pfLOUZZq+XM53+kd0fowX8YfNn64kdwGYQHFcQ7OT3BlQOYWOKWnrwh c5VytL3NvZ0LMZoQjpTQnC98+KkksMD1GJolHTM8mdFwwvN6lT/xKiDkwpBmOKhgHHCP J2ChsXqE9I5HYj1asAo7tA1Tm12kTJGj5Hs4ncw6VigNOQ+9/TWKqWvqPFbScdBgIP2a B1q9HZ1g7JfmE4ndQKF1FNul+zV9Jobo8h5dp1ahUaC32Htqm7Wpt/ZwGgDm9cDUy0f9 0DXg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p12-20020a170906784c00b00741a0720a2dsi1725520ejm.776.2022.09.14.01.18.56; Wed, 14 Sep 2022 01:19:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229989AbiINHPH (ORCPT + 99 others); Wed, 14 Sep 2022 03:15:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40078 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229590AbiINHPG (ORCPT ); Wed, 14 Sep 2022 03:15:06 -0400 Received: from mail.wantstofly.org (hmm.wantstofly.org [213.239.204.108]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 74DB861719 for ; Wed, 14 Sep 2022 00:15:04 -0700 (PDT) Received: by mail.wantstofly.org (Postfix, from userid 1000) id 156187F54E; Wed, 14 Sep 2022 10:15:02 +0300 (EEST) Date: Wed, 14 Sep 2022 10:15:02 +0300 From: Lennert Buytenhek To: Greg Kroah-Hartman , Jiri Slaby , Andy Shevchenko Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org Subject: I/O page faults from 8250_mid PCIe UART after TIOCVHANGUP Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On an Intel SoC with several 8250_mid PCIe UARTs built into the CPU, I can reliably trigger I/O page faults if I invoke TIOCVHANGUP on any of the UARTs and then re-open that UART. Invoking TIOCVHANGUP appears to clear the MSI address/data registers in the UART via tty_ioctl() -> tty_vhangup() -> __tty_hangup() -> uart_hangup() -> uart_shutdown() -> uart_port_shutdown() -> univ8250_release_irq() -> free_irq() -> irq_domain_deactivate_irq() -> __irq_domain_deactivate_irq() -> msi_domain_deactivate() -> __pci_write_msi_msg(): [root@icelake ~]# lspci -s 00:1a.0 -vv | grep -A1 MSI: Capabilities: [40] MSI: Enable+ Count=1/1 Maskable- 64bit- Address: fee00278 Data: 0000 [root@icelake ~]# cat hangup.c #include #include int main(int argc, char *argv[]) { ioctl(1, TIOCVHANGUP); return 0; } [root@icelake ~]# gcc -Wall -o hangup hangup.c [root@icelake ~]# ./hangup > /dev/ttyS4 [root@icelake ~]# lspci -s 00:1a.0 -vv | grep -A1 MSI: Capabilities: [40] MSI: Enable+ Count=1/1 Maskable- 64bit- Address: 00000000 Data: 0000 [root@icelake ~]# Opening the serial port device again while the UART is in this state then appears to cause the UART to generate an interrupt before the MSI vector has been set up again, causing a DMA write to I/O virtual address zero: [root@icelake console]# echo > /dev/ttyS4 [ 979.463307] DMAR: DRHD: handling fault status reg 3 [ 979.469409] DMAR: [DMA Write NO_PASID] Request device [00:1a.0] fault addr 0x0 [fault reason 0x05] PTE Write access is not set I'm guessing there's something under tty_open() -> uart_open() -> tty_port_open() -> uart_port_activate() -> uart_port_startup() -> serial8250_do_startup() that triggers a UART interrupt before the MSI vector has been set up again. I did a quick search but it didn't seem like this is a known issue. Thanks, Lennert