From nobody Thu Sep 19 17:09:14 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=1723124798; cv=none; d=zohomail.com; s=zohoarc; b=kXavOuNNtgioqSijfGNbRVIIE9B/cJfWodHnz2VALULs4wCJUpHmZ5Pe0lyOajJ/GiaOqycxBKhl8b1Z20GeCUCV7JTjAf8aoZzUu/DqTevD/dWMBbTSEil8DHufkijOOTXh0A7rXzJo9zcXd0Y7puQAbAX8yOZlBl8uhanT8ks= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1723124798; 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=E6jJmilCAYKj/QJkIbHrN87ZkSwCG5OPRTk65J0LtEY=; b=UUEfj4w82+1lTEMMdLDM7pAaT5uhePUtEI9W4CvmvQEA8eVHmTT2RpBX2r1yFRbuhdJNMjiqOw+6egthPpfFqXzavBwS1BL3VZOBFacCgY+7j/Py+MRXxLqJOSXgQVtr7N0fQ2k4NX72znXxkIzlWaIwernEhjJ0v7WFLrKHB2c= 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 1723124798523959.5856440331263; Thu, 8 Aug 2024 06:46:38 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.774206.1184725 (Exim 4.92) (envelope-from ) id 1sc3TH-0007O4-IA; Thu, 08 Aug 2024 13:46:27 +0000 Received: by outflank-mailman (output) from mailman id 774206.1184725; Thu, 08 Aug 2024 13:46:27 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sc3TH-0007Nx-FR; Thu, 08 Aug 2024 13:46:27 +0000 Received: by outflank-mailman (input) for mailman id 774206; Thu, 08 Aug 2024 13:46:26 +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 1sc3Py-0003nA-Nl for xen-devel@lists.xenproject.org; Thu, 08 Aug 2024 13:43:02 +0000 Received: from mail-lj1-x22a.google.com (mail-lj1-x22a.google.com [2a00:1450:4864:20::22a]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 210833b2-558c-11ef-8776-851b0ebba9a2; Thu, 08 Aug 2024 15:43:01 +0200 (CEST) Received: by mail-lj1-x22a.google.com with SMTP id 38308e7fff4ca-2ef248ab2aeso14004031fa.0 for ; Thu, 08 Aug 2024 06:43:01 -0700 (PDT) Received: from EMEAENGAAD19049.citrite.net ([185.25.67.249]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a7dc9ecb551sm741537166b.223.2024.08.08.06.42.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Aug 2024 06:42:59 -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: 210833b2-558c-11ef-8776-851b0ebba9a2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloud.com; s=cloud; t=1723124580; x=1723729380; 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=E6jJmilCAYKj/QJkIbHrN87ZkSwCG5OPRTk65J0LtEY=; b=J92yXKdUgPmIiKBHw1e98X5vquPKThAE2VnIeF6rg7YeajBix5Jlg3yxi3afBEXdyu s4z3lZ+podWwJ8c3wgyg4hw8Nrgf2ZXD2kTvoa1+codHw7D+mWCtWLR442vOqX3TJLU0 XrznsB7k7JTM4y+ZytzPUt5+jziTQAqNGw0ZQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723124580; x=1723729380; 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=E6jJmilCAYKj/QJkIbHrN87ZkSwCG5OPRTk65J0LtEY=; b=GpqVhj39HwMd36rMCatDEu+89GBDyoLrQfEYBINRPGjJm6Cm7rBFKQFuzKMK9ZWOnr qjJp/ZFaEsO8bczCLAL1a+9NSZJobcL+tnbzFSQ4z95lyTw7hI6Xp+82xhXTxzh2w3sa lrOdPt6pAYsdzvRuCTj6MDEWKelihm0LRIK0feered2E/ZiwS3OCmgRGtQPNC5oWAcs/ 6OOCunFlE3gZsY7gXvf3q577Vzb76/a0hiixNSh6zt39Cy/a+8gqV6U7nYDc4fpixK+A BEastFptbz5nJl79DF1P9vHbQnf2Z5rjkQYPFT/izUy/szuqJRrv0wwOnZq+ggFe2kPO EqlA== X-Gm-Message-State: AOJu0YzuXGgO3jmpZZz7MfYGXJlqM/Kw21veZ43N0MKzHFHmfr30gwXF TDfJDw5ThOWozkDjP7LKDYUF2mNpYO6wUfFsCE3ff+PPcqmKA93gL0CoHW3QZJsKGcJeYqqYkZ5 m X-Google-Smtp-Source: AGHT+IFAXzgZL2cAgDALpEN6211JBmUy1AR6RqCr32r8YqyiC74Mdv2qvVDmSS6e3wxq8C8G2MgVvA== X-Received: by 2002:a2e:a583:0:b0:2ef:2dbe:7455 with SMTP id 38308e7fff4ca-2f19de1b687mr21530961fa.1.1723124580109; Thu, 08 Aug 2024 06:43:00 -0700 (PDT) From: Alejandro Vallejo To: Xen-devel Cc: Alejandro Vallejo , Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Subject: [PATCH v5 04/10] xen/x86: Add supporting code for uploading LAPIC contexts during domain create Date: Thu, 8 Aug 2024 14:42:44 +0100 Message-ID: <20240808134251.29995-5-alejandro.vallejo@cloud.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240808134251.29995-1-alejandro.vallejo@cloud.com> References: <20240808134251.29995-1-alejandro.vallejo@cloud.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @cloud.com) X-ZM-MESSAGEID: 1723124798797116600 Content-Type: text/plain; charset="utf-8" If toolstack were to upload LAPIC contexts as part of domain creation it would encounter a problem were the architectural state does not reflect the APIC ID in the hidden state. This patch ensures updates to the hidden state trigger an update in the architectural registers so the APIC ID in both is consistent. Signed-off-by: Alejandro Vallejo --- We could also let toolstack synthesise architectural registers, but that would be adding logic on how architectural state operates to software that really shouldn't care. I could be persuaded to do it the other way, but I think it's going to be messier. v5: * No change --- xen/arch/x86/hvm/vlapic.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/xen/arch/x86/hvm/vlapic.c b/xen/arch/x86/hvm/vlapic.c index 0e0699fc8279..3fa839087fe0 100644 --- a/xen/arch/x86/hvm/vlapic.c +++ b/xen/arch/x86/hvm/vlapic.c @@ -1620,7 +1620,27 @@ static int cf_check lapic_load_hidden(struct domain = *d, hvm_domain_context_t *h) =20 s->loaded.hw =3D 1; if ( s->loaded.regs ) + { + /* + * We already processed architectural regs in lapic_load_regs(), so + * this must be a migration. Fix up inconsistencies from any older= Xen. + */ lapic_load_fixup(s); + } + else + { + /* + * We haven't seen architectural regs so this could be a migration= or a + * plain domain create. In the domain create case it's fine to mod= ify + * the architectural state to align it to the APIC ID that was just + * uploaded and in the migrate case it doesn't matter because the + * architectural state will be replaced by the LAPIC_REGS ctx late= r on. + */ + if ( vlapic_x2apic_mode(s) ) + set_x2apic_id(s); + else + vlapic_set_reg(s, APIC_ID, SET_xAPIC_ID(s->hw.x2apic_id)); + } =20 hvm_update_vlapic_mode(v); =20 --=20 2.45.2