[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [XEN v2 04/12] xen/Arm: vGICv3: Adapt emulation of GICR_TYPER for AArch32


  • To: Julien Grall <julien@xxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • From: Ayan Kumar Halder <ayankuma@xxxxxxx>
  • Date: Mon, 7 Nov 2022 14:00:09 +0000
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none
  • 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=ZL8uh4o5OnqxFdIWC5o66OuCu2zVKxRXW7MDG4snNlo=; b=PmXukiQj5A2QDk3lKtV12m3jKn9yIF+nDEicwoCpOJ/aZISUftuzCQE/iXBmR77Mpn01jvemy4+2vAWYdgrJzVwCsQVHFYqMDZ/AD3NwjkgbNBXqy22C6zDNKrSOiv4oz2Eh33QfTNknrujx6J458vvbR2byUEf5OM51XiMYYqe6oFcqTNRoFvCQySRIjePnEMyv6XyVYZdypaLKD3It3HWqICsF4sbCongE8yeNbM1X+6Tt1eLcHRdckqC4E33EzdjJIOVzhozkqFzDXWpnaBJ1tIiYaZuvN9r5r9b/cmElbgPx2Dup5syLWHyBCifolnseMVIEh4iHqtXq4Ah8eg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RD6WW09V/yt5DgDXFNmFwpxuNPXgZrHHu6kok/8rH0qboo8QYPUM1UAVGlwMk1Jw42IbrxbaUkxbQHgOyNYzn9OTI/M4R2TDfl7K6ukwqZk9aHW09jJo1+Nl9YdVeCxWcPQcDzO3n4tSB1DDjX5AvhnBDKfGE8ZrX0EhsR8wdX2IzQgKNbp2G+/e78hmv2t4aQpm0i5/i1y+HUTbzOCVhSLNmwWxOQB8bV7+SCJPp5VB7fbH4S+lChHTbWtftxT2QjYRo4YfBTVVZtX18sayw8WG6XRLDW7X3tKBIountx0n6G88juRfM1VbkspSXf58GSt41oxJRXAqcwPJKbPSbg==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com;
  • Cc: sstabellini@xxxxxxxxxx, stefanos@xxxxxxxxxx, Volodymyr_Babchuk@xxxxxxxx, bertrand.marquis@xxxxxxx, burzalodowa@xxxxxxxxx
  • Delivery-date: Mon, 07 Nov 2022 14:00:48 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>


On 07/11/2022 11:54, Julien Grall wrote:
Hi Ayan,

Hi Julien,

I need one clarification.


On 07/11/2022 11:33, Ayan Kumar Halder wrote:

On 06/11/2022 18:04, Julien Grall wrote:
Hi Ayan,

Hi Julien,

I need a clarification.


In the title you are using AArch32 but below you are using...

On 31/10/2022 15:13, Ayan Kumar Halder wrote:
v->arch.vmpidr is assigned to uint64_t variable. This is to enable left shifts
for Aarch32 so that one can extract affinity bits.

... Aarch32. The naming also seem to be inconsistent across your series. AFAIU, it should be AArch32. So please look at all your commits and make sure you use the same everywhere.
Ack

This is then assigned to 'typer' so that the affinity bits form the upper 32 bits.

Refer Arm IHI 0069H ID020922,
The upper 32 bits of GICR_TYPER represent the affinity
whereas the lower 32 bits represent the other bits (eg processor
number, etc).

Signed-off-by: Ayan Kumar Halder <ayankuma@xxxxxxx>
---

Changes from :-
1. v1 - Assigned v->arch.vmpidr to "uint64_t vmpdir". Then, we can use
MPIDR_AFFINITY_LEVEL macros to extract the affinity value.

  xen/arch/arm/vgic-v3.c | 10 ++++++----
  1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/xen/arch/arm/vgic-v3.c b/xen/arch/arm/vgic-v3.c
index 3f4509dcd3..e5e6f2c573 100644
--- a/xen/arch/arm/vgic-v3.c
+++ b/xen/arch/arm/vgic-v3.c
@@ -191,13 +191,15 @@ static int __vgic_v3_rdistr_rd_mmio_read(struct vcpu *v, mmio_info_t *info,
      case VREG64(GICR_TYPER):
      {
          uint64_t typer, aff;
+        uint64_t vmpidr = v->arch.vmpidr;
            if ( !vgic_reg64_check_access(dabt) ) goto bad_width;
-        aff = (MPIDR_AFFINITY_LEVEL(v->arch.vmpidr, 3) << 56 |
-               MPIDR_AFFINITY_LEVEL(v->arch.vmpidr, 2) << 48 |
-               MPIDR_AFFINITY_LEVEL(v->arch.vmpidr, 1) << 40 |
-               MPIDR_AFFINITY_LEVEL(v->arch.vmpidr, 0) << 32);
+        aff = (MPIDR_AFFINITY_LEVEL(vmpidr, 3) << 56 |

Shouldn't we #ifdef this level for 32-bit? Or maybe check if the domain is 64-bit so we are using consistently regardless of the hypervisor bitness.

We have typecasted "v->arch.vmpidr" (which is 32bit for AArch32 and 64bit for AArch64)  to vmpidr (uint64_t).

So, we don't need to have any #ifdef for AArch32 or AArch64.

This is not related to the typecast. This is more that fact that affinity level 3 doesn't exist for 32-bit guest. For instance vpsci.c will protect level 3 with an #ifdef.

Just to make sure, I understand you. You are suggesting this ?

--- a/xen/arch/arm/vgic-v3.c
+++ b/xen/arch/arm/vgic-v3.c
@@ -191,13 +191,15 @@ static int __vgic_v3_rdistr_rd_mmio_read(struct vcpu *v, 
mmio_info_t *info,
     case VREG64(GICR_TYPER):
     {
         uint64_t typer, aff;
+        uint64_t vmpidr = v->arch.vmpidr;
if ( !vgic_reg64_check_access(dabt) ) goto bad_width;
-        aff = (MPIDR_AFFINITY_LEVEL(v->arch.vmpidr, 3) << 56 |
-               MPIDR_AFFINITY_LEVEL(v->arch.vmpidr, 2) << 48 |
-               MPIDR_AFFINITY_LEVEL(v->arch.vmpidr, 1) << 40 |
-               MPIDR_AFFINITY_LEVEL(v->arch.vmpidr, 0) << 32);
+        aff = (
+#ifdef CONFIG_ARM_64
+               MPIDR_AFFINITY_LEVEL(vmpidr, 3) << 56 |
+#endif
+               MPIDR_AFFINITY_LEVEL(vmpidr, 2) << 48 |
+               MPIDR_AFFINITY_LEVEL(vmpidr, 1) << 40 |
+               MPIDR_AFFINITY_LEVEL(vmpidr, 0) << 32);
         typer = aff;
+
         /* We use the VCPU ID as the redistributor ID in bits[23:8] */
         typer |= v->vcpu_id << GICR_TYPER_PROC_NUM_SHIFT;

If so, then we can drop the patch "[XEN v2 02/12] xen/Arm: GICv3: Move the macros to compute the affnity level to arm64/arm32"

Also, we should do the following change :-

ayankuma@xcbayankuma41x:/scratch/ayankuma/r52_xen/xen-pristine$ git diff xen/arch/arm/gic-v3.c
diff --git a/xen/arch/arm/gic-v3.c b/xen/arch/arm/gic-v3.c
index d8ce0f46c6..e7d5338152 100644
--- a/xen/arch/arm/gic-v3.c
+++ b/xen/arch/arm/gic-v3.c
@@ -527,7 +527,10 @@ static void gicv3_set_pending_state(struct irq_desc *irqd, bool pending)
 static inline uint64_t gicv3_mpidr_to_affinity(int cpu)
 {
      uint64_t mpidr = cpu_logical_map(cpu);
-     return (MPIDR_AFFINITY_LEVEL(mpidr, 3) << 32 |
+     return (
+#ifdef CONFIG_ARM_64
+             MPIDR_AFFINITY_LEVEL(mpidr, 3) << 32 |
+#endif
              MPIDR_AFFINITY_LEVEL(mpidr, 2) << 16 |
              MPIDR_AFFINITY_LEVEL(mpidr, 1) << 8  |
              MPIDR_AFFINITY_LEVEL(mpidr, 0));
@@ -720,7 +723,10 @@ static int __init gicv3_populate_rdist(void)
      * Convert affinity to a 32bit value that can be matched to GICR_TYPER
      * bits [63:32]
      */
-    aff = (MPIDR_AFFINITY_LEVEL(mpidr, 3) << 24 |
+    aff = (
+#ifdef CONFIG_ARM_64
+           MPIDR_AFFINITY_LEVEL(mpidr, 3) << 24 |
+#endif
            MPIDR_AFFINITY_LEVEL(mpidr, 2) << 16 |
            MPIDR_AFFINITY_LEVEL(mpidr, 1) << 8 |
            MPIDR_AFFINITY_LEVEL(mpidr, 0));
@@ -972,7 +978,10 @@ static void gicv3_send_sgi_list(enum gic_sgi sgi, const cpumask_t *cpumask)
          * Prepare affinity path of the cluster for which SGI is generated
          * along with SGI number
          */
-        val = (MPIDR_AFFINITY_LEVEL(cluster_id, 3) << 48  |
+        val = (
+#ifdef CONFIG_ARM_64
+               MPIDR_AFFINITY_LEVEL(cluster_id, 3) << 48  |
+#endif
                MPIDR_AFFINITY_LEVEL(cluster_id, 2) << 32  |
                sgi << 24                                  |
                MPIDR_AFFINITY_LEVEL(cluster_id, 1) << 16  |

- Ayan


Cheers,




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.