From: Alejandro Vallejo <alejandro.vallejo@cloud.com>
To: xen-devel@lists.xenproject.org
Cc: Alejandro Vallejo <alejandro.vallejo@cloud.com>,
Anthony PERARD <anthony.perard@vates.tech>,
Juergen Gross <jgross@suse.com>
Subject: [PATCH v7 09/10] tools/libguest: Set distinct x2APIC IDs for each vCPU
Date: Mon, 21 Oct 2024 16:45:59 +0100 [thread overview]
Message-ID: <20241021154600.11745-10-alejandro.vallejo@cloud.com> (raw)
In-Reply-To: <20241021154600.11745-1-alejandro.vallejo@cloud.com>
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 <alejandro.vallejo@cloud.com>
---
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 = NULL;
int rc;
@@ -1111,6 +1114,8 @@ static int vcpu_hvm(struct xc_dom_image *dom)
vcpu_ctx.mtrr_d.typecode = HVM_SAVE_CODE(MTRR);
vcpu_ctx.mtrr_d.length = HVM_SAVE_LENGTH(MTRR);
vcpu_ctx.mtrr = *mtrr_record;
+ vcpu_ctx.lapic_d.typecode = HVM_SAVE_CODE(LAPIC);
+ vcpu_ctx.lapic_d.length = HVM_SAVE_LENGTH(LAPIC);
vcpu_ctx.end_d = bsp_ctx.end_d;
vcpu_ctx.end = bsp_ctx.end;
@@ -1125,6 +1130,18 @@ static int vcpu_hvm(struct xc_dom_image *dom)
{
vcpu_ctx.mtrr_d.instance = i;
+ lapic_record = 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 = *lapic_record;
+ vcpu_ctx.lapic.x2apic_id = dom->cpu_to_apicid[i];
+ vcpu_ctx.lapic_d.instance = i;
+
rc = xc_domain_hvm_setcontext(dom->xch, dom->guest_domid,
(uint8_t *)&vcpu_ctx, sizeof(vcpu_ctx));
if ( rc != 0 )
--
2.47.0
next prev parent reply other threads:[~2024-10-21 15:46 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-21 15:45 [PATCH v7 00/10] x86: Expose consistent topology to guests Alejandro Vallejo
2024-10-21 15:45 ` [PATCH v7 01/10] lib/x86: Bump max basic leaf in {pv,hvm}_max_policy Alejandro Vallejo
2024-10-29 17:57 ` Andrew Cooper
2024-10-21 15:45 ` [PATCH v7 02/10] xen/x86: Add initial x2APIC ID to the per-vLAPIC save area Alejandro Vallejo
2024-10-29 20:30 ` Andrew Cooper
2024-10-30 6:37 ` Jan Beulich
2024-10-30 12:03 ` Alejandro Vallejo
2024-10-30 12:05 ` Jan Beulich
2024-10-30 12:25 ` Andrew Cooper
2024-10-30 12:00 ` Alejandro Vallejo
2024-10-21 15:45 ` [PATCH v7 03/10] xen/x86: Add supporting code for uploading LAPIC contexts during domain create Alejandro Vallejo
2024-12-02 9:27 ` Jan Beulich
2024-10-21 15:45 ` [PATCH v7 04/10] tools/hvmloader: Retrieve (x2)APIC IDs from the APs themselves Alejandro Vallejo
2024-10-30 11:31 ` Andrew Cooper
2024-10-30 12:04 ` Jan Beulich
2024-11-11 11:20 ` Alejandro Vallejo
2024-11-11 12:07 ` Jan Beulich
2024-12-02 9:36 ` Jan Beulich
2024-10-21 15:45 ` [PATCH v7 05/10] tools/libacpi: Use LUT of APIC IDs rather than function pointer Alejandro Vallejo
2024-10-30 14:56 ` Andrew Cooper
2024-12-02 9:40 ` Jan Beulich
2024-10-21 15:45 ` [PATCH v7 06/10] tools/libguest: Always set vCPU context in vcpu_hvm() Alejandro Vallejo
2024-10-21 15:45 ` [PATCH v7 07/10] xen/lib: Add topology generator for x86 Alejandro Vallejo
2024-10-21 15:45 ` [PATCH v7 08/10] xen/x86: Derive topologically correct x2APIC IDs from the policy Alejandro Vallejo
2024-10-21 15:45 ` Alejandro Vallejo [this message]
2024-10-21 15:46 ` [PATCH v7 10/10] tools/x86: Synthesise domain topologies Alejandro Vallejo
2024-12-02 9:18 ` Jan Beulich
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241021154600.11745-10-alejandro.vallejo@cloud.com \
--to=alejandro.vallejo@cloud.com \
--cc=anthony.perard@vates.tech \
--cc=jgross@suse.com \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.