Skip to contentSkip to conversation

mem/cxl_type3: fix hpa to dpa logic

PATCH In review Yao Xingtao via 1 participant 6 messages Mar 27, 2024 – Apr 7, 2024

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mem/cxl_type3: fix hpa to dpa logic

In 3, 6, 12 interleave ways, we could not access cxl memory properly, and when the process is running on it, a 'segmentation fault' error will occur.

According to the CXL specification '8.2.4.20.13 Decoder Protection', there are two branches to convert HPA to DPA:
b1: Decoder[m].IW < 8 (for 1, 2, 4, 8, 16 interleave ways)
b2: Decoder[m].IW >= 8 (for 3, 6, 12 interleave ways)

but only b1 has been implemented.

To solve this issue, we should implement b2:
DPAOffset[51:IG+8]=HPAOffset[51:IG+IW] / 3
DPAOffset[IG+7:0]=HPAOffset[IG+7:0]
DPA=DPAOffset + Decoder[n].DPABase

Links: https://lore.kernel.org/linux-cxl/[email protected]/

---
 hw/mem/cxl_type3.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)
hw/mem/cxl_type3.c +11 -4
index b0a7e9f11b..2c1218fb12 100644
@@ -805,10 +805,17 @@ static bool cxl_type3_dpa(CXLType3Dev *ct3d, hwaddr host_addr, uint64_t *dpa)
             continue;
         }
 
-        *dpa = dpa_base +
-            ((MAKE_64BIT_MASK(0, 8 + ig) & hpa_offset) |
-             ((MAKE_64BIT_MASK(8 + ig + iw, 64 - 8 - ig - iw) & hpa_offset)
-              >> iw));
+        if (iw < 8) {
+            *dpa = dpa_base +
+                ((MAKE_64BIT_MASK(0, 8 + ig) & hpa_offset) |
+                 ((MAKE_64BIT_MASK(8 + ig + iw, 64 - 8 - ig - iw) & hpa_offset)
+                  >> iw));
+        } else {
+            *dpa = dpa_base +
+                ((MAKE_64BIT_MASK(0, 8 + ig) & hpa_offset) |
+                 ((((MAKE_64BIT_MASK(ig + iw, 64 - ig - iw) & hpa_offset)
+                   >> (ig + iw)) / 3) << (ig + 8)));
+        }
 
         return true;
     }
Signature · 1 line
2.37.3
#1 lore raw
Quoted 11 lines · On Tue, 26 Mar 2024 21:46:53 -0400 Yao Xingtao <[email protected]> wrote:

In 3, 6, 12 interleave ways, we could not access cxl memory properly, and when the process is running on it, a 'segmentation fault' error will occur.

According to the CXL specification '8.2.4.20.13 Decoder Protection', there are two branches to convert HPA to DPA:
b1: Decoder[m].IW < 8 (for 1, 2, 4, 8, 16 interleave ways)
b2: Decoder[m].IW >= 8 (for 3, 6, 12 interleave ways)

but only b1 has been implemented.

Quoted 7 lines

To solve this issue, we should implement b2:
DPAOffset[51:IG+8]=HPAOffset[51:IG+IW] / 3
DPAOffset[IG+7:0]=HPAOffset[IG+7:0]
DPA=DPAOffset + Decoder[n].DPABase

Links: https://lore.kernel.org/linux-cxl/[email protected]/

Not implementing this was intentional (shouldn't seg fault obviously) but I thought we were not advertising EP support for 3, 6, 12? The HDM Decoder configuration checking is currently terrible so we don't prevent the bits being set (adding device side sanity checks for those decoders has been on the todo list for a long time). There are a lot of ways of programming those that will blow up.

Can you confirm that the emulation reports they are supported.
https://elixir.bootlin.com/qemu/v9.0.0-rc1/source/hw/cxl/cxl-component-utils.c#L246
implies it shouldn't and so any software using them is broken.

The non power of 2 decodes always made me nervous as the maths is more complex and any changes to that decode will need careful checking. For the power of 2 cases it was a bunch of writes to edge conditions etc and checking the right data landed in the backing stores.

Joanthan

Quoted 30 lines
---
 hw/mem/cxl_type3.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)
hw/mem/cxl_type3.c +11 -4
index b0a7e9f11b..2c1218fb12 100644
@@ -805,10 +805,17 @@ static bool cxl_type3_dpa(CXLType3Dev *ct3d, hwaddr host_addr, uint64_t *dpa)
             continue;
         }
 
-        *dpa = dpa_base +
-            ((MAKE_64BIT_MASK(0, 8 + ig) & hpa_offset) |
-             ((MAKE_64BIT_MASK(8 + ig + iw, 64 - 8 - ig - iw) & hpa_offset)
-              >> iw));  
+        if (iw < 8) {
+            *dpa = dpa_base +
+                ((MAKE_64BIT_MASK(0, 8 + ig) & hpa_offset) |
+                 ((MAKE_64BIT_MASK(8 + ig + iw, 64 - 8 - ig - iw) & hpa_offset)
+                  >> iw));
+        } else {
+            *dpa = dpa_base +
+                ((MAKE_64BIT_MASK(0, 8 + ig) & hpa_offset) |
+                 ((((MAKE_64BIT_MASK(ig + iw, 64 - ig - iw) & hpa_offset)
+                   >> (ig + iw)) / 3) << (ig + 8)));
+        }
 
         return true;
     }
#2 lore raw

Jonathan

thanks for your reply!

Quoted 39 lines

-----Original Message-----
From: Jonathan Cameron <[email protected]>
Sent: Wednesday, March 27, 2024 9:28 PM
To: Yao, Xingtao/姚 幸涛 <[email protected]>
Cc: [email protected]; [email protected]; Cao, Quanquan/曹 全全 <[email protected]>
Subject: Re: [PATCH] mem/cxl_type3: fix hpa to dpa logic

Quoted 9 lines · On Tue, 26 Mar 2024 21:46:53 -0400 Yao Xingtao <[email protected]> wrote:

In 3, 6, 12 interleave ways, we could not access cxl memory properly, and when the process is running on it, a 'segmentation fault' error will occur.

According to the CXL specification '8.2.4.20.13 Decoder Protection', there are two branches to convert HPA to DPA:
b1: Decoder[m].IW < 8 (for 1, 2, 4, 8, 16 interleave ways)
b2: Decoder[m].IW >= 8 (for 3, 6, 12 interleave ways)

Quoted 8 lines

but only b1 has been implemented.

To solve this issue, we should implement b2:
DPAOffset[51:IG+8]=HPAOffset[51:IG+IW] / 3
DPAOffset[IG+7:0]=HPAOffset[IG+7:0]
DPA=DPAOffset + Decoder[n].DPABase

Links:

https://lore.kernel.org/linux-cxl/3e84b919-7631-d1db-3e1d-33000f3f3868@fujits
u.com/

Quoted 1 line

Not implementing this was intentional (shouldn't seg fault obviously) but I thought we were not advertising EP support for 3, 6, 12? The HDM Decoder configuration checking is currently terrible so we don't prevent the bits being set (adding device side sanity checks for those decoders has been on the todo list for a long time). There are a lot of ways of programming those that will blow up.

Quoted 4 lines

Can you confirm that the emulation reports they are supported.
https://elixir.bootlin.com/qemu/v9.0.0-rc1/source/hw/cxl/cxl-component-utils.c
#L246
implies it shouldn't and so any software using them is broken.

yes, the feature is not supported by QEMU, but I can still create a 6-interleave-ways region on kernel layer.

I checked the source code of kernel, and found that the kernel did not check this bit when committing decoder. we may add some check on kernel side.

Quoted 5 lines

The non power of 2 decodes always made me nervous as the maths is more complex and any changes to that decode will need careful checking. For the power of 2 cases it was a bunch of writes to edge conditions etc and checking the right data landed in the backing stores.

after applying this modification, I tested some command by using these memory, like 'ls', 'top'.. and they can be executed normally, maybe there are some other problems I haven't met yet.

Quoted 36 lines

Joanthan

hw/mem/cxl_type3.c static bool cxl_type3_dpa(CXLType3Dev *ct3d, hwaddr

Quoted 9 lines
---
 hw/mem/cxl_type3.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)
hw/mem/cxl_type3.c +0 -0
index b0a7e9f11b..2c1218fb12 100644
@@ -805,10 +805,17 @@ static bool cxl_type3_dpa(CXLType3Dev *ct3d, hwaddr

host_addr, uint64_t *dpa)

hw/mem/cxl_type3.c static bool cxl_type3_dpa(CXLType3Dev *ct3d, hwaddr host_addr, uint64_t *dpa)

Quoted 11 lines
hw/mem/cxl_type3.c +4 -4
             continue;
         }
 
-        *dpa = dpa_base +
-            ((MAKE_64BIT_MASK(0, 8 + ig) & hpa_offset) |
-             ((MAKE_64BIT_MASK(8 + ig + iw, 64 - 8 - ig - iw) & hpa_offset)
-              >> iw));
+        if (iw < 8) {
+            *dpa = dpa_base +
+                ((MAKE_64BIT_MASK(0, 8 + ig) & hpa_offset) |
+                 ((MAKE_64BIT_MASK(8 + ig + iw, 64 - 8 - ig - iw) &

hpa_offset)

Quoted 10 lines
hw/mem/cxl_type3.c +7 -0
+                  >> iw));
+        } else {
+            *dpa = dpa_base +
+                ((MAKE_64BIT_MASK(0, 8 + ig) & hpa_offset) |
+                 ((((MAKE_64BIT_MASK(ig + iw, 64 - ig - iw) & hpa_offset)
+                   >> (ig + iw)) / 3) << (ig + 8)));
+        }
 
         return true;
     }
#3 lore raw
Quoted 43 lines · On Thu, 28 Mar 2024 06:24:24 +0000 "Xingtao Yao (Fujitsu)"…

Jonathan

thanks for your reply!

Quoted 39 lines

-----Original Message-----
From: Jonathan Cameron <[email protected]>
Sent: Wednesday, March 27, 2024 9:28 PM
To: Yao, Xingtao/姚 幸涛 <[email protected]>
Cc: [email protected]; [email protected]; Cao, Quanquan/曹 全全 <[email protected]>
Subject: Re: [PATCH] mem/cxl_type3: fix hpa to dpa logic

Quoted 9 lines · On Tue, 26 Mar 2024 21:46:53 -0400 Yao Xingtao <[email protected]> wrote:

In 3, 6, 12 interleave ways, we could not access cxl memory properly, and when the process is running on it, a 'segmentation fault' error will occur.

According to the CXL specification '8.2.4.20.13 Decoder Protection', there are two branches to convert HPA to DPA:
b1: Decoder[m].IW < 8 (for 1, 2, 4, 8, 16 interleave ways)
b2: Decoder[m].IW >= 8 (for 3, 6, 12 interleave ways)

Quoted 8 lines

but only b1 has been implemented.

To solve this issue, we should implement b2:
DPAOffset[51:IG+8]=HPAOffset[51:IG+IW] / 3
DPAOffset[IG+7:0]=HPAOffset[IG+7:0]
DPA=DPAOffset + Decoder[n].DPABase

Links:

https://lore.kernel.org/linux-cxl/3e84b919-7631-d1db-3e1d-33000f3f3868@fujits
u.com/

Quoted 1 line

Not implementing this was intentional (shouldn't seg fault obviously) but I thought we were not advertising EP support for 3, 6, 12? The HDM Decoder configuration checking is currently terrible so we don't prevent the bits being set (adding device side sanity checks for those decoders has been on the todo list for a long time). There are a lot of ways of programming those that will blow up.

Quoted 8 lines
Quoted 4 lines

Can you confirm that the emulation reports they are supported.
https://elixir.bootlin.com/qemu/v9.0.0-rc1/source/hw/cxl/cxl-component-utils.c
#L246
implies it shouldn't and so any software using them is broken.

yes, the feature is not supported by QEMU, but I can still create a 6-interleave-ways region on kernel layer.

I checked the source code of kernel, and found that the kernel did not check this bit when committing decoder. we may add some check on kernel side.

ouch. We definitely want that check! The decoder commit will fail anyway (which QEMU doesn't yet because we don't do all the sanity checks we should). However failing on commit is nasty as the reason should have been detected earlier.

Quoted 8 lines
Quoted 6 lines

The non power of 2 decodes always made me nervous as the maths is more complex and any changes to that decode will need careful checking. For the power of 2 cases it was a bunch of writes to edge conditions etc and checking the right data landed in the backing stores.

after applying this modification, I tested some command by using these memory, like 'ls', 'top'.. and they can be executed normally, maybe there are some other problems I haven't met yet.

I usually run a bunch of manual tests with devmem2 to ensure the edge cases are handled correctly, but I've not really seen any errors that didn't also show up in running stressors (e.g. stressng) or just memhog on the memory.

Jonathan

Quoted 38 lines
Quoted 37 lines

Joanthan

hw/mem/cxl_type3.c static bool cxl_type3_dpa(CXLType3Dev *ct3d, hwaddr

Quoted 9 lines
---
 hw/mem/cxl_type3.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)
hw/mem/cxl_type3.c +0 -0
index b0a7e9f11b..2c1218fb12 100644
@@ -805,10 +805,17 @@ static bool cxl_type3_dpa(CXLType3Dev *ct3d, hwaddr  

host_addr, uint64_t *dpa)

hw/mem/cxl_type3.c static bool cxl_type3_dpa(CXLType3Dev *ct3d, hwaddr host_addr, uint64_t *dpa)

Quoted 11 lines
hw/mem/cxl_type3.c +4 -4
             continue;
         }
 
-        *dpa = dpa_base +
-            ((MAKE_64BIT_MASK(0, 8 + ig) & hpa_offset) |
-             ((MAKE_64BIT_MASK(8 + ig + iw, 64 - 8 - ig - iw) & hpa_offset)  
-              >> iw));  
+        if (iw < 8) {
+            *dpa = dpa_base +
+                ((MAKE_64BIT_MASK(0, 8 + ig) & hpa_offset) |
+                 ((MAKE_64BIT_MASK(8 + ig + iw, 64 - 8 - ig - iw) &  

hpa_offset)

Quoted 10 lines
hw/mem/cxl_type3.c +7 -0
+                  >> iw));
+        } else {
+            *dpa = dpa_base +
+                ((MAKE_64BIT_MASK(0, 8 + ig) & hpa_offset) |
+                 ((((MAKE_64BIT_MASK(ig + iw, 64 - ig - iw) & hpa_offset)
+                   >> (ig + iw)) / 3) << (ig + 8)));
+        }
 
         return true;
     }  
#4 lore raw
Quoted 66 lines · On Mon, 1 Apr 2024 17:00:50 +0100 Jonathan Cameron via <[email protected]>…
Quoted 43 lines · On Thu, 28 Mar 2024 06:24:24 +0000 "Xingtao Yao (Fujitsu)"…

Jonathan

thanks for your reply!

Quoted 39 lines

-----Original Message-----
From: Jonathan Cameron <[email protected]>
Sent: Wednesday, March 27, 2024 9:28 PM
To: Yao, Xingtao/姚 幸涛 <[email protected]>
Cc: [email protected]; [email protected]; Cao, Quanquan/曹 全全 <[email protected]>
Subject: Re: [PATCH] mem/cxl_type3: fix hpa to dpa logic

Quoted 9 lines · On Tue, 26 Mar 2024 21:46:53 -0400 Yao Xingtao <[email protected]> wrote:

In 3, 6, 12 interleave ways, we could not access cxl memory properly, and when the process is running on it, a 'segmentation fault' error will occur.

According to the CXL specification '8.2.4.20.13 Decoder Protection', there are two branches to convert HPA to DPA:
b1: Decoder[m].IW < 8 (for 1, 2, 4, 8, 16 interleave ways)
b2: Decoder[m].IW >= 8 (for 3, 6, 12 interleave ways)

Quoted 8 lines

but only b1 has been implemented.

To solve this issue, we should implement b2:
DPAOffset[51:IG+8]=HPAOffset[51:IG+IW] / 3
DPAOffset[IG+7:0]=HPAOffset[IG+7:0]
DPA=DPAOffset + Decoder[n].DPABase

Links:

https://lore.kernel.org/linux-cxl/3e84b919-7631-d1db-3e1d-33000f3f3868@fujits
u.com/

Quoted 1 line

Not implementing this was intentional (shouldn't seg fault obviously) but I thought we were not advertising EP support for 3, 6, 12? The HDM Decoder configuration checking is currently terrible so we don't prevent the bits being set (adding device side sanity checks for those decoders has been on the todo list for a long time). There are a lot of ways of programming those that will blow up.

Quoted 8 lines
Quoted 4 lines

Can you confirm that the emulation reports they are supported.
https://elixir.bootlin.com/qemu/v9.0.0-rc1/source/hw/cxl/cxl-component-utils.c
#L246
implies it shouldn't and so any software using them is broken.

yes, the feature is not supported by QEMU, but I can still create a 6-interleave-ways region on kernel layer.

I checked the source code of kernel, and found that the kernel did not check this bit when committing decoder. we may add some check on kernel side.

ouch. We definitely want that check! The decoder commit will fail anyway (which QEMU doesn't yet because we don't do all the sanity checks we should). However failing on commit is nasty as the reason should have been detected earlier.

Quoted 6 lines
Quoted 6 lines

The non power of 2 decodes always made me nervous as the maths is more complex and any changes to that decode will need careful checking. For the power of 2 cases it was a bunch of writes to edge conditions etc and checking the right data landed in the backing stores.

Quoted 6 lines
Quoted 2 lines

after applying this modification, I tested some command by using these memory, like 'ls', 'top'.. and they can be executed normally, maybe there are some other problems I haven't met yet.

I usually run a bunch of manual tests with devmem2 to ensure the edge cases are handled correctly, but I've not really seen any errors that didn't also show up in running stressors (e.g. stressng) or just memhog on the memory.

Hi Yao,

If you have time, please spin a v2 that also sets the relevant flag to say the QEMU emulation supports this interleave.

Whilst we test the kernel fixes, we can just drop that patch but longer term I'm find with having this support in general in the QEMU emulation - so I won't queue it up as a fix, but instead as a feature.

Thanks,

Jonathan

Quoted 43 lines

Jonathan

Quoted 38 lines
Quoted 37 lines

Joanthan

hw/mem/cxl_type3.c static bool cxl_type3_dpa(CXLType3Dev *ct3d, hwaddr

Quoted 9 lines
---
 hw/mem/cxl_type3.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)
hw/mem/cxl_type3.c +0 -0
index b0a7e9f11b..2c1218fb12 100644
@@ -805,10 +805,17 @@ static bool cxl_type3_dpa(CXLType3Dev *ct3d, hwaddr    

host_addr, uint64_t *dpa)

hw/mem/cxl_type3.c static bool cxl_type3_dpa(CXLType3Dev *ct3d, hwaddr host_addr, uint64_t *dpa)

Quoted 11 lines
hw/mem/cxl_type3.c +4 -4
             continue;
         }
 
-        *dpa = dpa_base +
-            ((MAKE_64BIT_MASK(0, 8 + ig) & hpa_offset) |
-             ((MAKE_64BIT_MASK(8 + ig + iw, 64 - 8 - ig - iw) & hpa_offset)    
-              >> iw));    
+        if (iw < 8) {
+            *dpa = dpa_base +
+                ((MAKE_64BIT_MASK(0, 8 + ig) & hpa_offset) |
+                 ((MAKE_64BIT_MASK(8 + ig + iw, 64 - 8 - ig - iw) &    

hpa_offset)

Quoted 10 lines
hw/mem/cxl_type3.c +7 -0
+                  >> iw));
+        } else {
+            *dpa = dpa_base +
+                ((MAKE_64BIT_MASK(0, 8 + ig) & hpa_offset) |
+                 ((((MAKE_64BIT_MASK(ig + iw, 64 - ig - iw) & hpa_offset)
+                   >> (ig + iw)) / 3) << (ig + 8)));
+        }
 
         return true;
     }    
#5 lore raw
Quoted 92 lines

-----Original Message-----
From: Jonathan Cameron <[email protected]>
Sent: Saturday, April 6, 2024 12:46 AM
To: Jonathan Cameron via <[email protected]>
Cc: Jonathan Cameron <[email protected]>; Yao, Xingtao/姚 幸涛 <[email protected]>; [email protected]; Cao, Quanquan/曹 全全 <[email protected]>
Subject: Re: [PATCH] mem/cxl_type3: fix hpa to dpa logic

Quoted 5 lines · On Mon, 1 Apr 2024 17:00:50 +0100 Jonathan Cameron via <[email protected]>…
Quoted 2 lines · On Thu, 28 Mar 2024 06:24:24 +0000 "Xingtao Yao (Fujitsu)"…

Jonathan

Quoted 7 lines
Quoted 7 lines

thanks for your reply!

Quoted 5 lines

-----Original Message-----
From: Jonathan Cameron <[email protected]>
Sent: Wednesday, March 27, 2024 9:28 PM
To: Yao, Xingtao/姚 幸涛 <[email protected]>
Cc: [email protected]; [email protected]; Cao, Quanquan/曹 全

全

Quoted 17 lines
Quoted 17 lines
Quoted 17 lines

<[email protected]>
Subject: Re: [PATCH] mem/cxl_type3: fix hpa to dpa logic

Quoted 11 lines · On Tue, 26 Mar 2024 21:46:53 -0400 Yao Xingtao <[email protected]> wrote:

In 3, 6, 12 interleave ways, we could not access cxl memory properly, and when the process is running on it, a 'segmentation fault' error will occur.

According to the CXL specification '8.2.4.20.13 Decoder Protection', there are two branches to convert HPA to DPA:
b1: Decoder[m].IW < 8 (for 1, 2, 4, 8, 16 interleave ways)
b2: Decoder[m].IW >= 8 (for 3, 6, 12 interleave ways)

but only b1 has been implemented.

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines

To solve this issue, we should implement b2:
DPAOffset[51:IG+8]=HPAOffset[51:IG+IW] / 3
DPAOffset[IG+7:0]=HPAOffset[IG+7:0]
DPA=DPAOffset + Decoder[n].DPABase

Links:

https://lore.kernel.org/linux-cxl/3e84b919-7631-d1db-3e1d-33000f3f3868@fujits

Quoted 10 lines
Quoted 10 lines
Quoted 10 lines

u.com/

Quoted 1 line

Not implementing this was intentional (shouldn't seg fault obviously) but I thought we were not advertising EP support for 3, 6, 12? The HDM Decoder configuration checking is currently terrible so we don't prevent the bits being set (adding device side sanity checks for those decoders has been on the todo list for a long time). There are a lot of ways of programming those that will blow up.

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

Can you confirm that the emulation reports they are supported.

https://elixir.bootlin.com/qemu/v9.0.0-rc1/source/hw/cxl/cxl-component-utils.c

Quoted 3 lines
Quoted 3 lines
Quoted 2 lines

#L246
implies it shouldn't and so any software using them is broken.

yes, the feature is not supported by QEMU, but I can still create a

6-interleave-ways region on kernel layer.

Quoted 2 lines
Quoted 2 lines

I checked the source code of kernel, and found that the kernel did not check

this bit when committing decoder.

Quoted 14 lines
Quoted 1 line

we may add some check on kernel side.

ouch. We definitely want that check! The decoder commit will fail anyway (which QEMU doesn't yet because we don't do all the sanity checks we should). However failing on commit is nasty as the reason should have been detected earlier.

Quoted 7 lines
Quoted 6 lines

The non power of 2 decodes always made me nervous as the maths is more complex and any changes to that decode will need careful checking. For the power of 2 cases it was a bunch of writes to edge conditions etc and checking the right data landed in the backing stores.

after applying this modification, I tested some command by using these

memory, like 'ls', 'top'..

Quoted 1 line
Quoted 1 line

and they can be executed normally, maybe there are some other problems I

haven't met yet.

Quoted 2 lines

I usually run a bunch of manual tests with devmem2 to ensure the edge cases are

handled

Quoted 8 lines
Quoted 2 lines

correctly, but I've not really seen any errors that didn't also show up in running stressors (e.g. stressng) or just memhog on the memory.

Hi Yao,

If you have time, please spin a v2 that also sets the relevant flag to say the QEMU emulation supports this interleave.

OK, I will.

Quoted 55 lines

Whilst we test the kernel fixes, we can just drop that patch but longer term I'm find with having this support in general in the QEMU emulation - so I won't queue it up as a fix, but instead as a feature.

Thanks,

Jonathan

Quoted 12 lines

Jonathan

Quoted 9 lines
Quoted 9 lines

Joanthan

Quoted 4 lines
---
 hw/mem/cxl_type3.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

hw/mem/cxl_type3.c static bool cxl_type3_dpa(CXLType3Dev *ct3d,

Quoted 5 lines
hw/mem/cxl_type3.c +0 -0
index b0a7e9f11b..2c1218fb12 100644
@@ -805,10 +805,17 @@ static bool cxl_type3_dpa(CXLType3Dev *ct3d,

hwaddr

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

host_addr, uint64_t *dpa)

Quoted 6 lines
hw/mem/cxl_type3.c +0 -3
             continue;
         }
 
-        *dpa = dpa_base +
-            ((MAKE_64BIT_MASK(0, 8 + ig) & hpa_offset) |
-             ((MAKE_64BIT_MASK(8 + ig + iw, 64 - 8 - ig - iw) &

hpa_offset)

Quoted 11 lines
Quoted 11 lines
Quoted 11 lines

hw/mem/cxl_type3.c static bool cxl_type3_dpa(CXLType3Dev *ct3d, hwaddr host_addr, uint64_t *dpa)

Quoted 5 lines
hw/mem/cxl_type3.c +4 -1
-              >> iw));
+        if (iw < 8) {
+            *dpa = dpa_base +
+                ((MAKE_64BIT_MASK(0, 8 + ig) & hpa_offset) |
+                 ((MAKE_64BIT_MASK(8 + ig + iw, 64 - 8 - ig - iw) &

hpa_offset)

Quoted 5 lines
hw/mem/cxl_type3.c +5 -0
+                  >> iw));
+        } else {
+            *dpa = dpa_base +
+                ((MAKE_64BIT_MASK(0, 8 + ig) & hpa_offset) |
+                 ((((MAKE_64BIT_MASK(ig + iw, 64 - ig - iw) &

hpa_offset)

Quoted 8 lines
Quoted 6 lines
Quoted 5 lines
Quoted 5 lines
hw/mem/cxl_type3.c +2 -0
+                   >> (ig + iw)) / 3) << (ig + 8)));
+        }
 
         return true;
     }