From nobody Fri Feb 13 16:37:23 2026 Received: from mail-yb1-f201.google.com (mail-yb1-f201.google.com [209.85.219.201]) (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 B98AC14A82 for ; Thu, 23 May 2024 16:04:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716480265; cv=none; b=Vpfa+TMTT02oqGWZcN7eBXXskC8AE6AleCfEiwWKBgtWMpuJPjjP//Yqgqu6fOJ6Wo0EHHPeXLNG4G5bGz8WtLmOb232CVMXZAVMCmyF3ix57X/HNM9tFPdsGPc2KHMezkIuqPEPza+Ssv3IxcdAg1NCQfInAhi2JvU37NA1iVo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716480265; c=relaxed/simple; bh=03UHZfKAtBNlLwH0CZMJBaBFQPZIRqFCOkef15fj/yY=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=hoh65Bf5IUS+yK0LNlJX+PbQEFxjhng5Dh/VYGYnG3sQfS/zDPiDv2JyltMpzEtaLVov9wQA0gOjB6yiUmhEtfJcSplxCmcmq93eGkAI1UfltYixBIywlHV4UH+d9KTQ7EkyK5cITw3OaKimiCnsFE78XunJRnda8CAnyuZ2Eto= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--sebastianene.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=luLavgD8; arc=none smtp.client-ip=209.85.219.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--sebastianene.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="luLavgD8" Received: by mail-yb1-f201.google.com with SMTP id 3f1490d57ef6-df4e86c7d39so3128455276.2 for ; Thu, 23 May 2024 09:04:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1716480263; x=1717085063; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=YPQFdz2LOhxHiN/om4KkSSYOqO0RGIsb3SSw4n/adp8=; b=luLavgD8dR10ePRdop1LhwyVY3nKrJX71S8QspLtoxY8hD1DuvibOQXkGCR/BVP97Z +0HiVUit7ag/eToyMNXtTvp04WKznIYMSaEjU40DAoc3cg+AaFTprma1zYmS/4Vqo2FR +FcV6EQv/8HEswN/2PyLGMtUsAWnBVIHX6JQHzgOJaT7XLoTlqIKJdcLn9tBowCRaldv LUssJKCKRZSWeoxORo0y9SUnkMm+0djpSgT+lWqxz0RZL0MZqPOsKjrllVzvtitwlbGg b6H91ORze+yExjuwtoGy27YLh8G768unFnDVxxI9wZSmpNpEgg/es4Xs7XDH5WJ5IHKY QTgQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716480263; x=1717085063; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=YPQFdz2LOhxHiN/om4KkSSYOqO0RGIsb3SSw4n/adp8=; b=Ap4kt8jujstYL9F/hPprZBpRHYjqTjkcx0ly8keWawPKwh1qQQXmq72OT+mRnEGAUn XEH8NySoBK3+eOo+nutcrJPr8ILffnq6ruWNTlq49DScR7BxsjKqrKm7KuWW2wHPvPWf Hk49Fzf9lUZftooutEN9sPVO9mUGFW/D3DaZuuefiV+OPVfMnrqRU1SEuFMxItTKE8MU cubW/FPp3J09a0Ca7q/z+zF2up62Ck9J7yZxLtmxp2F2cy8fzFc+2jHV8BfpjxEgOLkW 4wZoY8YEfMqEuuKI7ehcr7F2BNoXAMJ8UO+xDLeHq6+sNYQpElvKpybRyG5GmWJVOg5r clwg== X-Gm-Message-State: AOJu0YyH7ijQ6i6FxUV5HdLVVvtSCAtoBHcdWF9U2Y3Sm/TPus2kv97L OgLHXqPH9ObT0a/LJWLAjZPI1iWZdWzvSarFYyWmU6CKqYMbOmsDQgJ4FwZH8wpDng3U11aDA5x v9H2R79R6nFisAMrGrr9gnq3buA== X-Google-Smtp-Source: AGHT+IGLtprpewNaPwvA33vAxsqmxIcNdZv7l9A4L9Dlu5J4R4Npwq8RXML9iq9TjEe3qMDW9kUt96ZxiOC87YwNAhY= X-Received: from sebkvm.c.googlers.com ([fda3:e722:ac3:cc00:28:9cb1:c0a8:cd5]) (user=sebastianene job=sendgmr) by 2002:a05:6902:20c1:b0:de5:3003:4b64 with SMTP id 3f1490d57ef6-df4e0a80c05mr417513276.1.1716480262730; Thu, 23 May 2024 09:04:22 -0700 (PDT) Date: Thu, 23 May 2024 16:04:12 +0000 In-Reply-To: <20240523160413.868830-1-sebastianene@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240523160413.868830-1-sebastianene@google.com> X-Mailer: git-send-email 2.45.1.288.g0e0cd299f1-goog Message-ID: <20240523160413.868830-2-sebastianene@google.com> Subject: [PATCH 1/2] dt-bindings: vcpu_stall_detector: Add a PPI interrupt to the virtual device From: Sebastian Ene To: arnd@arndb.de, gregkh@linuxfoundation.org, will@kernel.org, maz@kernel.org, Rob Herring , Dragan Cvetic , Guenter Roeck Cc: linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, kernel-team@android.com, Sebastian Ene Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The vcpu stall detector allows the host to monitor the availability of a guest VM. Introduce a PPI interrupt which can be injected from the host into the virtual gic to let the guest reboot itself. Signed-off-by: Sebastian Ene Acked-by: Conor Dooley --- .../devicetree/bindings/misc/qemu,vcpu-stall-detector.yaml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Documentation/devicetree/bindings/misc/qemu,vcpu-stall-detecto= r.yaml b/Documentation/devicetree/bindings/misc/qemu,vcpu-stall-detector.ya= ml index 1aebeb696ee0..e12d80be00cd 100644 --- a/Documentation/devicetree/bindings/misc/qemu,vcpu-stall-detector.yaml +++ b/Documentation/devicetree/bindings/misc/qemu,vcpu-stall-detector.yaml @@ -29,6 +29,9 @@ properties: Defaults to 10 if unset. default: 10 =20 + interrupts: + maxItems: 1 + timeout-sec: description: | The stall detector expiration timeout measured in seconds. @@ -43,9 +46,12 @@ additionalProperties: false =20 examples: - | + #include + vmwdt@9030000 { compatible =3D "qemu,vcpu-stall-detector"; reg =3D <0x9030000 0x10000>; clock-frequency =3D <10>; timeout-sec =3D <8>; + interrupts =3D ; }; --=20 2.45.1.288.g0e0cd299f1-goog From nobody Fri Feb 13 16:37:23 2026 Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.202]) (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 0259C1D55D for ; Thu, 23 May 2024 16:04:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716480268; cv=none; b=FOMP0jlq1yyvhzhOqtwVbxd0o4NhbjS2qf7/58bwuz1t5Nvo0dJ10VsGctvQQ+ArynV9Gkv+BU5VaVVHYI91baaZELww1U3Hs0AczWDVKUt04aSKldsbVxcVlQ0r/VrIIqNVt7adnibF3jMAleiVl/cK0HMUNoTEXfiTVLBcygU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716480268; c=relaxed/simple; bh=EhTBCoWEsH6RQeHWfu+3Ppem+Bmf+xIMkgx/LOGt+8s=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=BgysTmtM9dj6UVqcOK1AYqMe5cNQAL2bAZuUu1/uZ3xU9x4ey+wIGTP6zOArRr2MEzkEEO272hLbslC0AzFG1jnJfraBPCLYRpUU6fr2Ch1UsgNrvrtLWsqpX/QajS4L2Gito2HVei8Whdlk7oUNu8kUcvn9scIqFUJfGS2E+Eo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--sebastianene.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=RXxeiBjj; arc=none smtp.client-ip=209.85.128.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--sebastianene.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="RXxeiBjj" Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-61b2ef746c9so254101517b3.1 for ; Thu, 23 May 2024 09:04:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1716480265; x=1717085065; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=3d3iyJqmM/1eDHi6IVV043bTCqbOnpQe2A0l9FAURNs=; b=RXxeiBjjFncawXnhuOMFZDJN5S23C+oXf0DEXlPgBqL108Uwku/Z+RmPh9S7gWEPsl N3ndt7oExXpqqgzIITD6ugUGkN8CBJskCX8Hvfz9638+vPGAlWPrpYmR6O6Zpj9mvpAT CuX7RWD8P3SXOSvKBQTb71FwKeFY+c68HEPKzUkDYoYI59yToe4VirrkZ76WP5q0KKTu jGAbtt6CKpjBjRJh3pEUB/95sARYDXm/7eWU3ef8p326OaFQnkkl4fY0XLlUI3EiMmSi fuevxJCBy8hHUGEkHG4jLxtUQAxJ0hKXk2DjXz+uSyKEiV29C0zbFYQbx+HnkRy/P5Te eKEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716480265; x=1717085065; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=3d3iyJqmM/1eDHi6IVV043bTCqbOnpQe2A0l9FAURNs=; b=aYFvPuP+einmD1pGjXTxL8XBCKpQIsbIFcUHADUv+XGP8Wz//+eiNUrBqeeUyqwPJ+ TntzP2bYZE03dDjGwL+3Ub7NiGRKUtCcyAlDRnGSWDGXhxYXSYLt3AmprFCaBNOlNNAj araI/GQshczT+r9ioPrhD8rBBCxiQnwrqz4BJ4G/AYmazQIWli6E9aGDWc0PuHiv9gAj Xb0xXqE+0rDlj5MtFeqFGXLyUwz9idAaZnIZJv7Sj9wAloNMZjLoiWirmcowRAniuQVl /NZNFiho6KPyX7Dsdj2jvpaZHqG2QnEjoeAYvfrZ49lZeDzI7yxCNPzneVbrhRwVTXXU UnJA== X-Gm-Message-State: AOJu0YwcGElu6dqG21FbuztzwSFwCmbeEnhmoEXsUPRvngmK6UAcbXmv chqGXs07qAj4+SKP2xAuAlXMCPMsQvRZKOHsS6DrFTaTHvJyvI12wTGsOzVkzSKtGkv3YUXZ6JD TjBeT5ZPOrcx3p2ZXkqQCSsaUmw== X-Google-Smtp-Source: AGHT+IESLjYZSJRI10bNAhY1mQgDdw0aTOQt2wYMTwe81yGAhnG89hGg49am+K4s35CF2jj0v1b5wbDesfLFNl9I1x0= X-Received: from sebkvm.c.googlers.com ([fda3:e722:ac3:cc00:28:9cb1:c0a8:cd5]) (user=sebastianene job=sendgmr) by 2002:a05:6902:1207:b0:df4:db4d:5db2 with SMTP id 3f1490d57ef6-df4e0bcd6d0mr1593000276.7.1716480265117; Thu, 23 May 2024 09:04:25 -0700 (PDT) Date: Thu, 23 May 2024 16:04:13 +0000 In-Reply-To: <20240523160413.868830-1-sebastianene@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240523160413.868830-1-sebastianene@google.com> X-Mailer: git-send-email 2.45.1.288.g0e0cd299f1-goog Message-ID: <20240523160413.868830-3-sebastianene@google.com> Subject: [PATCH 2/2] misc: Register a PPI for the vcpu stall detection virtual device From: Sebastian Ene To: arnd@arndb.de, gregkh@linuxfoundation.org, will@kernel.org, maz@kernel.org, Rob Herring , Dragan Cvetic , Guenter Roeck Cc: linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, kernel-team@android.com, Sebastian Ene Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Request a PPI for each vCPU during probe which will be used by the host to communicate a stall detected event on the vCPU. When the host raises this interrupt from the virtual machine monitor, the guest is expected to handle the interrupt and panic. Signed-off-by: Sebastian Ene --- drivers/misc/vcpu_stall_detector.c | 41 ++++++++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 2 deletions(-) diff --git a/drivers/misc/vcpu_stall_detector.c b/drivers/misc/vcpu_stall_d= etector.c index e2015c87f03f..c580cd7fd225 100644 --- a/drivers/misc/vcpu_stall_detector.c +++ b/drivers/misc/vcpu_stall_detector.c @@ -32,6 +32,7 @@ struct vcpu_stall_detect_config { u32 clock_freq_hz; u32 stall_timeout_sec; + int ppi_irq; =20 void __iomem *membase; struct platform_device *dev; @@ -77,6 +78,12 @@ vcpu_stall_detect_timer_fn(struct hrtimer *hrtimer) return HRTIMER_RESTART; } =20 +static irqreturn_t vcpu_stall_detector_irq(int irq, void *dev) +{ + panic("vCPU stall detector"); + return IRQ_HANDLED; +} + static int start_stall_detector_cpu(unsigned int cpu) { u32 ticks, ping_timeout_ms; @@ -132,7 +139,7 @@ static int stop_stall_detector_cpu(unsigned int cpu) =20 static int vcpu_stall_detect_probe(struct platform_device *pdev) { - int ret; + int ret, irq, num_irqs; struct resource *r; void __iomem *membase; u32 clock_freq_hz =3D VCPU_STALL_DEFAULT_CLOCK_HZ; @@ -169,9 +176,32 @@ static int vcpu_stall_detect_probe(struct platform_dev= ice *pdev) vcpu_stall_config =3D (struct vcpu_stall_detect_config) { .membase =3D membase, .clock_freq_hz =3D clock_freq_hz, - .stall_timeout_sec =3D stall_timeout_sec + .stall_timeout_sec =3D stall_timeout_sec, + .ppi_irq =3D -1, }; =20 + num_irqs =3D platform_irq_count(pdev); + if (num_irqs < 0) { + dev_err(&pdev->dev, "Failed to get irqs\n"); + ret =3D num_irqs; + goto err; + } else if (num_irqs > 1) { + dev_err(&pdev->dev, "Multipple irqs detected\n"); + ret =3D -EINVAL; + goto err; + } else if (num_irqs =3D=3D 1) { + irq =3D platform_get_irq(pdev, 0); + if ((irq > 0) && irq_is_percpu_devid(irq)) { + ret =3D request_percpu_irq(irq, + vcpu_stall_detector_irq, + "vcpu_stall_detector", + vcpu_stall_detectors); + if (!ret) + vcpu_stall_config.ppi_irq =3D irq; + + } + } + ret =3D cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "virt/vcpu_stall_detector:online", start_stall_detector_cpu, @@ -184,6 +214,9 @@ static int vcpu_stall_detect_probe(struct platform_devi= ce *pdev) vcpu_stall_config.hp_online =3D ret; return 0; err: + if (vcpu_stall_config.ppi_irq > 0) + free_percpu_irq(vcpu_stall_config.ppi_irq, + vcpu_stall_detectors); return ret; } =20 @@ -193,6 +226,10 @@ static void vcpu_stall_detect_remove(struct platform_d= evice *pdev) =20 cpuhp_remove_state(vcpu_stall_config.hp_online); =20 + if (vcpu_stall_config.ppi_irq > 0) + free_percpu_irq(vcpu_stall_config.ppi_irq, + vcpu_stall_detectors); + for_each_possible_cpu(cpu) stop_stall_detector_cpu(cpu); } --=20 2.45.1.288.g0e0cd299f1-goog