riscv: dts: spacemit: k3: fix IMSIC guest parameters
Subsystems (4)
PATCH 1/1 riscv: dts: spacemit: k3: fix IMSIC guest parameters
From: "GUO Ren (XuanTie)" <[email protected]>
The initial K3 device tree used generic/placeholder values for the IMSIC guest configuration:
riscv,guest-index-bits = <6>; riscv,num-guest-ids = <511>;
According to the SpacemiT K3 User Manual [1] these values are incorrect for the X100 cores:
- Hypervisor Extension: RVH 1.0, GEILEN = 8
- Advanced Interrupt Architecture (AIA):
- M-mode MSI: 512
- S-mode MSI: 512
- VS-mode MSI: 64
Therefore:
- S-mode IMSIC (simsic) only needs guest-index-bits = 3 (to cover GEILEN = 8) and num-guest-ids = 63.
- M-mode IMSIC (mimsic) does not implement guest interrupt files at all, so the guest-related properties must be omitted.
Although the KVM AIA driver will re-detect the actual number of guest interrupt files via hgeie and correct guest-index-bits at runtime, the device tree should still describe the correct hardware parameters.
Update the device tree to match the silicon.
--- arch/riscv/boot/dts/spacemit/k3.dtsi | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
arch/riscv/boot/dts/spacemit/k3.dtsi +2 -4
@@ -1127,9 +1127,9 @@ simsic: interrupt-controller@e0400000 { <&cpu4_intc 9>, <&cpu5_intc 9>, <&cpu6_intc 9>, <&cpu7_intc 9>; msi-controller; - riscv,guest-index-bits = <6>; + riscv,guest-index-bits = <3>; riscv,hart-index-bits = <4>; - riscv,num-guest-ids = <511>; + riscv,num-guest-ids = <63>; riscv,num-ids = <511>; };
@@ -1168,9 +1168,7 @@ mimsic: interrupt-controller@f1000000 { <&cpu4_intc 11>, <&cpu5_intc 11>, <&cpu6_intc 11>, <&cpu7_intc 11>; msi-controller; - riscv,guest-index-bits = <6>; riscv,hart-index-bits = <4>; - riscv,num-guest-ids = <511>; riscv,num-ids = <511>; status = "reserved"; };
Signature · 1 line
2.43.0
[email protected]
AI reviewThank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [High] Reducing `riscv,guest-index-bits` to `<3>` incorrectly caps guest interrupt files and…
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Reducing riscv,guest-index-bits to <3> incorrectly caps guest interrupt files and catastrophically breaks the physical MMIO layout for secondary CPUs. --
--- Patch [1]: [PATCH] riscv: dts: spacemit: k3: fix IMSIC guest parameters --- commit bd339af20fe829df6f685236a32dbabad41e337c
Author: GUO Ren (XuanTie) <[email protected]>
riscv: dts: spacemit: k3: fix IMSIC guest parameters
This commit updates the K3 device tree IMSIC guest configurations based on the SpacemiT K3 User Manual. It lowers guest-index-bits and num-guest-ids for simsic, and removes them entirely for mimsic.
Quoted 4 lines
arch/riscv/boot/dts/spacemit/k3.dtsi +0
-0
[ ... ]
arch/riscv/boot/dts/spacemit/k3.dtsi simsic: interrupt-controller@e0400000 { · line 1249
Quoted 6 lines
arch/riscv/boot/dts/spacemit/k3.dtsi +1
-1@@ -1246,9 +1246,9 @@ simsic: interrupt-controller@e0400000 { <&cpu4_intc 9>, <&cpu5_intc 9>, <&cpu6_intc 9>, <&cpu7_intc 9>; msi-controller; - riscv,guest-index-bits = <6>; + riscv,guest-index-bits = <3>;
[Severity: High]
Will reducing riscv,guest-index-bits to 3 break the physical MMIO layout for secondary CPUs and incorrectly cap the guest interrupt files?
The IMSIC irqchip driver uses riscv,guest-index-bits to determine the physical MMIO stride between HARTs (stride = BIT(guest-index-bits) * 4096). By reducing this from 6 to 3, the calculated stride drops from 256 KB to 32 KB.
With a 32 KB stride, CPU 1's supervisor IMSIC file is incorrectly calculated to be at base + 32 KB. This offset actually hits CPU 0's 8th guest interrupt file instead of CPU 1's true supervisor file (at 256 KB).
Additionally, the AIA spec states guest files are indexed 1 to GEILEN. With GEILEN=8, representing index 8 requires at least 4 bits. Setting guest-index-bits = 3 mathematically limits the maximum addressable index to 7 (BIT(3) - 1), truncating the 8th guest file.
The commit message mentions that KVM will dynamically correct this via hgeie, but KVM reads nr_guest_files directly from the irqchip driver, which enforces the BIT(guest-index-bits) - 1 limit. Is it possible this change will cause MSIs and IPIs for secondary CPUs to fail?
Quoted 5 lines
arch/riscv/boot/dts/spacemit/k3.dtsi +1
-1riscv,hart-index-bits = <4>; - riscv,num-guest-ids = <511>; + riscv,num-guest-ids = <63>; riscv,num-ids = <511>; };
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Yixun Lan
maintainerhi Guo,
Quoted 21 lines · Guo Ren
From: "GUO Ren (XuanTie)" <[email protected]>
The initial K3 device tree used generic/placeholder values for the IMSIC guest configuration:
riscv,guest-index-bits = <6>; riscv,num-guest-ids = <511>;According to the SpacemiT K3 User Manual [1] these values are incorrect for the X100 cores:
- Hypervisor Extension: RVH 1.0, GEILEN = 8
- Advanced Interrupt Architecture (AIA):
- M-mode MSI: 512
- S-mode MSI: 512
- VS-mode MSI: 64Therefore:
- S-mode IMSIC (simsic) only needs guest-index-bits = 3 (to cover GEILEN = 8) and num-guest-ids = 63.
..
Quoted 3 lines
- M-mode IMSIC (mimsic) does not implement guest interrupt files at all, so the guest-related properties must be omitted.
Cc Junhui
There is already one fix for IMSIC [1], but it's actually too late to pick for v7.3 .. I'm not sure how best to handle this, would it possible on your side to pick Junhui's patch and rework to combine them to send a V2? or I could pick his patch first ..
https://lore.kernel.org/all/[email protected]/
Quoted 6 lines
Although the KVM AIA driver will re-detect the actual number of guest interrupt files via hgeie and correct guest-index-bits at runtime, the device tree should still describe the correct hardware parameters.
Update the device tree to match the silicon.
..
Quoted 2 lines
no blank line and use "Link: https://.. [1]" format
Quoted 38 lines
Fixes 56f37e391a62 ("riscv: dts: spacemit: add initial support for K3 SoC")Cc Guodong Xu <[email protected]>Cc Yixun Lan <[email protected]>Signed-off-by GUO Ren (XuanTie) <[email protected]>--- arch/riscv/boot/dts/spacemit/k3.dtsi | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)arch/riscv/boot/dts/spacemit/k3.dtsi +2
-4@@ -1127,9 +1127,9 @@ simsic: interrupt-controller@e0400000 { <&cpu4_intc 9>, <&cpu5_intc 9>, <&cpu6_intc 9>, <&cpu7_intc 9>; msi-controller; - riscv,guest-index-bits = <6>; + riscv,guest-index-bits = <3>; riscv,hart-index-bits = <4>; - riscv,num-guest-ids = <511>; + riscv,num-guest-ids = <63>; riscv,num-ids = <511>; };@@ -1168,9 +1168,7 @@ mimsic: interrupt-controller@f1000000 { <&cpu4_intc 11>, <&cpu5_intc 11>, <&cpu6_intc 11>, <&cpu7_intc 11>; msi-controller; - riscv,guest-index-bits = <6>; riscv,hart-index-bits = <4>; - riscv,num-guest-ids = <511>; riscv,num-ids = <511>; status = "reserved"; };Signature · 1 line
2.43.0
Signature · 1 line
Yixun Lan (dlan)
Hi Guo,
Quoted 46 lines · Guo Ren
From: "GUO Ren (XuanTie)" <[email protected]>
The initial K3 device tree used generic/placeholder values for the IMSIC guest configuration:
riscv,guest-index-bits = <6>; riscv,num-guest-ids = <511>;According to the SpacemiT K3 User Manual [1] these values are incorrect for the X100 cores:
- Hypervisor Extension: RVH 1.0, GEILEN = 8
- Advanced Interrupt Architecture (AIA):
- M-mode MSI: 512
- S-mode MSI: 512
- VS-mode MSI: 64Therefore:
- S-mode IMSIC (simsic) only needs guest-index-bits = 3 (to cover GEILEN = 8) and num-guest-ids = 63.
- M-mode IMSIC (mimsic) does not implement guest interrupt files at all, so the guest-related properties must be omitted.Although the KVM AIA driver will re-detect the actual number of guest interrupt files via hgeie and correct guest-index-bits at runtime, the device tree should still describe the correct hardware parameters.
Update the device tree to match the silicon.
Fixes 56f37e391a62 ("riscv: dts: spacemit: add initial support for K3 SoC")Cc Guodong Xu <[email protected]>Cc Yixun Lan <[email protected]>Signed-off-by GUO Ren (XuanTie) <[email protected]>--- arch/riscv/boot/dts/spacemit/k3.dtsi | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)arch/riscv/boot/dts/spacemit/k3.dtsi +0
-0
arch/riscv/boot/dts/spacemit/k3.dtsi simsic: interrupt-controller@e0400000 { · line 1130
Quoted 5 lines
arch/riscv/boot/dts/spacemit/k3.dtsi +1
-1@@ -1127,9 +1127,9 @@ simsic: interrupt-controller@e0400000 { <&cpu4_intc 9>, <&cpu5_intc 9>, <&cpu6_intc 9>, <&cpu7_intc 9>; msi-controller; - riscv,guest-index-bits = <6>; + riscv,guest-index-bits = <3>;
According to the IMSIC DT binding, riscv,guest-index-bits describes the number of guest-index bits in the MSI target address, not the number of guest interrupt files actually implemented by a hart.
On K3, the per-hart IMSIC stride is 0x40000 bytes (0x200000 / 8). Therefore, riscv,guest-index-bits should remain 6, which satisfies the per-hart stride formula specified by the AIA specification:
2^(guest-index-bits + 12) = 2^(6 + 12) = 0x40000 bytes
KVM already handles the difference between the address space and the actual number of guest interrupt files. It reads HGEIE to find the actual number of guest interrupt files and uses the smaller value:
/*
* Number of usable per-HART HGEI lines should be minimum of
* per-HART IMSIC guest files and number of bits in HGEIE. */
if (lc)
hgctrl->nr_hgei =
min((ulong)hgctrl->nr_hgei, lc->nr_guest_files);I also tested this on K3. HGEIE returned 0xfe after writing all ones, so the driver gets fls_long(0xfe) - 1 = 7 usable guest interrupt files.
arch/riscv/boot/dts/spacemit/k3.dtsi simsic: interrupt-controller@e0400000 { · line 1132
Quoted 3 lines
arch/riscv/boot/dts/spacemit/k3.dtsi +1
-1riscv,hart-index-bits = <4>; - riscv,num-guest-ids = <511>; + riscv,num-guest-ids = <63>;
This change looks good to me.
arch/riscv/boot/dts/spacemit/k3.dtsi mimsic: interrupt-controller@f1000000 { · line 1174
Quoted 13 lines
arch/riscv/boot/dts/spacemit/k3.dtsi +0
-2riscv,num-ids = <511>; };@@ -1168,9 +1168,7 @@ mimsic: interrupt-controller@f1000000 { <&cpu4_intc 11>, <&cpu5_intc 11>, <&cpu6_intc 11>, <&cpu7_intc 11>; msi-controller; - riscv,guest-index-bits = <6>; riscv,hart-index-bits = <4>; - riscv,num-guest-ids = <511>; riscv,num-ids = <511>; status = "reserved"; };
For the mimsic part, I already sent a related fix earlier:
https://lore.kernel.org/linux-riscv/[email protected]/
If you would like, you can pick that patch and combine the two changes into a v2, as Yixun suggested.
Signature · 2 lines
Best regards, Junhui Liu
Quoted 75 lines · Junhui Liu
Hi Guo,
Quoted 46 lines · Guo Ren
From: "GUO Ren (XuanTie)" <[email protected]>
The initial K3 device tree used generic/placeholder values for the IMSIC guest configuration:
riscv,guest-index-bits = <6>; riscv,num-guest-ids = <511>;According to the SpacemiT K3 User Manual [1], these values are incorrect for the X100 cores:
- Hypervisor Extension: RVH 1.0, GEILEN = 8
- Advanced Interrupt Architecture (AIA):
- M-mode MSI: 512
- S-mode MSI: 512
- VS-mode MSI: 64Therefore:
- S-mode IMSIC (simsic) only needs guest-index-bits = 3 (to cover GEILEN = 8) and num-guest-ids = 63.
- M-mode IMSIC (mimsic) does not implement guest interrupt files at all, so the guest-related properties must be omitted.Although the KVM AIA driver will re-detect the actual number of guest interrupt files via hgeie and correct guest-index-bits at runtime, the device tree should still describe the correct hardware parameters.
Update the device tree to match the silicon.
Fixes 56f37e391a62 ("riscv: dts: spacemit: add initial support for K3 SoC")Cc Guodong Xu <[email protected]>Cc Yixun Lan <[email protected]>Signed-off-by GUO Ren (XuanTie) <[email protected]>--- arch/riscv/boot/dts/spacemit/k3.dtsi | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)arch/riscv/boot/dts/spacemit/k3.dtsi +0
-0arch/riscv/boot/dts/spacemit/k3.dtsi simsic: interrupt-controller@e0400000 { · line 1130
Quoted 5 lines
arch/riscv/boot/dts/spacemit/k3.dtsi +1
-1@@ -1127,9 +1127,9 @@ simsic: interrupt-controller@e0400000 { <&cpu4_intc 9>, <&cpu5_intc 9>, <&cpu6_intc 9>, <&cpu7_intc 9>; msi-controller; - riscv,guest-index-bits = <6>; + riscv,guest-index-bits = <3>;According to the IMSIC DT binding, riscv,guest-index-bits describes the number of guest-index bits in the MSI target address, not the number of guest interrupt files actually implemented by a hart.
On K3, the per-hart IMSIC stride is
0x40000bytes (0x200000/ 8). Therefore, riscv,guest-index-bits should remain 6, which satisfies the per-hart stride formula specified by the AIA specification:2^(guest-index-bits + 12) = 2^(6 + 12) =
0x40000bytesKVM already handles the difference between the address space and the actual number of guest interrupt files. It reads HGEIE to find the actual number of guest interrupt files and uses the smaller value:
/*
* Number of usable per-HART HGEI lines should be minimum of
* per-HART IMSIC guest files and number of bits in HGEIE. */
if (lc)
Quoted 5 lines
hgctrl->nr_hgei = min((ulong)hgctrl->nr_hgei, lc->nr_guest_files);I also tested this on K3. HGEIE returned
0xfeafter writing all ones, so the driver getsfls_long(0xfe)- 1 = 7 usable guest interrupt file
I don't think the reserved per-hart address stride alone is sufficient reason to set riscv,guest-index-bits to 6.
As mentioned in the commit log:
"Although the KVM AIA driver will re-detect the actual number of guest interrupt files via hgeie and correct guest-index-bits at runtime, the device tree should still describe the correct hardware parameters."
Although K3 reserves a 0x40000-byte IMSIC address window per hart, only the first 0x8000 bytes, corresponding to guest indexes 0 through 7, are actually implemented. The remaining range from 0x8000 to 0x3ffff does not correspond to any implemented interrupt file.
If we describe guest-index-bits = <6>, that raises a few questions:
- What hardware resource is represented by guest indexes 8 through 63?
- What behavior does the K3 hardware guarantee for accesses to the
unused 0x8000-0x3ffff range?
- Shall we let the kernel map that unused range and consume
additional page-table entries for it?
Quoted 6 lines
arch/riscv/boot/dts/spacemit/k3.dtsi simsic: interrupt-controller@e0400000 { · line 1132
Quoted 4 lines
arch/riscv/boot/dts/spacemit/k3.dtsi +1
-1riscv,hart-index-bits = <4>; - riscv,num-guest-ids = <511>; + riscv,num-guest-ids = <63>;This change looks good to me.
Thx for the review.
Quoted 4 lines
Quoted 4 lines
arch/riscv/boot/dts/spacemit/k3.dtsi +0
-0riscv,num-ids = <511>; };
Quoted 13 lines
arch/riscv/boot/dts/spacemit/k3.dtsi mimsic: interrupt-controller@f1000000 { · line 1174
Quoted 10 lines
arch/riscv/boot/dts/spacemit/k3.dtsi +0
-2@@ -1168,9 +1168,7 @@ mimsic: interrupt-controller@f1000000 { <&cpu4_intc 11>, <&cpu5_intc 11>, <&cpu6_intc 11>, <&cpu7_intc 11>; msi-controller; - riscv,guest-index-bits = <6>; riscv,hart-index-bits = <4>; - riscv,num-guest-ids = <511>; riscv,num-ids = <511>; status = "reserved"; };For the mimsic part, I already sent a related fix earlier:
https://lore.kernel.org/linux-riscv/[email protected]/
Okay, I would remove the mimsic part.
Quoted 3 lines
If you would like, you can pick that patch and combine the two changes into a v2, as Yixun suggested.
Signature · 2 lines
Best Regards Guo Ren
Quoted 25 lines · Yixun Lan
hi Guo,
Quoted 17 lines · Guo Ren
From: "GUO Ren (XuanTie)" <[email protected]>
The initial K3 device tree used generic/placeholder values for the IMSIC guest configuration:
riscv,guest-index-bits = <6>; riscv,num-guest-ids = <511>;According to the SpacemiT K3 User Manual [1] these values are incorrect for the X100 cores:
- Hypervisor Extension: RVH 1.0, GEILEN = 8
- Advanced Interrupt Architecture (AIA):
- M-mode MSI: 512
- S-mode MSI: 512
- VS-mode MSI: 64Quoted 4 lines
Therefore:
- S-mode IMSIC (simsic) only needs guest-index-bits = 3 (to cover GEILEN = 8) and num-guest-ids = 63.
Quoted 8 lines
..
Quoted 3 lines
- M-mode IMSIC (mimsic) does not implement guest interrupt files at all, so the guest-related properties must be omitted.
Cc Junhui
There is already one fix for IMSIC [1], but it's actually too late to pick for v7.3 .. I'm not sure how best to handle this, would it possible
It's not for v7.3; we could merge it in the next window. The mimsic part is a separate fix; we could do these separately.
Quoted 2 lines
on your side to pick Junhui's patch and rework to combine them to send a V2? or I could pick his patch first ..
I would remove the mimsic part, but I won't include it in v2. Because there is no update for the mimsic patch, v2 makes it confusing.
Quoted 55 lines
https://lore.kernel.org/all/[email protected]/
Quoted 6 lines
Although the KVM AIA driver will re-detect the actual number of guest interrupt files via hgeie and correct guest-index-bits at runtime, the device tree should still describe the correct hardware parameters.
Update the device tree to match the silicon.
..
Quoted 2 lines
no blank line and use "Link: https://.. [1]" format
Quoted 36 lines
Fixes 56f37e391a62 ("riscv: dts: spacemit: add initial support for K3 SoC")Cc Guodong Xu <[email protected]>Cc Yixun Lan <[email protected]>Signed-off-by GUO Ren (XuanTie) <[email protected]>--- arch/riscv/boot/dts/spacemit/k3.dtsi | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)arch/riscv/boot/dts/spacemit/k3.dtsi +2
-5@@ -1127,9 +1127,9 @@ simsic: interrupt-controller@e0400000 { <&cpu4_intc 9>, <&cpu5_intc 9>, <&cpu6_intc 9>, <&cpu7_intc 9>; msi-controller; - riscv,guest-index-bits = <6>; + riscv,guest-index-bits = <3>; riscv,hart-index-bits = <4>; - riscv,num-guest-ids = <511>; + riscv,num-guest-ids = <63>; riscv,num-ids = <511>; };@@ -1168,9 +1168,7 @@ mimsic: interrupt-controller@f1000000 { <&cpu4_intc 11>, <&cpu5_intc 11>, <&cpu6_intc 11>, <&cpu7_intc 11>; msi-controller; - riscv,guest-index-bits = <6>; riscv,hart-index-bits = <4>; - riscv,num-guest-ids = <511>; riscv,num-ids = <511>; status = "reserved"; }; --Quoted 2 lines
2.43.0
--
Yixun Lan (dlan)
Signature · 2 lines
Best Regards Guo Ren
Quoted 96 lines · Guo Ren
Quoted 75 lines · Junhui Liu
Hi Guo,
Quoted 46 lines · Guo Ren
From: "GUO Ren (XuanTie)" <[email protected]>
The initial K3 device tree used generic/placeholder values for the IMSIC guest configuration:
riscv,guest-index-bits = <6>; riscv,num-guest-ids = <511>;According to the SpacemiT K3 User Manual [1], these values are incorrect for the X100 cores:
- Hypervisor Extension: RVH 1.0, GEILEN = 8
- Advanced Interrupt Architecture (AIA):
- M-mode MSI: 512
- S-mode MSI: 512
- VS-mode MSI: 64Therefore:
- S-mode IMSIC (simsic) only needs guest-index-bits = 3 (to cover GEILEN = 8) and num-guest-ids = 63.
- M-mode IMSIC (mimsic) does not implement guest interrupt files at all, so the guest-related properties must be omitted.Although the KVM AIA driver will re-detect the actual number of guest interrupt files via hgeie and correct guest-index-bits at runtime, the device tree should still describe the correct hardware parameters.
Update the device tree to match the silicon.
Fixes 56f37e391a62 ("riscv: dts: spacemit: add initial support for K3 SoC")Cc Guodong Xu <[email protected]>Cc Yixun Lan <[email protected]>Signed-off-by GUO Ren (XuanTie) <[email protected]>--- arch/riscv/boot/dts/spacemit/k3.dtsi | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)arch/riscv/boot/dts/spacemit/k3.dtsi +0
-0arch/riscv/boot/dts/spacemit/k3.dtsi simsic: interrupt-controller@e0400000 { · line 1130
Quoted 5 lines
arch/riscv/boot/dts/spacemit/k3.dtsi +1
-1@@ -1127,9 +1127,9 @@ simsic: interrupt-controller@e0400000 { <&cpu4_intc 9>, <&cpu5_intc 9>, <&cpu6_intc 9>, <&cpu7_intc 9>; msi-controller; - riscv,guest-index-bits = <6>; + riscv,guest-index-bits = <3>;According to the IMSIC DT binding, riscv,guest-index-bits describes the number of guest-index bits in the MSI target address, not the number of guest interrupt files actually implemented by a hart.
On K3, the per-hart IMSIC stride is
0x40000bytes (0x200000/ 8). Therefore, riscv,guest-index-bits should remain 6, which satisfies the per-hart stride formula specified by the AIA specification:2^(guest-index-bits + 12) = 2^(6 + 12) =
0x40000bytesKVM already handles the difference between the address space and the actual number of guest interrupt files. It reads HGEIE to find the actual number of guest interrupt files and uses the smaller value:
/*
* Number of usable per-HART HGEI lines should be minimum of
* per-HART IMSIC guest files and number of bits in HGEIE. */
if (lc)Quoted 5 lines
hgctrl->nr_hgei = min((ulong)hgctrl->nr_hgei, lc->nr_guest_files);I also tested this on K3. HGEIE returned
0xfeafter writing all ones, so the driver getsfls_long(0xfe)- 1 = 7 usable guest interrupt fileI don't think the reserved per-hart address stride alone is sufficient reason to set riscv,guest-index-bits to 6.
As mentioned in the commit log:
"Although the KVM AIA driver will re-detect the actual number of guest interrupt files via hgeie and correct guest-index-bits at runtime, the device tree should still describe the correct hardware parameters."Although K3 reserves a 0x40000-byte IMSIC address window per hart, only the first
0x8000bytes, corresponding to guest indexes 0 through 7, are actually implemented. The remaining range from0x8000to0x3ffffdoes not correspond to any implemented interrupt file.
Quoted 6 lines
If we describe guest-index-bits = <6>, that raises a few questions:
- What hardware resource is represented by guest indexes 8 through 63?
- What behavior does the K3 hardware guarantee for accesses to the
unused 0x8000-0x3ffff range?
- Shall we let the kernel map that unused range and consume
additional page-table entries for it?
After re-reading imsic_parse_fwnode(), you're right. I misunderstood the semantics here. riscv,guest-index-bits is used to describe the guest-index field in the IMSIC address layout and therefore determines the per-hart address stride; it does not directly represent the number of guest interrupt files actually implemented.
Thanks to you & sashiko-bot for pointing this out.
Quoted 35 lines
Quoted 7 lines
arch/riscv/boot/dts/spacemit/k3.dtsi simsic: interrupt-controller@e0400000 { · line 1132
Quoted 5 lines
arch/riscv/boot/dts/spacemit/k3.dtsi +1
-1riscv,hart-index-bits = <4>; - riscv,num-guest-ids = <511>; + riscv,num-guest-ids = <63>;This change looks good to me.
Thx for the review.
Quoted 4 lines
Quoted 4 lines
arch/riscv/boot/dts/spacemit/k3.dtsi +0
-0riscv,num-ids = <511>; };Quoted 13 lines
arch/riscv/boot/dts/spacemit/k3.dtsi mimsic: interrupt-controller@f1000000 { · line 1174
Quoted 10 lines
arch/riscv/boot/dts/spacemit/k3.dtsi +0
-2@@ -1168,9 +1168,7 @@ mimsic: interrupt-controller@f1000000 { <&cpu4_intc 11>, <&cpu5_intc 11>, <&cpu6_intc 11>, <&cpu7_intc 11>; msi-controller; - riscv,guest-index-bits = <6>; riscv,hart-index-bits = <4>; - riscv,num-guest-ids = <511>; riscv,num-ids = <511>; status = "reserved"; };For the mimsic part, I already sent a related fix earlier:
https://lore.kernel.org/linux-riscv/[email protected]/Okay, I would remove the mimsic part.
Quoted 3 lines
If you would like, you can pick that patch and combine the two changes into a v2, as Yixun suggested.
--
Best Regards
Guo Ren
Signature · 2 lines
Best Regards Guo Ren