[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2] arm/vgic-v3: fix virq offset in the rank when storing irouter
- To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
- From: Hongda Deng <Hongda.Deng@xxxxxxx>
- Date: Fri, 29 Jul 2022 16:36:02 +0800
- Arc-authentication-results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 63.35.35.123) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com; arc=pass (0 oda=1 ltdi=1 spf=[1,1,smtp.mailfrom=arm.com] dmarc=[1,1,header.from=arm.com])
- Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 40.67.248.234) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=none (message not signed); arc=none
- Arc-message-signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Luj6WGcvC7Id5jsfCrQ8DFeZ6tuRojWkwmRg1mcIZIE=; b=gVm478eOuqIubw5u9XoJt9R535+W8cvh95T8e8kzaEe6BSe+oVayDfkMiiaA16RmhNxHEjr8pWLPvGClXrL2irZCXhZqSlY/K4I13J1db99BFKQyfMSaARc6RH96aQrkw4W23NEoZTKPbRt8jPVIXKYan2tY453A9Kqkdql651w1MIgIj2EP7RjiRHGJaivq/kQaR8z91e0z7LqMiBV7TFQlaEClKUnOcRbwg74UGqRhCxtx/gKCW9rzAm2MFsWrH2bBR46di3SroZdAiXtkkYyaIi0o3rkx2mXcHx8jT4OJI3h8tH3nxXJv/3YJFU+TtE8QWbWeyPw4fXQR3TgTtQ==
- Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Luj6WGcvC7Id5jsfCrQ8DFeZ6tuRojWkwmRg1mcIZIE=; b=Vq0Kb099bLjI0qid4pG832axX2GJjEQcP0dD7EqJR0C4j2xKv7GL/wvwCnJ0LQrsh+g4QZmhkTd4K/t/U2wew4zkIzvMMhYiR8Gt+L8zxpsWgyRjhjLNQI6ppJHks0T2bMqyPAPP1PI7csTbw5agcbYfefqFhr1Olc1gzho3ki4g0d+/GM4S69SP+Of9kG171+bufVKySRVsdgkKoE43mPL+epfh/O7UNIef9DE///Cxfuga65GA7qTkjJ47R1M2TNg4HMLO3Lk4Ckhmc/4WRicMFDnf6Ckki75uxb69EiLWP3HUbAscTkRMUdgB2SJE/ghk8NsUHL4BaJ/jr5gCZw==
- Arc-seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=a4TAxabySP5nMZfx2td/ADE+pl6gTAFQUDfzJhNxiad2bit6Ti9nrHdTUcnBRTPkZbyqSwQynpYjJmQjkMO48nhfegCIOhVtoRzsBCjrUBvHKlP5O/IKelu0WYBbFs+VrPWxtSEFdGNActskvtiIFib1Kx4soOxTQf5YS37AOxACyhYHRF6z6B3Z5gLCEd7EnBP4NQpMclYk8sQU4i+O6/597JYMLwKz6Ec+jFHK+Oom0ab+F+D4KjHwJCqeFlvT8gsKrS5IdAKKGr3ryF0SmopbVfBj8Gfi42XipSc0lcUznKI8uYbSAd7ytrjr86k+YX8hi6aWf+HGIeo02f4VQA==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IJKZHrqZH0kNDbOzcu0AjjfVySQRXm4BZmhUrH8ezo9YOWAp7mtLYSw7D856WYyGqXWVN12wGWDTfNl3aMir6XJqh/aWe7TlC3uGqt8dFGcluxqCa17J0MJpgDjh3bPEG1l4cqQYRZeDEmTmYwg3kF7PcHctD4HU0793GOsoUa8mHrv/aZrwwuph+J0UNR7xWzTQqIw40h7JGSLqE0KVPQHedHMNtyaW8UMZBkTQ46CMJr5DIz+H9nsqEv10C3kFD1AM3KFrS/qTNkTZCgcxW+wGAj8ipj2FyJ5xS8KnYXVGCFxTEhTyawOQebrXlAcPUxzlmnqdOSKDgwsDPW58eg==
- Cc: <Wei.Chen@xxxxxxx>, Hongda Deng <Hongda.Deng@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>
- Delivery-date: Fri, 29 Jul 2022 08:36:46 +0000
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
- Nodisclaimer: true
When vGIC performs irouter registers emulation, to get the target vCPU
via virq conveniently, Xen doesn't store the irouter value directly,
instead it will use the value (affinities) in irouter to calculate the
target vCPU, and then save the target vCPU in irq rank->vcpu[offset].
When vGIC tries to get the target vCPU, it first calculates the target
vCPU index via
int target = read_atomic(&rank->vcpu[virq & INTERRUPT_RANK_MASK]);
and then it gets the target vCPU via
v->domain->vcpu[target];
When vGIC tries to store irouter for one virq, the target vCPU index
in the rank is computed as
offset &= virq & INTERRUPT_RANK_MASK;
finally it gets the target vCPU via
d->vcpu[read_atomic(&rank->vcpu[offset])];
There is a difference between them while getting the target vCPU index
in the rank. Actually (virq & INTERRUPT_RANK_MASK) would already get
the target vCPU index in the rank, it's wrong to add '&' before '=' when
calculate the offset.
For example, the target vCPU index in the rank should be 6 for virq 38,
but vGIC will get offset=0 when vGIC stores the irouter for this virq,
and finally vGIC will access the wrong target vCPU index in the rank
when updating the irouter.
Fixes: 5d495f4349b5 ("xen/arm: vgic: Optimize the way to store the target vCPU
in the rank")
Signed-off-by: Hongda Deng <Hongda.Deng@xxxxxxx>
---
xen/arch/arm/vgic-v3.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/xen/arch/arm/vgic-v3.c b/xen/arch/arm/vgic-v3.c
index e4ba9a6476..7fb99a9ff2 100644
--- a/xen/arch/arm/vgic-v3.c
+++ b/xen/arch/arm/vgic-v3.c
@@ -135,7 +135,7 @@ static void vgic_store_irouter(struct domain *d, struct
vgic_irq_rank *rank,
ASSERT(virq >= 32);
/* Get the index in the rank */
- offset &= virq & INTERRUPT_RANK_MASK;
+ offset = virq & INTERRUPT_RANK_MASK;
new_vcpu = vgic_v3_irouter_to_vcpu(d, irouter);
old_vcpu = d->vcpu[read_atomic(&rank->vcpu[offset])];
--
2.25.1
|