From nobody Mon Jun 15 06:26:17 2026 Received: from mail-pf1-f181.google.com (mail-pf1-f181.google.com [209.85.210.181]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E3A3737CD5D for ; Wed, 8 Apr 2026 12:01:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775649720; cv=none; b=pUJ9zH9r4AqLCtFKI2VBnlL1nHzVJ7SLIAAsYvGTIyoGKBc3ISNALHnng/n6o/6uYJB7F6AqmqLaeFNU7WXvDu83LUqThhgU1tsgH71Odx8dHNaFCF5t9GqWM5XN8+AhEukKjZgLU2zARBOGWYyETTPHewbYJ0Pw2wt7LBOr0zc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775649720; c=relaxed/simple; bh=9NbnFzTEGh6+lE1PwksEW7af7i8jzYb/dCKoYyURmxQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=phOqv5gHXgV3tv1oMexLJ+qrpf0ZoE0O/WtTocj+ZaKEfOuqbthzc9Jzn+wSfFO+51bPcw70gGkPVmXJ4JuyJufqM9EjxWC0aw5N6M7iz3Q/ICs3ey5OMFumd51mCbGi5oiLkMjDlbgSJObF9aQmWhjeOszasiifVqUoPF9uPFg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=FcozcVtG; arc=none smtp.client-ip=209.85.210.181 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="FcozcVtG" Received: by mail-pf1-f181.google.com with SMTP id d2e1a72fcca58-82ce0a9b3f7so2614204b3a.0 for ; Wed, 08 Apr 2026 05:01:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1775649718; x=1776254518; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=PYNm6J9AhUQ6HT8V6B6W7Iuh7E+aasxrExqJ2exyz7U=; b=FcozcVtG9cxE+N635I6r7uMJ3TvmOLaFn35Phn8ibNkhGn3TjmDONgqxtA9W+dwdvB /AAawq1I4g/JIrlXTMFmFRmpGBb0unoUhbUV6F3jYboi83haRf+vUeWbk8D+Q3gH7sbv 6lFzn3z0h+drRLHGKyllmRKbqEm9/95tcMilqGJoG+xHqlCH0PSVMnv6I20KQlUQRUZI EhqbTglBZIubP6SBiOi0aUmbjZPYbiJ6COHfIVGt7Y9x9o9j226uO5biv6wuepQm6SLN 4nBM7TvNRC//zIWStfk5brec6BIhh5a/XAkOGKq7/WLmsN901gz6J1Pwa3/l4/mU6+DG +uOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775649718; x=1776254518; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=PYNm6J9AhUQ6HT8V6B6W7Iuh7E+aasxrExqJ2exyz7U=; b=tPpdr94I72BHlbG0U6AiJEo1t4JrIWn07FlN0V73Wd4agDXY9aoREquTF/6/jcTGKt zakCi1pYB4vKRtw4oIFDhRHC91K15nrwh60LpRFCs7B1agb6LhauOFdzPPl5O3ag4HUv gySqSGPJLxBKoCnb+28d0pPk15/eaXKy57STM4Cdc28IkgP9dSlxZ6rYu/SnV4XK1TEQ NHhn/w2YiPdHxxOk4qm848T/BulCe9Ddl+VX4irpgSvd/xVL98LZfUGzQ19kI53VFKDd zLnt9NTp035I6AzRe7s0e7hKafe5Bwc4ehWvHDL3SQnrxO2blL0NfdM0tmvHNE3JqE08 gdLg== X-Forwarded-Encrypted: i=1; AJvYcCXume9MAhRIBCd0DZkjZbVNNIwdP7WcmcixPY0eRm2heqdGlBhJa+M29L1+1JW6BdqbS0ORP56rPbpIQfQ=@vger.kernel.org X-Gm-Message-State: AOJu0YzmFfhkuKC47WSZGmM4D4UNQvu+6+5TQbGEurv2ypBDg4oqExqz MUWZC438o2CHb3epmEtD9G22z9B4WEZ71e2TcwaXt1eg37EuC5r28gwDTtmPvw== X-Gm-Gg: AeBDiev8ceAh3dwCm9EAPz43Bdt132e5Rzrs063blFOOfnw2F51f5TL8OfuJoyxQgHv d9x6ooGkd9B2qCWS/mCFgVvueHnG6K8kFoxBO7+dv4H74VYIjjTZbWYQqa+EACKOS7wmBH9Xn8c XDchsTnV9NI9X5R7Do+2zNEDwBJoiFR/DKLUsu+e+xsn6Avl7klJ11UFHSrFoSfNSI5UUp3jJms cmB5yBtfovFetyp847iFExx/wowKE8DyGGeatfaK7FoIQ4GVGdw1hdj+QJn5N1rsaun7aH+KHgt TAGB5qav5bpi+Ix21142PwmijU8GH5jnciv5Gd2eXIG1Pe4TrD9yKhXkDbNbOXIHBpEWj9t7DHW auqw3xO6HBw0Te94msSSbnZBHUauXjCJj95moGQskWlEyR8tnF+zF5d3SsmxdY1mCNpRiLxa7iW lAtvB4T8yxAAi6aek/enb++nNI5CXv/KRKFZhokBrZhCvy X-Received: by 2002:a05:6a00:92a9:b0:82c:ed02:a242 with SMTP id d2e1a72fcca58-82d0dc05906mr20919689b3a.52.1775649718138; Wed, 08 Apr 2026 05:01:58 -0700 (PDT) Received: from Mac.localdomain ([49.205.216.49]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-82cf9b3e169sm21209322b3a.18.2026.04.08.05.01.54 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 08 Apr 2026 05:01:57 -0700 (PDT) From: "Ritesh Harjani (IBM)" To: linuxppc-dev@lists.ozlabs.org, Haren Myneni Cc: Madhavan Srinivasan , Christophe Leroy , Venkat Rao Bagalkote , Nicholas Piggin , linux-kernel@vger.kernel.org, "Ritesh Harjani (IBM)" , stable@vger.kernel.org Subject: [RFC v2 01/10] pseries/papr-hvpipe: Fix race with interrupt handler Date: Wed, 8 Apr 2026 17:31:31 +0530 Message-ID: <54c52b89a626627aa57191b67a3ee22710b46f7f.1775648406.git.ritesh.list@gmail.com> X-Mailer: git-send-email 2.50.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" While executing ->ioctl handler or ->release handler, if an interrupt fires on the same cpu, then we can enter into a deadlock. This patch fixes both these handlers to take spin_lock_irq{save|restore} versions of the lock to prevent this deadlock. Cc: stable@vger.kernel.org Fixes: 814ef095f12c9 ("powerpc/pseries: Add papr-hvpipe char driver for HVP= IPE interfaces") Signed-off-by: Ritesh Harjani (IBM) --- arch/powerpc/platforms/pseries/papr-hvpipe.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/arch/powerpc/platforms/pseries/papr-hvpipe.c b/arch/powerpc/pl= atforms/pseries/papr-hvpipe.c index 14ae480d060a..c41d45e1986d 100644 --- a/arch/powerpc/platforms/pseries/papr-hvpipe.c +++ b/arch/powerpc/platforms/pseries/papr-hvpipe.c @@ -444,13 +444,14 @@ static int papr_hvpipe_handle_release(struct inode *i= node, struct file *file) { struct hvpipe_source_info *src_info; + unsigned long flags; =20 /* * Hold the lock, remove source from src_list, reset the * hvpipe status and release the lock to prevent any race * with message event IRQ. */ - spin_lock(&hvpipe_src_list_lock); + spin_lock_irqsave(&hvpipe_src_list_lock, flags); src_info =3D file->private_data; list_del(&src_info->list); file->private_data =3D NULL; @@ -461,10 +462,10 @@ static int papr_hvpipe_handle_release(struct inode *i= node, */ if (src_info->hvpipe_status & HVPIPE_MSG_AVAILABLE) { src_info->hvpipe_status =3D 0; - spin_unlock(&hvpipe_src_list_lock); + spin_unlock_irqrestore(&hvpipe_src_list_lock, flags); hvpipe_rtas_recv_msg(NULL, 0); } else - spin_unlock(&hvpipe_src_list_lock); + spin_unlock_irqrestore(&hvpipe_src_list_lock, flags); =20 kfree(src_info); return 0; @@ -480,20 +481,21 @@ static const struct file_operations papr_hvpipe_handl= e_ops =3D { static int papr_hvpipe_dev_create_handle(u32 srcID) { struct hvpipe_source_info *src_info __free(kfree) =3D NULL; + unsigned long flags; =20 - spin_lock(&hvpipe_src_list_lock); + spin_lock_irqsave(&hvpipe_src_list_lock, flags); /* * Do not allow more than one process communicates with * each source. */ src_info =3D hvpipe_find_source(srcID); if (src_info) { - spin_unlock(&hvpipe_src_list_lock); + spin_unlock_irqrestore(&hvpipe_src_list_lock, flags); pr_err("pid(%d) is already using the source(%d)\n", src_info->tsk->pid, srcID); return -EALREADY; } - spin_unlock(&hvpipe_src_list_lock); + spin_unlock_irqrestore(&hvpipe_src_list_lock, flags); =20 src_info =3D kzalloc_obj(*src_info, GFP_KERNEL_ACCOUNT); if (!src_info) @@ -510,18 +512,18 @@ static int papr_hvpipe_dev_create_handle(u32 srcID) return fdf.err; =20 retain_and_null_ptr(src_info); - spin_lock(&hvpipe_src_list_lock); + spin_lock_irqsave(&hvpipe_src_list_lock, flags); /* * If two processes are executing ioctl() for the same * source ID concurrently, prevent the second process to * acquire FD. */ if (hvpipe_find_source(srcID)) { - spin_unlock(&hvpipe_src_list_lock); + spin_unlock_irqrestore(&hvpipe_src_list_lock, flags); return -EALREADY; } list_add(&src_info->list, &hvpipe_src_list); - spin_unlock(&hvpipe_src_list_lock); + spin_unlock_irqrestore(&hvpipe_src_list_lock, flags); return fd_publish(fdf); } =20 --=20 2.39.5 From nobody Mon Jun 15 06:26:17 2026 Received: from mail-pf1-f179.google.com (mail-pf1-f179.google.com [209.85.210.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1BD0238F25D for ; Wed, 8 Apr 2026 12:02:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775649724; cv=none; b=WvfYviyPIcm3EFaRlS/LEGBNk+gZIz3QZvGyr3FeGvG32IX3A9RCdCA5WstyCE5ZahZMB7tdaFUJmHcUE5SUL+71NWpd/JqzKqp6J4Q7g/dCR/0wIglWPFydBIz0o93CMNiQUAqT2RfWlA5MWwP6IgDhm1u0NA4sk8gYMMgvMnU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775649724; c=relaxed/simple; bh=GdgHfu4NwRR5nHQPLhhd8u0gAQp21be2yqKo5lXv4k4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=CP3jRFeREeSR4WPNs7Exs/eT/OGhFt+mWL46viYSU8H7OTtG/jxbNCnK5sQzJtE8kLTOxlaRSuLp29LPMuEzEjuDP3nAZVRDJIC394ou3i7l6rmAZY7F9P46noPC00Gn9EUKTuLlanV5czb0IXwz1keOQriWMqsqW2SUpTnv84E= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=R60ZS7am; arc=none smtp.client-ip=209.85.210.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="R60ZS7am" Received: by mail-pf1-f179.google.com with SMTP id d2e1a72fcca58-82418b0178cso2877991b3a.1 for ; Wed, 08 Apr 2026 05:02:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1775649722; x=1776254522; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=PHdUj5TFH9dKxJLMiJUsQpHQaLsjedD8VYK/u5ysz28=; b=R60ZS7am8ikHKkUZLgQN0PLWPN0ZIXCAC+Ie1WkwR2cz02qjJ0q+BfyguPkocZexf+ Zm88nyaqMrmvnpQid5vivRaiRV4JhAq7dP3OhvdlOraKEgqvHlHlXPsbCToKo5j+JSvh FhZ7J6JIEm4Zmco3BUT+EFA548+zI0A/9JU/EpUJQVQ1/OYj4a/1uY2Sjs2myh0+GCtS 0VA0ok19DwYDJVONEO2gIcJLM+6yut+WmIb5+BN3MDyfv2QBYmEOyuqZh9dp8yiKbZ4k dtjxiWZAsrlzq6xmo2gf1aKF49MSCZ6kDtqZMPwOq2rYYVGR/fLpaAnz0E4gIFKHBlLD KMLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775649722; x=1776254522; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=PHdUj5TFH9dKxJLMiJUsQpHQaLsjedD8VYK/u5ysz28=; b=EZUenZGaH7RDfC1BMnhRTFSls5GnbAOdNNmCzkFqo9pjYoEJGkEXVDTREpbbO06ukS erNgcS/g4G2KV2jVGQztONCWNAWEe2INpuQg7Vn9GRDIxDRZ3ieBMhi0o5vd2BvPMQTG uWZYTrqekBzN8SDo/DnDRP7Day+LTmffZGsJCz9lWx71zI4xCqAvCEsPxVUBVTwq/thC QDLb0t9PPrldlaDTBlYKARnN7M9GB3EOkrq/soeu+MkSpkaldWLXZZpmqi1ft7S6hK6Z wH0jBosgYxfg7TuxDe2AZ5gcs+w7KikEhVl5b+g3mfKcWVQtuu4FOYuXJK3oIWJna8l5 CDcg== X-Forwarded-Encrypted: i=1; AJvYcCXL/M25hRLTlHz7J1fbFId/q90/buSzYQb4LnqSNfL//nDLKKGsYoDPl+SPOnYdWEgwisqXe3U2jX4ZsHQ=@vger.kernel.org X-Gm-Message-State: AOJu0YwN9cipngjcqZ2OgK82zRUBwG24saaEOFjmxPBc4F9gtYMck1i8 PIvwKE4cNeaw/vjM1LTpmejKUsk9Cp8ydDc7Qne9p2RCbcy896BuPAqv X-Gm-Gg: AeBDietRGROESHxCJI/iL88/JBwa9x7Tas+gPA40bv2Zil3hXmmzhXEAlEGq1diiuUJ JEGGE7/jInBqHzVRPqusA/XUuzPBwT/6HvqcmFO+0nnfl6/JmqH86D4J536B0enYIWmF1QPOeS5 m4GCD9aQU3zcYMp0X3JBWD2t7rH1Fmszq8irOIqIpA/d0RHph9hTGkItdOgxM0WuwoYt2TOV5IZ SE52VxZx/Kcrsm/O3goBLSKwFt65F35O4+kD3LdehJomswQq95hBmlJfWs5f2BdSbjTv4bpbU/O m8cQ0NzYnui7yOrthiWas72hp96z92+/hq5xyewlJnXXoY3PZIvQN4wYAmHHLrspiuzD4pY+VCA 3fAYvcgbSjlDcqbXjGSa4iUrOTj0uVPgOmZ+KqZkSmavXvnu+DuTdB0/AQgss5Lrbui3Pdsit4w /qWhcFUGpZQSuebr0fp95irBjKQ6mqM/H4TIlxpnKiUyKB X-Received: by 2002:a05:6a00:4b50:b0:820:2f9b:fe31 with SMTP id d2e1a72fcca58-82d0db53786mr21789802b3a.30.1775649722177; Wed, 08 Apr 2026 05:02:02 -0700 (PDT) Received: from Mac.localdomain ([49.205.216.49]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-82cf9b3e169sm21209322b3a.18.2026.04.08.05.01.58 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 08 Apr 2026 05:02:01 -0700 (PDT) From: "Ritesh Harjani (IBM)" To: linuxppc-dev@lists.ozlabs.org, Haren Myneni Cc: Madhavan Srinivasan , Christophe Leroy , Venkat Rao Bagalkote , Nicholas Piggin , linux-kernel@vger.kernel.org, "Ritesh Harjani (IBM)" , stable@vger.kernel.org Subject: [RFC v2 02/10] pseries/papr-hvpipe: Prevent kernel stack memory leak to userspace Date: Wed, 8 Apr 2026 17:31:32 +0530 Message-ID: X-Mailer: git-send-email 2.50.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The hdr variable is allocated on the stack and only hdr.version and hdr.flags are initialized explicitly. Because the struct papr_hvpipe_hdr contains reserved padding bytes (reserved[3] and reserved2[40]), these could leak the uninitialized bytes to userspace after copy_to_user(). This patch fixes that by initializing the whole struct to 0. Cc: stable@vger.kernel.org Fixes: 814ef095f12c9 ("powerpc/pseries: Add papr-hvpipe char driver for HVP= IPE interfaces") Signed-off-by: Ritesh Harjani (IBM) --- arch/powerpc/platforms/pseries/papr-hvpipe.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/powerpc/platforms/pseries/papr-hvpipe.c b/arch/powerpc/pl= atforms/pseries/papr-hvpipe.c index c41d45e1986d..3392874ebdf6 100644 --- a/arch/powerpc/platforms/pseries/papr-hvpipe.c +++ b/arch/powerpc/platforms/pseries/papr-hvpipe.c @@ -327,7 +327,7 @@ static ssize_t papr_hvpipe_handle_read(struct file *fil= e, { =20 struct hvpipe_source_info *src_info =3D file->private_data; - struct papr_hvpipe_hdr hdr; + struct papr_hvpipe_hdr hdr =3D {}; long ret; =20 /* --=20 2.39.5 From nobody Mon Jun 15 06:26:17 2026 Received: from mail-pf1-f178.google.com (mail-pf1-f178.google.com [209.85.210.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1650238F25D for ; Wed, 8 Apr 2026 12:02:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775649728; cv=none; b=gnpR+VL0XBeT4dePtLtU2YfS4tp08aVMuiQwJdy9rdwv0uOJoRfEY3b/NIjtTlTfEW4ahp0GVLAOHgr7iZmJyVAtaQSR/nF6/bxLv264nmLQTHibqr3Ii95J0eIxFXcG8m4wiyN3uUpxN+rcIhGGd5m7GUZxRomnoCsN5Gs6mQY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775649728; c=relaxed/simple; bh=ClRhNRwxPLJnSZeAFoT+Im+tz9UAH8Wr+KY9oPbAxZg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=GdvgDWcvey46ZUdD9JaBLLf8Z+LSvu8MB/y4+XlsqJAaICx2ZNz8tUoIejqFF27b9QJsPet/EeGV7rRmoYOBMvPRzyAyDVVBxTzKLDCyKWTB0A9DsUEFXLfsgL8la8vS9TIZUuTc29jzxCQx+sB07wDXXKEgQTsl5cljUrnyXVY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=kWinODTd; arc=none smtp.client-ip=209.85.210.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="kWinODTd" Received: by mail-pf1-f178.google.com with SMTP id d2e1a72fcca58-82c28f0a4ecso4542295b3a.3 for ; Wed, 08 Apr 2026 05:02:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1775649726; x=1776254526; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=yT/imSl5xO1+XIbW+YZh2He2MwMtKgkLKK3cHIqMkqk=; b=kWinODTdxSVKhFMJPUtPQE8XmJdI6oEACLtzxdpwcxDwq7yCU3N7B39EMBubJ7QUAR 3sHLE2JYrpGWJZL5j8jF6JI8osUZ4Do7g6LeTT8Cw85Fswr/lqlmV7w4C41S9yDerm2j hasOrBWlaYWmwGkrJLZWH6NPiwEp7kL4thUUwp2czzj9To7dG4pFYrgn30VRjknN7EwX 4LkZf1fElT4xf4x/r0tvanDHHmOkxN1+RueOyfxTdYjJx/Qn3ztpXz1MADigRIYKYwUZ fMTb9JFQnQ5pcsV5oz+pzK210iDyo8BcjnMJYp8pAopySa0A8HbW7fiz1J3g/XrXKvOE /sRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775649726; x=1776254526; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=yT/imSl5xO1+XIbW+YZh2He2MwMtKgkLKK3cHIqMkqk=; b=Pzg+/SPHAHscipiLxmh5rjkLqExpt8/49c8tGOmFYory+/PuMrL19WLDLELWp3+LsO oLqbPHRtD4/XiSF4pKa0fZ30H7DvHcQtq2YAfzE0BXFhW7husNo8iAYt9/PdCHecGEYz xktIWMvT1Io6zF4Ivrc3sYR4u4N11JYbpTtjZVv5t1TUqXxuvMMzWkkDWEmm28P0ohQa YSAqirIWYxSyF8lVRYgyWAtM8XECVInY4RTPgXGdfx8ZyEOQIaIFEz5Hed3m8u95gJB/ xG/Tm3XBknbag0vDqqRiIsW4alvhhCafE6NvTJSy7w41JgCj6D3EiuJQZKz5uskzyqKF 7ZMw== X-Forwarded-Encrypted: i=1; AJvYcCWAy537SS5EVIGMRqRuxeCRvfqoyInHCsZYLFUHFK1LinmLcPfaan4AiZfxPXylviwvzMHxSP2bqvxgHg4=@vger.kernel.org X-Gm-Message-State: AOJu0Yw5v5kJr3zwFhTYaqFCN3vCGcR37wdzYUfz3j0Vrgzw7SnzWlPN ckEHsoKAo4oEqjz7elT6N7Jb5AwsY58eoIljdOgabBJteOxj6HkcS2PA X-Gm-Gg: AeBDieuSZu/hQ+7CQzT8lQKoPDKqmOiagsGgeTU47m68gRhXTcIp/blzFK3fS37Rqjv y8ZEkXcM+QOvDpPDjvchvQhF6tRhUxZjYWvNZQN+50KlmF/JISm7cD+1EW2qvMUO3CKvpToJJBH YLUGaxOg2Fxfp54r7T0Ern60Ow3yIZzFcsJcOyknYJZfEge6QTw2ZaUb67f8LAecKz//ee6LbA3 SlEy6MgIMtKe5TwGYAikBHcpl5gNVBnVQIGo6i+vpsoyYDtg2ol7AVexmpCEmIUeSs1f4CV1jRD OFX/jS4vvqJ6AeqwAjdwifHSoJvxqrKnrwH5GUd3a7XdI++bPOL7AJzDKUnFjItspcdTngcx4lW VOXAgkjlzf8KIyCqcdh0kfTv4y4KUELMcNzAtCH0982I6CUh4fPFxe7yMvPeouX8wozuXmCT+nV DVf13mOEaSRuH/SuxqI+yYLV/1hfdISn7yz5uq0QtQRwEb X-Received: by 2002:a05:6a00:4613:b0:81e:e09d:2687 with SMTP id d2e1a72fcca58-82d0da27ab5mr20793609b3a.1.1775649725987; Wed, 08 Apr 2026 05:02:05 -0700 (PDT) Received: from Mac.localdomain ([49.205.216.49]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-82cf9b3e169sm21209322b3a.18.2026.04.08.05.02.02 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 08 Apr 2026 05:02:05 -0700 (PDT) From: "Ritesh Harjani (IBM)" To: linuxppc-dev@lists.ozlabs.org, Haren Myneni Cc: Madhavan Srinivasan , Christophe Leroy , Venkat Rao Bagalkote , Nicholas Piggin , linux-kernel@vger.kernel.org, "Ritesh Harjani (IBM)" Subject: [RFC v2 03/10] pseries/papr-hvpipe: Fix null ptr deref in papr_hvpipe_dev_create_handle() Date: Wed, 8 Apr 2026 17:31:33 +0530 Message-ID: <0843d293fa00a345f156977534e5cb666f1d8bcd.1775648406.git.ritesh.list@gmail.com> X-Mailer: git-send-email 2.50.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" commit 6d3789d347a7 ("papr-hvpipe: convert papr_hvpipe_dev_create_handle() = to FD_PREPARE()"), changed the create handle to FD_PREPARE(), but it caused kernel null-ptr-deref because after call to retain_and_null_ptr(src_info), src_info is re-used for adding it to the global list. Getting the following kernel panic in papr_hvpipe_dev_create_handle() when trying to add src_info to the list. Kernel attempted to write user page (0) - exploit attempt? (uid: 0) BUG: Kernel NULL pointer dereference on write at 0x00000000 Faulting instruction address: 0xc0000000001b44a0 Oops: Kernel access of bad area, sig: 11 [#1] ... Call Trace: papr_hvpipe_dev_ioctl+0x1f4/0x48c (unreliable) sys_ioctl+0x528/0x1064 system_call_exception+0x128/0x360 system_call_vectored_common+0x15c/0x2ec Now, the error handling with FD_PREPARE's file cleanup and __free(kfree) au= to cleanup is getting too convoluted. This is mainly because we need to ensure only 1 user get the srcID handle. To simplify this, we allocate prepare the src_info in the beginning and add it to the global list under a spinlock after checking that no duplicates exist. This simplify the error handling where if the FD_ADD fails, we can simply remove the src_info from the list and consume any pending msg in hvpipe to be cleared, after src_info became visible in the global list. Fixes: 6d3789d347a7 ("papr-hvpipe: convert papr_hvpipe_dev_create_handle() = to FD_PREPARE()") Reported-by: Haren Myneni Signed-off-by: Ritesh Harjani (IBM) --- arch/powerpc/platforms/pseries/papr-hvpipe.c | 57 ++++++++++---------- 1 file changed, 30 insertions(+), 27 deletions(-) diff --git a/arch/powerpc/platforms/pseries/papr-hvpipe.c b/arch/powerpc/pl= atforms/pseries/papr-hvpipe.c index 3392874ebdf6..402781299497 100644 --- a/arch/powerpc/platforms/pseries/papr-hvpipe.c +++ b/arch/powerpc/platforms/pseries/papr-hvpipe.c @@ -480,23 +480,10 @@ static const struct file_operations papr_hvpipe_handl= e_ops =3D { =20 static int papr_hvpipe_dev_create_handle(u32 srcID) { - struct hvpipe_source_info *src_info __free(kfree) =3D NULL; + struct hvpipe_source_info *src_info; + int fd; unsigned long flags; =20 - spin_lock_irqsave(&hvpipe_src_list_lock, flags); - /* - * Do not allow more than one process communicates with - * each source. - */ - src_info =3D hvpipe_find_source(srcID); - if (src_info) { - spin_unlock_irqrestore(&hvpipe_src_list_lock, flags); - pr_err("pid(%d) is already using the source(%d)\n", - src_info->tsk->pid, srcID); - return -EALREADY; - } - spin_unlock_irqrestore(&hvpipe_src_list_lock, flags); - src_info =3D kzalloc_obj(*src_info, GFP_KERNEL_ACCOUNT); if (!src_info) return -ENOMEM; @@ -505,26 +492,42 @@ static int papr_hvpipe_dev_create_handle(u32 srcID) src_info->tsk =3D current; init_waitqueue_head(&src_info->recv_wqh); =20 - FD_PREPARE(fdf, O_RDONLY | O_CLOEXEC, - anon_inode_getfile("[papr-hvpipe]", &papr_hvpipe_handle_ops, - (void *)src_info, O_RDWR)); - if (fdf.err) - return fdf.err; - - retain_and_null_ptr(src_info); - spin_lock_irqsave(&hvpipe_src_list_lock, flags); /* - * If two processes are executing ioctl() for the same - * source ID concurrently, prevent the second process to - * acquire FD. + * Do not allow more than one process communicates with + * each source. */ + spin_lock_irqsave(&hvpipe_src_list_lock, flags); if (hvpipe_find_source(srcID)) { spin_unlock_irqrestore(&hvpipe_src_list_lock, flags); + pr_err("pid(%d) could not get the source(%d)\n", + src_info->tsk->pid, srcID); + kfree(src_info); return -EALREADY; } list_add(&src_info->list, &hvpipe_src_list); spin_unlock_irqrestore(&hvpipe_src_list_lock, flags); - return fd_publish(fdf); + + fd =3D FD_ADD(O_RDONLY | O_CLOEXEC, + anon_inode_getfile("[papr-hvpipe]", &papr_hvpipe_handle_ops, + (void *)src_info, O_RDWR)); + if (fd < 0) { + spin_lock_irqsave(&hvpipe_src_list_lock, flags); + list_del(&src_info->list); + spin_unlock_irqrestore(&hvpipe_src_list_lock, flags); + /* + * if we fail to add FD, that means no userspace program is + * polling. In that case if there is a msg pending because the + * interrupt was fired after the src_info was added to the + * global list, then let's consume it here, to unblock the + * hvpipe + */ + if (src_info->hvpipe_status & HVPIPE_MSG_AVAILABLE) + hvpipe_rtas_recv_msg(NULL, 0); + kfree(src_info); + return fd; + } + + return fd; } =20 /* --=20 2.39.5 From nobody Mon Jun 15 06:26:17 2026 Received: from mail-pf1-f178.google.com (mail-pf1-f178.google.com [209.85.210.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EC8763BB9FA for ; Wed, 8 Apr 2026 12:02:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775649732; cv=none; b=OWHwNAv3obe9SIaTOrbC5yffhkhfgUEvqDRHHarXPrKZ2J3y/ZsdCTz/uSYfH+VI1lc5aYr61/i6qHuY5uvVZJNwQta7FhAIsdpCEoUCmvX/oXWnhQ6Fqz3jTGFB8+TAYMl6xhnA7383FoPGMbB6rY/x8HQ/O/Y5pHeelV0vGn8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775649732; c=relaxed/simple; bh=j+Bctf1u2e7YmJBQKZJcXUbKRyq1OMk/hFfMjUn2rLY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=INzw1NTbcDSVl/9BNcmrDQy9L0VVsWCrrevTNWDALfYHrT5Kys2YwS4fmj4N+ZeUt7rWGeNZ6aRj0SLzp7M/1lyXtB0N2OWTFdweDlpDAPqvNxBFHDaaMXisGIpdFF9utznvevnrH6HfHyc80yWiuIeuSt2MR/lSvZjp3lp8U98= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Q70v6FMK; arc=none smtp.client-ip=209.85.210.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Q70v6FMK" Received: by mail-pf1-f178.google.com with SMTP id d2e1a72fcca58-82cd5c07f93so2694052b3a.1 for ; Wed, 08 Apr 2026 05:02:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1775649730; x=1776254530; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=mu3P1VfNo0DCayRCdHHojPZFKAzDzWNLwEKMHMNVDaE=; b=Q70v6FMKT+oz0zrf2xE8Xk0yqp6uZF412BQmlwq8Vc0APsnXxBoHR2Z5FfKYTaiJsJ xhANDjNc8rcgimZAP4KhKsjenetwWNt7o6zMFXuoghV6MRPERBJ8OLN+RQHrwT8utwTT m4dvNeN4eO4I8ewoHQYrTwCUQFS+p+rhVpZ8BOGuBwka/ntKHEEAR07k7oQBkUBDOo/G UOyUfoVbS5e5UpocCkaAd67N3z9wFvuhVPMZ62Hw0WuXLAGbu8y5UgEMmQsyewvofizk 3wtBnmWVzwsAPTnu/KLmTxhJVISMa8ohhwRRzAjgu8LWElAMG86xNKGeXtxII33tHEAO //bg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775649730; x=1776254530; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=mu3P1VfNo0DCayRCdHHojPZFKAzDzWNLwEKMHMNVDaE=; b=dpL3ZEVw2IMBoSH4ZbJAnTxcZ3BgaRbadUFHSjStHpFLWrdfUCHjJ2KMvbK+wBJJUo iq3NqWsDknS6SKGlFJZezDVg/JrlY2mzJLDIr+lAUBdKiH37vsrSDuWgkCWyXAXiapQa kvSIEB0KR+pDDV4YCpuhUr+IzTjIvn83S3gOps1rdouRN3riGxMLSby3QJcbTB+8GHia C3WME22BFKRR0ZaARlj8sJ6PKGU8sAlhNLTNdiSCBiELO2fJxqn2IIlZcwUD5L7LI/9p iMNUcwEN+icdNVxElAVUXlCEvr9zSMQ3Ns6xvSYI3A+zaVmz6HNWDuOkywmIVOUd329q GIXw== X-Forwarded-Encrypted: i=1; AJvYcCW7ybr4Cg7lLLTkVNtScHIpTaDIQkHWuprFfcGxP9zrOtB6EBEdYt+G4q7f/d+USfQplKv7/bk1r4hhSvM=@vger.kernel.org X-Gm-Message-State: AOJu0YwYzx/WXa2GUIpHVIzbLdHFaJjqBmTZenHW+dedWIh9e2286/6U Z6pvK9ztpXLOdqH8VILmZN5OYhWHnYzg7g5VEZ1DEM16dRiTh26NTZqJ X-Gm-Gg: AeBDievb9fGqP2FAh8dvcBPcc0BGpTO1s61LTJZHo5mXHpinv6RikMLGzHa36hjntQ/ pqj1EDzv79TdubTlGVNfJAGWoaffk8UqcCW2t0ZfhhbwtSFg203HfnvjJZ03tNRvu2WgwFvukjr TZAkhxGo1sJFyz7EQPSaWhpAHeEXNLokyp48R5zQhH5x8odaHuAN6V8LgwcTZTdv+EgBYpgIbqH pioK2SJO2dpg/lYf1iiblTUEAwfxPBOVrBrDScC82CApwk+xX6qNrgRZlOVn2dn94YsDF6WZU6s s4Yik5Z+pOEddNaSCqwFvQyRNFtcmLmN/Nk2S6ng7WRTYSlZzp/rzdoAyIzAPtIvfrUViJKf0kV Q1b+x/P6VEZ6Ad3TbL09/yMkVMw8iDaSzhWqK5/JWZW7arS+YRWFoTPpg0jaP/UudCI33wybxS6 PB6g== X-Received: by 2002:a05:6a00:2e93:b0:827:4343:4c1 with SMTP id d2e1a72fcca58-82d0db32d62mr19867111b3a.29.1775649730179; Wed, 08 Apr 2026 05:02:10 -0700 (PDT) Received: from Mac.localdomain ([49.205.216.49]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-82cf9b3e169sm21209322b3a.18.2026.04.08.05.02.06 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 08 Apr 2026 05:02:09 -0700 (PDT) From: "Ritesh Harjani (IBM)" To: linuxppc-dev@lists.ozlabs.org, Haren Myneni Cc: Madhavan Srinivasan , Christophe Leroy , Venkat Rao Bagalkote , Nicholas Piggin , linux-kernel@vger.kernel.org, "Ritesh Harjani (IBM)" Subject: [RFC v2 04/10] pseries/papr-hvpipe: Fix the usage of copy_to_user() Date: Wed, 8 Apr 2026 17:31:34 +0530 Message-ID: X-Mailer: git-send-email 2.50.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" copy_to_user() return bytes_not_copied to the user buffer. If there was an error writing bytes into the user buffer, i.e. if copy_to_user returns a non-zero value, then we simply return -EFAULT from the ->read() call. Also let's make sure we clear the hvpipe_status flag, if we have consumed the hvpipe msg by making the rtas call. ret =3D -EFAULT means copy_to_user has failed but that still means that the msg was read from the hvpipe, hence for both cases, success & -EFAULT, we should clear the HVPIPE_MSG_AVAILABLE flag in hvpipe_status. Signed-off-by: Ritesh Harjani (IBM) --- arch/powerpc/platforms/pseries/papr-hvpipe.c | 23 ++++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/arch/powerpc/platforms/pseries/papr-hvpipe.c b/arch/powerpc/pl= atforms/pseries/papr-hvpipe.c index 402781299497..5c773a6f0efc 100644 --- a/arch/powerpc/platforms/pseries/papr-hvpipe.c +++ b/arch/powerpc/platforms/pseries/papr-hvpipe.c @@ -206,10 +206,11 @@ static int hvpipe_rtas_recv_msg(char __user *buf, int= size) bytes_written, size); bytes_written =3D size; } - ret =3D copy_to_user(buf, + if (copy_to_user(buf, rtas_work_area_raw_buf(work_area), - bytes_written); - if (!ret) + bytes_written)) + ret =3D -EFAULT; + else ret =3D bytes_written; } } else { @@ -328,7 +329,7 @@ static ssize_t papr_hvpipe_handle_read(struct file *fil= e, =20 struct hvpipe_source_info *src_info =3D file->private_data; struct papr_hvpipe_hdr hdr =3D {}; - long ret; + ssize_t ret =3D 0; =20 /* * Return -ENXIO during migration @@ -376,7 +377,7 @@ static ssize_t papr_hvpipe_handle_read(struct file *fil= e, =20 ret =3D copy_to_user(buf, &hdr, HVPIPE_HDR_LEN); if (ret) - return ret; + return -EFAULT; =20 /* * Message event has payload, so get the payload with @@ -385,19 +386,23 @@ static ssize_t papr_hvpipe_handle_read(struct file *f= ile, if (hdr.flags & HVPIPE_MSG_AVAILABLE) { ret =3D hvpipe_rtas_recv_msg(buf + HVPIPE_HDR_LEN, size - HVPIPE_HDR_LEN); - if (ret > 0) { + /* + * Always clear MSG_AVAILABLE once the RTAS call has drained + * the message, regardless of whether copy_to_user succeeded. + */ + if (ret > 0 || ret =3D=3D -EFAULT) src_info->hvpipe_status &=3D ~HVPIPE_MSG_AVAILABLE; - ret +=3D HVPIPE_HDR_LEN; - } } else if (hdr.flags & HVPIPE_LOST_CONNECTION) { /* * Hypervisor is closing the pipe for the specific * source. So notify user space. */ src_info->hvpipe_status &=3D ~HVPIPE_LOST_CONNECTION; - ret =3D HVPIPE_HDR_LEN; } =20 + if (ret >=3D 0) + ret +=3D HVPIPE_HDR_LEN; + return ret; } =20 --=20 2.39.5 From nobody Mon Jun 15 06:26:17 2026 Received: from mail-pf1-f176.google.com (mail-pf1-f176.google.com [209.85.210.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BFA143BBA14 for ; Wed, 8 Apr 2026 12:02:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775649735; cv=none; b=KcjkEOLpuqhhDKBujIjdryv9mhHyjgwwDyn+BqtO7ARz14kahLvZS5UhrK0XC/JL+m5G2jmvKM+fCYeYq/D1rIyy9bhDp92wBVPfpa/IFt3tJlx7n8bLtqHs4V1Wr5XxH0tprB59/e04j4lLaL4LsjlpFxaszQgXfC1KJtXMzw4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775649735; c=relaxed/simple; bh=7Fhwna8jLL60cvy6qgSTOwe9NdAiEs0LaNSE0YtwvnQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QF5F6dXnxn4NBG2kcQZomljEdOlLxguXx4j1HBIk29GQQRjuK7BW7kUb62Z8cx3zylrpm/7eNMGBsNJGc/7IpDEcBz5nZ0oYp97NJ5pBSdKkocbjfdXZZIfEdVsJjYRdKUVOdtwLGpO0qxnnLSex1fQIgIW9lvrMdACzrS6pCj0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=cqJvZTsb; arc=none smtp.client-ip=209.85.210.176 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="cqJvZTsb" Received: by mail-pf1-f176.google.com with SMTP id d2e1a72fcca58-82cd70febc7so4518384b3a.2 for ; Wed, 08 Apr 2026 05:02:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1775649734; x=1776254534; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=FkcaRdjNdQrSS4RW7vp7wN/6lfwG0aLJHvzJtjGnR8s=; b=cqJvZTsbZ+t0fwHxXGnK8JIEUpTHa4jX+ymh9wVhQiArXuOUfJMcyuX0R0BwDzNS6P yX2/E3Y0VhKL2JKxb6PUrkNU8bdptrC0lW5s5FRfIlqk1xUXsjqwDOZeMX7nwtcs0apJ ZamF2+JzPIp7LRm0pc1h/rVfS6DIT82bj7naCZptWD5pYVBNz+jgv3A+0dKsNTwQ23ZA Q6yfMDFlkv86d3o2KiNAhh0273h8rR+0S0usMyYPa1KjuYLsZuz4dpj46UlrP1QIP1L6 nIWuU17ksGWHUzsDb4zEheNPq4DZ3RXNlqt+cH8NEWu5eCO96zYCmxlHCRxO7srRb16x hg7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775649734; x=1776254534; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=FkcaRdjNdQrSS4RW7vp7wN/6lfwG0aLJHvzJtjGnR8s=; b=jP6IuQqjDW1ZI9NTpnlqag0z4WuwMx2qDVift3wrct4Cglo5vvqNzLbGtxShjA1Fe7 fiqYLdxFHv5tZ0xx0r4L9P4+H3PosGdeKj3oOPqJNri8BGPGz67WapRkaqGGAP/mY4+5 +NBJ0C8injdPlvBNeIqgarOoOa7ieLwvEA+7fzqZ5DalcGK8U0iasBlRJ7Tl8srDtDtI AcZ4uQa5pXpM14r2ogA2rO7okC1+szx7eqHAHIeCOig2FrWFqV25Ce6MoVYg73eTT0F6 aR59ViuePfrC//lhqy15+X6ccKTD/i/Rm5iuJdXehYGLmC3+WD7GxZtZQKILA66r6qB2 YBog== X-Forwarded-Encrypted: i=1; AJvYcCWaxjl0Xdym1S9oB2PujCQphVWdYK2dwP2JflGJK6cUESsJsDdmLb8sq/c7dFTgVkGAXkemsy5tU4HVzRI=@vger.kernel.org X-Gm-Message-State: AOJu0YyvoGwpZvfuWoz6dVtOcGxpWm2XwioPryMMyfGMzknEIVGSBKOf sASaddRTirVhDEc7n8jM7t735pGECSOH8hwiqb/LRElMO+FAPpaIGYad X-Gm-Gg: AeBDiev6J0HyUPY/yqooky9mq8Bj3VTbD6aTmQXkXCCkmxJaCqwpp8Ck15db7/17u94 8N1h0s2YqVS2TmIgYICsjvXrAgME58xNWhLNhxFxTb79ZlQzycZJInR1FRJVd5zSkoCNv+CNBwE fro31kPls27vq8V6FK90vz/y7tMK8xwIL6UjHTcCsyOSFStMne6GyUAxscBf7oYltE+7elmyLpB l/aJ5nuVbdSzQg0lKg3+RYudzf3DtA0OjPonOYxc8OLkwJ4Qm9VsKJbhqPyGROF+LAtpVi5sC33 MyZ8lDcdkc2HC73VTALj8Oo3w6huldKbBzifLJbdzxatE3ltXSEIDKdmiqRm/svHTPh9v3ziwcl Ldug4bbVIAh5TIDQeS/EMamDEwJtoH3oclE1BcdTp+3qkoad+oSd9phCBBy9vukvbQm1FcTlP/8 Z+uzXBNOElol/lgAI3r6PaqYMOtF561/+p/Hv++jc6PK3s X-Received: by 2002:a05:6a00:6c94:b0:829:9a7b:db84 with SMTP id d2e1a72fcca58-82d0dba35d7mr20895852b3a.49.1775649733978; Wed, 08 Apr 2026 05:02:13 -0700 (PDT) Received: from Mac.localdomain ([49.205.216.49]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-82cf9b3e169sm21209322b3a.18.2026.04.08.05.02.10 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 08 Apr 2026 05:02:13 -0700 (PDT) From: "Ritesh Harjani (IBM)" To: linuxppc-dev@lists.ozlabs.org, Haren Myneni Cc: Madhavan Srinivasan , Christophe Leroy , Venkat Rao Bagalkote , Nicholas Piggin , linux-kernel@vger.kernel.org, "Ritesh Harjani (IBM)" Subject: [RFC v2 05/10] pseries/papr-hvpipe: Simplify spin unlock usage in papr_hvpipe_handle_release() Date: Wed, 8 Apr 2026 17:31:35 +0530 Message-ID: X-Mailer: git-send-email 2.50.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Once the src_info is removed from the global list, no one can access it. This simplies the usage of spin_unlock_irqrestore() in papr_hvpipe_handle_release() Signed-off-by: Ritesh Harjani (IBM) --- arch/powerpc/platforms/pseries/papr-hvpipe.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/arch/powerpc/platforms/pseries/papr-hvpipe.c b/arch/powerpc/pl= atforms/pseries/papr-hvpipe.c index 5c773a6f0efc..7d05d6dcdb79 100644 --- a/arch/powerpc/platforms/pseries/papr-hvpipe.c +++ b/arch/powerpc/platforms/pseries/papr-hvpipe.c @@ -460,6 +460,7 @@ static int papr_hvpipe_handle_release(struct inode *ino= de, src_info =3D file->private_data; list_del(&src_info->list); file->private_data =3D NULL; + spin_unlock_irqrestore(&hvpipe_src_list_lock, flags); /* * If the pipe for this specific source has any pending * payload, issue recv HVPIPE RTAS so that pipe will not @@ -467,10 +468,8 @@ static int papr_hvpipe_handle_release(struct inode *in= ode, */ if (src_info->hvpipe_status & HVPIPE_MSG_AVAILABLE) { src_info->hvpipe_status =3D 0; - spin_unlock_irqrestore(&hvpipe_src_list_lock, flags); hvpipe_rtas_recv_msg(NULL, 0); - } else - spin_unlock_irqrestore(&hvpipe_src_list_lock, flags); + } =20 kfree(src_info); return 0; --=20 2.39.5 From nobody Mon Jun 15 06:26:17 2026 Received: from mail-pg1-f181.google.com (mail-pg1-f181.google.com [209.85.215.181]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 746353BC676 for ; Wed, 8 Apr 2026 12:02:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775649739; cv=none; b=EJAWI/38eBwZRPdvRKnWi4k6CT5hTqB9loCAvE2bgChebuxX5M2Atv4+wbOTX7g4iHbko/Dy/b9nOlMxKPax4rpDonLZb0p7wMTN5iLvI6gipYBoikEzh6typf0HcAtShj6oxgiWZlyEGinSXEDfGcc340e2T61vAAvjzU1vF8E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775649739; c=relaxed/simple; bh=RoVNWgDRlOba9KdEHSNZquXA4zqOJEPc7UaDRgiBUrU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=U+/ZmTuIk9epjXaBdTC6b33s/efiE5iGxAkBQ37udOEjfbSFbwek97+6nZIffaO3Af81nJ6zgJoyemjnq19tjYRQmG5uDaALrJ/qdRAZvUboUfgHMTlMG6EBZy71+Wn0BM3g3iz5BuGOyuwscQMoz8StvbJOXq4CurcM2rRoh6M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=rUBn4mjb; arc=none smtp.client-ip=209.85.215.181 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="rUBn4mjb" Received: by mail-pg1-f181.google.com with SMTP id 41be03b00d2f7-c742723c863so4023036a12.0 for ; Wed, 08 Apr 2026 05:02:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1775649738; x=1776254538; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=LxoXdEEXs0w/jw6jTRsQHNSCF81gwq53jiJYY0lS3Rw=; b=rUBn4mjbx1H6plSgaNJ2Cq3mYn2xhhQ9roYcMSEfq5yLsOyqJumK43pQ+SpZ40ng/v q7QTDLav+vB0IZKBsx61UMn755MtOQwb0ybBCwGWTKCOdl43kmpN/HXozql5bgVs8h40 99PToiHjJAlLQJwG57ZKimKfjUHeUGhkgvvGroAlvcCef9EchSEDTASbHoxmpHAUkGfy 7PaLJl1mAqNZq7ggIeLp5gwlZ8SqHMeTXBENfHpb1GaYC3pZ48QDUVlipWQyQdq08+P8 wTKCPJaemLTY6rKBMwlRgArVD6VUvzP6OIejb6Drx4x7nEEzcMFBGUDnf4w2U2P3aXtq RPXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775649738; x=1776254538; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=LxoXdEEXs0w/jw6jTRsQHNSCF81gwq53jiJYY0lS3Rw=; b=Td8iRdHQAkP22Xvu4MO0eNlr1tJTTkDzfAUpXuUUysulK5w7uaWSBy0WIdze8i0Vep W//dEkH4hEiE6rzgd9jU6VV9NcHPg8gBbPsw0+PiT20V4UydKJqa4kcg1xxFQR61+ttg +fXAfrcNinlfwGECBjrujiFE8hkAqu+rO9gUYHlbW1aVaHQgPzsK94qO57cVbk3ZcX6E 2lcHIvmPZMaFuSCv1m8U1x0cvlh+xJcKHjk2IVHG44IAt0q60cBrPpf1VRWwir65EUnU qkmjKbo5ooq+PIIQpvZwTC3npeURrglNaTp46n5ASsml/sitC330drm/9+8WK8THPvdu nmOw== X-Forwarded-Encrypted: i=1; AJvYcCVHEJT3fETg6ZtsKMOYsMslABfwKrvDaSkUU1s8hb2cDTR+F3M5Nc2x/ftl5ztoreJ/yxLaEN7B7bgndnI=@vger.kernel.org X-Gm-Message-State: AOJu0YwUVueUNfGYKexKkxrbqld+noDF40k+/tz09CJ6oHLLpO4FtGwB EFfAeQD3z4YPOuKBHqmiWsGYEW91jBJVrhM0MKNcP9dk3qwtAqtB4jzO X-Gm-Gg: AeBDievF+S0cpNkOsTVayyS5aLWnuYAbpSHGNht+7yH50m3MtHXXLX7gZQW9nZmoFoo wes1ykUpVUlPwBdfJnu1TfU953ZvfGlOqtVbAF2eENXVo/w8q5lqPSoj72IRH7IJjX0Mqy8mLr+ nlwNk3LWfX8ud9yYDSTjw1bVe5Iem75/8C6C9rkksY+X4XDvFSrM//KFjKdWaxUKzWNnFp2X3ez LNIw5RLcAziy7P9EtaeIwVE4YNSPgNLD+qN+S4tESyVAdja2a2dGk2R62QZY9EEmIWijxyyFISI Rj42i+tympcg1dgT3CQjZsXAbNoNTw7xfpcyO6bU2bJWwRQE2kdylx1PZnQMFkDkYCOHIBo4fL8 lsNEWdXSXNISz26biOUTMuiuLzBc41i0/pLQHhlYkrTKgGgnI3I658/HJGcoVjfv1HH9zQLvtTD A77UvKhrPRs1MPYprUhZwLCm2UHqBECm6jXVaHozg4HUET X-Received: by 2002:a05:6a00:4fd6:b0:82c:df25:fbc4 with SMTP id d2e1a72fcca58-82d0dbcce73mr22490656b3a.52.1775649737668; Wed, 08 Apr 2026 05:02:17 -0700 (PDT) Received: from Mac.localdomain ([49.205.216.49]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-82cf9b3e169sm21209322b3a.18.2026.04.08.05.02.14 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 08 Apr 2026 05:02:17 -0700 (PDT) From: "Ritesh Harjani (IBM)" To: linuxppc-dev@lists.ozlabs.org, Haren Myneni Cc: Madhavan Srinivasan , Christophe Leroy , Venkat Rao Bagalkote , Nicholas Piggin , linux-kernel@vger.kernel.org, "Ritesh Harjani (IBM)" Subject: [RFC v2 06/10] pseries/papr-hvpipe: Kill task_struct pointer from struct hvpipe_source_info Date: Wed, 8 Apr 2026 17:31:36 +0530 Message-ID: <47f37e9d782b8e87566c4f2da065569f319d1b3c.1775648406.git.ritesh.list@gmail.com> X-Mailer: git-send-email 2.50.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" We don't really use task_struct pointer for anything meaningful. So just kill it for now, and we can bring back later if we need this for any future debug purposes. Signed-off-by: Ritesh Harjani (IBM) --- arch/powerpc/platforms/pseries/papr-hvpipe.c | 5 ++--- arch/powerpc/platforms/pseries/papr-hvpipe.h | 1 - 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/arch/powerpc/platforms/pseries/papr-hvpipe.c b/arch/powerpc/pl= atforms/pseries/papr-hvpipe.c index 7d05d6dcdb79..41958ed8ee97 100644 --- a/arch/powerpc/platforms/pseries/papr-hvpipe.c +++ b/arch/powerpc/platforms/pseries/papr-hvpipe.c @@ -493,7 +493,6 @@ static int papr_hvpipe_dev_create_handle(u32 srcID) return -ENOMEM; =20 src_info->srcID =3D srcID; - src_info->tsk =3D current; init_waitqueue_head(&src_info->recv_wqh); =20 /* @@ -503,8 +502,8 @@ static int papr_hvpipe_dev_create_handle(u32 srcID) spin_lock_irqsave(&hvpipe_src_list_lock, flags); if (hvpipe_find_source(srcID)) { spin_unlock_irqrestore(&hvpipe_src_list_lock, flags); - pr_err("pid(%d) could not get the source(%d)\n", - src_info->tsk->pid, srcID); + pr_err("pid(%s:%d) could not get the source(%d)\n", + current->comm, task_pid_nr(current), srcID); kfree(src_info); return -EALREADY; } diff --git a/arch/powerpc/platforms/pseries/papr-hvpipe.h b/arch/powerpc/pl= atforms/pseries/papr-hvpipe.h index c343f4230865..4bdf7bb2fc4d 100644 --- a/arch/powerpc/platforms/pseries/papr-hvpipe.h +++ b/arch/powerpc/platforms/pseries/papr-hvpipe.h @@ -21,7 +21,6 @@ struct hvpipe_source_info { u32 srcID; u32 hvpipe_status; wait_queue_head_t recv_wqh; /* wake up poll() waitq */ - struct task_struct *tsk; }; =20 /* --=20 2.39.5 From nobody Mon Jun 15 06:26:17 2026 Received: from mail-pg1-f180.google.com (mail-pg1-f180.google.com [209.85.215.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7312B3BC683 for ; Wed, 8 Apr 2026 12:02:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775649743; cv=none; b=tvNgXd72gcfpRw8W/Yeu/6WiQQePUVfRMT4sS1GZbe4fpU8lQAfP6MBOf810bOrNcwN/ZK97GJYqQu85uYNboJ8u6ryvVj3xholRziTVtmWcJLKW/ud69WT+w/7vN0GDTVArYUGjNKxPO5yzIUdmn0S/Cm4NEaRzkbe+n4j6OII= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775649743; c=relaxed/simple; bh=9xVmVnnQEmBhLZ6zKtAVXz9LYcbBNbD4AhA7vmG0KWA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mm+wjNe1r1cf/5lXujadlY6q8MQZpzw0uneDzuWIx06rB/KuuM1AN7Qk7L2Hxso702jiizvn9M3L3cdD17Dht3maLbELtjXojU0CBFb9PJkEAGJKEge1mhWVNdeyeV8FEIFSlKzJsFnWXZSr3DJumBqzWd9ZZFEMpDDeXZPv/UE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=lj5AfM79; arc=none smtp.client-ip=209.85.215.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="lj5AfM79" Received: by mail-pg1-f180.google.com with SMTP id 41be03b00d2f7-c76b6abdb73so4444394a12.1 for ; Wed, 08 Apr 2026 05:02:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1775649742; x=1776254542; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=SCwuqGPqq1xW71wkNIANtyK3Rl5bXk4EbTq6DUkJUCM=; b=lj5AfM79XIFL65DIyFT4+Bkd6ZQXn5Ss++exuq7LzYQcv6QzPWQaMXtebm/5BXCivq /4vYK3pGuIxSjBsl+c+t3LNkX310PfM4M/dmgpRr0wsE/7EcH2LUZ5aXGhVzgWcHAixq RFJRQMSgmESm5+T4PL8SJWl446toKuVB9P9K9ilQ+2UdDa82Nrvs5WXKC2MCR5SgsUg8 UDbaHfQo+tX1W6aklCU9Zj1arTlKJTamaPlp5n3akHlYGZU0Db45VNLr85UI8/e55BKn 7iH9wapGKMFS0gA/HOxwmFkJOUqS67b03/0zm5na0+i0oJERFkSMv8EdJ5vqo2V8D7ll lllg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775649742; x=1776254542; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=SCwuqGPqq1xW71wkNIANtyK3Rl5bXk4EbTq6DUkJUCM=; b=NUbmAy+aiKOAIOqSHnqGGMTKQ7FORyFZ9tJy1ViJtBdWlHprRdy/PvAAoiC18p8qZV RyUqGoFCN/w7X/mHMPc2+XEeooTLoK/8wfT8KFkkyro9y6WVfXWWojuUWS0zV4GBawy9 yEqUHMy+rvXVi8EAKaWN5hPv+3ubi9ResneFis1pqc0hCMObRHNuxU5s75HYy19tTZWP E7XLulpIfO72m6Xgu1jRdnWHU0vxhHmsnFbvQ9Asjsv8Z8SN/BIj95W8wYsWVbvr/Icn 0EXVT2CxpquLoK2j7q32csv0Iw3hzeyZBv73liGyPQfvKUj/FcKkcdNlfYECvjPo4/XN uIOA== X-Forwarded-Encrypted: i=1; AJvYcCVggrCHNu/G7sb02kJzs5QdnIHDrT4L77jYtrdewKWC/iMpz+IzJrAhQaPUANz2OJpAQrpX3azMBn1aZcM=@vger.kernel.org X-Gm-Message-State: AOJu0Yysrvtz7QCcssP+60Ymg2Rw2R47temZVbl9h5gDT73i7B2rdx7P ferzSvHCQpvK5V5gBp76aLvwvfDPxHBqhXoDSF57j1rKAxviQZP5vrg4 X-Gm-Gg: AeBDiesc/FeAMmKVEHvOVJ7QNYWQ42Z1wAasFpo08ne4OvP0B66/JKtQ0nnOQtVrGHY RE8ja7Eg4I/vLEBiSbIkXzjCXmn43Jy73FXPPYYaCx3cfxyfhYXHDa6vfwOAhqqGL54aCkXTI7n /SCamFJgaDzF/1XppokTk+loVsCpXE8WRHUaufPNSyikgBICaVxvHINhRfmLkbP/Ml+G8PG5BRl f+S+kdO3tFisRVshJ6ICWL0if55+45XwawHDLgxfXd9+trBYN/F61XczvflRSwKnqgSEjcK3WQU zThFTAmUTood6DS16xMPBpiBad1F9QI6q5yU4PcCV7HH20x95kp/xtVQWeQlRje0sjjsbRIAf6q I8/QWLYfMDZvsJRo8q/hPCzYDwYdETojAE0pYvGMj+HZND7hqOih8qouawLv9r5Gob0qBwqCBIs 5QVZZhog4Ph5YOvxeQHFSI2kSIYinLgXm8e2ackl9Yqrr0 X-Received: by 2002:a05:6a00:8e09:b0:827:3e19:574a with SMTP id d2e1a72fcca58-82d0db97457mr21444881b3a.42.1775649741673; Wed, 08 Apr 2026 05:02:21 -0700 (PDT) Received: from Mac.localdomain ([49.205.216.49]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-82cf9b3e169sm21209322b3a.18.2026.04.08.05.02.18 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 08 Apr 2026 05:02:20 -0700 (PDT) From: "Ritesh Harjani (IBM)" To: linuxppc-dev@lists.ozlabs.org, Haren Myneni Cc: Madhavan Srinivasan , Christophe Leroy , Venkat Rao Bagalkote , Nicholas Piggin , linux-kernel@vger.kernel.org, "Ritesh Harjani (IBM)" Subject: [RFC v2 07/10] pseries/papr-hvpipe: Refactor and simplify hvpipe_rtas_recv_msg() Date: Wed, 8 Apr 2026 17:31:37 +0530 Message-ID: <78feef3c4670f9de041e7e835b4451d42eb2d39a.1775648406.git.ritesh.list@gmail.com> X-Mailer: git-send-email 2.50.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Simplify hvpipe_rtas_recv_msg() by removing three levels of nesting... if (!ret) if (buf) if (size < bytes_written) ... this refactoring of the function bails out to "out:" label first, in ca= se of any error. This simplifies the init flow. Signed-off-by: Ritesh Harjani (IBM) --- arch/powerpc/platforms/pseries/papr-hvpipe.c | 52 ++++++++++---------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/arch/powerpc/platforms/pseries/papr-hvpipe.c b/arch/powerpc/pl= atforms/pseries/papr-hvpipe.c index 41958ed8ee97..ac2c4b42b373 100644 --- a/arch/powerpc/platforms/pseries/papr-hvpipe.c +++ b/arch/powerpc/platforms/pseries/papr-hvpipe.c @@ -190,34 +190,34 @@ static int hvpipe_rtas_recv_msg(char __user *buf, int= size) return -ENOMEM; } - ret =3D rtas_ibm_receive_hvpipe_msg(work_area, &srcID, - &bytes_written); - if (!ret) { - /* - * Recv HVPIPE RTAS is successful. - * When releasing FD or no one is waiting on the - * specific source, issue recv HVPIPE RTAS call - * so that pipe is not blocked - this func is called - * with NULL buf. - */ - if (buf) { - if (size < bytes_written) { - pr_err("Received the payload size =3D %d, but the buffer size =3D %d\n= ", - bytes_written, size); - bytes_written =3D size; - } - if (copy_to_user(buf, - rtas_work_area_raw_buf(work_area), - bytes_written)) - ret =3D -EFAULT; - else - ret =3D bytes_written; - } - } else { - pr_err("ibm,receive-hvpipe-msg failed with %d\n", - ret); + /* + * Recv HVPIPE RTAS is successful. + * When releasing FD or no one is waiting on the + * specific source, issue recv HVPIPE RTAS call + * so that pipe is not blocked - this func is called + * with NULL buf. + */ + ret =3D rtas_ibm_receive_hvpipe_msg(work_area, &srcID, &bytes_written); + if (ret) { + pr_err("ibm,receive-hvpipe-msg failed with %d\n", ret); + goto out; } + if (!buf) + goto out; + + if (size < bytes_written) { + pr_err("Received the payload size =3D %d, but the buffer size =3D %d\n", + bytes_written, size); + bytes_written =3D size; + } + + if (copy_to_user(buf, rtas_work_area_raw_buf(work_area), bytes_written)) + ret =3D -EFAULT; + else + ret =3D bytes_written; + +out: rtas_work_area_free(work_area); return ret; } -- 2.39.5 From nobody Mon Jun 15 06:26:17 2026 Received: from mail-pf1-f177.google.com (mail-pf1-f177.google.com [209.85.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 79C643B95F9 for ; Wed, 8 Apr 2026 12:02:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775649747; cv=none; b=liQLshzF1cwMgP0C4QITW9yoG2xnhYQ1mZDTarC0PwgCccVe8vyYpQKjmebzk61yQ1rXEzz+JhIKX3Xds4C/cIe2/r9ZtsYfPcutaiAjp3YXti8bjEwZ7+w3hABtfMmBTuZt5Ncqouh+bHAGJvZP6atzzKCHNeNsI3/7Uvg/Tdg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775649747; c=relaxed/simple; bh=OB1EJTI3OjTKytPUQyznROmSRXazcnBRHOjCCFirnGI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pl9HWi+oqiClReboOI5CHsvf3gjPK16UjkbyLbKjBYc8tkFi8afeZ69FGTbtJoEcVgcXKuon2K3FFMG58ipdN2sgLgMtOKqheYz7xSyXZUxnnI+Fc3f1hrpdOpm/VmhwYbk8yJLMHuADQIaRpYZmZC0n+9vZtNMN6fRTRBVfj1w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=nSBWWy4o; arc=none smtp.client-ip=209.85.210.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="nSBWWy4o" Received: by mail-pf1-f177.google.com with SMTP id d2e1a72fcca58-82cef263bedso2824682b3a.0 for ; Wed, 08 Apr 2026 05:02:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1775649746; x=1776254546; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=LvwUSoCp81ob7OZ/uiYdZqYepJJ6XzLLo7Vd69vn/eY=; b=nSBWWy4o8LbJEzo7J319Af518mY+skjgXHS2XbW5PYBgpvDpZjP4SbMTHMh1uyiL35 D5XA4rTeIInWVKKJq7Vt76N4XK1El3dckNrhaB1U2fK3e313kiPmsuNfz1N7xFDvs1Z5 XaxCEDWKQAsIVuHdlFQDdkjAn09r87OKxYEyB6JVpxaY4tS4L51ilpzDFNtMHUxA4+rv /cA2OMNdZGimQ0/GC688SIfcnKbBNnx4TSqIAKv+nB+PaRzaAdScdUWK53Bsr78A0X2s /ug10ZAVDAfscrB6XEJrLzSqLuaCHy42DT3Wcu8shZjkP6jBojLAGSUNKOrkKFYzigkN kXLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775649746; x=1776254546; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=LvwUSoCp81ob7OZ/uiYdZqYepJJ6XzLLo7Vd69vn/eY=; b=R1FTA1PLpgSK5sJ/2EIyx624NCwbSmGEfypFkGfr8gZLJ+70Mr1eOugO2hzFx8ZZN8 8fPcjdfqezbta9A7D/9XSeGl0B3Oz5n7BOoSrSgK9pSxOgCwrjA1TLHeLzQcVhf/VCsf DtKYqmVoxCd/T81ZSA/vbnmylDOK3JaFmxFNlmw4KahJFstXyTMppoBHERbzs/2Dwcyv raocwuvVEf0CsoOaONXUkEXc2YY0VZWfq+o3lp9LZH/JTLMvzdiS9tkEUjvyTc2lU/af BSATnnTouHqjhEihXdnFUD0tpBzplAUyIU8tKfoY1bwSUvhCgS4gubkUCClW2QFhl8WK xqYw== X-Forwarded-Encrypted: i=1; AJvYcCUIexJIk7+6VrsHckMElsKTthPx25wtnOqOmv8kvQoz2t8qCUpMISVJR2LE2rY6M9bzc04wzgQWJGeiXPs=@vger.kernel.org X-Gm-Message-State: AOJu0YwgXpTowkZ8IFewWReBJladCWNPt/ZpU4LjXBgnqioBZVdqKnEW FsQ+2LKnhJW61ZRcS+dJjnoVlV31Gd1jjoA9lSvK4Zu9PkxGG33QGN36 X-Gm-Gg: AeBDietY8cHWkLICjT7CLht3wtB+xacQZ7qN94EnnSL1RBarBf419sQoog60HUldNM+ NNXWTMgm6sVyBIOmkF0XJa4N10WkkPo1NNgTbR78M4bv4NqOldtxYwgXHwj/rMw0BFiKMpw7kkM TwrbsrjYUVPX7oCjlK68Tf+KlhxgFEuSyzVvcgIcGk6VMdpRNuW0XG4G2jiefnUmIsZDB3+4aKe K+yyxAOxqgKR9V3PpRvUrQmH6KzRwgd89h8lqtE7Sv3jaMNtRB8I8FnaAf2kQyEJaWYtYTLxC3F v/APh2UVwGa1Ulw7rcaPgkISIWzAe4XV6oRIiy+JAPp15gIq0d1EJj1sMXtfv2EBt4VfIc27+GC 3pLtLJfJivqt99ggXFWaIOdhWRI9OmUXIEe4/s/Ik7VIkQM9+Ux7MaUv+QfFCfSxHWI8xB/WSkD o8CLVe3rnQO+HU3SEHjTK30/vqKlbM1cnNkVsDz2BRwESo X-Received: by 2002:a05:6a00:6ca8:b0:82c:ae58:46ad with SMTP id d2e1a72fcca58-82d0dbc813emr20521123b3a.51.1775649745709; Wed, 08 Apr 2026 05:02:25 -0700 (PDT) Received: from Mac.localdomain ([49.205.216.49]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-82cf9b3e169sm21209322b3a.18.2026.04.08.05.02.22 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 08 Apr 2026 05:02:24 -0700 (PDT) From: "Ritesh Harjani (IBM)" To: linuxppc-dev@lists.ozlabs.org, Haren Myneni Cc: Madhavan Srinivasan , Christophe Leroy , Venkat Rao Bagalkote , Nicholas Piggin , linux-kernel@vger.kernel.org, "Ritesh Harjani (IBM)" Subject: [RFC v2 08/10] pseries/papr-hvpipe: Simplify error handling in papr_hvpipe_init() Date: Wed, 8 Apr 2026 17:31:38 +0530 Message-ID: <82eca9775d5c66104d7499aa877841cd89d5731d.1775648406.git.ritesh.list@gmail.com> X-Mailer: git-send-email 2.50.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Remove such 3 levels of nesting patterns to check success return values from function calls. ret =3D enable_hvpipe_IRQ() if (!ret) ret =3D set_hvpipe_sys_param(1) if (!ret) ret =3D misc_register() Instead just bail out to "out*:" labels, in case of any error. This simplifies the init flow. Signed-off-by: Ritesh Harjani (IBM) --- arch/powerpc/platforms/pseries/papr-hvpipe.c | 26 +++++++++++--------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/arch/powerpc/platforms/pseries/papr-hvpipe.c b/arch/powerpc/pl= atforms/pseries/papr-hvpipe.c index ac2c4b42b373..5d04d1fa4370 100644 --- a/arch/powerpc/platforms/pseries/papr-hvpipe.c +++ b/arch/powerpc/platforms/pseries/papr-hvpipe.c @@ -783,23 +783,27 @@ static int __init papr_hvpipe_init(void) } =20 ret =3D enable_hvpipe_IRQ(); - if (!ret) { - ret =3D set_hvpipe_sys_param(1); - if (!ret) - ret =3D misc_register(&papr_hvpipe_dev); - } + if (ret) + goto out_wq; =20 - if (!ret) { - pr_info("hvpipe feature is enabled\n"); - hvpipe_feature =3D true; - return 0; - } + ret =3D set_hvpipe_sys_param(1); + if (ret) + goto out_wq; =20 - pr_err("hvpipe feature is not enabled %d\n", ret); + ret =3D misc_register(&papr_hvpipe_dev); + if (ret) + goto out_wq; + + pr_info("hvpipe feature is enabled\n"); + hvpipe_feature =3D true; + return 0; + +out_wq: destroy_workqueue(papr_hvpipe_wq); out: kfree(papr_hvpipe_work); papr_hvpipe_work =3D NULL; + pr_err("hvpipe feature is not enabled %d\n", ret); return ret; } machine_device_initcall(pseries, papr_hvpipe_init); --=20 2.39.5 From nobody Mon Jun 15 06:26:17 2026 Received: from mail-pf1-f176.google.com (mail-pf1-f176.google.com [209.85.210.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AEE12382371 for ; Wed, 8 Apr 2026 12:02:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775649751; cv=none; b=L05ukGrNcyFh7pD6KKdlH1w/UkGk9s42JHkoI6Vl5tgftgWYHdwXS/R2mIbpgdxq8SWbgtd9QGPBZORr7YSVEjWTmX1nMWTYd10fc5sOEEdagtEum0lHP1wMQW7gp1gT1PVQTrBT0xKKuP4MWHwRyAtVGJBMCW9hRdJZjDnsg1Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775649751; c=relaxed/simple; bh=xMbK7T6KWi0V+gO4vzEsqrXXTtPwjXs8fCxY/s3y6qM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QG8qXOEsDJj2wJNxDjDuOfd1xxKpKkAYHdKvHr6X8Ocv5ykNKzYs9L6EquLa7tWBuCORRGsCOQ1zHR6Oi0/am7jOPSfYuL3Ux62wY3ZddT9ngvJ4H3DdZSXLNbMOuR4dYNoN2xma7E6I4yYFeAq3wcreThuvwphfp/+z7E4Etz8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=pA15+2TK; arc=none smtp.client-ip=209.85.210.176 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="pA15+2TK" Received: by mail-pf1-f176.google.com with SMTP id d2e1a72fcca58-82cd6614a90so2723252b3a.3 for ; Wed, 08 Apr 2026 05:02:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1775649750; x=1776254550; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Q3dbB2q+3EGiEdHuQW3UFthejsHpGEStr/Ch17qN9iY=; b=pA15+2TKSN2luHw7vo6dQLaUtbl+B4uwjfm9VbbqhSDyuDyMTU23PhXuG/8nAOL18C VeOysNSbt1vCdsW1YbRGFNeSiNIMF89NPihQsuV2oNrHkixfwBgOvSK3h3tLQVXNPLF1 l2/mz4BGuK+UHaTHd+LIpeBMZqxkhZYvJAY4qlzV2xCob8T5NhcYm6QNAW5F3rMgwj+p Utc7+BbUVpQqeIei/XweC8trlLcS8WYFOytvVZO/m+/l9RyT94hbgoQqIBK5chNcemL5 Gh1r8145UDA3CjUrU7kTQS7iRPWsNjrxsmloprGHD8ie2N/8b/6xq8um4hSxnrHQ+5Gn 7bEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775649750; x=1776254550; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=Q3dbB2q+3EGiEdHuQW3UFthejsHpGEStr/Ch17qN9iY=; b=jjrvu9aTWQ1uTEdwx98XeSxD49+R5Cpj1FLuxCqsSwo6JGC8387s9n1v/RSY4Bx4YL SlLSa1lprzXCxSgz3I5QISR/mCWWh19o6EwP/WsFWo6W/CfFDC35FSIFAswxTbnamvBp O4PdPAWgi3Cfv2oZxKeQdvfeHt3E+gbUbSxWp/tWSlH4HyLrdXhZTAZGJrt35nMqXPay POXhO01MVjRwfU5cxslDROTCD50tcJacNVQ8esTqVwaYbxxWMcshGuBxnSEIrpQZ0fUj 7mNu+SgVRJjw2787wj2EEMzarhTQb7dUmWzy6zsigzH/sabgkEmtfIO7kR/uYNFU0xUI lwaQ== X-Forwarded-Encrypted: i=1; AJvYcCUy6+vyA0vmv9QQx0w1KHDFSi35fumgBa/eWunZSpBeQlnnjmIDLhCRz3epLASgpWV0ExwXoGzmyAqCoaw=@vger.kernel.org X-Gm-Message-State: AOJu0YzJeoPtZbRQd5f982vHU51MhhcHPSbELiN4U0jsloqOacSUPVDT xsTRvLFll4C8G0Q3Sw440AJwqTTrc4BIwBk7hpcr4440+SG4g3MWfYwv X-Gm-Gg: AeBDiev/EBoaU81AovzFoiWrqI1hmhtLI6IQLW+snLRt3iO7OLoM94iRpsncvGD6kD1 Uodb8PWUwl6q9NfXjBTOI4TU/5a+OY4TeOBFaEIYp372+EFhwiSHgi3nSpQSEG9WhAHKFdC9fzX 8aDynIHjedYeQFBjEbV4hYSS0w5tR6KVBYl4wiIrdKFfM7KPlkE/kr8fpnJfq7UWf2HrrPyjKSH SFXb/n3r7gidBW6Iv5x8PzmvGL+9y1KJYi5v0L6uRLG2pPbDWpTdSFWPdaNi912ZdXY42K3MWyn c4tyc3P30RZ2StRnLvdPcAWGGhi9itTO4qCmPF8K29og4UQNN3LQbvnxy42mVGS9BmIJUlqOMSH BMkYFh5m4GfgkyzWIq2Wyr92cSz5DaJsPs9DViuFwLhGRrUb5FZ9Wg9rjuigUxLbNR6Rbyy7dvp IunXp2UgovCUsfaL2x//BafkrJzFACLCsqQv9099Va1tSW X-Received: by 2002:a05:6a00:1405:b0:82c:2480:4e3d with SMTP id d2e1a72fcca58-82d0da44765mr19104719b3a.9.1775649750053; Wed, 08 Apr 2026 05:02:30 -0700 (PDT) Received: from Mac.localdomain ([49.205.216.49]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-82cf9b3e169sm21209322b3a.18.2026.04.08.05.02.26 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 08 Apr 2026 05:02:29 -0700 (PDT) From: "Ritesh Harjani (IBM)" To: linuxppc-dev@lists.ozlabs.org, Haren Myneni Cc: Madhavan Srinivasan , Christophe Leroy , Venkat Rao Bagalkote , Nicholas Piggin , linux-kernel@vger.kernel.org, "Ritesh Harjani (IBM)" Subject: [RFC v2 09/10] pseries/papr-hvpipe: Fix style and checkpatch issues in enable_hvpipe_IRQ() Date: Wed, 8 Apr 2026 17:31:39 +0530 Message-ID: <8e9de6c5a96b66f4ee8ed6801684ae0222dc6752.1775648406.git.ritesh.list@gmail.com> X-Mailer: git-send-email 2.50.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" While at it let's also fix the similar style issue in enable_hvpipe_IRQ() function. This also fixes a minor checkpatch warning which I got due to an extra space before " =3D=3D". Signed-off-by: Ritesh Harjani (IBM) --- arch/powerpc/platforms/pseries/papr-hvpipe.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/arch/powerpc/platforms/pseries/papr-hvpipe.c b/arch/powerpc/pl= atforms/pseries/papr-hvpipe.c index 5d04d1fa4370..c708869ca732 100644 --- a/arch/powerpc/platforms/pseries/papr-hvpipe.c +++ b/arch/powerpc/platforms/pseries/papr-hvpipe.c @@ -693,20 +693,19 @@ static int __init enable_hvpipe_IRQ(void) struct device_node *np; =20 hvpipe_check_exception_token =3D rtas_function_token(RTAS_FN_CHECK_EXCEPT= ION); - if (hvpipe_check_exception_token =3D=3D RTAS_UNKNOWN_SERVICE) + if (hvpipe_check_exception_token =3D=3D RTAS_UNKNOWN_SERVICE) return -ENODEV; =20 /* hvpipe events */ np =3D of_find_node_by_path("/event-sources/ibm,hvpipe-msg-events"); - if (np !=3D NULL) { - request_event_sources_irqs(np, hvpipe_event_interrupt, - "HPIPE_EVENT"); - of_node_put(np); - } else { - pr_err("Can not enable hvpipe event IRQ\n"); + if (!np) { + pr_err("No device node found, could not enable hvpipe event IRQ\n"); return -ENODEV; } =20 + request_event_sources_irqs(np, hvpipe_event_interrupt, "HPIPE_EVENT"); + of_node_put(np); + return 0; } =20 --=20 2.39.5 From nobody Mon Jun 15 06:26:17 2026 Received: from mail-pf1-f180.google.com (mail-pf1-f180.google.com [209.85.210.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 178EE38F25D for ; Wed, 8 Apr 2026 12:02:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775649756; cv=none; b=JZSdB/WkEAXnQJngtmjL8eRnTK7VrhNe9mjIs633TRPO6AQgudlDpryl95EV8km7FgbjeFVm440gefRCKoPb4wIrgitLrBLYH2oIGw5L7VfCpxbxd6cjWnf8K31Q1z8pzOe/bW8aLxejeINVmDgSaOw3RZOzxVuflQL461jENhk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775649756; c=relaxed/simple; bh=aFUbtpt9Tomu9YSEge6zlhFTW2jyhVQ/M5oB3NWYB/U=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ZL2mZH4Dh39tqiOYfxSWQezpMbwaSLshnYvXyg+tH7Td2VZoV76i+BzMUPFtEDjCjklUtDbgXa9Kn5zRJ//GnIwZMknujHX3uH7lJKVlBTjBIoNjsSHA12Riqx6g/SMQLt6MxgyfgnfvBu4yaImti6BdWsFzHiTnjLRlfN4fudQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=QuKvpYEl; arc=none smtp.client-ip=209.85.210.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="QuKvpYEl" Received: by mail-pf1-f180.google.com with SMTP id d2e1a72fcca58-82cdb4ab547so3030235b3a.2 for ; Wed, 08 Apr 2026 05:02:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1775649754; x=1776254554; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=HxF/5xyzxh7moQ/DzCaZduABbVHgNK2NM9rE5Y5cP+w=; b=QuKvpYElVZbRx0NVRR+UddSGLkzRWCWopPPXTzkGt5appvTzkHONmI6ggswgPhxDhe dCrB3MfvZaczQrEB03Bw8qXrb2TUr0Qg9LFi/mNG0n/naKxWXQlRYKBxNWE8GUA4wOdm 76ascwpdF7NkVRAB6yLB5Jd9qAU8u7bOisj3OIC70lN6nfstbJgJMAO9X/9YKccic5i5 g5EPhSwhv0YfP1gHFOERHOVoupCCjLDwmk0nUITIrHUHJ5qaDGfkeNZc33i65zIw6g9/ Sba0e7eFOcr+k7huKCijikIXs/QL2OLoEWIJ/Y8rc4CHRABZD+G7b7bYl6eK7jHpLyn0 fyZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775649754; x=1776254554; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=HxF/5xyzxh7moQ/DzCaZduABbVHgNK2NM9rE5Y5cP+w=; b=iUN1h3n3K2c4Sm47F+9K7D1QfKC4nULpRxRCeXKKEYmUxadV8Sj8MHUHJGLhcKX00O CE/B3mfluTo9Lul+xLdk4c6ZdO7kkkuKagUmml7FUHx9CO7VmD9bYuYOzVK1pmJtsekk Jb/eNoV8F2fyf50lsmJlCGDw9vpUA46cF0NCa67eIPL7x9/BB5wCx3bfPNgh0zs9CklW i6XzpUA5pfSNqpwrntBzWcDWayOrO6kuPrLfSK+RfvcFjj9yoiszPbcTYcHDFiQzkSER QaVixrNo/Og/jy7JF9H0tbU8RQwV+ixMolyUhUHG93CZRoC2cyOcmVzu05rNpM40+g0h PjKw== X-Forwarded-Encrypted: i=1; AJvYcCUMB2JvBP6X+Lw/POjZbuR2A+0bn2Q2SACxIUmxowpD8FF8T7LsO1y7VUtnMi+T8M33plerus35QVbCb2M=@vger.kernel.org X-Gm-Message-State: AOJu0YyS830B7lEUr0A1qf0/wUJtc6eLGtBPVmmLstPokG4azvH3KN+K j+9UHlwfEbW1G5D98ZVy0+MEO3x9JwV9vbmAvm5dmO1GfGWBoZ4MNJqwODVbeA== X-Gm-Gg: AeBDiethq3OLiSh+zW9cpCMYDsLJZ1JN16VZ4CpO7+QWT3JB/+X1IhS062G0RzI3TI3 UpfP7tXDeQ+2ITgWCq5mU6xPpY25RZREtX3Ul7bH2BW/LLUEW2AimUSC/pKo5S02BvwriqzS2yD 9UnvftmlBKZZc3R5mBUDt6EdIS3XrnY6IMTFzjK5+ioGgMM5M9ksmBPRZhL1YyokEsvtT5x/O8P FsEHV0hdQrSzdPNHZI3LMPFF/dV78x5n0mBcdKh7nGmRJ93Lv0htjgGp/LR03OPvqjLwnGIdf3K /cckvdtg8r5eMlFmBqnvaItUk3SFpO9QFUQN6aglvqJKKWOD7qlaEqsgjdyVdBFI76uOQJRZYn3 UmIopKwk9EC4TUzkfbwbFoWSliXtFozHHJddD00BuKEo4XGDhblK5MOd7MeGcdy4+6Qjz05N8/X /WcqaR0ZsLmpvzHXlo5DHNbFzH+B5VJnGmiOwG62EKQc4u5z4ch/COGYw= X-Received: by 2002:a05:6a00:3e12:b0:82c:7876:a03e with SMTP id d2e1a72fcca58-82d0da8f384mr20097042b3a.17.1775649754432; Wed, 08 Apr 2026 05:02:34 -0700 (PDT) Received: from Mac.localdomain ([49.205.216.49]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-82cf9b3e169sm21209322b3a.18.2026.04.08.05.02.30 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 08 Apr 2026 05:02:33 -0700 (PDT) From: "Ritesh Harjani (IBM)" To: linuxppc-dev@lists.ozlabs.org, Haren Myneni Cc: Madhavan Srinivasan , Christophe Leroy , Venkat Rao Bagalkote , Nicholas Piggin , linux-kernel@vger.kernel.org, "Ritesh Harjani (IBM)" Subject: [RFC v2 10/10] pseries/papr-hvpipe: Fix error handling in case of init routine fails Date: Wed, 8 Apr 2026 17:31:40 +0530 Message-ID: <3ff4de80fce72914eff23a169c974786858517e1.1775648406.git.ritesh.list@gmail.com> X-Mailer: git-send-email 2.50.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" We have already enabled interrupt sources and enabled hvpipe to received interrupts, if misc_register() fails, we will destroy the workqueue, but the HMC might send us a msg via hvpipe which will call, queue work on the workqueue which might be destroyed. So instead, let's reverse the order of enabling set_hvpipe_sys_param(1) and in case of an error let's remove the misc dev by calling misc_deregister(). Signed-off-by: Ritesh Harjani (IBM) --- arch/powerpc/platforms/pseries/papr-hvpipe.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/arch/powerpc/platforms/pseries/papr-hvpipe.c b/arch/powerpc/pl= atforms/pseries/papr-hvpipe.c index c708869ca732..b6d0b36915c6 100644 --- a/arch/powerpc/platforms/pseries/papr-hvpipe.c +++ b/arch/powerpc/platforms/pseries/papr-hvpipe.c @@ -785,18 +785,20 @@ static int __init papr_hvpipe_init(void) if (ret) goto out_wq; - ret =3D set_hvpipe_sys_param(1); + ret =3D misc_register(&papr_hvpipe_dev); if (ret) goto out_wq; - ret =3D misc_register(&papr_hvpipe_dev); + ret =3D set_hvpipe_sys_param(1); if (ret) - goto out_wq; + goto out_misc; pr_info("hvpipe feature is enabled\n"); hvpipe_feature =3D true; return 0; +out_misc: + misc_deregister(&papr_hvpipe_dev); out_wq: destroy_workqueue(papr_hvpipe_wq); out: -- 2.39.5