From nobody Sat Nov 15 22:35:30 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linux.microsoft.com ARC-Seal: i=1; a=rsa-sha256; t=1747740807; cv=none; d=zohomail.com; s=zohoarc; b=IsX1aHgyxtCl4O0bseVQ1fFcFf2D4EIelWQSCIaDSvZIokF1zMG5jiO3LZmJb4a2ADhY0nLMR5ifccH5hrAEQbOC7yX1PynyjMszexT2LwQYoks5IJJXpmxCJ/Jsq+27nlhZq3mBiV3MKbXI6gYeiUS5PyEb4d7BRm1bINsfX0g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1747740807; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=O5AveMoK8EmReCoMvMCJ1vDHuzWdNWb/gBB/UE1Qmjs=; b=DvcfhPqM8sfn1TeMpsY49vNnRMwGrizHbxnkn0QBrTHjhCzdNzhe1h2/yaRerjzQU7XruOvMLSqF31nDCduloyna8K61ezA8TpmkxffYsEkLz9Cvrar2kSNtYOl53ytNTjgTD1qFzqFr7V+dyM1Qe7s2adBTnc8z6XVylXrfuac= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1747740807092165.67754861623314; Tue, 20 May 2025 04:33:27 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uHLCb-0008PR-EK; Tue, 20 May 2025 07:32:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uHLCQ-0008Cd-Tn for qemu-devel@nongnu.org; Tue, 20 May 2025 07:31:59 -0400 Received: from linux.microsoft.com ([13.77.154.182]) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uHLCM-0001KA-Th for qemu-devel@nongnu.org; Tue, 20 May 2025 07:31:57 -0400 Received: from DESKTOP-TUU1E5L.fritz.box (unknown [172.201.77.43]) by linux.microsoft.com (Postfix) with ESMTPSA id 1A29C20277E5; Tue, 20 May 2025 04:31:49 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 1A29C20277E5 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1747740713; bh=O5AveMoK8EmReCoMvMCJ1vDHuzWdNWb/gBB/UE1Qmjs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=agmdJtQT04hqbssRTI6NROen5cPOqtUEV95YDIh9gEFI4wVBCg0rpOMR7e5PQkJ0u Ib2V9RFk/5YpHOqjT7pUJxUEOhq9jvzxyR71hcyskYqN7CCtAGmCdN4nHPJ0+u27Bm rE2mh7tvEeR0OLZaGDFgDkp8m/KLwpl13t8wjxmg= From: Magnus Kulke To: magnuskulke@microsoft.com, qemu-devel@nongnu.org, liuwe@microsoft.com Cc: Paolo Bonzini , "Michael S. Tsirkin" , Wei Liu , Phil Dennis-Jordan , Roman Bolshakov , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Zhao Liu , Richard Henderson , Cameron Esfahani , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= Subject: [RFC PATCH 13/25] accel/mshv: Add vCPU signal handling Date: Tue, 20 May 2025 13:30:06 +0200 Message-Id: <20250520113018.49569-14-magnuskulke@linux.microsoft.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250520113018.49569-1-magnuskulke@linux.microsoft.com> References: <20250520113018.49569-1-magnuskulke@linux.microsoft.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=13.77.154.182; envelope-from=magnuskulke@linux.microsoft.com; helo=linux.microsoft.com X-Spam_score_int: -19 X-Spam_score: -2.0 X-Spam_bar: -- X-Spam_report: (-2.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linux.microsoft.com) X-ZM-MESSAGEID: 1747740809102116600 Content-Type: text/plain; charset="utf-8" Implement signal handling for MSHV vCPUs to support asynchronous interrupts from the main thread. Signed-off-by: Magnus Kulke --- accel/mshv/mshv-all.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/accel/mshv/mshv-all.c b/accel/mshv/mshv-all.c index 71fedc9137..97212c54f1 100644 --- a/accel/mshv/mshv-all.c +++ b/accel/mshv/mshv-all.c @@ -531,6 +531,33 @@ static int mshv_cpu_exec(CPUState *cpu) return ret; } =20 +/* + * The signal handler is triggered when QEMU's main thread receives a SIG_= IPI + * (SIGUSR1). This signal causes the current CPU thread to be kicked, forc= ing a + * VM exit on the CPU. The VM exit generates an exit reason that breaks th= e loop + * (see mshv_cpu_exec). If the exit is due to a Ctrl+A+x command, the syst= em + * will shut down. For other cases, the system will continue running. + */ +static void sa_ipi_handler(int sig) +{ + qemu_cpu_kick_self(); +} + +static void init_signal(CPUState *cpu) +{ + /* init cpu signals */ + struct sigaction sigact; + sigset_t set; + + memset(&sigact, 0, sizeof(sigact)); + sigact.sa_handler =3D sa_ipi_handler; + sigaction(SIG_IPI, &sigact, NULL); + + pthread_sigmask(SIG_BLOCK, NULL, &set); + sigdelset(&set, SIG_IPI); + pthread_sigmask(SIG_SETMASK, &set, NULL); +} + static void *mshv_vcpu_thread(void *arg) { CPUState *cpu =3D arg; @@ -547,6 +574,7 @@ static void *mshv_vcpu_thread(void *arg) error_report("Failed to init vcpu %d", cpu->cpu_index); goto cleanup; } + init_signal(cpu); =20 /* signal CPU creation */ cpu_thread_signal_created(cpu); --=20 2.34.1