Received: by 2002:a89:413:0:b0:1fd:dba5:e537 with SMTP id m19csp176025lqs; Thu, 13 Jun 2024 07:14:49 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWJWpY0QQue+FrxN/3qeRFl06bFkbPEWswkMibnDRm+9H0lYO04oyo/wpMKGVuDJwkCBDgIsb/Y4/ccKX6/zFWs2XCts2G282r08VuYwg== X-Google-Smtp-Source: AGHT+IF6ZE28IxbDdjvibmoXkvGNOuxkcYcGSJuA4HlDAHYe365bT1aSG70D4iE0kaONO7LtAUt7 X-Received: by 2002:a05:622a:1828:b0:43d:dd5a:5d52 with SMTP id d75a77b69052e-4417a9fba62mr46053961cf.2.1718288089153; Thu, 13 Jun 2024 07:14:49 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718288089; cv=pass; d=google.com; s=arc-20160816; b=nEyM0/CU8escKYnr0p673zoqkwEnmfVsU19q890ch80QjqCmEwxt+/6ZY/5xx6YoI3 9tequvmVPntPDfaSM9ajOJ3+CRE0fuU9sY2gUD3ld5dtHSEGRg4NK1PPpINfTgNx/HC2 JIquhH8FhVY0drWmFJO3IR5tvvYVW/dYKJxALyUbdeqsN41BKMScKBIoBov/KCQdfLuO Zd38aoZvq/L8CJI99SdifdUKIYgrDhED24XbuhNYbTJ8ko/eINGrqeycavg5I0OzCORW nEQyiC6hiTyr9nNVLeHp5+espapNIH7MOxh6uYStjFc4gY+3GL1wyP7wQV3miZ3+iTtj Dldg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:from:subject:message-id:references:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:in-reply-to:date :dkim-signature; bh=kksLUlRbd518rfKCwHFZPSF7kwu3hMJcK/JCkJY2+7A=; fh=RQrvNSCRMHpTLVMajWvovKgjKU9yd9mGbpIc/8icGsw=; b=E96Knzo+Cbt8FdAlZX0/krr6/F45u1CnZ+FXq98Q7JNHQwNTY4Z+xKm68IXbBQvbA4 kXbyfloIuA+Tk9Zl0NWr+/ITxxopfhOAzvudVExQKx8wn3+pcxhwvefngIKMuDzY8v55 c/sQQUY5K9MkKD4LVmvu6v41F/lbE4t9yWJDsxJiMWuONmXjbKbSZW+4+0VpcZiHXzHB WEp21Xibu4wdYoeU+j3C5R5k3rC5YAkdvE9fX7TpWSVjbFJAa0tcKy/JC66LMc1Ru83/ xa+y3EkAcJr67Kti8TkcqKydyND23aPbWot1lreEkzpdvNWXPUguufcuOYDXt1KrcimR 2ZdA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=my73vdYd; arc=pass (i=1 spf=pass spfdomain=flex--sebastianene.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-213412-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-213412-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id d75a77b69052e-441f30f3ea3si14610891cf.639.2024.06.13.07.14.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Jun 2024 07:14:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-213412-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=my73vdYd; arc=pass (i=1 spf=pass spfdomain=flex--sebastianene.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-213412-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-213412-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 431191C20895 for ; Thu, 13 Jun 2024 14:14:44 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1CED7145B33; Thu, 13 Jun 2024 14:13:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="my73vdYd" Received: from mail-wr1-f73.google.com (mail-wr1-f73.google.com [209.85.221.73]) (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 A56DE146A7C for ; Thu, 13 Jun 2024 14:13:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.73 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718288031; cv=none; b=I0g8FV/VQQ5YZxWRgCdLlkoTYxixtnbYfh/vSSCSWpKCuUbwqwMcYA8DIyY5Qn+IQrse8PsyPu6/xH1nIB1km8Sy5Cx/a8zi8QP2ajR5VE4VSSWE9aYCMqC73xQMZUooqz7TnCKu0iy+6N9bJuStl/eM+jJc2OGIa8ACEJFP/zc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718288031; c=relaxed/simple; bh=aghr2MGo+eWlZkTOaZiyMRhjN7zE3f7gxvto8w/AHuU=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=JSQDj9UQJB/CZv48yFSWq2Ddqf8WzHw3htwI9gmUy8Fw+lAkqAB6HnK8v/Rj+RGeDJLMSblAPJsMzSuO0lcOdM9RS1TdYbWNeZGZgOqH8MRo4uqwlOkKEJ/djISu8NFqGLnj2Zw1sjW8kI+snTASxL4uHbW0mCnMgw0d8D1I+Bs= 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=my73vdYd; arc=none smtp.client-ip=209.85.221.73 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 Received: by mail-wr1-f73.google.com with SMTP id ffacd0b85a97d-35f1f358e59so596847f8f.0 for ; Thu, 13 Jun 2024 07:13:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1718288028; x=1718892828; 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=kksLUlRbd518rfKCwHFZPSF7kwu3hMJcK/JCkJY2+7A=; b=my73vdYdnqc65jYN9oebJJ7GYlRZPQgC5oEf3gj2oDxN9L1cYDBfPVq+N8DE9ErGix TnkZ73FoUEh1g+SrjnECUmcM7U99IJamRtgAsCfUnGrn7cPjug2VkKHWjSQn8e2zN/Th oR1UuHowE8cgeV9lXWZcrWXtykPuMnAn2MC7+2H4r0JMZ25LkjxnPgcJsWfU6fjDDwpq h8ctCxTHf3bOLFGVGhEBVDU7rfOpF0nAYCIXmjdaxVs4gH8siGmHaWd+FZewChl0zuvp p97i4uqnUGrmPCsEubleADE4b8l//iND5zC5Plp5RGIUdoFTIhqORpU/NGgOum8m7ugC xsqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718288028; x=1718892828; 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=kksLUlRbd518rfKCwHFZPSF7kwu3hMJcK/JCkJY2+7A=; b=vxvJnrFTHVN6VbfK9oDMUulTomKs3pSHJjdouIHdtt6iIvFJRBgvOqQvv/k/TTBx0V SNir2wdQOMx/nRHSYCf2TgyOXPcu8oFERHVB6vrnYBGHQidwGYwmNlRTevqhW7F/8mCY o767KGvQ5bP/naWaFXLt1lm27xuBqG0zmRo5hz3o/6wDu0fk6uCj1KtVjGkkENz9yXjj p6NmdZ8xp4Kill5Z1TK6SZL3muTGPJ1iDf9am/aWXDw8agSMRTfyXM2jlrP0BfDF/2eH HUSKjKcAaKaBQK9uRO9nidU0yI2/yC9N0bdCY19uHgpPOlBvoKDXTxNuZoAvaJkErXzJ 4J5g== X-Gm-Message-State: AOJu0Yx+8oswP2Wn/J70nmzpXGzk0CpQjUdsZjB24gJ21Mbuc9X+LnYo tS6HxPZ6x4J5FW0lxTjR3YUDp+6/i5jpFggMu+EZfFnEAfRswqCLBXCL+J6Z9lHTvDxtR58O1qz iCwwE+i6OkG8rPDT9NTWI+y+iow== X-Received: from sebkvm.c.googlers.com ([fda3:e722:ac3:cc00:28:9cb1:c0a8:cd5]) (user=sebastianene job=sendgmr) by 2002:a5d:6104:0:b0:35f:2f69:4246 with SMTP id ffacd0b85a97d-360718be27amr6841f8f.0.1718288028118; Thu, 13 Jun 2024 07:13:48 -0700 (PDT) Date: Thu, 13 Jun 2024 14:13:35 +0000 In-Reply-To: <20240613141335.1134341-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: <20240613141335.1134341-1-sebastianene@google.com> X-Mailer: git-send-email 2.45.2.505.gda0bf45e8d-goog Message-ID: <20240613141335.1134341-3-sebastianene@google.com> Subject: [PATCH v2 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-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 | 31 ++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/drivers/misc/vcpu_stall_detector.c b/drivers/misc/vcpu_stall_detector.c index e2015c87f03f..41b8c2119e20 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; void __iomem *membase; struct platform_device *dev; @@ -77,6 +78,12 @@ vcpu_stall_detect_timer_fn(struct hrtimer *hrtimer) return HRTIMER_RESTART; } +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) static int vcpu_stall_detect_probe(struct platform_device *pdev) { - int ret; + int ret, irq; struct resource *r; void __iomem *membase; u32 clock_freq_hz = VCPU_STALL_DEFAULT_CLOCK_HZ; @@ -169,9 +176,22 @@ static int vcpu_stall_detect_probe(struct platform_device *pdev) vcpu_stall_config = (struct vcpu_stall_detect_config) { .membase = membase, .clock_freq_hz = clock_freq_hz, - .stall_timeout_sec = stall_timeout_sec + .stall_timeout_sec = stall_timeout_sec, + .ppi_irq = -1, }; + irq = platform_get_irq_optional(pdev, 0); + if (irq > 0) { + ret = request_percpu_irq(irq, + vcpu_stall_detector_irq, + "vcpu_stall_detector", + vcpu_stall_detectors); + if (ret) + goto err; + + vcpu_stall_config.ppi_irq = irq; + } + ret = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "virt/vcpu_stall_detector:online", start_stall_detector_cpu, @@ -184,6 +204,9 @@ static int vcpu_stall_detect_probe(struct platform_device *pdev) vcpu_stall_config.hp_online = ret; return 0; err: + if (vcpu_stall_config.ppi_irq > 0) + free_percpu_irq(vcpu_stall_config.ppi_irq, + vcpu_stall_detectors); return ret; } @@ -193,6 +216,10 @@ static void vcpu_stall_detect_remove(struct platform_device *pdev) cpuhp_remove_state(vcpu_stall_config.hp_online); + 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); } -- 2.45.2.505.gda0bf45e8d-goog