From nobody Fri Oct 23 15:32:32 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1790940048; cv=none; d=zohomail.com; s=zohoarc; b=Uszd59rvgCrWrpKUgXdZ2YbpHycxna4sjvo6r7X6VE/4jk2tzJV3N1FpljjP3R5iRoimRijott+Es+skhSY/wr25Cfv1fAuW+s486JhhQlcz/nRP23HEi0Jc1UTbl1E5JTNZg1LSNgy7rKNnhMK9gLtW9hYlbRs5WL29UntzLRg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1790940048; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=UqlocLvpi/8FAA19/MNga9Pe2S0YGE5N86Jze2jUass=; b=kHw9ncCrtWCDM5qBNdhufevAM18F0SMjzR5x7Xn/6evnek1nhsHo18MQrr2UrLnzZeZQSVBVcNFJYmlJnaFB13Kq7O3d9Q5yDFsEHG/nZYfmehjfsRAFsTu2WJFiU5M1BxvVLV0OVhJ05N/OThkAbSbqADn6zg+/+Eqb+35l88c= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1790940048145578.5991257741592; Fri, 2 Oct 2026 04:20:48 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1439054.1657562 (Exim 4.92) (envelope-from ) id 1xCbJL-0004JO-4z; Fri, 02 Oct 2026 11:20:19 +0000 Received: by outflank-mailman (output) from mailman id 1439054.1657562; Fri, 02 Oct 2026 11:20:19 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1xCbJL-0004JH-2P; Fri, 02 Oct 2026 11:20:19 +0000 Received: by outflank-mailman (input) for mailman id 1439054; Fri, 02 Oct 2026 11:20:17 +0000 Received: from mail.xenproject.org ([104.130.215.37]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1xCbJJ-0004JB-GL for xen-devel@lists.xenproject.org; Fri, 02 Oct 2026 11:20:17 +0000 Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.96) (envelope-from ) id 1xCbJI-00B6IU-1Z; Fri, 02 Oct 2026 11:20:16 +0000 Received: from 224.pool85-54-217.dynamic.orange.es ([85.54.217.224] helo=localhost) by xenbits.xenproject.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1xCbJI-00AxNy-1E; Fri, 02 Oct 2026 11:20:16 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xenproject.org; s=20200302mail; h=Content-Transfer-Encoding:Content-Type: MIME-Version:Message-ID:Date:Subject:Cc:To:From; bh=UqlocLvpi/8FAA19/MNga9Pe2S0YGE5N86Jze2jUass=; b=Mw4YDfa2tDDstgIiVzMpa0MrDj +Ox629DkH69V9Ms/AGPLAIlA/yJAlCgt6j7Heq7EaFdhm6jU3IoYy4qv+OJh9dOfisugBZ3qgR1JZ 6+mAjKFsBhKf0sF/h+IQ2KPE+7Nx92nb6dBI9q2ghiVQZHC4NooM7SAT7jj/3AKpCoX0=; From: Roger Pau Monne To: xen-devel@lists.xenproject.org Cc: Grygorii Strashko , Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Teddy Astie Subject: [PATCH v2] x86/domain: restrict context switch hooks for the idle domain Date: Fri, 2 Oct 2026 13:20:05 +0200 Message-ID: <20261002112005.20656-1-roger@xenproject.org> X-Mailer: git-send-email 2.55.0 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @xenproject.org) X-ZM-MESSAGEID: 1790940048540158500 From: Grygorii Strashko The arch_init_idle_domain() initializes struct arch_csw idle_csw as: static const struct arch_csw idle_csw =3D { .from =3D paravirt_ctxt_switch_from, .to =3D paravirt_ctxt_switch_to, .tail =3D idle_loop, }; but only place where d->arch.ctxt_switch->{to,from}() are used is __context_switch() where they are both guarded by !is_idle_domain(pd) which makes the callbacks in idle_csw unreachable. Introduce a new poison value to be used in unreachable function hooks, and set the from/to fields of idle_csw to it. Use a different value from the currently defined ones for easy differentiation. Signed-off-by: Grygorii Strashko Signed-off-by: Roger Pau Monn=C3=A9 Reviewed-by: Jan Beulich --- Changes since v1: - Introduce and use a poison value instead of the implicit NULL. --- xen/arch/x86/domain.c | 4 ++-- xen/arch/x86/include/asm/config.h | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c index 996b50af7a17..6ebe6c5052b3 100644 --- a/xen/arch/x86/domain.c +++ b/xen/arch/x86/domain.c @@ -813,8 +813,8 @@ static bool emulation_flags_ok(const struct domain *d, = uint32_t emflags) void __init arch_init_idle_domain(struct domain *d) { static const struct arch_csw idle_csw =3D { - .from =3D paravirt_ctxt_switch_from, - .to =3D paravirt_ctxt_switch_to, + .from =3D FUNCTION_POISON, + .to =3D FUNCTION_POISON, .tail =3D idle_loop, }; =20 diff --git a/xen/arch/x86/include/asm/config.h b/xen/arch/x86/include/asm/c= onfig.h index 1b28349a427b..bf82cd082a59 100644 --- a/xen/arch/x86/include/asm/config.h +++ b/xen/arch/x86/include/asm/config.h @@ -56,6 +56,9 @@ #define LIST_POISON1 ((void *)0x0100100100100100UL) #define LIST_POISON2 ((void *)0x0200200200200200UL) =20 +/* Poison unreachable function hooks with a non-canonical value. */ +#define FUNCTION_POISON ((void *)0xDEAD0000DEAD0000UL) + #include =20 #define PML4_ENTRY_BITS 39 --=20 2.55.0