From nobody Thu Dec 26 17:41:58 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=1729525607; cv=none; d=zohomail.com; s=zohoarc; b=iJ11lPu4U6u8kkTnIGGYYaUdKgtszdmTgk59lc7b/nRYpFqumMaU5LiJ1H9PuAFQn3+ZG5PNrOk6PPj2+GKsdIlfudDRR4iFs3lWOZyVKrGZnpMP940DcUBf7uvBhra3ZVyZBL6vwz3HY3Ui1dQBxbMQlyklT+8yAm/R+PaI19M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729525607; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=1Ah3/FAbVDfMti3UAa0nn+9bbUxazwt70g5vkEVtpiQ=; b=Zxk6NG4uKPbvo5q62Yk2527hsn5b0ikaYvGdGDr7Bi31dy85/RbfdQzxQUrUTpbsZT1tom0YDaiXebI1rWUZfKg60TKchEG4ZXYoNF7fNVPol5reawIn3UCTFalvNMP8UxOfsU2HLsjhtGiYvVnG5kClpUYgbX/pPJjNN0rcPUU= 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 1729525607403333.58111123805475; Mon, 21 Oct 2024 08:46:47 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.823745.1237869 (Exim 4.92) (envelope-from ) id 1t2uc8-0000w5-VF; Mon, 21 Oct 2024 15:46:36 +0000 Received: by outflank-mailman (output) from mailman id 823745.1237869; Mon, 21 Oct 2024 15:46:36 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1t2uc8-0000sr-EJ; Mon, 21 Oct 2024 15:46:36 +0000 Received: by outflank-mailman (input) for mailman id 823745; Mon, 21 Oct 2024 15:46:34 +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 1t2uc6-0006wR-Bm for xen-devel@lists.xenproject.org; Mon, 21 Oct 2024 15:46:34 +0000 Received: from mail-ej1-x634.google.com (mail-ej1-x634.google.com [2a00:1450:4864:20::634]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id a4dd602d-8fc3-11ef-99a3-01e77a169b0f; Mon, 21 Oct 2024 17:46:32 +0200 (CEST) Received: by mail-ej1-x634.google.com with SMTP id a640c23a62f3a-a9a6acac4c3so513927966b.0 for ; Mon, 21 Oct 2024 08:46:32 -0700 (PDT) Received: from localhost.localdomain (0545937c.skybroadband.com. [5.69.147.124]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a9a91370fe5sm215688966b.112.2024.10.21.08.46.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Oct 2024 08:46:30 -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: a4dd602d-8fc3-11ef-99a3-01e77a169b0f DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloud.com; s=cloud; t=1729525591; x=1730130391; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=1Ah3/FAbVDfMti3UAa0nn+9bbUxazwt70g5vkEVtpiQ=; b=NWUY+epNoew5/1ldTepo39PKCN1U7eBVUnS36w5owKxRhJqxVsbFaIscMzvDPch6fa v08E/2ilPKswXK7A27b4q1AN6km/9GfvzinaWZf5PDrxO1HwIGR4MLMhUuxLsfMEpPhI oTrgaJqMkPBtZIr9N1sUCa0bhwZue4kgdfPLk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729525591; x=1730130391; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=1Ah3/FAbVDfMti3UAa0nn+9bbUxazwt70g5vkEVtpiQ=; b=VNfWA7UugFsYGu/tURwu4l8zOBERnp9RIqaSK6zNOIpS0g7lCnpth6s4vzawqAuH8E iITBjbUjQ532aPAOxt5ka9d3dB5hOZqmo1VBV1l+jlw7gszuIEou+jG7MQT+aIhKqxRY 30+Jmp457atv2puJ3Li2nxXmEVu55MeuEJ/Cxtv/nsLZ+a1S7WBOOU64yuXZ9prCnY9S D4BiRTEnKGulB3yPR374iFUA/stZvbb8e3xD9hFo7WviqufMgymHbEUdsMdl1x1x2Nxq 65GQxJwvk0roN0tCk4mEJLq88HHz79aO2IsL7CnTnKYptixumqBdrTjGvLkvJmLfVjcH gp/w== X-Gm-Message-State: AOJu0Yw87dQ++8Zch4n0JvgFOP4WcxDrUvdfdZeA3W/WgSnPBgd3aDIZ zEpCCUmQb0ccLxXok4Ne+dlwgOs5G9TIrc6/LRp1NbkearX9xW8mTYSZ7bdQKwNlY+pYBNU+hIe Q X-Google-Smtp-Source: AGHT+IHrrel4rYJieUp5DclhkwRc/OzjjzSiMA6PoQqA3Un6eQfLV09C+ETms8nfNVWbTtbGfL3cog== X-Received: by 2002:a17:907:e89:b0:a99:61f7:8413 with SMTP id a640c23a62f3a-a9a69a75abdmr1097909866b.23.1729525591042; Mon, 21 Oct 2024 08:46:31 -0700 (PDT) From: Alejandro Vallejo To: xen-devel@lists.xenproject.org Cc: Alejandro Vallejo , Anthony PERARD , Juergen Gross Subject: [PATCH v7 09/10] tools/libguest: Set distinct x2APIC IDs for each vCPU Date: Mon, 21 Oct 2024 16:45:59 +0100 Message-ID: <20241021154600.11745-10-alejandro.vallejo@cloud.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241021154600.11745-1-alejandro.vallejo@cloud.com> References: <20241021154600.11745-1-alejandro.vallejo@cloud.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @cloud.com) X-ZM-MESSAGEID: 1729525608737116600 Content-Type: text/plain; charset="utf-8" Have toolstack populate the new x2APIC ID in the LAPIC save record with the proper IDs intended for each vCPU. Signed-off-by: Alejandro Vallejo --- v7: * Unchanged --- tools/libs/guest/xg_dom_x86.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/tools/libs/guest/xg_dom_x86.c b/tools/libs/guest/xg_dom_x86.c index c98229317db7..38486140ed15 100644 --- a/tools/libs/guest/xg_dom_x86.c +++ b/tools/libs/guest/xg_dom_x86.c @@ -1004,11 +1004,14 @@ static int vcpu_hvm(struct xc_dom_image *dom) HVM_SAVE_TYPE(HEADER) header; struct hvm_save_descriptor mtrr_d; HVM_SAVE_TYPE(MTRR) mtrr; + struct hvm_save_descriptor lapic_d; + HVM_SAVE_TYPE(LAPIC) lapic; struct hvm_save_descriptor end_d; HVM_SAVE_TYPE(END) end; } vcpu_ctx; - /* Context from full_ctx */ + /* Contexts from full_ctx */ const HVM_SAVE_TYPE(MTRR) *mtrr_record; + const HVM_SAVE_TYPE(LAPIC) *lapic_record; /* Raw context as taken from Xen */ uint8_t *full_ctx =3D NULL; int rc; @@ -1111,6 +1114,8 @@ static int vcpu_hvm(struct xc_dom_image *dom) vcpu_ctx.mtrr_d.typecode =3D HVM_SAVE_CODE(MTRR); vcpu_ctx.mtrr_d.length =3D HVM_SAVE_LENGTH(MTRR); vcpu_ctx.mtrr =3D *mtrr_record; + vcpu_ctx.lapic_d.typecode =3D HVM_SAVE_CODE(LAPIC); + vcpu_ctx.lapic_d.length =3D HVM_SAVE_LENGTH(LAPIC); vcpu_ctx.end_d =3D bsp_ctx.end_d; vcpu_ctx.end =3D bsp_ctx.end; =20 @@ -1125,6 +1130,18 @@ static int vcpu_hvm(struct xc_dom_image *dom) { vcpu_ctx.mtrr_d.instance =3D i; =20 + lapic_record =3D hvm_get_save_record(full_ctx, HVM_SAVE_CODE(LAPIC= ), i); + if ( !lapic_record ) + { + xc_dom_panic(dom->xch, XC_INTERNAL_ERROR, + "%s: unable to get LAPIC[%d] save record", __func= __, i); + goto out; + } + + vcpu_ctx.lapic =3D *lapic_record; + vcpu_ctx.lapic.x2apic_id =3D dom->cpu_to_apicid[i]; + vcpu_ctx.lapic_d.instance =3D i; + rc =3D xc_domain_hvm_setcontext(dom->xch, dom->guest_domid, (uint8_t *)&vcpu_ctx, sizeof(vcpu_ct= x)); if ( rc !=3D 0 ) --=20 2.47.0