From nobody Mon Sep 16 19:03:11 2024 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=reject dis=none) header.from=cloud.com ARC-Seal: i=1; a=rsa-sha256; t=1721398899; cv=none; d=zohomail.com; s=zohoarc; b=Oi7VIPNjh5AxO8caMqi6YrZePNQKLQ4euJuiwzz2ofPIn8pseUpQXvtK1eOCdFKZP8Tsix7KVnziKhsZUtoVnsJXGfkd5YPjlXtetuvZBuW8t+jZx78tkf7EDeHw8yHANt2Qa30kpCFOnFw/1iSDc4Xntw4mgXr9fmK7rwxc+ws= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1721398899; h=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=5mKoKQlcx9bJbBptsIYJsL6Whb62TcTKnY7xLKDf1v0=; b=OJU4E9PYCdZiKvLaLd3opHOe+7KJdWzoYe6nDfEdFj75lI7mlylJlNI82qpx+iHQRwQXP5PWAcZmcOv+lLOssdlX7xJtMO+6LoRzGOz5sgDi3M/kiqgqnCc6AYdAURNQUWJCwklBGGe5086HX5PcfZoiooZjBT4uZD5/m6w7Yoc= 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=reject dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1721398899820422.4394582688591; Fri, 19 Jul 2024 07:21:39 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.761098.1171083 (Exim 4.92) (envelope-from ) id 1sUoU0-0001qe-W9; Fri, 19 Jul 2024 14:21:16 +0000 Received: by outflank-mailman (output) from mailman id 761098.1171083; Fri, 19 Jul 2024 14:21:16 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sUoU0-0001qX-T9; Fri, 19 Jul 2024 14:21:16 +0000 Received: by outflank-mailman (input) for mailman id 761098; Fri, 19 Jul 2024 14:21:15 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sUoTz-0001qR-6L for xen-devel@lists.xenproject.org; Fri, 19 Jul 2024 14:21:15 +0000 Received: from mail-ed1-x52f.google.com (mail-ed1-x52f.google.com [2a00:1450:4864:20::52f]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 26e7d52e-45da-11ef-8776-851b0ebba9a2; Fri, 19 Jul 2024 16:21:13 +0200 (CEST) Received: by mail-ed1-x52f.google.com with SMTP id 4fb4d7f45d1cf-5a167b9df7eso1237327a12.3 for ; Fri, 19 Jul 2024 07:21:13 -0700 (PDT) Received: from EMEAENGAAD91498.citrite.net ([217.156.233.154]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a7a3c7bddc6sm38351866b.69.2024.07.19.07.21.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Jul 2024 07:21:11 -0700 (PDT) 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" X-Inumbo-ID: 26e7d52e-45da-11ef-8776-851b0ebba9a2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloud.com; s=cloud; t=1721398872; x=1722003672; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=5mKoKQlcx9bJbBptsIYJsL6Whb62TcTKnY7xLKDf1v0=; b=hC2DujudJ++7S9frQp9ywk9jbCqt3FKXEMilz6nMI0n4XPevP4Dai6CybnXyixfpBa VOMHhtM3xSMQUXzR6LXRgqyOGOSQgZfTx3zR6fX0v1WQ+SJxecwkNJSfl2hDqyF6D9Px A01Ewv1hwnYWWI4jl/m1QE8F5g9fEBstd6tJ0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721398872; x=1722003672; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=5mKoKQlcx9bJbBptsIYJsL6Whb62TcTKnY7xLKDf1v0=; b=grkGXOPSsokzEv8RhRnsBecgQ8DkWeqqXsjDTsYEUMq/2R9hQ+uz94WXefmQObjZbg qLdsmI3oLUGxpaxguf4ryAXMQB8aEGC/P/9bSYgn1P20QBXS0NFvMGh3TdWiHvaobDmt 3sgoxeERxXRBquSVw4ncHDPUrIn9GyHzA2lnu/1vmOtSdiXTaRF7pm4eiwwBun9N43Bd jATBYr4F89P/+KlwHLszIkaP2LsnM/MKICXr8Yl2VTeQyXMa7N+VYQ1x+UJj+KPJIrrc VoU1Gck5YxHuuksl/2rdhksLYNvZLuQeOlnDudM9ckuEeC/hOWF+gKcPkxIHziaSY8iA 1blA== X-Gm-Message-State: AOJu0Yw1Zg0N7F+OG477Wy1LhGFAli4NZlMY1S2ER/rTcG+ukGF+G9hg aeuouXfs5FR8dj6jY9NIEdKwbqHq8kL/TknofurXmph+ywvKIUR6SGktpCIFuB1JmwzPEZ2Bi2i O X-Google-Smtp-Source: AGHT+IG5+aGcvK2yZQ2J1dJ41Tx5MoQ32oGaGTOkUPFPBwbDx4YkjxUNmXkKePi211DRsWbpDrtabg== X-Received: by 2002:a17:906:7b4d:b0:a6f:6803:57ef with SMTP id a640c23a62f3a-a7a0119ddddmr561622366b.27.1721398872096; Fri, 19 Jul 2024 07:21:12 -0700 (PDT) From: Matthew Barnes To: Xen-devel Cc: Matthew Barnes , Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Alejandro Vallejo Subject: [RFC XEN PATCH v2] x86/cpuid: Expose max_vcpus field in HVM hypervisor leaf Date: Fri, 19 Jul 2024 15:21:09 +0100 Message-Id: X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Bcc: Matthew Barnes Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @cloud.com) X-ZM-MESSAGEID: 1721398900888116600 Content-Type: text/plain; charset="utf-8" Currently, OVMF is hard-coded to set up a maximum of 64 vCPUs on startup. There are efforts to support a maximum of 128 vCPUs, which would involve bumping the OVMF constant from 64 to 128. However, it would be more future-proof for OVMF to access the maximum number of vCPUs for a domain and set itself up appropriately at run-time. GitLab ticket: https://gitlab.com/xen-project/xen/-/issues/191 For OVMF to access the maximum vCPU count, this patch has Xen expose the maximum vCPU ID via cpuid on the HVM hypervisor leaf in edx. Signed-off-by: Matthew Barnes --- Changes in v2: - Tweak value from "maximum vcpu count" to "maximum vcpu id" - Reword commit message to avoid "have to" wording - Fix vpcus -> vcpus typo --- xen/arch/x86/traps.c | 4 ++++ xen/include/public/arch-x86/cpuid.h | 3 +++ 2 files changed, 7 insertions(+) diff --git a/xen/arch/x86/traps.c b/xen/arch/x86/traps.c index ee91fc56b125..f39b598e9bba 100644 --- a/xen/arch/x86/traps.c +++ b/xen/arch/x86/traps.c @@ -1169,6 +1169,10 @@ void cpuid_hypervisor_leaves(const struct vcpu *v, u= int32_t leaf, res->a |=3D XEN_HVM_CPUID_DOMID_PRESENT; res->c =3D d->domain_id; =20 + /* Indicate presence of max vcpu id and set it in edx */ + res->a |=3D XEN_HVM_CPUID_MAX_VCPU_ID_PRESENT; + res->d =3D d->max_vcpus - 1; + /* * Per-vCPU event channel upcalls are implemented and work * correctly with PIRQs routed over event channels. diff --git a/xen/include/public/arch-x86/cpuid.h b/xen/include/public/arch-= x86/cpuid.h index 3bb0dd249ff9..7673e285a9ec 100644 --- a/xen/include/public/arch-x86/cpuid.h +++ b/xen/include/public/arch-x86/cpuid.h @@ -87,6 +87,7 @@ * Sub-leaf 0: EAX: Features * Sub-leaf 0: EBX: vcpu id (iff EAX has XEN_HVM_CPUID_VCPU_ID_PRESENT fla= g) * Sub-leaf 0: ECX: domain id (iff EAX has XEN_HVM_CPUID_DOMID_PRESENT fla= g) + * Sub-leaf 0: EDX: max vcpu id (iff EAX has XEN_HVM_CPUID_MAX_VCPU_ID_PRE= SENT flag) */ #define XEN_HVM_CPUID_APIC_ACCESS_VIRT (1u << 0) /* Virtualized APIC regis= ters */ #define XEN_HVM_CPUID_X2APIC_VIRT (1u << 1) /* Virtualized x2APIC acc= esses */ @@ -107,6 +108,8 @@ */ #define XEN_HVM_CPUID_UPCALL_VECTOR (1u << 6) =20 +#define XEN_HVM_CPUID_MAX_VCPU_ID_PRESENT (1u << 7) /* max vcpu id is pres= ent in EDX */ + /* * Leaf 6 (0x40000x05) * PV-specific parameters --=20 2.34.1