From patchwork Tue Feb 20 08:52:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 13563622 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id AE0A1C48BC3 for ; Tue, 20 Feb 2024 08:52:59 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.683258.1062696 (Exim 4.92) (envelope-from ) id 1rcLrw-0002FI-SD; Tue, 20 Feb 2024 08:52:52 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 683258.1062696; Tue, 20 Feb 2024 08:52:52 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rcLrw-0002FB-PZ; Tue, 20 Feb 2024 08:52:52 +0000 Received: by outflank-mailman (input) for mailman id 683258; Tue, 20 Feb 2024 08:52:51 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rcLrv-0002F1-Gq for xen-devel@lists.xenproject.org; Tue, 20 Feb 2024 08:52:51 +0000 Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [2a00:1450:4864:20::42a]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 6cb49d55-cfcd-11ee-98f5-efadbce2ee36; Tue, 20 Feb 2024 09:52:49 +0100 (CET) Received: by mail-wr1-x42a.google.com with SMTP id ffacd0b85a97d-33d066f8239so2400258f8f.1 for ; Tue, 20 Feb 2024 00:52:49 -0800 (PST) Received: from [10.156.60.236] (ip-037-024-206-209.um08.pools.vodafone-ip.de. [37.24.206.209]) by smtp.gmail.com with ESMTPSA id w14-20020adfcd0e000000b0033d14c96ec1sm12607957wrm.45.2024.02.20.00.52.48 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 20 Feb 2024 00:52:48 -0800 (PST) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 6cb49d55-cfcd-11ee-98f5-efadbce2ee36 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1708419169; x=1709023969; darn=lists.xenproject.org; h=content-transfer-encoding:in-reply-to:autocrypt:references:cc:to :from:content-language:subject:user-agent:mime-version:date :message-id:from:to:cc:subject:date:message-id:reply-to; bh=WRod7K1c22IPHMjkp91uZ7nODYMwBBoK3lXCfwDbDuI=; b=aip4Y3F4NXVJyTTIb7c3oEiYSHFXiNPPMpPIodVp2NvONU59jEPhAPeSaFufdP4Ycf n9CMY4agsSxSchxxvFGKbhpgtBHpAkyJBW2LanWGbxIstkAbNzY7zk8WyLmqHJGS19Yn qUmN+mnxkWyDsQhqZ+fLykn/EVKzpxefFIvKbxlGYmLWCYIbWemLa73uQ17PDBHCTu3m 2DT+lW6CTSAJfa+b0X2FnhLg8zQCn8vOo6R3oytd/eRM4o5TPiSmp8dPD4TimbvuUHJ6 Rj2fi4ohng09hYDr16M8a204AWYPOcDTbPQ+lJ0XbSRAogYEon0qd/F/YNvLFWKGNxTn 4sJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708419169; x=1709023969; h=content-transfer-encoding:in-reply-to:autocrypt:references:cc:to :from:content-language:subject:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=WRod7K1c22IPHMjkp91uZ7nODYMwBBoK3lXCfwDbDuI=; b=nVOkmC3rAmBAnua82VXcDik0rLfBcOgft4ZVaMT4P9w6vDWioZ0MMgtDVYSnUHloDJ g+5PIvP1ekKCyeZP/TIJrBOAFbe8J6OfET91ywpufwX/BWMDtJh5oGPLzTYB27kGn1gW 3ZOXG67dtbRhwxA02zMSIw8gcc/ZjWNtBW76eA2MavNiVB2SRuTis7lvXPGbjUyAGK0O EOy4hbZY1+sHnXnnxenBmzabiQNWjFzbdl3TnIeGGBKcwyhkMadvx5gJFGew2kEg5p2P UoA09iYmqmhVmp5TAVc/1Mozi++3hHVZIOnzV42RSA3wI7lVnSAHnvNGN7wBMGFfAqfK uo9Q== X-Gm-Message-State: AOJu0YwDyq5YVUi42HJEV9VhgyCWu7fxa/ddB33WEZlt/nhs1cH5LtuD RHHjiRUJjfkRFTfXSZqshWUS1PE76g8rpcGL4yEMENm7L2WJqUpGCu5fsgK7XZ4AyF/NOkF2PoA = X-Google-Smtp-Source: AGHT+IEpHdJFuqVJhMhY5pj5+YOKKSzQlBfKrUOA5rRUTJ7UfOR2TR9gjLx4gSRka+z2g1v92KZ+7w== X-Received: by 2002:adf:e450:0:b0:33b:60ca:269f with SMTP id t16-20020adfe450000000b0033b60ca269fmr9573558wrm.43.1708419169003; Tue, 20 Feb 2024 00:52:49 -0800 (PST) Message-ID: Date: Tue, 20 Feb 2024 09:52:48 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH v4 1/8] serial: fake IRQ-regs context in poll handlers Content-Language: en-US From: Jan Beulich To: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , George Dunlap , Julien Grall , Stefano Stabellini , Wei Liu References: Autocrypt: addr=jbeulich@suse.com; keydata= xsDiBFk3nEQRBADAEaSw6zC/EJkiwGPXbWtPxl2xCdSoeepS07jW8UgcHNurfHvUzogEq5xk hu507c3BarVjyWCJOylMNR98Yd8VqD9UfmX0Hb8/BrA+Hl6/DB/eqGptrf4BSRwcZQ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V2WZsUMlnDL9 mpwIGFhlbM3gfDMs7MPMu8YQRFVdUvtSpaAs8OFfGQ0ia3LGZcjA6Ik2+xcqscEJzNH+qh8V m5jjp28yZgaqTaRbg3M/+MTbMpicpZuqF4rnB0AQD12/3BNWDR6bmh+EkYSMcEIpQmBM51qM EKYTQGybRCjpnKHGOxG0rfFY1085mBDZCH5Kx0cl0HVJuQKC+dV2ZY5AqjcKwAxpE75MLFkr wkkEGBECAAkFAlk3nEQCGwwACgkQoDSui/t3IH7nnwCfcJWUDUFKdCsBH/E5d+0ZnMQi+G0A nAuWpQkjM1ASeQwSHEeAWPgskBQL In-Reply-To: In preparation of dropping the register parameters from serial_[rt]x_interrupt() and in turn from IRQ handler functions, register state needs making available another way for the few key handlers which need it. Fake IRQ-like state. Signed-off-by: Jan Beulich Reviewed-by: Julien Grall --- The use of guest_cpu_user_regs() in dbc_uart_poll() is inconsistent with other console poll functions we have, and it's unclear whether that's actually generally correct. It is only for this reason that it doesn't need changing here. Andrew suggested to move set_irq_regs() to BUGFRAME_run_fn handling; it's not clear to me whether that would be (a) correct from an abstract pov (that's exception, not interrupt context after all) and (b) really beneficial. --- v4: Drop xhci-dbc.c change as unnecessary with dump_registers() falling back to using guest_cpu_user_regs() as of patch 2, i.e. ahead of serial_rx_interrupt() having its 2nd parameter dropped. v2: New. --- a/xen/drivers/char/ehci-dbgp.c +++ b/xen/drivers/char/ehci-dbgp.c @@ -1253,6 +1253,7 @@ static void cf_check _ehci_dbgp_poll(str unsigned long flags; unsigned int timeout = MICROSECS(DBGP_CHECK_INTERVAL); bool empty = false; + struct cpu_user_regs *old_regs; if ( !dbgp->ehci_debug ) return; @@ -1268,12 +1269,17 @@ static void cf_check _ehci_dbgp_poll(str spin_unlock_irqrestore(&port->tx_lock, flags); } + /* Mimic interrupt context. */ + old_regs = set_irq_regs(regs); + if ( dbgp->in.chunk ) serial_rx_interrupt(port, regs); if ( empty ) serial_tx_interrupt(port, regs); + set_irq_regs(old_regs); + if ( spin_trylock_irqsave(&port->tx_lock, flags) ) { if ( dbgp->state == dbgp_idle && !dbgp->in.chunk && --- a/xen/drivers/char/ns16550.c +++ b/xen/drivers/char/ns16550.c @@ -211,10 +211,14 @@ static void cf_check __ns16550_poll(stru { struct serial_port *port = this_cpu(poll_port); struct ns16550 *uart = port->uart; + struct cpu_user_regs *old_regs; if ( uart->intr_works ) return; /* Interrupts work - no more polling */ + /* Mimic interrupt context. */ + old_regs = set_irq_regs(regs); + while ( ns_read_reg(uart, UART_LSR) & UART_LSR_DR ) { if ( ns16550_ioport_invalid(uart) ) @@ -227,6 +231,7 @@ static void cf_check __ns16550_poll(stru serial_tx_interrupt(port, regs); out: + set_irq_regs(old_regs); set_timer(&uart->timer, NOW() + MILLISECS(uart->timeout_ms)); }