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 B3873CD4F2C for ; Fri, 12 Jun 2026 09:28:16 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.1336438.1598197 (Exim 4.92) (envelope-from ) id 1wXyAz-0001uF-L9; Fri, 12 Jun 2026 09:27:45 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 1336438.1598197; Fri, 12 Jun 2026 09:27:45 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wXyAz-0001u8-I1; Fri, 12 Jun 2026 09:27:45 +0000 Received: by outflank-mailman (input) for mailman id 1336438; Fri, 12 Jun 2026 09:27:44 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wXyAy-0001u2-3Z for xen-devel@lists.xenproject.org; Fri, 12 Jun 2026 09:27:44 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wXyAu-009dgL-TH for xen-devel@lists.xenproject.org; Fri, 12 Jun 2026 11:27:40 +0200 Received: from [10.42.69.7] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a2bd106-bab6-0a2a0a5309dd-0a2a4507a650-28 for ; Fri, 12 Jun 2026 11:27:40 +0200 Received: from [209.85.221.46] (helo=mail-wr1-f46.google.com) by tlsNG-ef75cf.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.1) (envelope-from ) id 6a2bd10c-229c-0a2a45070019-d155dd2eed6c-3 for ; Fri, 12 Jun 2026 11:27:40 +0200 Received: by mail-wr1-f46.google.com with SMTP id ffacd0b85a97d-45eeba68948so555974f8f.1 for ; Fri, 12 Jun 2026 02:27:40 -0700 (PDT) Received: from [10.156.60.236] (ip-037-024-206-209.um08.pools.vodafone-ip.de. [37.24.206.209]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-490ea843d63sm51441555e9.12.2026.06.12.02.27.39 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 12 Jun 2026 02:27:39 -0700 (PDT) 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" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=google header.d=suse.com header.i="@suse.com" header.h="Content-Transfer-Encoding:In-Reply-To:Autocrypt:From:Content-Language:References:Cc:To:Subject:User-Agent:MIME-Version:Date:Message-ID" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1781256460; x=1781861260; darn=lists.xenproject.org; h=content-transfer-encoding:in-reply-to:autocrypt:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:from:to:cc:subject:date:message-id:reply-to; bh=UuqefO+BCmkHbDRWiT+tgDlqdP5xX1r/enShExC4NfQ=; b=FlVuP1/lKV49OWbvs2XtUHPudgL/J3M7znKPyZjxhF361U4yRc1XsWGLiwSp21bMjt tXBHnVBZVLtpymRfh/rrtZ6NcuQFd7wJbfx3sJnpHD+SF11PAP4dVjH72KyZ+TTbYkvD Dubw6ssNRN5l+KX654YiaKKKOzu/BP0xv1q0lMxCt1Omd0Wyai4IOnF5Jwj1ZDQWqTTi /pFTD+FW0+npApnnJQW+gwUT9qg4fUMjkQ4PU+0EMJBg6Zlhk4ZBLPLleVOBXcH9HyhR mZAFx6biGOpSYoa1R0taMRWfcr5SzGfhutuagy8lrdsjnCoSsAPCrnLnL6O4CVe9rO1A UXJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781256460; x=1781861260; h=content-transfer-encoding:in-reply-to:autocrypt:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=UuqefO+BCmkHbDRWiT+tgDlqdP5xX1r/enShExC4NfQ=; b=W7PJPU66/BZFzlja7lwY0tSaMo03fZAUle6IYzFlb6kN+JwarhQWw+ttuGqV332c0l gMeML8JTFvqTu8xgrb9ORC7+pgingVocvigd2uGJMAsniQMHvw6REEhwCa/4lNfldDJD JbQ7ACjTIHSRQGumvkyfPfjAZM+14i3REKTM5wAp213RaXwCnrM3Ws1MCdAdiGLYyp5l iaPMw6rrRL6bmKnTqGxJAnosdO3fvJ2+Gx+c3726TXVQpzK13i/xnknx4HODYI2ZT8bx GG608kzwI/3/W238TXBo2ZCVl4sLyl685mIVQAJIWA/0/QU5SXIj8N/NSwufAbT5pzsi VVDw== X-Forwarded-Encrypted: i=1; AFNElJ8IAYPDJSjn8N9KaF78P0AEoZyH72M6+QLZe3mTSlQQ0WxOeFL22T40csxNlPEyzx4y2omaRqwP5xA=@lists.xenproject.org X-Gm-Message-State: AOJu0YyJsIirC2ZZY/mruG0G3qKnPbPuyRel9QCAkP2VwEQKc4LYq8wS x2uPKINUoaFLMVXnwkFZlv0YcIqsWZBwKTgdiE4Y/76+NAVAF26PQFc1uqsJiewObg== X-Gm-Gg: Acq92OHkc7eeBxESUDGu4UHyL+mo988RNvcriF9rGhi0sHUN802wf5lQzu4MKBERCSs 5N4LxcjVcXqSXXt0IlRXPjc5Yk21Z7sYOtAwvKeSmPbxS45yB05uBK2hRr/PU6ifIYEoilbpE67 3ldfz76SZUJkj00QF7tYL0YI0Lkmn3stzpZOJR/1RLs14cCIVA+J6w0TJdYp0Af9E7aC6gedFzu vGVLpoH5sn8+d5Jk4D6QMBue2smALUFD0XB97J6Sxoun5xVJFg05K0g74gkg1tpXKV1QD92ZpYE H2xzWXd95SauWr9ORB6mi2OwRWoFp8XpQNGupe0suI+/PULY7nEe4vAfyvqXvDqacOlkFfYyMVT JgUe87mF9rdsFsmZkWZaX8ZoADWBxGURt7wTJSfL4ahrE+i3zUeGsvY0WJlllHkJ9wOtrsgvc5h ZLrqTJMCS/qsvjM4CUQ1f5miPuqaZjyZSIE/bDjX0waaPtYEvk+edH0fGNvb8q+NiE2y3U7TW5e nuf9QlsyUoP7r8= X-Received: by 2002:a05:600c:3145:b0:490:be44:32ea with SMTP id 5b1f17b1804b1-490ec4a16b9mr24529325e9.7.1781256460151; Fri, 12 Jun 2026 02:27:40 -0700 (PDT) Message-ID: <93904b00-6e26-49c4-be8f-e7d8aed8e590@suse.com> Date: Fri, 12 Jun 2026 11:27:38 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH for-4.22 v3] xen/x86: Change stub page allocation/free To: Roger Pau Monne Cc: Oleksii Kurochko , Jason Andryuk , Andrew Cooper , Teddy Astie , Oleksii Kurochko , xen-devel@lists.xenproject.org References: <20260612082213.82235-1-roger.pau@citrix.com> Content-Language: en-US From: Jan Beulich Autocrypt: addr=jbeulich@suse.com; keydata= xsDiBFk3nEQRBADAEaSw6zC/EJkiwGPXbWtPxl2xCdSoeepS07jW8UgcHNurfHvUzogEq5xk hu507c3BarVjyWCJOylMNR98Yd8VqD9UfmX0Hb8/BrA+Hl6/DB/eqGptrf4BSRwcZQM32aZK 7Pj2XbGWIUrZrd70x1eAP9QE3P79Y2oLrsCgbZJfEwCgvz9JjGmQqQkRiTVzlZVCJYcyGGsD /0tbFCzD2h20ahe8rC1gbb3K3qk+LpBtvjBu1RY9drYk0NymiGbJWZgab6t1jM7sk2vuf0Py O9Hf9XBmK0uE9IgMaiCpc32XV9oASz6UJebwkX+zF2jG5I1BfnO9g7KlotcA/v5ClMjgo6Gl MDY4HxoSRu3i1cqqSDtVlt+AOVBJBACrZcnHAUSuCXBPy0jOlBhxPqRW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FKdCsBH/E5d+0ZnMQi+G0A nAuWpQkjM1ASeQwSHEeAWPgskBQL In-Reply-To: <20260612082213.82235-1-roger.pau@citrix.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-purgate-ID: tlsNG-ef75cf/1781256460-22772C48-5AC7B3D2/0/0 X-purgate-type: clean X-purgate-size: 1798 On 12.06.2026 10:22, Roger Pau Monne wrote: > From: Jason Andryuk > > Today the inline tracking of the stub page is problematic. 0xcc is used to > indicate unused, but it is also a "clear value." A !CONFIG_PV build or > when running with FRED support will not populate the LSTAR/CSTAR stubs at > CPU bringup. If a CPU is then offlined, the stubs page will be freed as > its content will be all 0xcc, regardless of the stubs page still begin > referenced by other CPUs. > > The new approach uses a global, CPU-indexed dynamically allocated array of > stub addresses. However, to handle NUMA aware allocations, we cannot > allocate all the memory in advance because of the NUMA dependency. Take > advantage of the fact that Xen will attempt to contiguously pack CPUs on > the same NUMA node (see normalise_cpu_order()), and on CPU bringup use the > same stubs page the previous CPU did if suitable. Note the code would > still function properly even if CPUs from NUMA nodes are not contiguously > packed, it just consumes more memory. > > stub pages are no longer freed. They remain referenced in the global Nit: Didn't you mean to s/stub/Stub/ as per Andrew's comment? > CPU-indexed array and are re-used if the CPU is re-onlined. > > The stubs array doesn't have an explicit lock. During boot it's accessed > single threaded. During runtime, &cpu_add_remove_lock serializes access. > > Fixes: 7a66ac8d1633 ("x86: move syscall trampolines off the stack") > Signed-off-by: Jason Andryuk > Signed-off-by: Roger Pau Monné > Tested-by: Jason Andryuk > Reviewed-by: Jason Andryuk Reviewed-by: Jan Beulich Jan