From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5F3CBCA5FC4 for ; Fri, 2 Oct 2026 09:29:42 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.1438970.1657491 (Exim 4.92) (envelope-from ) id 1xCZa4-0002pn-07; Fri, 02 Oct 2026 09:29:28 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 1438970.1657491; Fri, 02 Oct 2026 09:29:27 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1xCZa3-0002pg-T0; Fri, 02 Oct 2026 09:29:27 +0000 Received: by outflank-mailman (input) for mailman id 1438970; Fri, 02 Oct 2026 09:29:27 +0000 Received: from mail.xenproject.org ([104.130.215.37]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1xCZa3-0002pa-9P for xen-devel@lists.xenproject.org; Fri, 02 Oct 2026 09:29:27 +0000 Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.96) (envelope-from ) id 1xCZa0-00B49v-0w; Fri, 02 Oct 2026 09:29:24 +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 1xCZa0-00ALzJ-0d; Fri, 02 Oct 2026 09:29:24 +0000 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=In-Reply-To:Content-Transfer-Encoding: Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date; bh=HQTkvW4crQrLD5QsKVOBIYliSOuz7b2d8MPIBDXnBTE=; b=ECd6g9PhWw0UAR5q2ZMx9CRbZe PN/DvIEecEXY2J1n1Cv40YNi3gZk9k07hLwtkmlBDIv5d2+V7bbN3D0Vzfhg/nnE3R+jxRtqdoiVx ShDXR1RrhVqf8tmRe280BfHRvGJgUTC8pjXuMNRSq5B/AtLS44TrI3j1CCWXmm3gkDyQ=; Date: Fri, 2 Oct 2026 11:29:22 +0200 From: Roger Pau =?utf-8?B?TW9ubsOp?= To: Jan Beulich Cc: Grygorii Strashko , Andrew Cooper , Teddy Astie , xen-devel@lists.xenproject.org Subject: Re: [PATCH] x86/domain: restrict context switch hooks for the idle domain Message-ID: References: <20261001142757.98255-1-roger@xenproject.org> <4eb32155-1b04-4f04-ab9b-f30e584cb033@suse.com> <1226702d-5bb4-4e7a-8e6a-6534002cfd8c@suse.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: On Fri, Oct 02, 2026 at 11:23:17AM +0200, Roger Pau Monné wrote: > On Fri, Oct 02, 2026 at 10:09:02AM +0200, Jan Beulich wrote: > > On 02.10.2026 10:05, Roger Pau Monné wrote: > > > On Fri, Oct 02, 2026 at 09:55:09AM +0200, Jan Beulich wrote: > > >> On 02.10.2026 09:48, Roger Pau Monné wrote: > > >>> On Fri, Oct 02, 2026 at 07:45:07AM +0200, Jan Beulich wrote: > > >>>> On 01.10.2026 16:27, Roger Pau Monne wrote: > > >>>>> --- a/xen/arch/x86/domain.c > > >>>>> +++ b/xen/arch/x86/domain.c > > >>>>> @@ -813,8 +813,6 @@ 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 = { > > >>>>> - .from = paravirt_ctxt_switch_from, > > >>>>> - .to = paravirt_ctxt_switch_to, > > >>>>> .tail = idle_loop, > > >>>>> }; > > >>>> > > >>>> Leaving NULL pointers around isn't a good thing, though. May I suggest to > > >>>> at least poison the pointers then? > > >>> > > >>> I don't mind doing so, but I don't think we usually do that for other > > >>> hook structures, ie: hvm_function_table for example doesn't poison > > >>> unset hooks (and it possibly can't, because there are .hook != NULL > > >>> checks). > > >>> > > >>> TBH I'm missing a benefit of the poisoning here. Using NULL or a > > >>> poisoned value will both trigger a page-fault, and NULL has the > > >>> benefit of callers easily checking whether the hook is set. > > >> > > >> NULL in the context of a HVM vCPU will #PF. NULL in the context of a PV > > >> one may not, depending on what the guest may have put there. > > > > > > It still feels a bit arbitrary to do here but not in other places, > > > > We should imo resolve this by replacing NULLs wherever hooks could, due > > to other issues, end up "in sight" on paths reachable for PV guests. This > > would then also cover potential speculation along such paths. > > FTAOD, I plan to introduce a poison value using a non-canonical > address, ie: > > #define POINTER_POISON ((void *)0xDEAD0000DEAD0000UL) s/POINTER_POISON/FUNCTION_POISON/