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 2184BD5CC8A for ; Wed, 30 Oct 2024 10:31:03 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.828015.1242805 (Exim 4.92) (envelope-from ) id 1t65yT-00062T-L1; Wed, 30 Oct 2024 10:30:49 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 828015.1242805; Wed, 30 Oct 2024 10:30:49 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1t65yT-00062M-II; Wed, 30 Oct 2024 10:30:49 +0000 Received: by outflank-mailman (input) for mailman id 828015; Wed, 30 Oct 2024 10:30:48 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1t65yS-00062G-LO for xen-devel@lists.xenproject.org; Wed, 30 Oct 2024 10:30:48 +0000 Received: from mail-ej1-x62e.google.com (mail-ej1-x62e.google.com [2a00:1450:4864:20::62e]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 047ededf-96aa-11ef-a0c3-8be0dac302b0; Wed, 30 Oct 2024 11:30:43 +0100 (CET) Received: by mail-ej1-x62e.google.com with SMTP id a640c23a62f3a-a9a2cdc6f0cso853803066b.2 for ; Wed, 30 Oct 2024 03:30:43 -0700 (PDT) Received: from [10.125.226.166] ([185.25.67.249]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a9b1dec81adsm560680666b.27.2024.10.30.03.30.42 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 30 Oct 2024 03:30:42 -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" X-Inumbo-ID: 047ededf-96aa-11ef-a0c3-8be0dac302b0 X-Custom-Connection: eyJyZW1vdGVpcCI6IjJhMDA6MTQ1MDo0ODY0OjIwOjo2MmUiLCJoZWxvIjoibWFpbC1lajEteDYyZS5nb29nbGUuY29tIn0= X-Custom-Transaction: eyJpZCI6IjA0N2VkZWRmLTk2YWEtMTFlZi1hMGMzLThiZTBkYWMzMDJiMCIsInRzIjoxNzMwMjg0MjQzLjc0NjEyLCJzZW5kZXIiOiJhbmRyZXcuY29vcGVyQGNsb3VkLmNvbSIsInJlY2lwaWVudCI6Inhlbi1kZXZlbEBsaXN0cy54ZW5wcm9qZWN0Lm9yZyJ9 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1730284243; x=1730889043; 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=Tz5i/mNb7GRhZ+FQr8OH8hwL6Ideulocn0iYNfi2EEw=; b=p42hGVOJMDG/Y9j9lSAKA+0pSLczoyNZwRU/675zstQzMLaHV68Q2KyD2yJjJYxKUL 2xtUOkKBA+z0+flvxXGRMp16UCEER6V+VYc3GntwGxU8846/y7ZjtvJNmFUcyOB0JFJx kCQN+XJq+bbuUi6sIP8y7sRj3oTBQNrFkpVLk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730284243; x=1730889043; h=content-transfer-encoding:in-reply-to:autocrypt:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=Tz5i/mNb7GRhZ+FQr8OH8hwL6Ideulocn0iYNfi2EEw=; b=tsnP8Zjn79hiMtc4QlKM1d1ly7UiyUuUf4Nwirvs6JOfmoTUz9nH74hdU/my1yoW8+ GRuuruPMsFEk4NH7r9p5xVfym+7zxdjYW+1ivCEkxjOluVIYxzGzwiaE75XuOKa6vtmF jjRBcWTA5HMVAUdmyv4owoBrURC/db1EW7CmLt6fGnIp7PViQh/0jJlhQtxxc64GqyKG bD7ccOObYflB14/OGcv6kLujayBP2emZafpXQjbc3zpw5OoZx8c2WG/hDiGwozkuP6cJ kxHkhB6jaTmdPkT3YowGiE37LG8WVDNKJg2e7fX2rG8NaXEnUEO57024mRgnR9xvijAd WihA== X-Forwarded-Encrypted: i=1; AJvYcCVlfqtCAKVEA+MKDvhPOwKfZ8lw5Vj9sRxIkwPjRw4SJyTeWc7ALZCEBbKB/QFaDFxZSWhPxz3eQxI=@lists.xenproject.org X-Gm-Message-State: AOJu0YyejFa0ID8hLKjIupnBYB8SaGTEY2Uwv5PWJ8Z37/SuLA6K4xMk VimrP3Yxbj2j2l7y3056IYjwfeqS9mzgWRS7AdQV4JIQuLh2IH6RodIDsSPDB6Q= X-Google-Smtp-Source: AGHT+IFfXfWqoS5NBpyRNpy6DCSDEwgabSAeDW+s4v8eQ4rJErjCrawthy6hKKjihx7mr2NcczOVDw== X-Received: by 2002:a17:907:6d21:b0:a9a:80f9:d4e0 with SMTP id a640c23a62f3a-a9de5ee1056mr1561430566b.34.1730284243053; Wed, 30 Oct 2024 03:30:43 -0700 (PDT) Message-ID: Date: Wed, 30 Oct 2024 10:30:40 +0000 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] x86/cpu-policy: Extend the guest max policy max leaf/subleaves To: Jan Beulich Cc: =?UTF-8?Q?Roger_Pau_Monn=C3=A9?= , Alejandro Vallejo , Xen-devel References: <20241029175505.2698661-1-andrew.cooper3@citrix.com> <14173e8a-ec20-455a-87bf-ae6d3d9a9051@suse.com> Content-Language: en-GB From: Andrew Cooper Autocrypt: addr=andrew.cooper3@citrix.com; keydata= xsFNBFLhNn8BEADVhE+Hb8i0GV6mihnnr/uiQQdPF8kUoFzCOPXkf7jQ5sLYeJa0cQi6Penp VtiFYznTairnVsN5J+ujSTIb+OlMSJUWV4opS7WVNnxHbFTPYZVQ3erv7NKc2iVizCRZ2Kxn srM1oPXWRic8BIAdYOKOloF2300SL/bIpeD+x7h3w9B/qez7nOin5NzkxgFoaUeIal12pXSR Q354FKFoy6Vh96gc4VRqte3jw8mPuJQpfws+Pb+swvSf/i1q1+1I4jsRQQh2m6OTADHIqg2E ofTYAEh7R5HfPx0EXoEDMdRjOeKn8+vvkAwhviWXTHlG3R1QkbE5M/oywnZ83udJmi+lxjJ5 YhQ5IzomvJ16H0Bq+TLyVLO/VRksp1VR9HxCzItLNCS8PdpYYz5TC204ViycobYU65WMpzWe LFAGn8jSS25XIpqv0Y9k87dLbctKKA14Ifw2kq5OIVu2FuX+3i446JOa2vpCI9GcjCzi3oHV e00bzYiHMIl0FICrNJU0Kjho8pdo0m2uxkn6SYEpogAy9pnatUlO+erL4LqFUO7GXSdBRbw5 gNt25XTLdSFuZtMxkY3tq8MFss5QnjhehCVPEpE6y9ZjI4XB8ad1G4oBHVGK5LMsvg22PfMJ ISWFSHoF/B5+lHkCKWkFxZ0gZn33ju5n6/FOdEx4B8cMJt+cWwARAQABzSlBbmRyZXcgQ29v cGVyIDxhbmRyZXcuY29vcGVyM0BjaXRyaXguY29tPsLBegQTAQgAJAIbAwULCQgHAwUVCgkI CwUWAgMBAAIeAQIXgAUCWKD95wIZAQAKCRBlw/kGpdefoHbdD/9AIoR3k6fKl+RFiFpyAhvO 59ttDFI7nIAnlYngev2XUR3acFElJATHSDO0ju+hqWqAb8kVijXLops0gOfqt3VPZq9cuHlh IMDquatGLzAadfFx2eQYIYT+FYuMoPZy/aTUazmJIDVxP7L383grjIkn+7tAv+qeDfE+txL4 SAm1UHNvmdfgL2/l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au1R/uSiUFjewJdT/LX1EklKDcQwpk06Af/N7VZtSfEJeRV04unbsKVXWZAk uAJyDDKN99ziC0Wz5kcPyVD1HNf8bgaqGDzrv3TfYjwqayRFcMf7xJaL9xXedMcAEQEAAcLB XwQYAQgACQUCUuE2fwIbDAAKCRBlw/kGpdefoG4XEACD1Qf/er8EA7g23HMxYWd3FXHThrVQ HgiGdk5Yh632vjOm9L4sd/GCEACVQKjsu98e8o3ysitFlznEns5EAAXEbITrgKWXDDUWGYxd pnjj2u+GkVdsOAGk0kxczX6s+VRBhpbBI2PWnOsRJgU2n10PZ3mZD4Xu9kU2IXYmuW+e5KCA vTArRUdCrAtIa1k01sPipPPw6dfxx2e5asy21YOytzxuWFfJTGnVxZZSCyLUO83sh6OZhJkk b9rxL9wPmpN/t2IPaEKoAc0FTQZS36wAMOXkBh24PQ9gaLJvfPKpNzGD8XWR5HHF0NLIJhgg 4ZlEXQ2fVp3XrtocHqhu4UZR4koCijgB8sB7Tb0GCpwK+C4UePdFLfhKyRdSXuvY3AHJd4CP 4JzW0Bzq/WXY3XMOzUTYApGQpnUpdOmuQSfpV9MQO+/jo7r6yPbxT7CwRS5dcQPzUiuHLK9i nvjREdh84qycnx0/6dDroYhp0DFv4udxuAvt1h4wGwTPRQZerSm4xaYegEFusyhbZrI0U9tJ B8WrhBLXDiYlyJT6zOV2yZFuW47VrLsjYnHwn27hmxTC/7tvG3euCklmkn9Sl9IAKFu29RSo d5bD8kMSCYsTqtTfT6W4A3qHGvIDta3ptLYpIAOD2sY3GYq2nf3Bbzx81wZK14JdDDHUX2Rs 6+ahAA== In-Reply-To: <14173e8a-ec20-455a-87bf-ae6d3d9a9051@suse.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On 30/10/2024 6:51 am, Jan Beulich wrote: > On 29.10.2024 18:55, Andrew Cooper wrote: >> We already have one migration case opencoded (feat.max_subleaf). A more >> recent discovery is that we advertise x2APIC to guests without ensuring that >> we provide max_leaf >= 0xb. >> >> In general, any leaf known to Xen can be safely configured by the toolstack if >> it doesn't violate other constraints. >> >> Therefore, introduce guest_common_{max,default}_leaves() to generalise the >> special case we currently have for feat.max_subleaf, in preparation to be able >> to provide x2APIC topology in leaf 0xb even on older hardware. >> >> Signed-off-by: Andrew Cooper > Reviewed-by: Jan Beulich > > I'll have to update the AMX logic accordingly (maybe also the AVX10 one). Yeah - I need to get back to your shrinking series too. > I'd like to point out that this highlights a naming anomaly in > x86_cpu_policies_are_compatible(): update_domain_cpu_policy() passes in > the respective max policy as first argument. Imo the first parameter of > the function would better be named "max" there. That's covered in the documentation.  It made sense when I first planned things, but that was many many iterations ago. > >> --- a/xen/arch/x86/cpu-policy.c >> +++ b/xen/arch/x86/cpu-policy.c >> @@ -391,6 +391,27 @@ static void __init calculate_host_policy(void) >> p->platform_info.cpuid_faulting = cpu_has_cpuid_faulting; >> } >> >> +/* >> + * Guest max policies can have any max leaf/subleaf within bounds. >> + * >> + * - Some incoming VMs have a larger-than-necessary feat max_subleaf. >> + * - Some VMs we'd like to synthesise leaves not present on the host. >> + */ >> +static void __init guest_common_max_leaves(struct cpu_policy *p) >> +{ >> + p->basic.max_leaf = ARRAY_SIZE(p->basic.raw) - 1; >> + p->feat.max_subleaf = ARRAY_SIZE(p->feat.raw) - 1; >> + p->extd.max_leaf = 0x80000000U + ARRAY_SIZE(p->extd.raw) - 1; >> +} >> + >> +/* Guest default policies inherit the host max leaf/subleaf settings. */ >> +static void __init guest_common_default_leaves(struct cpu_policy *p) >> +{ >> + p->basic.max_leaf = host_cpu_policy.basic.max_leaf; >> + p->feat.max_subleaf = host_cpu_policy.feat.max_subleaf; >> + p->extd.max_leaf = host_cpu_policy.extd.max_leaf; >> +} > Which sadly still leaves open how to suitably shrink the max values, > when they're larger than necessary (for the guest). Only the toolstack can do the shrinking, and only as the about the final step after optional features have been activated. ~Andrew