From nobody Thu Sep 19 02:11: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=1719419354; cv=none; d=zohomail.com; s=zohoarc; b=G8RPPn0cq4/ZmEkqmDBZ8dS/U/4wEiec8piXKwAq8o0z4/eirhAjGyT5Ilb9ueWE+2mzBpuGisH8MnTLNQIn9w8p1Qrn0pR18TBcSjTXOpGXTUVqWA7UHvnc7El+InN1TpzL3NxzCdQa92DXnbh+x6rS8KlOJfKuVioqquc1Yok= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1719419354; 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=+a3HTs1RURAZACbO2vkeTxBlKVMK+XtuHSHuPekrrv4=; b=XtVJWYPzx8r66KVVH8GIS+7LBbaHMBxFAqx6p5oS/7YltYi7TO1SK/QipWK/xDaj/l5QQGsnfzECQDQkgNaEZ464whwvXHlTY7tdWMg6pW0lyPK/wtEisXFc3J0rveOFkDfHPZTHsfjCZLw2RZdjBV9uyMJHrxBSKDw1i44HCes= 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 1719419354238868.0613478843983; Wed, 26 Jun 2024 09:29:14 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.749272.1157335 (Exim 4.92) (envelope-from ) id 1sMVVn-0006ml-Fy; Wed, 26 Jun 2024 16:28:47 +0000 Received: by outflank-mailman (output) from mailman id 749272.1157335; Wed, 26 Jun 2024 16:28:47 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sMVVn-0006me-Cn; Wed, 26 Jun 2024 16:28:47 +0000 Received: by outflank-mailman (input) for mailman id 749272; Wed, 26 Jun 2024 16:28:46 +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 1sMVVm-0006MH-1a for xen-devel@lists.xenproject.org; Wed, 26 Jun 2024 16:28:46 +0000 Received: from mail-ej1-x630.google.com (mail-ej1-x630.google.com [2a00:1450:4864:20::630]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 285ce77d-33d9-11ef-90a3-e314d9c70b13; Wed, 26 Jun 2024 18:28:45 +0200 (CEST) Received: by mail-ej1-x630.google.com with SMTP id a640c23a62f3a-a724958f118so528867766b.0 for ; Wed, 26 Jun 2024 09:28:45 -0700 (PDT) Received: from EMEAENGAAD19049.citrite.net ([160.101.139.1]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a7291af7912sm42791866b.128.2024.06.26.09.28.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Jun 2024 09:28:43 -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: 285ce77d-33d9-11ef-90a3-e314d9c70b13 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloud.com; s=cloud; t=1719419324; x=1720024124; 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=+a3HTs1RURAZACbO2vkeTxBlKVMK+XtuHSHuPekrrv4=; b=CWY+Wdpkl3adtLlArY/ou46B99HHBRsvU7yepzw6vBuYTR/oTMAj+oFEwHOh/lxzTI p5JqWBckbfBvHLluhhYeb7F0RtM+HM93gg1GsfFuRtkwGUxfFGHsSEucT2hxw1HEQ5pz g41Rg837atHIRNmUurXPFflpgixrXqMAYJTYw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719419324; x=1720024124; 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=+a3HTs1RURAZACbO2vkeTxBlKVMK+XtuHSHuPekrrv4=; b=FM7qh2VPGzFhJ6P5ZTPjkf2CHAEUzl5+kCzP0GROQNmhk7ymR74jL0Ng/ivOJB8JPM kGvQyfu5cOeSIUZ4hxxTo4WUJ11avlwIqHBSq4fJk1LdhWQFkCIvechGY/F3JUEEq4az I8VCj+7voujMf7A920Nsj1bgas63+6rlSPtKS94b3/KlK1fe90ZRgKv6EByMiqscy3JV 4bzbX+o6uB207uX99sfF1bjKOhXJAWQHrb9hDnA8PMNNVdxdqKGatbemMRhllpKa6Y0o d8Oc1sCF44ve2H7eX1dGOOTu6X9K8oppD0S1SEAsv/UljFPcV0rept4fP9myDmomNPPm 1mzg== X-Gm-Message-State: AOJu0Yxzjt+nex8hKcnaQpcaE1Et1mqKmX2ex0vslYC5KvYzVJ8Tu4T6 AWGkJXIFqeab6XS+5v2S+Blx3vO2azNjk0PuV4Z5omnab6cDaMy4Z3ji74u6QapRurtTRIJPMt9 OtsI= X-Google-Smtp-Source: AGHT+IH358YZg6Ktj95b4hw3RChALxCQdzhV/QFgoEwYMEa0PDV0+0MqjNTKrlGlEzuXG5+dAy4sWg== X-Received: by 2002:a17:907:c308:b0:a72:603f:1ea2 with SMTP id a640c23a62f3a-a72603f2118mr814836066b.62.1719419324394; Wed, 26 Jun 2024 09:28:44 -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 v4 05/10] xen/x86: Add supporting code for uploading LAPIC contexts during domain create Date: Wed, 26 Jun 2024 17:28:32 +0100 Message-Id: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @cloud.com) X-ZM-MESSAGEID: 1719419354717100011 Content-Type: text/plain; charset="utf-8" This patch is a precondition for a later patch in which toolstack uses HVM contexts to upload LAPIC data to a newly constructed domain. If toolstack were to upload LAPIC contexts as part of domain creation as-is= 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 trig= ger an update in the architectural registers so the APIC ID in both is consiste= nt. Signed-off-by: Alejandro Vallejo --- v4: * New patch --- 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 b57e39d1c6dd..ebcf74711a13 100644 --- a/xen/arch/x86/hvm/vlapic.c +++ b/xen/arch/x86/hvm/vlapic.c @@ -1622,7 +1622,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.34.1