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 5CEB5CA5FC4 for ; Fri, 2 Oct 2026 09:23:40 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.1438956.1657474 (Exim 4.92) (envelope-from ) id 1xCZUB-0001lf-9V; Fri, 02 Oct 2026 09:23:23 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 1438956.1657474; Fri, 02 Oct 2026 09:23:23 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1xCZUB-0001lY-3n; Fri, 02 Oct 2026 09:23:23 +0000 Received: by outflank-mailman (input) for mailman id 1438956; Fri, 02 Oct 2026 09:23:22 +0000 Received: from mail.xenproject.org ([104.130.215.37]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1xCZUA-0001lS-Bo for xen-devel@lists.xenproject.org; Fri, 02 Oct 2026 09:23:22 +0000 Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.96) (envelope-from ) id 1xCZU7-00B42k-1H; Fri, 02 Oct 2026 09:23:19 +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 1xCZU7-00AJlw-1R; Fri, 02 Oct 2026 09:23:19 +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=eipSa4x1K942SwgiW09+SktOn4l3xvv8FkVi/tMDXFA=; b=At7G13rCZ2eBk8Dtkuih3wtrRa h4+yEa5GFdA3yYegYvj+HQGvEW3P7AesbbAqf2G8XrjTNKVjSXBimf240ewt4NGUkdShYienxIieu b5VP5kSs/S5jgjAduMrilyqlINfPLTltYMNQmqOZvW+cY1kG68ibH07lOPmRGJw/vUZY=; Date: Fri, 2 Oct 2026 11:23:17 +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: <1226702d-5bb4-4e7a-8e6a-6534002cfd8c@suse.com> 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) in asm/config.h. Would that be acceptable? Thanks, Roger.