1 | arm pullreq for rc1. All minor bugfixes, except for the sve-default-vector-length | 1 | Hi; here's the latest batch of arm changes. The big thing |
---|---|---|---|
2 | patches, which are somewhere between a bugfix and a new feature. | 2 | in here is the SMMUv3 changes to add stage-2 translation support. |
3 | 3 | ||
4 | thanks | 4 | thanks |
5 | -- PMM | 5 | -- PMM |
6 | 6 | ||
7 | The following changes since commit c08ccd1b53f488ac86c1f65cf7623dc91acc249a: | 7 | The following changes since commit aa9bbd865502ed517624ab6fe7d4b5d89ca95e43: |
8 | 8 | ||
9 | Merge remote-tracking branch 'remotes/rth-gitlab/tags/pull-tcg-20210726' into staging (2021-07-27 08:35:01 +0100) | 9 | Merge tag 'pull-ppc-20230528' of https://gitlab.com/danielhb/qemu into staging (2023-05-29 14:31:52 -0700) |
10 | 10 | ||
11 | are available in the Git repository at: | 11 | are available in the Git repository at: |
12 | 12 | ||
13 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20210727 | 13 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20230530 |
14 | 14 | ||
15 | for you to fetch changes up to e229a179a503f2aee43a76888cf12fbdfe8a3749: | 15 | for you to fetch changes up to b03d0d4f531a8b867e0aac1fab0b876903015680: |
16 | 16 | ||
17 | hw: aspeed_gpio: Fix memory size (2021-07-27 11:00:00 +0100) | 17 | docs: sbsa: correct graphics card name (2023-05-30 13:32:46 +0100) |
18 | 18 | ||
19 | ---------------------------------------------------------------- | 19 | ---------------------------------------------------------------- |
20 | target-arm queue: | 20 | target-arm queue: |
21 | * hw/arm/smmuv3: Check 31st bit to see if CD is valid | 21 | * fsl-imx6: Add SNVS support for i.MX6 boards |
22 | * qemu-options.hx: Fix formatting of -machine memory-backend option | 22 | * smmuv3: Add support for stage 2 translations |
23 | * hw: aspeed_gpio: Fix memory size | 23 | * hw/dma/xilinx_axidma: Check DMASR.HALTED to prevent infinite loop |
24 | * hw/arm/nseries: Display hexadecimal value with '0x' prefix | 24 | * hw/arm/xlnx-zynqmp: fix unsigned error when checking the RPUs number |
25 | * Add sve-default-vector-length cpu property | 25 | * cleanups for recent Kconfig changes |
26 | * docs: Update path that mentions deprecated.rst | 26 | * target/arm: Explicitly select short-format FSR for M-profile |
27 | * hw/intc/armv7m_nvic: for v8.1M VECTPENDING hides S exceptions from NS | 27 | * tests/qtest: Run arm-specific tests only if the required machine is available |
28 | * hw/intc/armv7m_nvic: Correct size of ICSR.VECTPENDING | 28 | * hw/arm/sbsa-ref: add GIC node into DT |
29 | * hw/intc/armv7m_nvic: ISCR.ISRPENDING is set for non-enabled pending interrupts | 29 | * docs: sbsa: correct graphics card name |
30 | * target/arm: Report M-profile alignment faults correctly to the guest | 30 | * Update copyright dates to 2023 |
31 | * target/arm: Add missing 'return's after calling v7m_exception_taken() | ||
32 | * target/arm: Enforce that M-profile SP low 2 bits are always zero | ||
33 | 31 | ||
34 | ---------------------------------------------------------------- | 32 | ---------------------------------------------------------------- |
35 | Joe Komlodi (1): | 33 | Clément Chigot (1): |
36 | hw/arm/smmuv3: Check 31st bit to see if CD is valid | 34 | hw/arm/xlnx-zynqmp: fix unsigned error when checking the RPUs number |
37 | 35 | ||
38 | Joel Stanley (1): | 36 | Enze Li (1): |
39 | hw: aspeed_gpio: Fix memory size | 37 | Update copyright dates to 2023 |
40 | 38 | ||
41 | Mao Zhongyi (1): | 39 | Fabiano Rosas (3): |
42 | docs: Update path that mentions deprecated.rst | 40 | target/arm: Explain why we need to select ARM_V7M |
41 | arm/Kconfig: Keep Kconfig default entries in default.mak as documentation | ||
42 | arm/Kconfig: Make TCG dependence explicit | ||
43 | 43 | ||
44 | Peter Maydell (7): | 44 | Marcin Juszkiewicz (2): |
45 | qemu-options.hx: Fix formatting of -machine memory-backend option | 45 | hw/arm/sbsa-ref: add GIC node into DT |
46 | target/arm: Enforce that M-profile SP low 2 bits are always zero | 46 | docs: sbsa: correct graphics card name |
47 | target/arm: Add missing 'return's after calling v7m_exception_taken() | ||
48 | target/arm: Report M-profile alignment faults correctly to the guest | ||
49 | hw/intc/armv7m_nvic: ISCR.ISRPENDING is set for non-enabled pending interrupts | ||
50 | hw/intc/armv7m_nvic: Correct size of ICSR.VECTPENDING | ||
51 | hw/intc/armv7m_nvic: for v8.1M VECTPENDING hides S exceptions from NS | ||
52 | 47 | ||
53 | Philippe Mathieu-Daudé (1): | 48 | Mostafa Saleh (10): |
54 | hw/arm/nseries: Display hexadecimal value with '0x' prefix | 49 | hw/arm/smmuv3: Add missing fields for IDR0 |
50 | hw/arm/smmuv3: Update translation config to hold stage-2 | ||
51 | hw/arm/smmuv3: Refactor stage-1 PTW | ||
52 | hw/arm/smmuv3: Add page table walk for stage-2 | ||
53 | hw/arm/smmuv3: Parse STE config for stage-2 | ||
54 | hw/arm/smmuv3: Make TLB lookup work for stage-2 | ||
55 | hw/arm/smmuv3: Add VMID to TLB tagging | ||
56 | hw/arm/smmuv3: Add CMDs related to stage-2 | ||
57 | hw/arm/smmuv3: Add stage-2 support in iova notifier | ||
58 | hw/arm/smmuv3: Add knob to choose translation stage and enable stage-2 | ||
55 | 59 | ||
56 | Richard Henderson (3): | 60 | Peter Maydell (1): |
57 | target/arm: Correctly bound length in sve_zcr_get_valid_len | 61 | target/arm: Explicitly select short-format FSR for M-profile |
58 | target/arm: Export aarch64_sve_zcr_get_valid_len | ||
59 | target/arm: Add sve-default-vector-length cpu property | ||
60 | 62 | ||
61 | docs/system/arm/cpu-features.rst | 15 ++++++++++ | 63 | Thomas Huth (1): |
62 | configure | 2 +- | 64 | tests/qtest: Run arm-specific tests only if the required machine is available |
63 | hw/arm/smmuv3-internal.h | 2 +- | ||
64 | target/arm/cpu.h | 5 ++++ | ||
65 | target/arm/internals.h | 10 +++++++ | ||
66 | hw/arm/nseries.c | 2 +- | ||
67 | hw/gpio/aspeed_gpio.c | 3 +- | ||
68 | hw/intc/armv7m_nvic.c | 40 +++++++++++++++++++-------- | ||
69 | target/arm/cpu.c | 14 ++++++++-- | ||
70 | target/arm/cpu64.c | 60 ++++++++++++++++++++++++++++++++++++++++ | ||
71 | target/arm/gdbstub.c | 4 +++ | ||
72 | target/arm/helper.c | 8 ++++-- | ||
73 | target/arm/m_helper.c | 24 ++++++++++++---- | ||
74 | target/arm/translate.c | 3 ++ | ||
75 | target/i386/cpu.c | 2 +- | ||
76 | MAINTAINERS | 2 +- | ||
77 | qemu-options.hx | 30 +++++++++++--------- | ||
78 | 17 files changed, 183 insertions(+), 43 deletions(-) | ||
79 | 65 | ||
66 | Tommy Wu (1): | ||
67 | hw/dma/xilinx_axidma: Check DMASR.HALTED to prevent infinite loop. | ||
68 | |||
69 | Vitaly Cheptsov (1): | ||
70 | fsl-imx6: Add SNVS support for i.MX6 boards | ||
71 | |||
72 | docs/conf.py | 2 +- | ||
73 | docs/system/arm/sbsa.rst | 2 +- | ||
74 | configs/devices/aarch64-softmmu/default.mak | 6 + | ||
75 | configs/devices/arm-softmmu/default.mak | 40 ++++ | ||
76 | hw/arm/smmu-internal.h | 37 +++ | ||
77 | hw/arm/smmuv3-internal.h | 12 +- | ||
78 | include/hw/arm/fsl-imx6.h | 2 + | ||
79 | include/hw/arm/smmu-common.h | 45 +++- | ||
80 | include/hw/arm/smmuv3.h | 4 + | ||
81 | include/qemu/help-texts.h | 2 +- | ||
82 | hw/arm/fsl-imx6.c | 8 + | ||
83 | hw/arm/sbsa-ref.c | 19 +- | ||
84 | hw/arm/smmu-common.c | 209 ++++++++++++++-- | ||
85 | hw/arm/smmuv3.c | 357 ++++++++++++++++++++++++---- | ||
86 | hw/arm/xlnx-zynqmp.c | 2 +- | ||
87 | hw/dma/xilinx_axidma.c | 11 +- | ||
88 | target/arm/tcg/tlb_helper.c | 13 +- | ||
89 | hw/arm/Kconfig | 123 ++++++---- | ||
90 | hw/arm/trace-events | 14 +- | ||
91 | target/arm/Kconfig | 3 + | ||
92 | tests/qtest/meson.build | 7 +- | ||
93 | 21 files changed, 773 insertions(+), 145 deletions(-) | ||
94 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Vitaly Cheptsov <cheptsov@ispras.ru> | ||
1 | 2 | ||
3 | SNVS is supported on both i.MX6 and i.MX6UL and is needed | ||
4 | to support shutdown on the board. | ||
5 | |||
6 | Cc: Peter Maydell <peter.maydell@linaro.org> (odd fixer:SABRELITE / i.MX6) | ||
7 | Cc: Jean-Christophe Dubois <jcd@tribudubois.net> (reviewer:SABRELITE / i.MX6) | ||
8 | Cc: qemu-arm@nongnu.org (open list:SABRELITE / i.MX6) | ||
9 | Cc: qemu-devel@nongnu.org (open list:All patches CC here) | ||
10 | Signed-off-by: Vitaly Cheptsov <cheptsov@ispras.ru> | ||
11 | Message-id: 20230515095015.66860-1-cheptsov@ispras.ru | ||
12 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
14 | --- | ||
15 | include/hw/arm/fsl-imx6.h | 2 ++ | ||
16 | hw/arm/fsl-imx6.c | 8 ++++++++ | ||
17 | 2 files changed, 10 insertions(+) | ||
18 | |||
19 | diff --git a/include/hw/arm/fsl-imx6.h b/include/hw/arm/fsl-imx6.h | ||
20 | index XXXXXXX..XXXXXXX 100644 | ||
21 | --- a/include/hw/arm/fsl-imx6.h | ||
22 | +++ b/include/hw/arm/fsl-imx6.h | ||
23 | @@ -XXX,XX +XXX,XX @@ | ||
24 | #include "hw/cpu/a9mpcore.h" | ||
25 | #include "hw/misc/imx6_ccm.h" | ||
26 | #include "hw/misc/imx6_src.h" | ||
27 | +#include "hw/misc/imx7_snvs.h" | ||
28 | #include "hw/watchdog/wdt_imx2.h" | ||
29 | #include "hw/char/imx_serial.h" | ||
30 | #include "hw/timer/imx_gpt.h" | ||
31 | @@ -XXX,XX +XXX,XX @@ struct FslIMX6State { | ||
32 | A9MPPrivState a9mpcore; | ||
33 | IMX6CCMState ccm; | ||
34 | IMX6SRCState src; | ||
35 | + IMX7SNVSState snvs; | ||
36 | IMXSerialState uart[FSL_IMX6_NUM_UARTS]; | ||
37 | IMXGPTState gpt; | ||
38 | IMXEPITState epit[FSL_IMX6_NUM_EPITS]; | ||
39 | diff --git a/hw/arm/fsl-imx6.c b/hw/arm/fsl-imx6.c | ||
40 | index XXXXXXX..XXXXXXX 100644 | ||
41 | --- a/hw/arm/fsl-imx6.c | ||
42 | +++ b/hw/arm/fsl-imx6.c | ||
43 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6_init(Object *obj) | ||
44 | |||
45 | object_initialize_child(obj, "src", &s->src, TYPE_IMX6_SRC); | ||
46 | |||
47 | + object_initialize_child(obj, "snvs", &s->snvs, TYPE_IMX7_SNVS); | ||
48 | + | ||
49 | for (i = 0; i < FSL_IMX6_NUM_UARTS; i++) { | ||
50 | snprintf(name, NAME_SIZE, "uart%d", i + 1); | ||
51 | object_initialize_child(obj, name, &s->uart[i], TYPE_IMX_SERIAL); | ||
52 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx6_realize(DeviceState *dev, Error **errp) | ||
53 | qdev_get_gpio_in(DEVICE(&s->a9mpcore), | ||
54 | FSL_IMX6_ENET_MAC_1588_IRQ)); | ||
55 | |||
56 | + /* | ||
57 | + * SNVS | ||
58 | + */ | ||
59 | + sysbus_realize(SYS_BUS_DEVICE(&s->snvs), &error_abort); | ||
60 | + sysbus_mmio_map(SYS_BUS_DEVICE(&s->snvs), 0, FSL_IMX6_SNVSHP_ADDR); | ||
61 | + | ||
62 | /* | ||
63 | * Watchdog | ||
64 | */ | ||
65 | -- | ||
66 | 2.34.1 | diff view generated by jsdifflib |
1 | From: Joe Komlodi <joe.komlodi@xilinx.com> | 1 | From: Mostafa Saleh <smostafa@google.com> |
---|---|---|---|
2 | 2 | ||
3 | The bit to see if a CD is valid is the last bit of the first word of the CD. | 3 | In preparation for adding stage-2 support. |
4 | Add IDR0 fields related to stage-2. | ||
4 | 5 | ||
5 | Signed-off-by: Joe Komlodi <joe.komlodi@xilinx.com> | 6 | VMID16: 16-bit VMID supported. |
6 | Message-id: 1626728232-134665-2-git-send-email-joe.komlodi@xilinx.com | 7 | S2P: Stage-2 translation supported. |
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 8 | |
9 | They are described in 6.3.1 SMMU_IDR0. | ||
10 | |||
11 | No functional change intended. | ||
12 | |||
13 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
14 | Reviewed-by: Eric Auger <eric.auger@redhat.com> | ||
15 | Signed-off-by: Mostafa Saleh <smostafa@google.com> | ||
16 | Tested-by: Eric Auger <eric.auger@redhat.com> | ||
17 | Tested-by: Jean-Philippe Brucker <jean-philippe@linaro.org> | ||
18 | Message-id: 20230516203327.2051088-2-smostafa@google.com | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 19 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
9 | --- | 20 | --- |
10 | hw/arm/smmuv3-internal.h | 2 +- | 21 | hw/arm/smmuv3-internal.h | 2 ++ |
11 | 1 file changed, 1 insertion(+), 1 deletion(-) | 22 | 1 file changed, 2 insertions(+) |
12 | 23 | ||
13 | diff --git a/hw/arm/smmuv3-internal.h b/hw/arm/smmuv3-internal.h | 24 | diff --git a/hw/arm/smmuv3-internal.h b/hw/arm/smmuv3-internal.h |
14 | index XXXXXXX..XXXXXXX 100644 | 25 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/hw/arm/smmuv3-internal.h | 26 | --- a/hw/arm/smmuv3-internal.h |
16 | +++ b/hw/arm/smmuv3-internal.h | 27 | +++ b/hw/arm/smmuv3-internal.h |
17 | @@ -XXX,XX +XXX,XX @@ static inline int pa_range(STE *ste) | 28 | @@ -XXX,XX +XXX,XX @@ typedef enum SMMUTranslationStatus { |
18 | 29 | /* MMIO Registers */ | |
19 | /* CD fields */ | 30 | |
20 | 31 | REG32(IDR0, 0x0) | |
21 | -#define CD_VALID(x) extract32((x)->word[0], 30, 1) | 32 | + FIELD(IDR0, S2P, 0 , 1) |
22 | +#define CD_VALID(x) extract32((x)->word[0], 31, 1) | 33 | FIELD(IDR0, S1P, 1 , 1) |
23 | #define CD_ASID(x) extract32((x)->word[1], 16, 16) | 34 | FIELD(IDR0, TTF, 2 , 2) |
24 | #define CD_TTB(x, sel) \ | 35 | FIELD(IDR0, COHACC, 4 , 1) |
25 | ({ \ | 36 | FIELD(IDR0, ASID16, 12, 1) |
37 | + FIELD(IDR0, VMID16, 18, 1) | ||
38 | FIELD(IDR0, TTENDIAN, 21, 2) | ||
39 | FIELD(IDR0, STALL_MODEL, 24, 2) | ||
40 | FIELD(IDR0, TERM_MODEL, 26, 1) | ||
26 | -- | 41 | -- |
27 | 2.20.1 | 42 | 2.34.1 |
28 | |||
29 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Mostafa Saleh <smostafa@google.com> | ||
1 | 2 | ||
3 | In preparation for adding stage-2 support, add a S2 config | ||
4 | struct(SMMUS2Cfg), composed of the following fields and embedded in | ||
5 | the main SMMUTransCfg: | ||
6 | -tsz: Size of IPA input region (S2T0SZ) | ||
7 | -sl0: Start level of translation (S2SL0) | ||
8 | -affd: AF Fault Disable (S2AFFD) | ||
9 | -record_faults: Record fault events (S2R) | ||
10 | -granule_sz: Granule page shift (based on S2TG) | ||
11 | -vmid: Virtual Machine ID (S2VMID) | ||
12 | -vttb: Address of translation table base (S2TTB) | ||
13 | -eff_ps: Effective PA output range (based on S2PS) | ||
14 | |||
15 | They will be used in the next patches in stage-2 address translation. | ||
16 | |||
17 | The fields in SMMUS2Cfg, are reordered to make the shared and stage-1 | ||
18 | fields next to each other, this reordering didn't change the struct | ||
19 | size (104 bytes before and after). | ||
20 | |||
21 | Stage-1 only fields: aa64, asid, tt, ttb, tbi, record_faults, oas. | ||
22 | oas is stage-1 output address size. However, it is used to check | ||
23 | input address in case stage-1 is unimplemented or bypassed according | ||
24 | to SMMUv3 manual IHI0070.E "3.4. Address sizes" | ||
25 | |||
26 | Shared fields: stage, disabled, bypassed, aborted, iotlb_*. | ||
27 | |||
28 | No functional change intended. | ||
29 | |||
30 | Reviewed-by: Eric Auger <eric.auger@redhat.com> | ||
31 | Signed-off-by: Mostafa Saleh <smostafa@google.com> | ||
32 | Tested-by: Eric Auger <eric.auger@redhat.com> | ||
33 | Tested-by: Jean-Philippe Brucker <jean-philippe@linaro.org> | ||
34 | Message-id: 20230516203327.2051088-3-smostafa@google.com | ||
35 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
36 | --- | ||
37 | include/hw/arm/smmu-common.h | 22 +++++++++++++++++++--- | ||
38 | 1 file changed, 19 insertions(+), 3 deletions(-) | ||
39 | |||
40 | diff --git a/include/hw/arm/smmu-common.h b/include/hw/arm/smmu-common.h | ||
41 | index XXXXXXX..XXXXXXX 100644 | ||
42 | --- a/include/hw/arm/smmu-common.h | ||
43 | +++ b/include/hw/arm/smmu-common.h | ||
44 | @@ -XXX,XX +XXX,XX @@ typedef struct SMMUTLBEntry { | ||
45 | uint8_t granule; | ||
46 | } SMMUTLBEntry; | ||
47 | |||
48 | +/* Stage-2 configuration. */ | ||
49 | +typedef struct SMMUS2Cfg { | ||
50 | + uint8_t tsz; /* Size of IPA input region (S2T0SZ) */ | ||
51 | + uint8_t sl0; /* Start level of translation (S2SL0) */ | ||
52 | + bool affd; /* AF Fault Disable (S2AFFD) */ | ||
53 | + bool record_faults; /* Record fault events (S2R) */ | ||
54 | + uint8_t granule_sz; /* Granule page shift (based on S2TG) */ | ||
55 | + uint8_t eff_ps; /* Effective PA output range (based on S2PS) */ | ||
56 | + uint16_t vmid; /* Virtual Machine ID (S2VMID) */ | ||
57 | + uint64_t vttb; /* Address of translation table base (S2TTB) */ | ||
58 | +} SMMUS2Cfg; | ||
59 | + | ||
60 | /* | ||
61 | * Generic structure populated by derived SMMU devices | ||
62 | * after decoding the configuration information and used as | ||
63 | * input to the page table walk | ||
64 | */ | ||
65 | typedef struct SMMUTransCfg { | ||
66 | + /* Shared fields between stage-1 and stage-2. */ | ||
67 | int stage; /* translation stage */ | ||
68 | - bool aa64; /* arch64 or aarch32 translation table */ | ||
69 | bool disabled; /* smmu is disabled */ | ||
70 | bool bypassed; /* translation is bypassed */ | ||
71 | bool aborted; /* translation is aborted */ | ||
72 | + uint32_t iotlb_hits; /* counts IOTLB hits */ | ||
73 | + uint32_t iotlb_misses; /* counts IOTLB misses*/ | ||
74 | + /* Used by stage-1 only. */ | ||
75 | + bool aa64; /* arch64 or aarch32 translation table */ | ||
76 | bool record_faults; /* record fault events */ | ||
77 | uint64_t ttb; /* TT base address */ | ||
78 | uint8_t oas; /* output address width */ | ||
79 | uint8_t tbi; /* Top Byte Ignore */ | ||
80 | uint16_t asid; | ||
81 | SMMUTransTableInfo tt[2]; | ||
82 | - uint32_t iotlb_hits; /* counts IOTLB hits for this asid */ | ||
83 | - uint32_t iotlb_misses; /* counts IOTLB misses for this asid */ | ||
84 | + /* Used by stage-2 only. */ | ||
85 | + struct SMMUS2Cfg s2cfg; | ||
86 | } SMMUTransCfg; | ||
87 | |||
88 | typedef struct SMMUDevice { | ||
89 | -- | ||
90 | 2.34.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Mostafa Saleh <smostafa@google.com> | ||
1 | 2 | ||
3 | In preparation for adding stage-2 support, rename smmu_ptw_64 to | ||
4 | smmu_ptw_64_s1 and refactor some of the code so it can be reused in | ||
5 | stage-2 page table walk. | ||
6 | |||
7 | Remove AA64 check from PTW as decode_cd already ensures that AA64 is | ||
8 | used, otherwise it faults with C_BAD_CD. | ||
9 | |||
10 | A stage member is added to SMMUPTWEventInfo to differentiate | ||
11 | between stage-1 and stage-2 ptw faults. | ||
12 | |||
13 | Add stage argument to trace_smmu_ptw_level be consistent with other | ||
14 | trace events. | ||
15 | |||
16 | Signed-off-by: Mostafa Saleh <smostafa@google.com> | ||
17 | Reviewed-by: Eric Auger <eric.auger@redhat.com> | ||
18 | Tested-by: Eric Auger <eric.auger@redhat.com> | ||
19 | Tested-by: Jean-Philippe Brucker <jean-philippe@linaro.org> | ||
20 | Message-id: 20230516203327.2051088-4-smostafa@google.com | ||
21 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
22 | --- | ||
23 | include/hw/arm/smmu-common.h | 16 +++++++++++++--- | ||
24 | hw/arm/smmu-common.c | 27 ++++++++++----------------- | ||
25 | hw/arm/smmuv3.c | 2 ++ | ||
26 | hw/arm/trace-events | 2 +- | ||
27 | 4 files changed, 26 insertions(+), 21 deletions(-) | ||
28 | |||
29 | diff --git a/include/hw/arm/smmu-common.h b/include/hw/arm/smmu-common.h | ||
30 | index XXXXXXX..XXXXXXX 100644 | ||
31 | --- a/include/hw/arm/smmu-common.h | ||
32 | +++ b/include/hw/arm/smmu-common.h | ||
33 | @@ -XXX,XX +XXX,XX @@ | ||
34 | #include "hw/pci/pci.h" | ||
35 | #include "qom/object.h" | ||
36 | |||
37 | -#define SMMU_PCI_BUS_MAX 256 | ||
38 | -#define SMMU_PCI_DEVFN_MAX 256 | ||
39 | -#define SMMU_PCI_DEVFN(sid) (sid & 0xFF) | ||
40 | +#define SMMU_PCI_BUS_MAX 256 | ||
41 | +#define SMMU_PCI_DEVFN_MAX 256 | ||
42 | +#define SMMU_PCI_DEVFN(sid) (sid & 0xFF) | ||
43 | + | ||
44 | +/* VMSAv8-64 Translation constants and functions */ | ||
45 | +#define VMSA_LEVELS 4 | ||
46 | + | ||
47 | +#define VMSA_STRIDE(gran) ((gran) - VMSA_LEVELS + 1) | ||
48 | +#define VMSA_BIT_LVL(isz, strd, lvl) ((isz) - (strd) * \ | ||
49 | + (VMSA_LEVELS - (lvl))) | ||
50 | +#define VMSA_IDXMSK(isz, strd, lvl) ((1ULL << \ | ||
51 | + VMSA_BIT_LVL(isz, strd, lvl)) - 1) | ||
52 | |||
53 | /* | ||
54 | * Page table walk error types | ||
55 | @@ -XXX,XX +XXX,XX @@ typedef enum { | ||
56 | } SMMUPTWEventType; | ||
57 | |||
58 | typedef struct SMMUPTWEventInfo { | ||
59 | + int stage; | ||
60 | SMMUPTWEventType type; | ||
61 | dma_addr_t addr; /* fetched address that induced an abort, if any */ | ||
62 | } SMMUPTWEventInfo; | ||
63 | diff --git a/hw/arm/smmu-common.c b/hw/arm/smmu-common.c | ||
64 | index XXXXXXX..XXXXXXX 100644 | ||
65 | --- a/hw/arm/smmu-common.c | ||
66 | +++ b/hw/arm/smmu-common.c | ||
67 | @@ -XXX,XX +XXX,XX @@ SMMUTransTableInfo *select_tt(SMMUTransCfg *cfg, dma_addr_t iova) | ||
68 | } | ||
69 | |||
70 | /** | ||
71 | - * smmu_ptw_64 - VMSAv8-64 Walk of the page tables for a given IOVA | ||
72 | + * smmu_ptw_64_s1 - VMSAv8-64 Walk of the page tables for a given IOVA | ||
73 | * @cfg: translation config | ||
74 | * @iova: iova to translate | ||
75 | * @perm: access type | ||
76 | @@ -XXX,XX +XXX,XX @@ SMMUTransTableInfo *select_tt(SMMUTransCfg *cfg, dma_addr_t iova) | ||
77 | * Upon success, @tlbe is filled with translated_addr and entry | ||
78 | * permission rights. | ||
79 | */ | ||
80 | -static int smmu_ptw_64(SMMUTransCfg *cfg, | ||
81 | - dma_addr_t iova, IOMMUAccessFlags perm, | ||
82 | - SMMUTLBEntry *tlbe, SMMUPTWEventInfo *info) | ||
83 | +static int smmu_ptw_64_s1(SMMUTransCfg *cfg, | ||
84 | + dma_addr_t iova, IOMMUAccessFlags perm, | ||
85 | + SMMUTLBEntry *tlbe, SMMUPTWEventInfo *info) | ||
86 | { | ||
87 | dma_addr_t baseaddr, indexmask; | ||
88 | int stage = cfg->stage; | ||
89 | @@ -XXX,XX +XXX,XX @@ static int smmu_ptw_64(SMMUTransCfg *cfg, | ||
90 | } | ||
91 | |||
92 | granule_sz = tt->granule_sz; | ||
93 | - stride = granule_sz - 3; | ||
94 | + stride = VMSA_STRIDE(granule_sz); | ||
95 | inputsize = 64 - tt->tsz; | ||
96 | level = 4 - (inputsize - 4) / stride; | ||
97 | - indexmask = (1ULL << (inputsize - (stride * (4 - level)))) - 1; | ||
98 | + indexmask = VMSA_IDXMSK(inputsize, stride, level); | ||
99 | baseaddr = extract64(tt->ttb, 0, 48); | ||
100 | baseaddr &= ~indexmask; | ||
101 | |||
102 | - while (level <= 3) { | ||
103 | + while (level < VMSA_LEVELS) { | ||
104 | uint64_t subpage_size = 1ULL << level_shift(level, granule_sz); | ||
105 | uint64_t mask = subpage_size - 1; | ||
106 | uint32_t offset = iova_level_offset(iova, inputsize, level, granule_sz); | ||
107 | @@ -XXX,XX +XXX,XX @@ static int smmu_ptw_64(SMMUTransCfg *cfg, | ||
108 | if (get_pte(baseaddr, offset, &pte, info)) { | ||
109 | goto error; | ||
110 | } | ||
111 | - trace_smmu_ptw_level(level, iova, subpage_size, | ||
112 | + trace_smmu_ptw_level(stage, level, iova, subpage_size, | ||
113 | baseaddr, offset, pte); | ||
114 | |||
115 | if (is_invalid_pte(pte) || is_reserved_pte(pte, level)) { | ||
116 | @@ -XXX,XX +XXX,XX @@ static int smmu_ptw_64(SMMUTransCfg *cfg, | ||
117 | info->type = SMMU_PTW_ERR_TRANSLATION; | ||
118 | |||
119 | error: | ||
120 | + info->stage = 1; | ||
121 | tlbe->entry.perm = IOMMU_NONE; | ||
122 | return -EINVAL; | ||
123 | } | ||
124 | @@ -XXX,XX +XXX,XX @@ error: | ||
125 | int smmu_ptw(SMMUTransCfg *cfg, dma_addr_t iova, IOMMUAccessFlags perm, | ||
126 | SMMUTLBEntry *tlbe, SMMUPTWEventInfo *info) | ||
127 | { | ||
128 | - if (!cfg->aa64) { | ||
129 | - /* | ||
130 | - * This code path is not entered as we check this while decoding | ||
131 | - * the configuration data in the derived SMMU model. | ||
132 | - */ | ||
133 | - g_assert_not_reached(); | ||
134 | - } | ||
135 | - | ||
136 | - return smmu_ptw_64(cfg, iova, perm, tlbe, info); | ||
137 | + return smmu_ptw_64_s1(cfg, iova, perm, tlbe, info); | ||
138 | } | ||
139 | |||
140 | /** | ||
141 | diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c | ||
142 | index XXXXXXX..XXXXXXX 100644 | ||
143 | --- a/hw/arm/smmuv3.c | ||
144 | +++ b/hw/arm/smmuv3.c | ||
145 | @@ -XXX,XX +XXX,XX @@ static IOMMUTLBEntry smmuv3_translate(IOMMUMemoryRegion *mr, hwaddr addr, | ||
146 | cached_entry = g_new0(SMMUTLBEntry, 1); | ||
147 | |||
148 | if (smmu_ptw(cfg, aligned_addr, flag, cached_entry, &ptw_info)) { | ||
149 | + /* All faults from PTW has S2 field. */ | ||
150 | + event.u.f_walk_eabt.s2 = (ptw_info.stage == 2); | ||
151 | g_free(cached_entry); | ||
152 | switch (ptw_info.type) { | ||
153 | case SMMU_PTW_ERR_WALK_EABT: | ||
154 | diff --git a/hw/arm/trace-events b/hw/arm/trace-events | ||
155 | index XXXXXXX..XXXXXXX 100644 | ||
156 | --- a/hw/arm/trace-events | ||
157 | +++ b/hw/arm/trace-events | ||
158 | @@ -XXX,XX +XXX,XX @@ virt_acpi_setup(void) "No fw cfg or ACPI disabled. Bailing out." | ||
159 | |||
160 | # smmu-common.c | ||
161 | smmu_add_mr(const char *name) "%s" | ||
162 | -smmu_ptw_level(int level, uint64_t iova, size_t subpage_size, uint64_t baseaddr, uint32_t offset, uint64_t pte) "level=%d iova=0x%"PRIx64" subpage_sz=0x%zx baseaddr=0x%"PRIx64" offset=%d => pte=0x%"PRIx64 | ||
163 | +smmu_ptw_level(int stage, int level, uint64_t iova, size_t subpage_size, uint64_t baseaddr, uint32_t offset, uint64_t pte) "stage=%d level=%d iova=0x%"PRIx64" subpage_sz=0x%zx baseaddr=0x%"PRIx64" offset=%d => pte=0x%"PRIx64 | ||
164 | smmu_ptw_invalid_pte(int stage, int level, uint64_t baseaddr, uint64_t pteaddr, uint32_t offset, uint64_t pte) "stage=%d level=%d base@=0x%"PRIx64" pte@=0x%"PRIx64" offset=%d pte=0x%"PRIx64 | ||
165 | smmu_ptw_page_pte(int stage, int level, uint64_t iova, uint64_t baseaddr, uint64_t pteaddr, uint64_t pte, uint64_t address) "stage=%d level=%d iova=0x%"PRIx64" base@=0x%"PRIx64" pte@=0x%"PRIx64" pte=0x%"PRIx64" page address = 0x%"PRIx64 | ||
166 | smmu_ptw_block_pte(int stage, int level, uint64_t baseaddr, uint64_t pteaddr, uint64_t pte, uint64_t iova, uint64_t gpa, int bsize_mb) "stage=%d level=%d base@=0x%"PRIx64" pte@=0x%"PRIx64" pte=0x%"PRIx64" iova=0x%"PRIx64" block address = 0x%"PRIx64" block size = %d MiB" | ||
167 | -- | ||
168 | 2.34.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | 1 | From: Mostafa Saleh <smostafa@google.com> | |
2 | |||
3 | In preparation for adding stage-2 support, add Stage-2 PTW code. | ||
4 | Only Aarch64 format is supported as stage-1. | ||
5 | |||
6 | Nesting stage-1 and stage-2 is not supported right now. | ||
7 | |||
8 | HTTU is not supported, SW is expected to maintain the Access flag. | ||
9 | This is described in the SMMUv3 manual(IHI 0070.E.a) | ||
10 | "5.2. Stream Table Entry" in "[181] S2AFFD". | ||
11 | This flag determines the behavior on access of a stage-2 page whose | ||
12 | descriptor has AF == 0: | ||
13 | - 0b0: An Access flag fault occurs (stall not supported). | ||
14 | - 0b1: An Access flag fault never occurs. | ||
15 | An Access fault takes priority over a Permission fault. | ||
16 | |||
17 | There are 3 address size checks for stage-2 according to | ||
18 | (IHI 0070.E.a) in "3.4. Address sizes". | ||
19 | - As nesting is not supported, input address is passed directly to | ||
20 | stage-2, and is checked against IAS. | ||
21 | We use cfg->oas to hold the OAS when stage-1 is not used, this is set | ||
22 | in the next patch. | ||
23 | This check is done outside of smmu_ptw_64_s2 as it is not part of | ||
24 | stage-2(it throws stage-1 fault), and the stage-2 function shouldn't | ||
25 | change it's behavior when nesting is supported. | ||
26 | When nesting is supported and we figure out how to combine TLB for | ||
27 | stage-1 and stage-2 we can move this check into the stage-1 function | ||
28 | as described in ARM DDI0487I.a in pseudocode | ||
29 | aarch64/translation/vmsa_translation/AArch64.S1Translate | ||
30 | aarch64/translation/vmsa_translation/AArch64.S1DisabledOutput | ||
31 | |||
32 | - Input to stage-2 is checked against s2t0sz, and throws stage-2 | ||
33 | transaltion fault if exceeds it. | ||
34 | |||
35 | - Output of stage-2 is checked against effective PA output range. | ||
36 | |||
37 | Reviewed-by: Eric Auger <eric.auger@redhat.com> | ||
38 | Signed-off-by: Mostafa Saleh <smostafa@google.com> | ||
39 | Tested-by: Eric Auger <eric.auger@redhat.com> | ||
40 | Tested-by: Jean-Philippe Brucker <jean-philippe@linaro.org> | ||
41 | Message-id: 20230516203327.2051088-5-smostafa@google.com | ||
42 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
43 | --- | ||
44 | hw/arm/smmu-internal.h | 35 ++++++++++ | ||
45 | hw/arm/smmu-common.c | 142 ++++++++++++++++++++++++++++++++++++++++- | ||
46 | 2 files changed, 176 insertions(+), 1 deletion(-) | ||
47 | |||
48 | diff --git a/hw/arm/smmu-internal.h b/hw/arm/smmu-internal.h | ||
49 | index XXXXXXX..XXXXXXX 100644 | ||
50 | --- a/hw/arm/smmu-internal.h | ||
51 | +++ b/hw/arm/smmu-internal.h | ||
52 | @@ -XXX,XX +XXX,XX @@ | ||
53 | #define PTE_APTABLE(pte) \ | ||
54 | (extract64(pte, 61, 2)) | ||
55 | |||
56 | +#define PTE_AF(pte) \ | ||
57 | + (extract64(pte, 10, 1)) | ||
58 | /* | ||
59 | * TODO: At the moment all transactions are considered as privileged (EL1) | ||
60 | * as IOMMU translation callback does not pass user/priv attributes. | ||
61 | @@ -XXX,XX +XXX,XX @@ | ||
62 | #define is_permission_fault(ap, perm) \ | ||
63 | (((perm) & IOMMU_WO) && ((ap) & 0x2)) | ||
64 | |||
65 | +#define is_permission_fault_s2(s2ap, perm) \ | ||
66 | + (!(((s2ap) & (perm)) == (perm))) | ||
67 | + | ||
68 | #define PTE_AP_TO_PERM(ap) \ | ||
69 | (IOMMU_ACCESS_FLAG(true, !((ap) & 0x2))) | ||
70 | |||
71 | @@ -XXX,XX +XXX,XX @@ uint64_t iova_level_offset(uint64_t iova, int inputsize, | ||
72 | MAKE_64BIT_MASK(0, gsz - 3); | ||
73 | } | ||
74 | |||
75 | +/* FEAT_LPA2 and FEAT_TTST are not implemented. */ | ||
76 | +static inline int get_start_level(int sl0 , int granule_sz) | ||
77 | +{ | ||
78 | + /* ARM DDI0487I.a: Table D8-12. */ | ||
79 | + if (granule_sz == 12) { | ||
80 | + return 2 - sl0; | ||
81 | + } | ||
82 | + /* ARM DDI0487I.a: Table D8-22 and Table D8-31. */ | ||
83 | + return 3 - sl0; | ||
84 | +} | ||
85 | + | ||
86 | +/* | ||
87 | + * Index in a concatenated first level stage-2 page table. | ||
88 | + * ARM DDI0487I.a: D8.2.2 Concatenated translation tables. | ||
89 | + */ | ||
90 | +static inline int pgd_concat_idx(int start_level, int granule_sz, | ||
91 | + dma_addr_t ipa) | ||
92 | +{ | ||
93 | + uint64_t ret; | ||
94 | + /* | ||
95 | + * Get the number of bits handled by next levels, then any extra bits in | ||
96 | + * the address should index the concatenated tables. This relation can be | ||
97 | + * deduced from tables in ARM DDI0487I.a: D8.2.7-9 | ||
98 | + */ | ||
99 | + int shift = level_shift(start_level - 1, granule_sz); | ||
100 | + | ||
101 | + ret = ipa >> shift; | ||
102 | + return ret; | ||
103 | +} | ||
104 | + | ||
105 | #define SMMU_IOTLB_ASID(key) ((key).asid) | ||
106 | |||
107 | typedef struct SMMUIOTLBPageInvInfo { | ||
108 | diff --git a/hw/arm/smmu-common.c b/hw/arm/smmu-common.c | ||
109 | index XXXXXXX..XXXXXXX 100644 | ||
110 | --- a/hw/arm/smmu-common.c | ||
111 | +++ b/hw/arm/smmu-common.c | ||
112 | @@ -XXX,XX +XXX,XX @@ error: | ||
113 | return -EINVAL; | ||
114 | } | ||
115 | |||
116 | +/** | ||
117 | + * smmu_ptw_64_s2 - VMSAv8-64 Walk of the page tables for a given ipa | ||
118 | + * for stage-2. | ||
119 | + * @cfg: translation config | ||
120 | + * @ipa: ipa to translate | ||
121 | + * @perm: access type | ||
122 | + * @tlbe: SMMUTLBEntry (out) | ||
123 | + * @info: handle to an error info | ||
124 | + * | ||
125 | + * Return 0 on success, < 0 on error. In case of error, @info is filled | ||
126 | + * and tlbe->perm is set to IOMMU_NONE. | ||
127 | + * Upon success, @tlbe is filled with translated_addr and entry | ||
128 | + * permission rights. | ||
129 | + */ | ||
130 | +static int smmu_ptw_64_s2(SMMUTransCfg *cfg, | ||
131 | + dma_addr_t ipa, IOMMUAccessFlags perm, | ||
132 | + SMMUTLBEntry *tlbe, SMMUPTWEventInfo *info) | ||
133 | +{ | ||
134 | + const int stage = 2; | ||
135 | + int granule_sz = cfg->s2cfg.granule_sz; | ||
136 | + /* ARM DDI0487I.a: Table D8-7. */ | ||
137 | + int inputsize = 64 - cfg->s2cfg.tsz; | ||
138 | + int level = get_start_level(cfg->s2cfg.sl0, granule_sz); | ||
139 | + int stride = VMSA_STRIDE(granule_sz); | ||
140 | + int idx = pgd_concat_idx(level, granule_sz, ipa); | ||
141 | + /* | ||
142 | + * Get the ttb from concatenated structure. | ||
143 | + * The offset is the idx * size of each ttb(number of ptes * (sizeof(pte)) | ||
144 | + */ | ||
145 | + uint64_t baseaddr = extract64(cfg->s2cfg.vttb, 0, 48) + (1 << stride) * | ||
146 | + idx * sizeof(uint64_t); | ||
147 | + dma_addr_t indexmask = VMSA_IDXMSK(inputsize, stride, level); | ||
148 | + | ||
149 | + baseaddr &= ~indexmask; | ||
150 | + | ||
151 | + /* | ||
152 | + * On input, a stage 2 Translation fault occurs if the IPA is outside the | ||
153 | + * range configured by the relevant S2T0SZ field of the STE. | ||
154 | + */ | ||
155 | + if (ipa >= (1ULL << inputsize)) { | ||
156 | + info->type = SMMU_PTW_ERR_TRANSLATION; | ||
157 | + goto error; | ||
158 | + } | ||
159 | + | ||
160 | + while (level < VMSA_LEVELS) { | ||
161 | + uint64_t subpage_size = 1ULL << level_shift(level, granule_sz); | ||
162 | + uint64_t mask = subpage_size - 1; | ||
163 | + uint32_t offset = iova_level_offset(ipa, inputsize, level, granule_sz); | ||
164 | + uint64_t pte, gpa; | ||
165 | + dma_addr_t pte_addr = baseaddr + offset * sizeof(pte); | ||
166 | + uint8_t s2ap; | ||
167 | + | ||
168 | + if (get_pte(baseaddr, offset, &pte, info)) { | ||
169 | + goto error; | ||
170 | + } | ||
171 | + trace_smmu_ptw_level(stage, level, ipa, subpage_size, | ||
172 | + baseaddr, offset, pte); | ||
173 | + if (is_invalid_pte(pte) || is_reserved_pte(pte, level)) { | ||
174 | + trace_smmu_ptw_invalid_pte(stage, level, baseaddr, | ||
175 | + pte_addr, offset, pte); | ||
176 | + break; | ||
177 | + } | ||
178 | + | ||
179 | + if (is_table_pte(pte, level)) { | ||
180 | + baseaddr = get_table_pte_address(pte, granule_sz); | ||
181 | + level++; | ||
182 | + continue; | ||
183 | + } else if (is_page_pte(pte, level)) { | ||
184 | + gpa = get_page_pte_address(pte, granule_sz); | ||
185 | + trace_smmu_ptw_page_pte(stage, level, ipa, | ||
186 | + baseaddr, pte_addr, pte, gpa); | ||
187 | + } else { | ||
188 | + uint64_t block_size; | ||
189 | + | ||
190 | + gpa = get_block_pte_address(pte, level, granule_sz, | ||
191 | + &block_size); | ||
192 | + trace_smmu_ptw_block_pte(stage, level, baseaddr, | ||
193 | + pte_addr, pte, ipa, gpa, | ||
194 | + block_size >> 20); | ||
195 | + } | ||
196 | + | ||
197 | + /* | ||
198 | + * If S2AFFD and PTE.AF are 0 => fault. (5.2. Stream Table Entry) | ||
199 | + * An Access fault takes priority over a Permission fault. | ||
200 | + */ | ||
201 | + if (!PTE_AF(pte) && !cfg->s2cfg.affd) { | ||
202 | + info->type = SMMU_PTW_ERR_ACCESS; | ||
203 | + goto error; | ||
204 | + } | ||
205 | + | ||
206 | + s2ap = PTE_AP(pte); | ||
207 | + if (is_permission_fault_s2(s2ap, perm)) { | ||
208 | + info->type = SMMU_PTW_ERR_PERMISSION; | ||
209 | + goto error; | ||
210 | + } | ||
211 | + | ||
212 | + /* | ||
213 | + * The address output from the translation causes a stage 2 Address | ||
214 | + * Size fault if it exceeds the effective PA output range. | ||
215 | + */ | ||
216 | + if (gpa >= (1ULL << cfg->s2cfg.eff_ps)) { | ||
217 | + info->type = SMMU_PTW_ERR_ADDR_SIZE; | ||
218 | + goto error; | ||
219 | + } | ||
220 | + | ||
221 | + tlbe->entry.translated_addr = gpa; | ||
222 | + tlbe->entry.iova = ipa & ~mask; | ||
223 | + tlbe->entry.addr_mask = mask; | ||
224 | + tlbe->entry.perm = s2ap; | ||
225 | + tlbe->level = level; | ||
226 | + tlbe->granule = granule_sz; | ||
227 | + return 0; | ||
228 | + } | ||
229 | + info->type = SMMU_PTW_ERR_TRANSLATION; | ||
230 | + | ||
231 | +error: | ||
232 | + info->stage = 2; | ||
233 | + tlbe->entry.perm = IOMMU_NONE; | ||
234 | + return -EINVAL; | ||
235 | +} | ||
236 | + | ||
237 | /** | ||
238 | * smmu_ptw - Walk the page tables for an IOVA, according to @cfg | ||
239 | * | ||
240 | @@ -XXX,XX +XXX,XX @@ error: | ||
241 | int smmu_ptw(SMMUTransCfg *cfg, dma_addr_t iova, IOMMUAccessFlags perm, | ||
242 | SMMUTLBEntry *tlbe, SMMUPTWEventInfo *info) | ||
243 | { | ||
244 | - return smmu_ptw_64_s1(cfg, iova, perm, tlbe, info); | ||
245 | + if (cfg->stage == 1) { | ||
246 | + return smmu_ptw_64_s1(cfg, iova, perm, tlbe, info); | ||
247 | + } else if (cfg->stage == 2) { | ||
248 | + /* | ||
249 | + * If bypassing stage 1(or unimplemented), the input address is passed | ||
250 | + * directly to stage 2 as IPA. If the input address of a transaction | ||
251 | + * exceeds the size of the IAS, a stage 1 Address Size fault occurs. | ||
252 | + * For AA64, IAS = OAS according to (IHI 0070.E.a) "3.4 Address sizes" | ||
253 | + */ | ||
254 | + if (iova >= (1ULL << cfg->oas)) { | ||
255 | + info->type = SMMU_PTW_ERR_ADDR_SIZE; | ||
256 | + info->stage = 1; | ||
257 | + tlbe->entry.perm = IOMMU_NONE; | ||
258 | + return -EINVAL; | ||
259 | + } | ||
260 | + | ||
261 | + return smmu_ptw_64_s2(cfg, iova, perm, tlbe, info); | ||
262 | + } | ||
263 | + | ||
264 | + g_assert_not_reached(); | ||
265 | } | ||
266 | |||
267 | /** | ||
268 | -- | ||
269 | 2.34.1 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Mostafa Saleh <smostafa@google.com> |
---|---|---|---|
2 | 2 | ||
3 | Rename from sve_zcr_get_valid_len and make accessible | 3 | Parse stage-2 configuration from STE and populate it in SMMUS2Cfg. |
4 | from outside of helper.c. | 4 | Validity of field values are checked when possible. |
5 | 5 | ||
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 6 | Only AA64 tables are supported and Small Translation Tables (STT) are |
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 7 | not supported. |
8 | Message-id: 20210723203344.968563-3-richard.henderson@linaro.org | 8 | |
9 | According to SMMUv3 UM(IHI0070E) "5.2 Stream Table Entry": All fields | ||
10 | with an S2 prefix (with the exception of S2VMID) are IGNORED when | ||
11 | stage-2 bypasses translation (Config[1] == 0). | ||
12 | |||
13 | Which means that VMID can be used(for TLB tagging) even if stage-2 is | ||
14 | bypassed, so we parse it unconditionally when S2P exists. Otherwise | ||
15 | it is set to -1.(only S1P) | ||
16 | |||
17 | As stall is not supported, if S2S is set the translation would abort. | ||
18 | For S2R, we reuse the same code used for stage-1 with flag | ||
19 | record_faults. However when nested translation is supported we would | ||
20 | need to separate stage-1 and stage-2 faults. | ||
21 | |||
22 | Fix wrong shift in STE_S2HD, STE_S2HA, STE_S2S. | ||
23 | |||
24 | Signed-off-by: Mostafa Saleh <smostafa@google.com> | ||
25 | Tested-by: Eric Auger <eric.auger@redhat.com> | ||
26 | Tested-by: Jean-Philippe Brucker <jean-philippe@linaro.org> | ||
27 | Reviewed-by: Eric Auger <eric.auger@redhat.com> | ||
28 | Message-id: 20230516203327.2051088-6-smostafa@google.com | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 29 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | --- | 30 | --- |
11 | target/arm/internals.h | 10 ++++++++++ | 31 | hw/arm/smmuv3-internal.h | 10 +- |
12 | target/arm/helper.c | 4 ++-- | 32 | include/hw/arm/smmu-common.h | 1 + |
13 | 2 files changed, 12 insertions(+), 2 deletions(-) | 33 | include/hw/arm/smmuv3.h | 3 + |
14 | 34 | hw/arm/smmuv3.c | 181 +++++++++++++++++++++++++++++++++-- | |
15 | diff --git a/target/arm/internals.h b/target/arm/internals.h | 35 | 4 files changed, 185 insertions(+), 10 deletions(-) |
36 | |||
37 | diff --git a/hw/arm/smmuv3-internal.h b/hw/arm/smmuv3-internal.h | ||
16 | index XXXXXXX..XXXXXXX 100644 | 38 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/target/arm/internals.h | 39 | --- a/hw/arm/smmuv3-internal.h |
18 | +++ b/target/arm/internals.h | 40 | +++ b/hw/arm/smmuv3-internal.h |
19 | @@ -XXX,XX +XXX,XX @@ void arm_translate_init(void); | 41 | @@ -XXX,XX +XXX,XX @@ typedef struct CD { |
20 | void arm_cpu_synchronize_from_tb(CPUState *cs, const TranslationBlock *tb); | 42 | #define STE_S2TG(x) extract32((x)->word[5], 14, 2) |
21 | #endif /* CONFIG_TCG */ | 43 | #define STE_S2PS(x) extract32((x)->word[5], 16, 3) |
22 | 44 | #define STE_S2AA64(x) extract32((x)->word[5], 19, 1) | |
23 | +/** | 45 | -#define STE_S2HD(x) extract32((x)->word[5], 24, 1) |
24 | + * aarch64_sve_zcr_get_valid_len: | 46 | -#define STE_S2HA(x) extract32((x)->word[5], 25, 1) |
25 | + * @cpu: cpu context | 47 | -#define STE_S2S(x) extract32((x)->word[5], 26, 1) |
26 | + * @start_len: maximum len to consider | 48 | +#define STE_S2ENDI(x) extract32((x)->word[5], 20, 1) |
27 | + * | 49 | +#define STE_S2AFFD(x) extract32((x)->word[5], 21, 1) |
28 | + * Return the maximum supported sve vector length <= @start_len. | 50 | +#define STE_S2HD(x) extract32((x)->word[5], 23, 1) |
29 | + * Note that both @start_len and the return value are in units | 51 | +#define STE_S2HA(x) extract32((x)->word[5], 24, 1) |
30 | + * of ZCR_ELx.LEN, so the vector bit length is (x + 1) * 128. | 52 | +#define STE_S2S(x) extract32((x)->word[5], 25, 1) |
31 | + */ | 53 | +#define STE_S2R(x) extract32((x)->word[5], 26, 1) |
32 | +uint32_t aarch64_sve_zcr_get_valid_len(ARMCPU *cpu, uint32_t start_len); | 54 | + |
33 | 55 | #define STE_CTXPTR(x) \ | |
34 | enum arm_fprounding { | 56 | ({ \ |
35 | FPROUNDING_TIEEVEN, | 57 | unsigned long addr; \ |
36 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 58 | diff --git a/include/hw/arm/smmu-common.h b/include/hw/arm/smmu-common.h |
37 | index XXXXXXX..XXXXXXX 100644 | 59 | index XXXXXXX..XXXXXXX 100644 |
38 | --- a/target/arm/helper.c | 60 | --- a/include/hw/arm/smmu-common.h |
39 | +++ b/target/arm/helper.c | 61 | +++ b/include/hw/arm/smmu-common.h |
40 | @@ -XXX,XX +XXX,XX @@ int sve_exception_el(CPUARMState *env, int el) | 62 | @@ -XXX,XX +XXX,XX @@ |
63 | |||
64 | /* VMSAv8-64 Translation constants and functions */ | ||
65 | #define VMSA_LEVELS 4 | ||
66 | +#define VMSA_MAX_S2_CONCAT 16 | ||
67 | |||
68 | #define VMSA_STRIDE(gran) ((gran) - VMSA_LEVELS + 1) | ||
69 | #define VMSA_BIT_LVL(isz, strd, lvl) ((isz) - (strd) * \ | ||
70 | diff --git a/include/hw/arm/smmuv3.h b/include/hw/arm/smmuv3.h | ||
71 | index XXXXXXX..XXXXXXX 100644 | ||
72 | --- a/include/hw/arm/smmuv3.h | ||
73 | +++ b/include/hw/arm/smmuv3.h | ||
74 | @@ -XXX,XX +XXX,XX @@ struct SMMUv3Class { | ||
75 | #define TYPE_ARM_SMMUV3 "arm-smmuv3" | ||
76 | OBJECT_DECLARE_TYPE(SMMUv3State, SMMUv3Class, ARM_SMMUV3) | ||
77 | |||
78 | +#define STAGE1_SUPPORTED(s) FIELD_EX32(s->idr[0], IDR0, S1P) | ||
79 | +#define STAGE2_SUPPORTED(s) FIELD_EX32(s->idr[0], IDR0, S2P) | ||
80 | + | ||
81 | #endif | ||
82 | diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c | ||
83 | index XXXXXXX..XXXXXXX 100644 | ||
84 | --- a/hw/arm/smmuv3.c | ||
85 | +++ b/hw/arm/smmuv3.c | ||
86 | @@ -XXX,XX +XXX,XX @@ | ||
87 | #include "smmuv3-internal.h" | ||
88 | #include "smmu-internal.h" | ||
89 | |||
90 | +#define PTW_RECORD_FAULT(cfg) (((cfg)->stage == 1) ? (cfg)->record_faults : \ | ||
91 | + (cfg)->s2cfg.record_faults) | ||
92 | + | ||
93 | /** | ||
94 | * smmuv3_trigger_irq - pulse @irq if enabled and update | ||
95 | * GERROR register in case of GERROR interrupt | ||
96 | @@ -XXX,XX +XXX,XX @@ static int smmu_get_cd(SMMUv3State *s, STE *ste, uint32_t ssid, | ||
41 | return 0; | 97 | return 0; |
42 | } | 98 | } |
43 | 99 | ||
44 | -static uint32_t sve_zcr_get_valid_len(ARMCPU *cpu, uint32_t start_len) | 100 | +/* |
45 | +uint32_t aarch64_sve_zcr_get_valid_len(ARMCPU *cpu, uint32_t start_len) | 101 | + * Max valid value is 39 when SMMU_IDR3.STT == 0. |
102 | + * In architectures after SMMUv3.0: | ||
103 | + * - If STE.S2TG selects a 4KB or 16KB granule, the minimum valid value for this | ||
104 | + * field is MAX(16, 64-IAS) | ||
105 | + * - If STE.S2TG selects a 64KB granule, the minimum valid value for this field | ||
106 | + * is (64-IAS). | ||
107 | + * As we only support AA64, IAS = OAS. | ||
108 | + */ | ||
109 | +static bool s2t0sz_valid(SMMUTransCfg *cfg) | ||
110 | +{ | ||
111 | + if (cfg->s2cfg.tsz > 39) { | ||
112 | + return false; | ||
113 | + } | ||
114 | + | ||
115 | + if (cfg->s2cfg.granule_sz == 16) { | ||
116 | + return (cfg->s2cfg.tsz >= 64 - oas2bits(SMMU_IDR5_OAS)); | ||
117 | + } | ||
118 | + | ||
119 | + return (cfg->s2cfg.tsz >= MAX(64 - oas2bits(SMMU_IDR5_OAS), 16)); | ||
120 | +} | ||
121 | + | ||
122 | +/* | ||
123 | + * Return true if s2 page table config is valid. | ||
124 | + * This checks with the configured start level, ias_bits and granularity we can | ||
125 | + * have a valid page table as described in ARM ARM D8.2 Translation process. | ||
126 | + * The idea here is to see for the highest possible number of IPA bits, how | ||
127 | + * many concatenated tables we would need, if it is more than 16, then this is | ||
128 | + * not possible. | ||
129 | + */ | ||
130 | +static bool s2_pgtable_config_valid(uint8_t sl0, uint8_t t0sz, uint8_t gran) | ||
131 | +{ | ||
132 | + int level = get_start_level(sl0, gran); | ||
133 | + uint64_t ipa_bits = 64 - t0sz; | ||
134 | + uint64_t max_ipa = (1ULL << ipa_bits) - 1; | ||
135 | + int nr_concat = pgd_concat_idx(level, gran, max_ipa) + 1; | ||
136 | + | ||
137 | + return nr_concat <= VMSA_MAX_S2_CONCAT; | ||
138 | +} | ||
139 | + | ||
140 | +static int decode_ste_s2_cfg(SMMUTransCfg *cfg, STE *ste) | ||
141 | +{ | ||
142 | + cfg->stage = 2; | ||
143 | + | ||
144 | + if (STE_S2AA64(ste) == 0x0) { | ||
145 | + qemu_log_mask(LOG_UNIMP, | ||
146 | + "SMMUv3 AArch32 tables not supported\n"); | ||
147 | + g_assert_not_reached(); | ||
148 | + } | ||
149 | + | ||
150 | + switch (STE_S2TG(ste)) { | ||
151 | + case 0x0: /* 4KB */ | ||
152 | + cfg->s2cfg.granule_sz = 12; | ||
153 | + break; | ||
154 | + case 0x1: /* 64KB */ | ||
155 | + cfg->s2cfg.granule_sz = 16; | ||
156 | + break; | ||
157 | + case 0x2: /* 16KB */ | ||
158 | + cfg->s2cfg.granule_sz = 14; | ||
159 | + break; | ||
160 | + default: | ||
161 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
162 | + "SMMUv3 bad STE S2TG: %x\n", STE_S2TG(ste)); | ||
163 | + goto bad_ste; | ||
164 | + } | ||
165 | + | ||
166 | + cfg->s2cfg.vttb = STE_S2TTB(ste); | ||
167 | + | ||
168 | + cfg->s2cfg.sl0 = STE_S2SL0(ste); | ||
169 | + /* FEAT_TTST not supported. */ | ||
170 | + if (cfg->s2cfg.sl0 == 0x3) { | ||
171 | + qemu_log_mask(LOG_UNIMP, "SMMUv3 S2SL0 = 0x3 has no meaning!\n"); | ||
172 | + goto bad_ste; | ||
173 | + } | ||
174 | + | ||
175 | + /* For AA64, The effective S2PS size is capped to the OAS. */ | ||
176 | + cfg->s2cfg.eff_ps = oas2bits(MIN(STE_S2PS(ste), SMMU_IDR5_OAS)); | ||
177 | + /* | ||
178 | + * It is ILLEGAL for the address in S2TTB to be outside the range | ||
179 | + * described by the effective S2PS value. | ||
180 | + */ | ||
181 | + if (cfg->s2cfg.vttb & ~(MAKE_64BIT_MASK(0, cfg->s2cfg.eff_ps))) { | ||
182 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
183 | + "SMMUv3 S2TTB too large 0x%lx, effective PS %d bits\n", | ||
184 | + cfg->s2cfg.vttb, cfg->s2cfg.eff_ps); | ||
185 | + goto bad_ste; | ||
186 | + } | ||
187 | + | ||
188 | + cfg->s2cfg.tsz = STE_S2T0SZ(ste); | ||
189 | + | ||
190 | + if (!s2t0sz_valid(cfg)) { | ||
191 | + qemu_log_mask(LOG_GUEST_ERROR, "SMMUv3 bad STE S2T0SZ = %d\n", | ||
192 | + cfg->s2cfg.tsz); | ||
193 | + goto bad_ste; | ||
194 | + } | ||
195 | + | ||
196 | + if (!s2_pgtable_config_valid(cfg->s2cfg.sl0, cfg->s2cfg.tsz, | ||
197 | + cfg->s2cfg.granule_sz)) { | ||
198 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
199 | + "SMMUv3 STE stage 2 config not valid!\n"); | ||
200 | + goto bad_ste; | ||
201 | + } | ||
202 | + | ||
203 | + /* Only LE supported(IDR0.TTENDIAN). */ | ||
204 | + if (STE_S2ENDI(ste)) { | ||
205 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
206 | + "SMMUv3 STE_S2ENDI only supports LE!\n"); | ||
207 | + goto bad_ste; | ||
208 | + } | ||
209 | + | ||
210 | + cfg->s2cfg.affd = STE_S2AFFD(ste); | ||
211 | + | ||
212 | + cfg->s2cfg.record_faults = STE_S2R(ste); | ||
213 | + /* As stall is not supported. */ | ||
214 | + if (STE_S2S(ste)) { | ||
215 | + qemu_log_mask(LOG_UNIMP, "SMMUv3 Stall not implemented!\n"); | ||
216 | + goto bad_ste; | ||
217 | + } | ||
218 | + | ||
219 | + /* This is still here as stage 2 has not been fully enabled yet. */ | ||
220 | + qemu_log_mask(LOG_UNIMP, "SMMUv3 does not support stage 2 yet\n"); | ||
221 | + goto bad_ste; | ||
222 | + | ||
223 | + return 0; | ||
224 | + | ||
225 | +bad_ste: | ||
226 | + return -EINVAL; | ||
227 | +} | ||
228 | + | ||
229 | /* Returns < 0 in case of invalid STE, 0 otherwise */ | ||
230 | static int decode_ste(SMMUv3State *s, SMMUTransCfg *cfg, | ||
231 | STE *ste, SMMUEventInfo *event) | ||
46 | { | 232 | { |
47 | uint32_t end_len; | 233 | uint32_t config; |
48 | 234 | + int ret; | |
49 | @@ -XXX,XX +XXX,XX @@ uint32_t sve_zcr_len_for_el(CPUARMState *env, int el) | 235 | |
50 | zcr_len = MIN(zcr_len, 0xf & (uint32_t)env->vfp.zcr_el[3]); | 236 | if (!STE_VALID(ste)) { |
237 | if (!event->inval_ste_allowed) { | ||
238 | @@ -XXX,XX +XXX,XX @@ static int decode_ste(SMMUv3State *s, SMMUTransCfg *cfg, | ||
239 | return 0; | ||
51 | } | 240 | } |
52 | 241 | ||
53 | - return sve_zcr_get_valid_len(cpu, zcr_len); | 242 | - if (STE_CFG_S2_ENABLED(config)) { |
54 | + return aarch64_sve_zcr_get_valid_len(cpu, zcr_len); | 243 | - qemu_log_mask(LOG_UNIMP, "SMMUv3 does not support stage 2 yet\n"); |
55 | } | 244 | + /* |
56 | 245 | + * If a stage is enabled in SW while not advertised, throw bad ste | |
57 | static void zcr_write(CPUARMState *env, const ARMCPRegInfo *ri, | 246 | + * according to user manual(IHI0070E) "5.2 Stream Table Entry". |
247 | + */ | ||
248 | + if (!STAGE1_SUPPORTED(s) && STE_CFG_S1_ENABLED(config)) { | ||
249 | + qemu_log_mask(LOG_GUEST_ERROR, "SMMUv3 S1 used but not supported.\n"); | ||
250 | goto bad_ste; | ||
251 | } | ||
252 | + if (!STAGE2_SUPPORTED(s) && STE_CFG_S2_ENABLED(config)) { | ||
253 | + qemu_log_mask(LOG_GUEST_ERROR, "SMMUv3 S2 used but not supported.\n"); | ||
254 | + goto bad_ste; | ||
255 | + } | ||
256 | + | ||
257 | + if (STAGE2_SUPPORTED(s)) { | ||
258 | + /* VMID is considered even if s2 is disabled. */ | ||
259 | + cfg->s2cfg.vmid = STE_S2VMID(ste); | ||
260 | + } else { | ||
261 | + /* Default to -1 */ | ||
262 | + cfg->s2cfg.vmid = -1; | ||
263 | + } | ||
264 | + | ||
265 | + if (STE_CFG_S2_ENABLED(config)) { | ||
266 | + /* | ||
267 | + * Stage-1 OAS defaults to OAS even if not enabled as it would be used | ||
268 | + * in input address check for stage-2. | ||
269 | + */ | ||
270 | + cfg->oas = oas2bits(SMMU_IDR5_OAS); | ||
271 | + ret = decode_ste_s2_cfg(cfg, ste); | ||
272 | + if (ret) { | ||
273 | + goto bad_ste; | ||
274 | + } | ||
275 | + } | ||
276 | |||
277 | if (STE_S1CDMAX(ste) != 0) { | ||
278 | qemu_log_mask(LOG_UNIMP, | ||
279 | @@ -XXX,XX +XXX,XX @@ static IOMMUTLBEntry smmuv3_translate(IOMMUMemoryRegion *mr, hwaddr addr, | ||
280 | if (cached_entry) { | ||
281 | if ((flag & IOMMU_WO) && !(cached_entry->entry.perm & IOMMU_WO)) { | ||
282 | status = SMMU_TRANS_ERROR; | ||
283 | - if (cfg->record_faults) { | ||
284 | + /* | ||
285 | + * We know that the TLB only contains either stage-1 or stage-2 as | ||
286 | + * nesting is not supported. So it is sufficient to check the | ||
287 | + * translation stage to know the TLB stage for now. | ||
288 | + */ | ||
289 | + event.u.f_walk_eabt.s2 = (cfg->stage == 2); | ||
290 | + if (PTW_RECORD_FAULT(cfg)) { | ||
291 | event.type = SMMU_EVT_F_PERMISSION; | ||
292 | event.u.f_permission.addr = addr; | ||
293 | event.u.f_permission.rnw = flag & 0x1; | ||
294 | @@ -XXX,XX +XXX,XX @@ static IOMMUTLBEntry smmuv3_translate(IOMMUMemoryRegion *mr, hwaddr addr, | ||
295 | event.u.f_walk_eabt.addr2 = ptw_info.addr; | ||
296 | break; | ||
297 | case SMMU_PTW_ERR_TRANSLATION: | ||
298 | - if (cfg->record_faults) { | ||
299 | + if (PTW_RECORD_FAULT(cfg)) { | ||
300 | event.type = SMMU_EVT_F_TRANSLATION; | ||
301 | event.u.f_translation.addr = addr; | ||
302 | event.u.f_translation.rnw = flag & 0x1; | ||
303 | } | ||
304 | break; | ||
305 | case SMMU_PTW_ERR_ADDR_SIZE: | ||
306 | - if (cfg->record_faults) { | ||
307 | + if (PTW_RECORD_FAULT(cfg)) { | ||
308 | event.type = SMMU_EVT_F_ADDR_SIZE; | ||
309 | event.u.f_addr_size.addr = addr; | ||
310 | event.u.f_addr_size.rnw = flag & 0x1; | ||
311 | } | ||
312 | break; | ||
313 | case SMMU_PTW_ERR_ACCESS: | ||
314 | - if (cfg->record_faults) { | ||
315 | + if (PTW_RECORD_FAULT(cfg)) { | ||
316 | event.type = SMMU_EVT_F_ACCESS; | ||
317 | event.u.f_access.addr = addr; | ||
318 | event.u.f_access.rnw = flag & 0x1; | ||
319 | } | ||
320 | break; | ||
321 | case SMMU_PTW_ERR_PERMISSION: | ||
322 | - if (cfg->record_faults) { | ||
323 | + if (PTW_RECORD_FAULT(cfg)) { | ||
324 | event.type = SMMU_EVT_F_PERMISSION; | ||
325 | event.u.f_permission.addr = addr; | ||
326 | event.u.f_permission.rnw = flag & 0x1; | ||
58 | -- | 327 | -- |
59 | 2.20.1 | 328 | 2.34.1 |
60 | |||
61 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Mostafa Saleh <smostafa@google.com> | ||
1 | 2 | ||
3 | Right now, either stage-1 or stage-2 are supported, this simplifies | ||
4 | how we can deal with TLBs. | ||
5 | This patch makes TLB lookup work if stage-2 is enabled instead of | ||
6 | stage-1. | ||
7 | TLB lookup is done before a PTW, if a valid entry is found we won't | ||
8 | do the PTW. | ||
9 | To be able to do TLB lookup, we need the correct tagging info, as | ||
10 | granularity and input size, so we get this based on the supported | ||
11 | translation stage. The TLB entries are added correctly from each | ||
12 | stage PTW. | ||
13 | |||
14 | When nested translation is supported, this would need to change, for | ||
15 | example if we go with a combined TLB implementation, we would need to | ||
16 | use the min of the granularities in TLB. | ||
17 | |||
18 | As stage-2 shouldn't be tagged by ASID, it will be set to -1 if S1P | ||
19 | is not enabled. | ||
20 | |||
21 | Signed-off-by: Mostafa Saleh <smostafa@google.com> | ||
22 | Reviewed-by: Eric Auger <eric.auger@redhat.com> | ||
23 | Tested-by: Eric Auger <eric.auger@redhat.com> | ||
24 | Tested-by: Jean-Philippe Brucker <jean-philippe@linaro.org> | ||
25 | Message-id: 20230516203327.2051088-7-smostafa@google.com | ||
26 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
27 | --- | ||
28 | hw/arm/smmuv3.c | 44 +++++++++++++++++++++++++++++++++----------- | ||
29 | 1 file changed, 33 insertions(+), 11 deletions(-) | ||
30 | |||
31 | diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c | ||
32 | index XXXXXXX..XXXXXXX 100644 | ||
33 | --- a/hw/arm/smmuv3.c | ||
34 | +++ b/hw/arm/smmuv3.c | ||
35 | @@ -XXX,XX +XXX,XX @@ static int smmuv3_decode_config(IOMMUMemoryRegion *mr, SMMUTransCfg *cfg, | ||
36 | STE ste; | ||
37 | CD cd; | ||
38 | |||
39 | + /* ASID defaults to -1 (if s1 is not supported). */ | ||
40 | + cfg->asid = -1; | ||
41 | + | ||
42 | ret = smmu_find_ste(s, sid, &ste, event); | ||
43 | if (ret) { | ||
44 | return ret; | ||
45 | @@ -XXX,XX +XXX,XX @@ static IOMMUTLBEntry smmuv3_translate(IOMMUMemoryRegion *mr, hwaddr addr, | ||
46 | .addr_mask = ~(hwaddr)0, | ||
47 | .perm = IOMMU_NONE, | ||
48 | }; | ||
49 | + /* | ||
50 | + * Combined attributes used for TLB lookup, as only one stage is supported, | ||
51 | + * it will hold attributes based on the enabled stage. | ||
52 | + */ | ||
53 | + SMMUTransTableInfo tt_combined; | ||
54 | |||
55 | qemu_mutex_lock(&s->mutex); | ||
56 | |||
57 | @@ -XXX,XX +XXX,XX @@ static IOMMUTLBEntry smmuv3_translate(IOMMUMemoryRegion *mr, hwaddr addr, | ||
58 | goto epilogue; | ||
59 | } | ||
60 | |||
61 | - tt = select_tt(cfg, addr); | ||
62 | - if (!tt) { | ||
63 | - if (cfg->record_faults) { | ||
64 | - event.type = SMMU_EVT_F_TRANSLATION; | ||
65 | - event.u.f_translation.addr = addr; | ||
66 | - event.u.f_translation.rnw = flag & 0x1; | ||
67 | + if (cfg->stage == 1) { | ||
68 | + /* Select stage1 translation table. */ | ||
69 | + tt = select_tt(cfg, addr); | ||
70 | + if (!tt) { | ||
71 | + if (cfg->record_faults) { | ||
72 | + event.type = SMMU_EVT_F_TRANSLATION; | ||
73 | + event.u.f_translation.addr = addr; | ||
74 | + event.u.f_translation.rnw = flag & 0x1; | ||
75 | + } | ||
76 | + status = SMMU_TRANS_ERROR; | ||
77 | + goto epilogue; | ||
78 | } | ||
79 | - status = SMMU_TRANS_ERROR; | ||
80 | - goto epilogue; | ||
81 | - } | ||
82 | + tt_combined.granule_sz = tt->granule_sz; | ||
83 | + tt_combined.tsz = tt->tsz; | ||
84 | |||
85 | - page_mask = (1ULL << (tt->granule_sz)) - 1; | ||
86 | + } else { | ||
87 | + /* Stage2. */ | ||
88 | + tt_combined.granule_sz = cfg->s2cfg.granule_sz; | ||
89 | + tt_combined.tsz = cfg->s2cfg.tsz; | ||
90 | + } | ||
91 | + /* | ||
92 | + * TLB lookup looks for granule and input size for a translation stage, | ||
93 | + * as only one stage is supported right now, choose the right values | ||
94 | + * from the configuration. | ||
95 | + */ | ||
96 | + page_mask = (1ULL << tt_combined.granule_sz) - 1; | ||
97 | aligned_addr = addr & ~page_mask; | ||
98 | |||
99 | - cached_entry = smmu_iotlb_lookup(bs, cfg, tt, aligned_addr); | ||
100 | + cached_entry = smmu_iotlb_lookup(bs, cfg, &tt_combined, aligned_addr); | ||
101 | if (cached_entry) { | ||
102 | if ((flag & IOMMU_WO) && !(cached_entry->entry.perm & IOMMU_WO)) { | ||
103 | status = SMMU_TRANS_ERROR; | ||
104 | -- | ||
105 | 2.34.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | 1 | From: Mostafa Saleh <smostafa@google.com> | |
2 | |||
3 | Allow TLB to be tagged with VMID. | ||
4 | |||
5 | If stage-1 is only supported, VMID is set to -1 and ignored from STE | ||
6 | and CMD_TLBI_NH* cmds. | ||
7 | |||
8 | Update smmu_iotlb_insert trace event to have vmid. | ||
9 | |||
10 | Signed-off-by: Mostafa Saleh <smostafa@google.com> | ||
11 | Reviewed-by: Eric Auger <eric.auger@redhat.com> | ||
12 | Tested-by: Eric Auger <eric.auger@redhat.com> | ||
13 | Tested-by: Jean-Philippe Brucker <jean-philippe@linaro.org> | ||
14 | Message-id: 20230516203327.2051088-8-smostafa@google.com | ||
15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
16 | --- | ||
17 | hw/arm/smmu-internal.h | 2 ++ | ||
18 | include/hw/arm/smmu-common.h | 5 +++-- | ||
19 | hw/arm/smmu-common.c | 36 ++++++++++++++++++++++-------------- | ||
20 | hw/arm/smmuv3.c | 12 +++++++++--- | ||
21 | hw/arm/trace-events | 6 +++--- | ||
22 | 5 files changed, 39 insertions(+), 22 deletions(-) | ||
23 | |||
24 | diff --git a/hw/arm/smmu-internal.h b/hw/arm/smmu-internal.h | ||
25 | index XXXXXXX..XXXXXXX 100644 | ||
26 | --- a/hw/arm/smmu-internal.h | ||
27 | +++ b/hw/arm/smmu-internal.h | ||
28 | @@ -XXX,XX +XXX,XX @@ static inline int pgd_concat_idx(int start_level, int granule_sz, | ||
29 | } | ||
30 | |||
31 | #define SMMU_IOTLB_ASID(key) ((key).asid) | ||
32 | +#define SMMU_IOTLB_VMID(key) ((key).vmid) | ||
33 | |||
34 | typedef struct SMMUIOTLBPageInvInfo { | ||
35 | int asid; | ||
36 | + int vmid; | ||
37 | uint64_t iova; | ||
38 | uint64_t mask; | ||
39 | } SMMUIOTLBPageInvInfo; | ||
40 | diff --git a/include/hw/arm/smmu-common.h b/include/hw/arm/smmu-common.h | ||
41 | index XXXXXXX..XXXXXXX 100644 | ||
42 | --- a/include/hw/arm/smmu-common.h | ||
43 | +++ b/include/hw/arm/smmu-common.h | ||
44 | @@ -XXX,XX +XXX,XX @@ typedef struct SMMUPciBus { | ||
45 | typedef struct SMMUIOTLBKey { | ||
46 | uint64_t iova; | ||
47 | uint16_t asid; | ||
48 | + uint16_t vmid; | ||
49 | uint8_t tg; | ||
50 | uint8_t level; | ||
51 | } SMMUIOTLBKey; | ||
52 | @@ -XXX,XX +XXX,XX @@ IOMMUMemoryRegion *smmu_iommu_mr(SMMUState *s, uint32_t sid); | ||
53 | SMMUTLBEntry *smmu_iotlb_lookup(SMMUState *bs, SMMUTransCfg *cfg, | ||
54 | SMMUTransTableInfo *tt, hwaddr iova); | ||
55 | void smmu_iotlb_insert(SMMUState *bs, SMMUTransCfg *cfg, SMMUTLBEntry *entry); | ||
56 | -SMMUIOTLBKey smmu_get_iotlb_key(uint16_t asid, uint64_t iova, | ||
57 | +SMMUIOTLBKey smmu_get_iotlb_key(uint16_t asid, uint16_t vmid, uint64_t iova, | ||
58 | uint8_t tg, uint8_t level); | ||
59 | void smmu_iotlb_inv_all(SMMUState *s); | ||
60 | void smmu_iotlb_inv_asid(SMMUState *s, uint16_t asid); | ||
61 | -void smmu_iotlb_inv_iova(SMMUState *s, int asid, dma_addr_t iova, | ||
62 | +void smmu_iotlb_inv_iova(SMMUState *s, int asid, int vmid, dma_addr_t iova, | ||
63 | uint8_t tg, uint64_t num_pages, uint8_t ttl); | ||
64 | |||
65 | /* Unmap the range of all the notifiers registered to any IOMMU mr */ | ||
66 | diff --git a/hw/arm/smmu-common.c b/hw/arm/smmu-common.c | ||
67 | index XXXXXXX..XXXXXXX 100644 | ||
68 | --- a/hw/arm/smmu-common.c | ||
69 | +++ b/hw/arm/smmu-common.c | ||
70 | @@ -XXX,XX +XXX,XX @@ static guint smmu_iotlb_key_hash(gconstpointer v) | ||
71 | |||
72 | /* Jenkins hash */ | ||
73 | a = b = c = JHASH_INITVAL + sizeof(*key); | ||
74 | - a += key->asid + key->level + key->tg; | ||
75 | + a += key->asid + key->vmid + key->level + key->tg; | ||
76 | b += extract64(key->iova, 0, 32); | ||
77 | c += extract64(key->iova, 32, 32); | ||
78 | |||
79 | @@ -XXX,XX +XXX,XX @@ static gboolean smmu_iotlb_key_equal(gconstpointer v1, gconstpointer v2) | ||
80 | SMMUIOTLBKey *k1 = (SMMUIOTLBKey *)v1, *k2 = (SMMUIOTLBKey *)v2; | ||
81 | |||
82 | return (k1->asid == k2->asid) && (k1->iova == k2->iova) && | ||
83 | - (k1->level == k2->level) && (k1->tg == k2->tg); | ||
84 | + (k1->level == k2->level) && (k1->tg == k2->tg) && | ||
85 | + (k1->vmid == k2->vmid); | ||
86 | } | ||
87 | |||
88 | -SMMUIOTLBKey smmu_get_iotlb_key(uint16_t asid, uint64_t iova, | ||
89 | +SMMUIOTLBKey smmu_get_iotlb_key(uint16_t asid, uint16_t vmid, uint64_t iova, | ||
90 | uint8_t tg, uint8_t level) | ||
91 | { | ||
92 | - SMMUIOTLBKey key = {.asid = asid, .iova = iova, .tg = tg, .level = level}; | ||
93 | + SMMUIOTLBKey key = {.asid = asid, .vmid = vmid, .iova = iova, | ||
94 | + .tg = tg, .level = level}; | ||
95 | |||
96 | return key; | ||
97 | } | ||
98 | @@ -XXX,XX +XXX,XX @@ SMMUTLBEntry *smmu_iotlb_lookup(SMMUState *bs, SMMUTransCfg *cfg, | ||
99 | uint64_t mask = subpage_size - 1; | ||
100 | SMMUIOTLBKey key; | ||
101 | |||
102 | - key = smmu_get_iotlb_key(cfg->asid, iova & ~mask, tg, level); | ||
103 | + key = smmu_get_iotlb_key(cfg->asid, cfg->s2cfg.vmid, | ||
104 | + iova & ~mask, tg, level); | ||
105 | entry = g_hash_table_lookup(bs->iotlb, &key); | ||
106 | if (entry) { | ||
107 | break; | ||
108 | @@ -XXX,XX +XXX,XX @@ SMMUTLBEntry *smmu_iotlb_lookup(SMMUState *bs, SMMUTransCfg *cfg, | ||
109 | |||
110 | if (entry) { | ||
111 | cfg->iotlb_hits++; | ||
112 | - trace_smmu_iotlb_lookup_hit(cfg->asid, iova, | ||
113 | + trace_smmu_iotlb_lookup_hit(cfg->asid, cfg->s2cfg.vmid, iova, | ||
114 | cfg->iotlb_hits, cfg->iotlb_misses, | ||
115 | 100 * cfg->iotlb_hits / | ||
116 | (cfg->iotlb_hits + cfg->iotlb_misses)); | ||
117 | } else { | ||
118 | cfg->iotlb_misses++; | ||
119 | - trace_smmu_iotlb_lookup_miss(cfg->asid, iova, | ||
120 | + trace_smmu_iotlb_lookup_miss(cfg->asid, cfg->s2cfg.vmid, iova, | ||
121 | cfg->iotlb_hits, cfg->iotlb_misses, | ||
122 | 100 * cfg->iotlb_hits / | ||
123 | (cfg->iotlb_hits + cfg->iotlb_misses)); | ||
124 | @@ -XXX,XX +XXX,XX @@ void smmu_iotlb_insert(SMMUState *bs, SMMUTransCfg *cfg, SMMUTLBEntry *new) | ||
125 | smmu_iotlb_inv_all(bs); | ||
126 | } | ||
127 | |||
128 | - *key = smmu_get_iotlb_key(cfg->asid, new->entry.iova, tg, new->level); | ||
129 | - trace_smmu_iotlb_insert(cfg->asid, new->entry.iova, tg, new->level); | ||
130 | + *key = smmu_get_iotlb_key(cfg->asid, cfg->s2cfg.vmid, new->entry.iova, | ||
131 | + tg, new->level); | ||
132 | + trace_smmu_iotlb_insert(cfg->asid, cfg->s2cfg.vmid, new->entry.iova, | ||
133 | + tg, new->level); | ||
134 | g_hash_table_insert(bs->iotlb, key, new); | ||
135 | } | ||
136 | |||
137 | @@ -XXX,XX +XXX,XX @@ static gboolean smmu_hash_remove_by_asid(gpointer key, gpointer value, | ||
138 | |||
139 | return SMMU_IOTLB_ASID(*iotlb_key) == asid; | ||
140 | } | ||
141 | - | ||
142 | -static gboolean smmu_hash_remove_by_asid_iova(gpointer key, gpointer value, | ||
143 | +static gboolean smmu_hash_remove_by_asid_vmid_iova(gpointer key, gpointer value, | ||
144 | gpointer user_data) | ||
145 | { | ||
146 | SMMUTLBEntry *iter = (SMMUTLBEntry *)value; | ||
147 | @@ -XXX,XX +XXX,XX @@ static gboolean smmu_hash_remove_by_asid_iova(gpointer key, gpointer value, | ||
148 | if (info->asid >= 0 && info->asid != SMMU_IOTLB_ASID(iotlb_key)) { | ||
149 | return false; | ||
150 | } | ||
151 | + if (info->vmid >= 0 && info->vmid != SMMU_IOTLB_VMID(iotlb_key)) { | ||
152 | + return false; | ||
153 | + } | ||
154 | return ((info->iova & ~entry->addr_mask) == entry->iova) || | ||
155 | ((entry->iova & ~info->mask) == info->iova); | ||
156 | } | ||
157 | |||
158 | -void smmu_iotlb_inv_iova(SMMUState *s, int asid, dma_addr_t iova, | ||
159 | +void smmu_iotlb_inv_iova(SMMUState *s, int asid, int vmid, dma_addr_t iova, | ||
160 | uint8_t tg, uint64_t num_pages, uint8_t ttl) | ||
161 | { | ||
162 | /* if tg is not set we use 4KB range invalidation */ | ||
163 | uint8_t granule = tg ? tg * 2 + 10 : 12; | ||
164 | |||
165 | if (ttl && (num_pages == 1) && (asid >= 0)) { | ||
166 | - SMMUIOTLBKey key = smmu_get_iotlb_key(asid, iova, tg, ttl); | ||
167 | + SMMUIOTLBKey key = smmu_get_iotlb_key(asid, vmid, iova, tg, ttl); | ||
168 | |||
169 | if (g_hash_table_remove(s->iotlb, &key)) { | ||
170 | return; | ||
171 | @@ -XXX,XX +XXX,XX @@ void smmu_iotlb_inv_iova(SMMUState *s, int asid, dma_addr_t iova, | ||
172 | |||
173 | SMMUIOTLBPageInvInfo info = { | ||
174 | .asid = asid, .iova = iova, | ||
175 | + .vmid = vmid, | ||
176 | .mask = (num_pages * 1 << granule) - 1}; | ||
177 | |||
178 | g_hash_table_foreach_remove(s->iotlb, | ||
179 | - smmu_hash_remove_by_asid_iova, | ||
180 | + smmu_hash_remove_by_asid_vmid_iova, | ||
181 | &info); | ||
182 | } | ||
183 | |||
184 | diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c | ||
185 | index XXXXXXX..XXXXXXX 100644 | ||
186 | --- a/hw/arm/smmuv3.c | ||
187 | +++ b/hw/arm/smmuv3.c | ||
188 | @@ -XXX,XX +XXX,XX @@ static void smmuv3_s1_range_inval(SMMUState *s, Cmd *cmd) | ||
189 | { | ||
190 | dma_addr_t end, addr = CMD_ADDR(cmd); | ||
191 | uint8_t type = CMD_TYPE(cmd); | ||
192 | - uint16_t vmid = CMD_VMID(cmd); | ||
193 | + int vmid = -1; | ||
194 | uint8_t scale = CMD_SCALE(cmd); | ||
195 | uint8_t num = CMD_NUM(cmd); | ||
196 | uint8_t ttl = CMD_TTL(cmd); | ||
197 | @@ -XXX,XX +XXX,XX @@ static void smmuv3_s1_range_inval(SMMUState *s, Cmd *cmd) | ||
198 | uint64_t num_pages; | ||
199 | uint8_t granule; | ||
200 | int asid = -1; | ||
201 | + SMMUv3State *smmuv3 = ARM_SMMUV3(s); | ||
202 | + | ||
203 | + /* Only consider VMID if stage-2 is supported. */ | ||
204 | + if (STAGE2_SUPPORTED(smmuv3)) { | ||
205 | + vmid = CMD_VMID(cmd); | ||
206 | + } | ||
207 | |||
208 | if (type == SMMU_CMD_TLBI_NH_VA) { | ||
209 | asid = CMD_ASID(cmd); | ||
210 | @@ -XXX,XX +XXX,XX @@ static void smmuv3_s1_range_inval(SMMUState *s, Cmd *cmd) | ||
211 | if (!tg) { | ||
212 | trace_smmuv3_s1_range_inval(vmid, asid, addr, tg, 1, ttl, leaf); | ||
213 | smmuv3_inv_notifiers_iova(s, asid, addr, tg, 1); | ||
214 | - smmu_iotlb_inv_iova(s, asid, addr, tg, 1, ttl); | ||
215 | + smmu_iotlb_inv_iova(s, asid, vmid, addr, tg, 1, ttl); | ||
216 | return; | ||
217 | } | ||
218 | |||
219 | @@ -XXX,XX +XXX,XX @@ static void smmuv3_s1_range_inval(SMMUState *s, Cmd *cmd) | ||
220 | num_pages = (mask + 1) >> granule; | ||
221 | trace_smmuv3_s1_range_inval(vmid, asid, addr, tg, num_pages, ttl, leaf); | ||
222 | smmuv3_inv_notifiers_iova(s, asid, addr, tg, num_pages); | ||
223 | - smmu_iotlb_inv_iova(s, asid, addr, tg, num_pages, ttl); | ||
224 | + smmu_iotlb_inv_iova(s, asid, vmid, addr, tg, num_pages, ttl); | ||
225 | addr += mask + 1; | ||
226 | } | ||
227 | } | ||
228 | diff --git a/hw/arm/trace-events b/hw/arm/trace-events | ||
229 | index XXXXXXX..XXXXXXX 100644 | ||
230 | --- a/hw/arm/trace-events | ||
231 | +++ b/hw/arm/trace-events | ||
232 | @@ -XXX,XX +XXX,XX @@ smmu_iotlb_inv_all(void) "IOTLB invalidate all" | ||
233 | smmu_iotlb_inv_asid(uint16_t asid) "IOTLB invalidate asid=%d" | ||
234 | smmu_iotlb_inv_iova(uint16_t asid, uint64_t addr) "IOTLB invalidate asid=%d addr=0x%"PRIx64 | ||
235 | smmu_inv_notifiers_mr(const char *name) "iommu mr=%s" | ||
236 | -smmu_iotlb_lookup_hit(uint16_t asid, uint64_t addr, uint32_t hit, uint32_t miss, uint32_t p) "IOTLB cache HIT asid=%d addr=0x%"PRIx64" hit=%d miss=%d hit rate=%d" | ||
237 | -smmu_iotlb_lookup_miss(uint16_t asid, uint64_t addr, uint32_t hit, uint32_t miss, uint32_t p) "IOTLB cache MISS asid=%d addr=0x%"PRIx64" hit=%d miss=%d hit rate=%d" | ||
238 | -smmu_iotlb_insert(uint16_t asid, uint64_t addr, uint8_t tg, uint8_t level) "IOTLB ++ asid=%d addr=0x%"PRIx64" tg=%d level=%d" | ||
239 | +smmu_iotlb_lookup_hit(uint16_t asid, uint16_t vmid, uint64_t addr, uint32_t hit, uint32_t miss, uint32_t p) "IOTLB cache HIT asid=%d vmid=%d addr=0x%"PRIx64" hit=%d miss=%d hit rate=%d" | ||
240 | +smmu_iotlb_lookup_miss(uint16_t asid, uint16_t vmid, uint64_t addr, uint32_t hit, uint32_t miss, uint32_t p) "IOTLB cache MISS asid=%d vmid=%d addr=0x%"PRIx64" hit=%d miss=%d hit rate=%d" | ||
241 | +smmu_iotlb_insert(uint16_t asid, uint16_t vmid, uint64_t addr, uint8_t tg, uint8_t level) "IOTLB ++ asid=%d vmid=%d addr=0x%"PRIx64" tg=%d level=%d" | ||
242 | |||
243 | # smmuv3.c | ||
244 | smmuv3_read_mmio(uint64_t addr, uint64_t val, unsigned size, uint32_t r) "addr: 0x%"PRIx64" val:0x%"PRIx64" size: 0x%x(%d)" | ||
245 | -- | ||
246 | 2.34.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | 1 | From: Mostafa Saleh <smostafa@google.com> | |
2 | |||
3 | CMD_TLBI_S2_IPA: As S1+S2 is not enabled, for now this can be the | ||
4 | same as CMD_TLBI_NH_VAA. | ||
5 | |||
6 | CMD_TLBI_S12_VMALL: Added new function to invalidate TLB by VMID. | ||
7 | |||
8 | For stage-1 only commands, add a check to throw CERROR_ILL if used | ||
9 | when stage-1 is not supported. | ||
10 | |||
11 | Reviewed-by: Eric Auger <eric.auger@redhat.com> | ||
12 | Signed-off-by: Mostafa Saleh <smostafa@google.com> | ||
13 | Tested-by: Eric Auger <eric.auger@redhat.com> | ||
14 | Tested-by: Jean-Philippe Brucker <jean-philippe@linaro.org> | ||
15 | Message-id: 20230516203327.2051088-9-smostafa@google.com | ||
16 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
17 | --- | ||
18 | include/hw/arm/smmu-common.h | 1 + | ||
19 | hw/arm/smmu-common.c | 16 +++++++++++ | ||
20 | hw/arm/smmuv3.c | 55 ++++++++++++++++++++++++++++++------ | ||
21 | hw/arm/trace-events | 4 ++- | ||
22 | 4 files changed, 67 insertions(+), 9 deletions(-) | ||
23 | |||
24 | diff --git a/include/hw/arm/smmu-common.h b/include/hw/arm/smmu-common.h | ||
25 | index XXXXXXX..XXXXXXX 100644 | ||
26 | --- a/include/hw/arm/smmu-common.h | ||
27 | +++ b/include/hw/arm/smmu-common.h | ||
28 | @@ -XXX,XX +XXX,XX @@ SMMUIOTLBKey smmu_get_iotlb_key(uint16_t asid, uint16_t vmid, uint64_t iova, | ||
29 | uint8_t tg, uint8_t level); | ||
30 | void smmu_iotlb_inv_all(SMMUState *s); | ||
31 | void smmu_iotlb_inv_asid(SMMUState *s, uint16_t asid); | ||
32 | +void smmu_iotlb_inv_vmid(SMMUState *s, uint16_t vmid); | ||
33 | void smmu_iotlb_inv_iova(SMMUState *s, int asid, int vmid, dma_addr_t iova, | ||
34 | uint8_t tg, uint64_t num_pages, uint8_t ttl); | ||
35 | |||
36 | diff --git a/hw/arm/smmu-common.c b/hw/arm/smmu-common.c | ||
37 | index XXXXXXX..XXXXXXX 100644 | ||
38 | --- a/hw/arm/smmu-common.c | ||
39 | +++ b/hw/arm/smmu-common.c | ||
40 | @@ -XXX,XX +XXX,XX @@ static gboolean smmu_hash_remove_by_asid(gpointer key, gpointer value, | ||
41 | |||
42 | return SMMU_IOTLB_ASID(*iotlb_key) == asid; | ||
43 | } | ||
44 | + | ||
45 | +static gboolean smmu_hash_remove_by_vmid(gpointer key, gpointer value, | ||
46 | + gpointer user_data) | ||
47 | +{ | ||
48 | + uint16_t vmid = *(uint16_t *)user_data; | ||
49 | + SMMUIOTLBKey *iotlb_key = (SMMUIOTLBKey *)key; | ||
50 | + | ||
51 | + return SMMU_IOTLB_VMID(*iotlb_key) == vmid; | ||
52 | +} | ||
53 | + | ||
54 | static gboolean smmu_hash_remove_by_asid_vmid_iova(gpointer key, gpointer value, | ||
55 | gpointer user_data) | ||
56 | { | ||
57 | @@ -XXX,XX +XXX,XX @@ void smmu_iotlb_inv_asid(SMMUState *s, uint16_t asid) | ||
58 | g_hash_table_foreach_remove(s->iotlb, smmu_hash_remove_by_asid, &asid); | ||
59 | } | ||
60 | |||
61 | +inline void smmu_iotlb_inv_vmid(SMMUState *s, uint16_t vmid) | ||
62 | +{ | ||
63 | + trace_smmu_iotlb_inv_vmid(vmid); | ||
64 | + g_hash_table_foreach_remove(s->iotlb, smmu_hash_remove_by_vmid, &vmid); | ||
65 | +} | ||
66 | + | ||
67 | /* VMSAv8-64 Translation */ | ||
68 | |||
69 | /** | ||
70 | diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c | ||
71 | index XXXXXXX..XXXXXXX 100644 | ||
72 | --- a/hw/arm/smmuv3.c | ||
73 | +++ b/hw/arm/smmuv3.c | ||
74 | @@ -XXX,XX +XXX,XX @@ static void smmuv3_inv_notifiers_iova(SMMUState *s, int asid, dma_addr_t iova, | ||
75 | } | ||
76 | } | ||
77 | |||
78 | -static void smmuv3_s1_range_inval(SMMUState *s, Cmd *cmd) | ||
79 | +static void smmuv3_range_inval(SMMUState *s, Cmd *cmd) | ||
80 | { | ||
81 | dma_addr_t end, addr = CMD_ADDR(cmd); | ||
82 | uint8_t type = CMD_TYPE(cmd); | ||
83 | @@ -XXX,XX +XXX,XX @@ static void smmuv3_s1_range_inval(SMMUState *s, Cmd *cmd) | ||
84 | } | ||
85 | |||
86 | if (!tg) { | ||
87 | - trace_smmuv3_s1_range_inval(vmid, asid, addr, tg, 1, ttl, leaf); | ||
88 | + trace_smmuv3_range_inval(vmid, asid, addr, tg, 1, ttl, leaf); | ||
89 | smmuv3_inv_notifiers_iova(s, asid, addr, tg, 1); | ||
90 | smmu_iotlb_inv_iova(s, asid, vmid, addr, tg, 1, ttl); | ||
91 | return; | ||
92 | @@ -XXX,XX +XXX,XX @@ static void smmuv3_s1_range_inval(SMMUState *s, Cmd *cmd) | ||
93 | uint64_t mask = dma_aligned_pow2_mask(addr, end, 64); | ||
94 | |||
95 | num_pages = (mask + 1) >> granule; | ||
96 | - trace_smmuv3_s1_range_inval(vmid, asid, addr, tg, num_pages, ttl, leaf); | ||
97 | + trace_smmuv3_range_inval(vmid, asid, addr, tg, num_pages, ttl, leaf); | ||
98 | smmuv3_inv_notifiers_iova(s, asid, addr, tg, num_pages); | ||
99 | smmu_iotlb_inv_iova(s, asid, vmid, addr, tg, num_pages, ttl); | ||
100 | addr += mask + 1; | ||
101 | @@ -XXX,XX +XXX,XX @@ static int smmuv3_cmdq_consume(SMMUv3State *s) | ||
102 | { | ||
103 | uint16_t asid = CMD_ASID(&cmd); | ||
104 | |||
105 | + if (!STAGE1_SUPPORTED(s)) { | ||
106 | + cmd_error = SMMU_CERROR_ILL; | ||
107 | + break; | ||
108 | + } | ||
109 | + | ||
110 | trace_smmuv3_cmdq_tlbi_nh_asid(asid); | ||
111 | smmu_inv_notifiers_all(&s->smmu_state); | ||
112 | smmu_iotlb_inv_asid(bs, asid); | ||
113 | break; | ||
114 | } | ||
115 | case SMMU_CMD_TLBI_NH_ALL: | ||
116 | + if (!STAGE1_SUPPORTED(s)) { | ||
117 | + cmd_error = SMMU_CERROR_ILL; | ||
118 | + break; | ||
119 | + } | ||
120 | + QEMU_FALLTHROUGH; | ||
121 | case SMMU_CMD_TLBI_NSNH_ALL: | ||
122 | trace_smmuv3_cmdq_tlbi_nh(); | ||
123 | smmu_inv_notifiers_all(&s->smmu_state); | ||
124 | @@ -XXX,XX +XXX,XX @@ static int smmuv3_cmdq_consume(SMMUv3State *s) | ||
125 | break; | ||
126 | case SMMU_CMD_TLBI_NH_VAA: | ||
127 | case SMMU_CMD_TLBI_NH_VA: | ||
128 | - smmuv3_s1_range_inval(bs, &cmd); | ||
129 | + if (!STAGE1_SUPPORTED(s)) { | ||
130 | + cmd_error = SMMU_CERROR_ILL; | ||
131 | + break; | ||
132 | + } | ||
133 | + smmuv3_range_inval(bs, &cmd); | ||
134 | + break; | ||
135 | + case SMMU_CMD_TLBI_S12_VMALL: | ||
136 | + { | ||
137 | + uint16_t vmid = CMD_VMID(&cmd); | ||
138 | + | ||
139 | + if (!STAGE2_SUPPORTED(s)) { | ||
140 | + cmd_error = SMMU_CERROR_ILL; | ||
141 | + break; | ||
142 | + } | ||
143 | + | ||
144 | + trace_smmuv3_cmdq_tlbi_s12_vmid(vmid); | ||
145 | + smmu_inv_notifiers_all(&s->smmu_state); | ||
146 | + smmu_iotlb_inv_vmid(bs, vmid); | ||
147 | + break; | ||
148 | + } | ||
149 | + case SMMU_CMD_TLBI_S2_IPA: | ||
150 | + if (!STAGE2_SUPPORTED(s)) { | ||
151 | + cmd_error = SMMU_CERROR_ILL; | ||
152 | + break; | ||
153 | + } | ||
154 | + /* | ||
155 | + * As currently only either s1 or s2 are supported | ||
156 | + * we can reuse same function for s2. | ||
157 | + */ | ||
158 | + smmuv3_range_inval(bs, &cmd); | ||
159 | break; | ||
160 | case SMMU_CMD_TLBI_EL3_ALL: | ||
161 | case SMMU_CMD_TLBI_EL3_VA: | ||
162 | @@ -XXX,XX +XXX,XX @@ static int smmuv3_cmdq_consume(SMMUv3State *s) | ||
163 | case SMMU_CMD_TLBI_EL2_ASID: | ||
164 | case SMMU_CMD_TLBI_EL2_VA: | ||
165 | case SMMU_CMD_TLBI_EL2_VAA: | ||
166 | - case SMMU_CMD_TLBI_S12_VMALL: | ||
167 | - case SMMU_CMD_TLBI_S2_IPA: | ||
168 | case SMMU_CMD_ATC_INV: | ||
169 | case SMMU_CMD_PRI_RESP: | ||
170 | case SMMU_CMD_RESUME: | ||
171 | @@ -XXX,XX +XXX,XX @@ static int smmuv3_cmdq_consume(SMMUv3State *s) | ||
172 | break; | ||
173 | default: | ||
174 | cmd_error = SMMU_CERROR_ILL; | ||
175 | - qemu_log_mask(LOG_GUEST_ERROR, | ||
176 | - "Illegal command type: %d\n", CMD_TYPE(&cmd)); | ||
177 | break; | ||
178 | } | ||
179 | qemu_mutex_unlock(&s->mutex); | ||
180 | if (cmd_error) { | ||
181 | + if (cmd_error == SMMU_CERROR_ILL) { | ||
182 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
183 | + "Illegal command type: %d\n", CMD_TYPE(&cmd)); | ||
184 | + } | ||
185 | break; | ||
186 | } | ||
187 | /* | ||
188 | diff --git a/hw/arm/trace-events b/hw/arm/trace-events | ||
189 | index XXXXXXX..XXXXXXX 100644 | ||
190 | --- a/hw/arm/trace-events | ||
191 | +++ b/hw/arm/trace-events | ||
192 | @@ -XXX,XX +XXX,XX @@ smmu_ptw_block_pte(int stage, int level, uint64_t baseaddr, uint64_t pteaddr, ui | ||
193 | smmu_get_pte(uint64_t baseaddr, int index, uint64_t pteaddr, uint64_t pte) "baseaddr=0x%"PRIx64" index=0x%x, pteaddr=0x%"PRIx64", pte=0x%"PRIx64 | ||
194 | smmu_iotlb_inv_all(void) "IOTLB invalidate all" | ||
195 | smmu_iotlb_inv_asid(uint16_t asid) "IOTLB invalidate asid=%d" | ||
196 | +smmu_iotlb_inv_vmid(uint16_t vmid) "IOTLB invalidate vmid=%d" | ||
197 | smmu_iotlb_inv_iova(uint16_t asid, uint64_t addr) "IOTLB invalidate asid=%d addr=0x%"PRIx64 | ||
198 | smmu_inv_notifiers_mr(const char *name) "iommu mr=%s" | ||
199 | smmu_iotlb_lookup_hit(uint16_t asid, uint16_t vmid, uint64_t addr, uint32_t hit, uint32_t miss, uint32_t p) "IOTLB cache HIT asid=%d vmid=%d addr=0x%"PRIx64" hit=%d miss=%d hit rate=%d" | ||
200 | @@ -XXX,XX +XXX,XX @@ smmuv3_cmdq_cfgi_ste_range(int start, int end) "start=0x%x - end=0x%x" | ||
201 | smmuv3_cmdq_cfgi_cd(uint32_t sid) "sid=0x%x" | ||
202 | smmuv3_config_cache_hit(uint32_t sid, uint32_t hits, uint32_t misses, uint32_t perc) "Config cache HIT for sid=0x%x (hits=%d, misses=%d, hit rate=%d)" | ||
203 | smmuv3_config_cache_miss(uint32_t sid, uint32_t hits, uint32_t misses, uint32_t perc) "Config cache MISS for sid=0x%x (hits=%d, misses=%d, hit rate=%d)" | ||
204 | -smmuv3_s1_range_inval(int vmid, int asid, uint64_t addr, uint8_t tg, uint64_t num_pages, uint8_t ttl, bool leaf) "vmid=%d asid=%d addr=0x%"PRIx64" tg=%d num_pages=0x%"PRIx64" ttl=%d leaf=%d" | ||
205 | +smmuv3_range_inval(int vmid, int asid, uint64_t addr, uint8_t tg, uint64_t num_pages, uint8_t ttl, bool leaf) "vmid=%d asid=%d addr=0x%"PRIx64" tg=%d num_pages=0x%"PRIx64" ttl=%d leaf=%d" | ||
206 | smmuv3_cmdq_tlbi_nh(void) "" | ||
207 | smmuv3_cmdq_tlbi_nh_asid(uint16_t asid) "asid=%d" | ||
208 | +smmuv3_cmdq_tlbi_s12_vmid(uint16_t vmid) "vmid=%d" | ||
209 | smmuv3_config_cache_inv(uint32_t sid) "Config cache INV for sid=0x%x" | ||
210 | smmuv3_notify_flag_add(const char *iommu) "ADD SMMUNotifier node for iommu mr=%s" | ||
211 | smmuv3_notify_flag_del(const char *iommu) "DEL SMMUNotifier node for iommu mr=%s" | ||
212 | -- | ||
213 | 2.34.1 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Mostafa Saleh <smostafa@google.com> |
---|---|---|---|
2 | 2 | ||
3 | Currently, our only caller is sve_zcr_len_for_el, which has | 3 | In smmuv3_notify_iova, read the granule based on translation stage |
4 | already masked the length extracted from ZCR_ELx, so the | 4 | and use VMID if valid value is sent. |
5 | masking done here is a nop. But we will shortly have uses | ||
6 | from other locations, where the length will be unmasked. | ||
7 | 5 | ||
8 | Saturate the length to ARM_MAX_VQ instead of truncating to | 6 | Signed-off-by: Mostafa Saleh <smostafa@google.com> |
9 | the low 4 bits. | 7 | Reviewed-by: Eric Auger <eric.auger@redhat.com> |
10 | 8 | Tested-by: Eric Auger <eric.auger@redhat.com> | |
11 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 9 | Tested-by: Jean-Philippe Brucker <jean-philippe@linaro.org> |
12 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Message-id: 20230516203327.2051088-10-smostafa@google.com |
13 | Message-id: 20210723203344.968563-2-richard.henderson@linaro.org | ||
14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
15 | --- | 12 | --- |
16 | target/arm/helper.c | 4 +++- | 13 | hw/arm/smmuv3.c | 39 ++++++++++++++++++++++++++------------- |
17 | 1 file changed, 3 insertions(+), 1 deletion(-) | 14 | hw/arm/trace-events | 2 +- |
15 | 2 files changed, 27 insertions(+), 14 deletions(-) | ||
18 | 16 | ||
19 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 17 | diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c |
20 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
21 | --- a/target/arm/helper.c | 19 | --- a/hw/arm/smmuv3.c |
22 | +++ b/target/arm/helper.c | 20 | +++ b/hw/arm/smmuv3.c |
23 | @@ -XXX,XX +XXX,XX @@ static uint32_t sve_zcr_get_valid_len(ARMCPU *cpu, uint32_t start_len) | 21 | @@ -XXX,XX +XXX,XX @@ epilogue: |
22 | * @mr: IOMMU mr region handle | ||
23 | * @n: notifier to be called | ||
24 | * @asid: address space ID or negative value if we don't care | ||
25 | + * @vmid: virtual machine ID or negative value if we don't care | ||
26 | * @iova: iova | ||
27 | * @tg: translation granule (if communicated through range invalidation) | ||
28 | * @num_pages: number of @granule sized pages (if tg != 0), otherwise 1 | ||
29 | */ | ||
30 | static void smmuv3_notify_iova(IOMMUMemoryRegion *mr, | ||
31 | IOMMUNotifier *n, | ||
32 | - int asid, dma_addr_t iova, | ||
33 | - uint8_t tg, uint64_t num_pages) | ||
34 | + int asid, int vmid, | ||
35 | + dma_addr_t iova, uint8_t tg, | ||
36 | + uint64_t num_pages) | ||
24 | { | 37 | { |
25 | uint32_t end_len; | 38 | SMMUDevice *sdev = container_of(mr, SMMUDevice, iommu); |
26 | 39 | IOMMUTLBEvent event; | |
27 | - end_len = start_len &= 0xf; | 40 | uint8_t granule; |
28 | + start_len = MIN(start_len, ARM_MAX_VQ - 1); | 41 | + SMMUv3State *s = sdev->smmu; |
29 | + end_len = start_len; | 42 | |
43 | if (!tg) { | ||
44 | SMMUEventInfo event = {.inval_ste_allowed = true}; | ||
45 | @@ -XXX,XX +XXX,XX @@ static void smmuv3_notify_iova(IOMMUMemoryRegion *mr, | ||
46 | return; | ||
47 | } | ||
48 | |||
49 | - tt = select_tt(cfg, iova); | ||
50 | - if (!tt) { | ||
51 | + if (vmid >= 0 && cfg->s2cfg.vmid != vmid) { | ||
52 | return; | ||
53 | } | ||
54 | - granule = tt->granule_sz; | ||
30 | + | 55 | + |
31 | if (!test_bit(start_len, cpu->sve_vq_map)) { | 56 | + if (STAGE1_SUPPORTED(s)) { |
32 | end_len = find_last_bit(cpu->sve_vq_map, start_len); | 57 | + tt = select_tt(cfg, iova); |
33 | assert(end_len < start_len); | 58 | + if (!tt) { |
59 | + return; | ||
60 | + } | ||
61 | + granule = tt->granule_sz; | ||
62 | + } else { | ||
63 | + granule = cfg->s2cfg.granule_sz; | ||
64 | + } | ||
65 | + | ||
66 | } else { | ||
67 | granule = tg * 2 + 10; | ||
68 | } | ||
69 | @@ -XXX,XX +XXX,XX @@ static void smmuv3_notify_iova(IOMMUMemoryRegion *mr, | ||
70 | memory_region_notify_iommu_one(n, &event); | ||
71 | } | ||
72 | |||
73 | -/* invalidate an asid/iova range tuple in all mr's */ | ||
74 | -static void smmuv3_inv_notifiers_iova(SMMUState *s, int asid, dma_addr_t iova, | ||
75 | - uint8_t tg, uint64_t num_pages) | ||
76 | +/* invalidate an asid/vmid/iova range tuple in all mr's */ | ||
77 | +static void smmuv3_inv_notifiers_iova(SMMUState *s, int asid, int vmid, | ||
78 | + dma_addr_t iova, uint8_t tg, | ||
79 | + uint64_t num_pages) | ||
80 | { | ||
81 | SMMUDevice *sdev; | ||
82 | |||
83 | @@ -XXX,XX +XXX,XX @@ static void smmuv3_inv_notifiers_iova(SMMUState *s, int asid, dma_addr_t iova, | ||
84 | IOMMUMemoryRegion *mr = &sdev->iommu; | ||
85 | IOMMUNotifier *n; | ||
86 | |||
87 | - trace_smmuv3_inv_notifiers_iova(mr->parent_obj.name, asid, iova, | ||
88 | - tg, num_pages); | ||
89 | + trace_smmuv3_inv_notifiers_iova(mr->parent_obj.name, asid, vmid, | ||
90 | + iova, tg, num_pages); | ||
91 | |||
92 | IOMMU_NOTIFIER_FOREACH(n, mr) { | ||
93 | - smmuv3_notify_iova(mr, n, asid, iova, tg, num_pages); | ||
94 | + smmuv3_notify_iova(mr, n, asid, vmid, iova, tg, num_pages); | ||
95 | } | ||
96 | } | ||
97 | } | ||
98 | @@ -XXX,XX +XXX,XX @@ static void smmuv3_range_inval(SMMUState *s, Cmd *cmd) | ||
99 | |||
100 | if (!tg) { | ||
101 | trace_smmuv3_range_inval(vmid, asid, addr, tg, 1, ttl, leaf); | ||
102 | - smmuv3_inv_notifiers_iova(s, asid, addr, tg, 1); | ||
103 | + smmuv3_inv_notifiers_iova(s, asid, vmid, addr, tg, 1); | ||
104 | smmu_iotlb_inv_iova(s, asid, vmid, addr, tg, 1, ttl); | ||
105 | return; | ||
106 | } | ||
107 | @@ -XXX,XX +XXX,XX @@ static void smmuv3_range_inval(SMMUState *s, Cmd *cmd) | ||
108 | |||
109 | num_pages = (mask + 1) >> granule; | ||
110 | trace_smmuv3_range_inval(vmid, asid, addr, tg, num_pages, ttl, leaf); | ||
111 | - smmuv3_inv_notifiers_iova(s, asid, addr, tg, num_pages); | ||
112 | + smmuv3_inv_notifiers_iova(s, asid, vmid, addr, tg, num_pages); | ||
113 | smmu_iotlb_inv_iova(s, asid, vmid, addr, tg, num_pages, ttl); | ||
114 | addr += mask + 1; | ||
115 | } | ||
116 | diff --git a/hw/arm/trace-events b/hw/arm/trace-events | ||
117 | index XXXXXXX..XXXXXXX 100644 | ||
118 | --- a/hw/arm/trace-events | ||
119 | +++ b/hw/arm/trace-events | ||
120 | @@ -XXX,XX +XXX,XX @@ smmuv3_cmdq_tlbi_s12_vmid(uint16_t vmid) "vmid=%d" | ||
121 | smmuv3_config_cache_inv(uint32_t sid) "Config cache INV for sid=0x%x" | ||
122 | smmuv3_notify_flag_add(const char *iommu) "ADD SMMUNotifier node for iommu mr=%s" | ||
123 | smmuv3_notify_flag_del(const char *iommu) "DEL SMMUNotifier node for iommu mr=%s" | ||
124 | -smmuv3_inv_notifiers_iova(const char *name, uint16_t asid, uint64_t iova, uint8_t tg, uint64_t num_pages) "iommu mr=%s asid=%d iova=0x%"PRIx64" tg=%d num_pages=0x%"PRIx64 | ||
125 | +smmuv3_inv_notifiers_iova(const char *name, uint16_t asid, uint16_t vmid, uint64_t iova, uint8_t tg, uint64_t num_pages) "iommu mr=%s asid=%d vmid=%d iova=0x%"PRIx64" tg=%d num_pages=0x%"PRIx64 | ||
126 | |||
34 | -- | 127 | -- |
35 | 2.20.1 | 128 | 2.34.1 |
36 | |||
37 | diff view generated by jsdifflib |
1 | From: Joel Stanley <joel@jms.id.au> | 1 | From: Mostafa Saleh <smostafa@google.com> |
---|---|---|---|
2 | 2 | ||
3 | The macro used to calculate the maximum memory size of the MMIO region | 3 | As everything is in place, we can use a new system property to |
4 | had a mistake, causing all GPIO models to create a mapping of 0x9D8. | 4 | advertise which stage is supported and remove bad_ste from STE |
5 | The intent was to have it be 0x9D8 - 0x800. | 5 | stage2 config. |
6 | 6 | ||
7 | This extra size doesn't matter on ast2400 and ast2500, which have a 4KB | 7 | The property added arm-smmuv3.stage can have 3 values: |
8 | region set aside for the GPIO controller. | 8 | - "1": Stage-1 only is advertised. |
9 | - "2": Stage-2 only is advertised. | ||
9 | 10 | ||
10 | On the ast2600 the 3.3V and 1.8V GPIO controllers are 2KB apart, so the | 11 | If not passed or an unsupported value is passed, it will default to |
11 | regions would overlap. Worse was the 1.8V controller would map over the | 12 | stage-1. |
12 | top of the following peripheral, which happens to be the RTC. | ||
13 | 13 | ||
14 | The mmio region used by each device is a maximum of 2KB, so avoid the | 14 | Advertise VMID16. |
15 | calculations and hard code this as the maximum. | ||
16 | 15 | ||
17 | Fixes: 36d737ee82b2 ("hw/gpio: Add in AST2600 specific implementation") | 16 | Don't try to decode CD, if stage-2 is configured. |
18 | Signed-off-by: Joel Stanley <joel@jms.id.au> | 17 | |
19 | Reviewed-by: Rashmica Gupta <rashmica.g@gmail.com> | 18 | Reviewed-by: Eric Auger <eric.auger@redhat.com> |
20 | Reviewed-by: Cédric Le Goater <clg@kaod.org> | 19 | Signed-off-by: Mostafa Saleh <smostafa@google.com> |
21 | Message-id: 20210713065854.134634-2-joel@jms.id.au | 20 | Tested-by: Eric Auger <eric.auger@redhat.com> |
22 | [PMM: fix autocorrect error in commit message] | 21 | Tested-by: Jean-Philippe Brucker <jean-philippe@linaro.org> |
22 | Message-id: 20230516203327.2051088-11-smostafa@google.com | ||
23 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 23 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
24 | --- | 24 | --- |
25 | hw/gpio/aspeed_gpio.c | 3 +-- | 25 | include/hw/arm/smmuv3.h | 1 + |
26 | 1 file changed, 1 insertion(+), 2 deletions(-) | 26 | hw/arm/smmuv3.c | 32 ++++++++++++++++++++++---------- |
27 | 2 files changed, 23 insertions(+), 10 deletions(-) | ||
27 | 28 | ||
28 | diff --git a/hw/gpio/aspeed_gpio.c b/hw/gpio/aspeed_gpio.c | 29 | diff --git a/include/hw/arm/smmuv3.h b/include/hw/arm/smmuv3.h |
29 | index XXXXXXX..XXXXXXX 100644 | 30 | index XXXXXXX..XXXXXXX 100644 |
30 | --- a/hw/gpio/aspeed_gpio.c | 31 | --- a/include/hw/arm/smmuv3.h |
31 | +++ b/hw/gpio/aspeed_gpio.c | 32 | +++ b/include/hw/arm/smmuv3.h |
33 | @@ -XXX,XX +XXX,XX @@ struct SMMUv3State { | ||
34 | |||
35 | qemu_irq irq[4]; | ||
36 | QemuMutex mutex; | ||
37 | + char *stage; | ||
38 | }; | ||
39 | |||
40 | typedef enum { | ||
41 | diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c | ||
42 | index XXXXXXX..XXXXXXX 100644 | ||
43 | --- a/hw/arm/smmuv3.c | ||
44 | +++ b/hw/arm/smmuv3.c | ||
32 | @@ -XXX,XX +XXX,XX @@ | 45 | @@ -XXX,XX +XXX,XX @@ |
33 | #define GPIO_1_8V_MEM_SIZE 0x9D8 | 46 | #include "hw/irq.h" |
34 | #define GPIO_1_8V_REG_ARRAY_SIZE ((GPIO_1_8V_MEM_SIZE - \ | 47 | #include "hw/sysbus.h" |
35 | GPIO_1_8V_REG_OFFSET) >> 2) | 48 | #include "migration/vmstate.h" |
36 | -#define GPIO_MAX_MEM_SIZE MAX(GPIO_3_6V_MEM_SIZE, GPIO_1_8V_MEM_SIZE) | 49 | +#include "hw/qdev-properties.h" |
37 | 50 | #include "hw/qdev-core.h" | |
38 | static int aspeed_evaluate_irq(GPIOSets *regs, int gpio_prev_high, int gpio) | 51 | #include "hw/pci/pci.h" |
52 | #include "cpu.h" | ||
53 | @@ -XXX,XX +XXX,XX @@ void smmuv3_record_event(SMMUv3State *s, SMMUEventInfo *info) | ||
54 | |||
55 | static void smmuv3_init_regs(SMMUv3State *s) | ||
39 | { | 56 | { |
40 | @@ -XXX,XX +XXX,XX @@ static void aspeed_gpio_realize(DeviceState *dev, Error **errp) | 57 | - /** |
58 | - * IDR0: stage1 only, AArch64 only, coherent access, 16b ASID, | ||
59 | - * multi-level stream table | ||
60 | - */ | ||
61 | - s->idr[0] = FIELD_DP32(s->idr[0], IDR0, S1P, 1); /* stage 1 supported */ | ||
62 | + /* Based on sys property, the stages supported in smmu will be advertised.*/ | ||
63 | + if (s->stage && !strcmp("2", s->stage)) { | ||
64 | + s->idr[0] = FIELD_DP32(s->idr[0], IDR0, S2P, 1); | ||
65 | + } else { | ||
66 | + s->idr[0] = FIELD_DP32(s->idr[0], IDR0, S1P, 1); | ||
67 | + } | ||
68 | + | ||
69 | s->idr[0] = FIELD_DP32(s->idr[0], IDR0, TTF, 2); /* AArch64 PTW only */ | ||
70 | s->idr[0] = FIELD_DP32(s->idr[0], IDR0, COHACC, 1); /* IO coherent */ | ||
71 | s->idr[0] = FIELD_DP32(s->idr[0], IDR0, ASID16, 1); /* 16-bit ASID */ | ||
72 | + s->idr[0] = FIELD_DP32(s->idr[0], IDR0, VMID16, 1); /* 16-bit VMID */ | ||
73 | s->idr[0] = FIELD_DP32(s->idr[0], IDR0, TTENDIAN, 2); /* little endian */ | ||
74 | s->idr[0] = FIELD_DP32(s->idr[0], IDR0, STALL_MODEL, 1); /* No stall */ | ||
75 | /* terminated transaction will always be aborted/error returned */ | ||
76 | @@ -XXX,XX +XXX,XX @@ static int decode_ste_s2_cfg(SMMUTransCfg *cfg, STE *ste) | ||
77 | goto bad_ste; | ||
41 | } | 78 | } |
42 | 79 | ||
43 | memory_region_init_io(&s->iomem, OBJECT(s), &aspeed_gpio_ops, s, | 80 | - /* This is still here as stage 2 has not been fully enabled yet. */ |
44 | - TYPE_ASPEED_GPIO, GPIO_MAX_MEM_SIZE); | 81 | - qemu_log_mask(LOG_UNIMP, "SMMUv3 does not support stage 2 yet\n"); |
45 | + TYPE_ASPEED_GPIO, 0x800); | 82 | - goto bad_ste; |
46 | 83 | - | |
47 | sysbus_init_mmio(sbd, &s->iomem); | 84 | return 0; |
85 | |||
86 | bad_ste: | ||
87 | @@ -XXX,XX +XXX,XX @@ static int smmuv3_decode_config(IOMMUMemoryRegion *mr, SMMUTransCfg *cfg, | ||
88 | return ret; | ||
89 | } | ||
90 | |||
91 | - if (cfg->aborted || cfg->bypassed) { | ||
92 | + if (cfg->aborted || cfg->bypassed || (cfg->stage == 2)) { | ||
93 | return 0; | ||
94 | } | ||
95 | |||
96 | @@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_smmuv3 = { | ||
97 | } | ||
98 | }; | ||
99 | |||
100 | +static Property smmuv3_properties[] = { | ||
101 | + /* | ||
102 | + * Stages of translation advertised. | ||
103 | + * "1": Stage 1 | ||
104 | + * "2": Stage 2 | ||
105 | + * Defaults to stage 1 | ||
106 | + */ | ||
107 | + DEFINE_PROP_STRING("stage", SMMUv3State, stage), | ||
108 | + DEFINE_PROP_END_OF_LIST() | ||
109 | +}; | ||
110 | + | ||
111 | static void smmuv3_instance_init(Object *obj) | ||
112 | { | ||
113 | /* Nothing much to do here as of now */ | ||
114 | @@ -XXX,XX +XXX,XX @@ static void smmuv3_class_init(ObjectClass *klass, void *data) | ||
115 | &c->parent_phases); | ||
116 | c->parent_realize = dc->realize; | ||
117 | dc->realize = smmu_realize; | ||
118 | + device_class_set_props(dc, smmuv3_properties); | ||
48 | } | 119 | } |
120 | |||
121 | static int smmuv3_notify_flag_changed(IOMMUMemoryRegion *iommu, | ||
49 | -- | 122 | -- |
50 | 2.20.1 | 123 | 2.34.1 |
51 | |||
52 | diff view generated by jsdifflib |
1 | In Arm v8.1M the VECTPENDING field in the ICSR has new behaviour: if | 1 | From: Tommy Wu <tommy.wu@sifive.com> |
---|---|---|---|
2 | the register is accessed NonSecure and the highest priority pending | ||
3 | enabled exception (that would be returned in the VECTPENDING field) | ||
4 | targets Secure, then the VECTPENDING field must read 1 rather than | ||
5 | the exception number of the pending exception. Implement this. | ||
6 | 2 | ||
3 | When we receive a packet from the xilinx_axienet and then try to s2mem | ||
4 | through the xilinx_axidma, if the descriptor ring buffer is full in the | ||
5 | xilinx axidma driver, we’ll assert the DMASR.HALTED in the | ||
6 | function : stream_process_s2mem and return 0. In the end, we’ll be stuck in | ||
7 | an infinite loop in axienet_eth_rx_notify. | ||
8 | |||
9 | This patch checks the DMASR.HALTED state when we try to push data | ||
10 | from xilinx axi-enet to xilinx axi-dma. When the DMASR.HALTED is asserted, | ||
11 | we will not keep pushing the data and then prevent the infinte loop. | ||
12 | |||
13 | Signed-off-by: Tommy Wu <tommy.wu@sifive.com> | ||
14 | Reviewed-by: Edgar E. Iglesias <edgar@zeroasic.com> | ||
15 | Reviewed-by: Frank Chang <frank.chang@sifive.com> | ||
16 | Message-id: 20230519062137.1251741-1-tommy.wu@sifive.com | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 17 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Message-id: 20210723162146.5167-7-peter.maydell@linaro.org | ||
10 | --- | 18 | --- |
11 | hw/intc/armv7m_nvic.c | 31 ++++++++++++++++++++++++------- | 19 | hw/dma/xilinx_axidma.c | 11 ++++++++--- |
12 | 1 file changed, 24 insertions(+), 7 deletions(-) | 20 | 1 file changed, 8 insertions(+), 3 deletions(-) |
13 | 21 | ||
14 | diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c | 22 | diff --git a/hw/dma/xilinx_axidma.c b/hw/dma/xilinx_axidma.c |
15 | index XXXXXXX..XXXXXXX 100644 | 23 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/hw/intc/armv7m_nvic.c | 24 | --- a/hw/dma/xilinx_axidma.c |
17 | +++ b/hw/intc/armv7m_nvic.c | 25 | +++ b/hw/dma/xilinx_axidma.c |
18 | @@ -XXX,XX +XXX,XX @@ void armv7m_nvic_acknowledge_irq(void *opaque) | 26 | @@ -XXX,XX +XXX,XX @@ static inline int stream_idle(struct Stream *s) |
19 | nvic_irq_update(s); | 27 | return !!(s->regs[R_DMASR] & DMASR_IDLE); |
20 | } | 28 | } |
21 | 29 | ||
22 | +static bool vectpending_targets_secure(NVICState *s) | 30 | +static inline int stream_halted(struct Stream *s) |
23 | +{ | 31 | +{ |
24 | + /* Return true if s->vectpending targets Secure state */ | 32 | + return !!(s->regs[R_DMASR] & DMASR_HALTED); |
25 | + if (s->vectpending_is_s_banked) { | ||
26 | + return true; | ||
27 | + } | ||
28 | + return !exc_is_banked(s->vectpending) && | ||
29 | + exc_targets_secure(s, s->vectpending); | ||
30 | +} | 33 | +} |
31 | + | 34 | + |
32 | void armv7m_nvic_get_pending_irq_info(void *opaque, | 35 | static void stream_reset(struct Stream *s) |
33 | int *pirq, bool *ptargets_secure) | ||
34 | { | 36 | { |
35 | @@ -XXX,XX +XXX,XX @@ void armv7m_nvic_get_pending_irq_info(void *opaque, | 37 | s->regs[R_DMASR] = DMASR_HALTED; /* starts up halted. */ |
36 | 38 | @@ -XXX,XX +XXX,XX @@ static void stream_process_mem2s(struct Stream *s, StreamSink *tx_data_dev, | |
37 | assert(pending > ARMV7M_EXCP_RESET && pending < s->num_irq); | 39 | uint64_t addr; |
38 | 40 | bool eop; | |
39 | - if (s->vectpending_is_s_banked) { | 41 | |
40 | - targets_secure = true; | 42 | - if (!stream_running(s) || stream_idle(s)) { |
41 | - } else { | 43 | + if (!stream_running(s) || stream_idle(s) || stream_halted(s)) { |
42 | - targets_secure = !exc_is_banked(pending) && | 44 | return; |
43 | - exc_targets_secure(s, pending); | 45 | } |
44 | - } | 46 | |
45 | + targets_secure = vectpending_targets_secure(s); | 47 | @@ -XXX,XX +XXX,XX @@ static size_t stream_process_s2mem(struct Stream *s, unsigned char *buf, |
46 | 48 | unsigned int rxlen; | |
47 | trace_nvic_get_pending_irq_info(pending, targets_secure); | 49 | size_t pos = 0; |
48 | 50 | ||
49 | @@ -XXX,XX +XXX,XX @@ static uint32_t nvic_readl(NVICState *s, uint32_t offset, MemTxAttrs attrs) | 51 | - if (!stream_running(s) || stream_idle(s)) { |
50 | /* VECTACTIVE */ | 52 | + if (!stream_running(s) || stream_idle(s) || stream_halted(s)) { |
51 | val = cpu->env.v7m.exception; | 53 | return 0; |
52 | /* VECTPENDING */ | 54 | } |
53 | - val |= (s->vectpending & 0x1ff) << 12; | 55 | |
54 | + if (s->vectpending) { | 56 | @@ -XXX,XX +XXX,XX @@ xilinx_axidma_data_stream_can_push(StreamSink *obj, |
55 | + /* | 57 | XilinxAXIDMAStreamSink *ds = XILINX_AXI_DMA_DATA_STREAM(obj); |
56 | + * From v8.1M VECTPENDING must read as 1 if accessed as | 58 | struct Stream *s = &ds->dma->streams[1]; |
57 | + * NonSecure and the highest priority pending and enabled | 59 | |
58 | + * exception targets Secure. | 60 | - if (!stream_running(s) || stream_idle(s)) { |
59 | + */ | 61 | + if (!stream_running(s) || stream_idle(s) || stream_halted(s)) { |
60 | + int vp = s->vectpending; | 62 | ds->dma->notify = notify; |
61 | + if (!attrs.secure && arm_feature(&cpu->env, ARM_FEATURE_V8_1M) && | 63 | ds->dma->notify_opaque = notify_opaque; |
62 | + vectpending_targets_secure(s)) { | 64 | return false; |
63 | + vp = 1; | ||
64 | + } | ||
65 | + val |= (vp & 0x1ff) << 12; | ||
66 | + } | ||
67 | /* ISRPENDING - set if any external IRQ is pending */ | ||
68 | if (nvic_isrpending(s)) { | ||
69 | val |= (1 << 22); | ||
70 | -- | 65 | -- |
71 | 2.20.1 | 66 | 2.34.1 |
72 | 67 | ||
73 | 68 | diff view generated by jsdifflib |
1 | The VECTPENDING field in the ICSR is 9 bits wide, in bits [20:12] of | 1 | From: Clément Chigot <chigot@adacore.com> |
---|---|---|---|
2 | the register. We were incorrectly masking it to 8 bits, so it would | ||
3 | report the wrong value if the pending exception was greater than 256. | ||
4 | Fix the bug. | ||
5 | 2 | ||
3 | When passing --smp with a number lower than XLNX_ZYNQMP_NUM_APU_CPUS, | ||
4 | the expression (ms->smp.cpus - XLNX_ZYNQMP_NUM_APU_CPUS) will result | ||
5 | in a positive number as ms->smp.cpus is a unsigned int. | ||
6 | This will raise the following error afterwards, as Qemu will try to | ||
7 | instantiate some additional RPUs. | ||
8 | | $ qemu-system-aarch64 --smp 1 -M xlnx-zcu102 | ||
9 | | ** | ||
10 | | ERROR:../src/tcg/tcg.c:777:tcg_register_thread: | ||
11 | | assertion failed: (n < tcg_max_ctxs) | ||
12 | |||
13 | Signed-off-by: Clément Chigot <chigot@adacore.com> | ||
14 | Reviewed-by: Francisco Iglesias <frasse.iglesias@gmail.com> | ||
15 | Tested-by: Francisco Iglesias <frasse.iglesias@gmail.com> | ||
16 | Message-id: 20230524143714.565792-1-chigot@adacore.com | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 17 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20210723162146.5167-6-peter.maydell@linaro.org | ||
9 | --- | 18 | --- |
10 | hw/intc/armv7m_nvic.c | 2 +- | 19 | hw/arm/xlnx-zynqmp.c | 2 +- |
11 | 1 file changed, 1 insertion(+), 1 deletion(-) | 20 | 1 file changed, 1 insertion(+), 1 deletion(-) |
12 | 21 | ||
13 | diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c | 22 | diff --git a/hw/arm/xlnx-zynqmp.c b/hw/arm/xlnx-zynqmp.c |
14 | index XXXXXXX..XXXXXXX 100644 | 23 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/hw/intc/armv7m_nvic.c | 24 | --- a/hw/arm/xlnx-zynqmp.c |
16 | +++ b/hw/intc/armv7m_nvic.c | 25 | +++ b/hw/arm/xlnx-zynqmp.c |
17 | @@ -XXX,XX +XXX,XX @@ static uint32_t nvic_readl(NVICState *s, uint32_t offset, MemTxAttrs attrs) | 26 | @@ -XXX,XX +XXX,XX @@ static void xlnx_zynqmp_create_rpu(MachineState *ms, XlnxZynqMPState *s, |
18 | /* VECTACTIVE */ | 27 | const char *boot_cpu, Error **errp) |
19 | val = cpu->env.v7m.exception; | 28 | { |
20 | /* VECTPENDING */ | 29 | int i; |
21 | - val |= (s->vectpending & 0xff) << 12; | 30 | - int num_rpus = MIN(ms->smp.cpus - XLNX_ZYNQMP_NUM_APU_CPUS, |
22 | + val |= (s->vectpending & 0x1ff) << 12; | 31 | + int num_rpus = MIN((int)(ms->smp.cpus - XLNX_ZYNQMP_NUM_APU_CPUS), |
23 | /* ISRPENDING - set if any external IRQ is pending */ | 32 | XLNX_ZYNQMP_NUM_RPU_CPUS); |
24 | if (nvic_isrpending(s)) { | 33 | |
25 | val |= (1 << 22); | 34 | if (num_rpus <= 0) { |
26 | -- | 35 | -- |
27 | 2.20.1 | 36 | 2.34.1 |
28 | 37 | ||
29 | 38 | diff view generated by jsdifflib |
1 | From: Mao Zhongyi <maozhongyi@cmss.chinamobile.com> | 1 | From: Thomas Huth <thuth@redhat.com> |
---|---|---|---|
2 | 2 | ||
3 | Missed in commit f3478392 "docs: Move deprecation, build | 3 | pflash-cfi02-test.c always uses the "musicpal" machine for testing, |
4 | and license info out of system/" | 4 | test-arm-mptimer.c always uses the "vexpress-a9" machine, and |
5 | microbit-test.c requires the "microbit" machine, so we should only | ||
6 | run these tests if the machines have been enabled in the configuration. | ||
5 | 7 | ||
6 | Signed-off-by: Mao Zhongyi <maozhongyi@cmss.chinamobile.com> | 8 | Signed-off-by: Thomas Huth <thuth@redhat.com> |
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Reviewed-by: Fabiano Rosas <farosas@suse.de> |
8 | Message-id: 20210723065828.1336760-1-maozhongyi@cmss.chinamobile.com | 10 | Message-id: 20230524080600.1618137-1-thuth@redhat.com |
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | --- | 12 | --- |
11 | configure | 2 +- | 13 | tests/qtest/meson.build | 7 ++++--- |
12 | target/i386/cpu.c | 2 +- | 14 | 1 file changed, 4 insertions(+), 3 deletions(-) |
13 | MAINTAINERS | 2 +- | ||
14 | 3 files changed, 3 insertions(+), 3 deletions(-) | ||
15 | 15 | ||
16 | diff --git a/configure b/configure | 16 | diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build |
17 | index XXXXXXX..XXXXXXX 100755 | ||
18 | --- a/configure | ||
19 | +++ b/configure | ||
20 | @@ -XXX,XX +XXX,XX @@ fi | ||
21 | |||
22 | if test -n "${deprecated_features}"; then | ||
23 | echo "Warning, deprecated features enabled." | ||
24 | - echo "Please see docs/system/deprecated.rst" | ||
25 | + echo "Please see docs/about/deprecated.rst" | ||
26 | echo " features: ${deprecated_features}" | ||
27 | fi | ||
28 | |||
29 | diff --git a/target/i386/cpu.c b/target/i386/cpu.c | ||
30 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
31 | --- a/target/i386/cpu.c | 18 | --- a/tests/qtest/meson.build |
32 | +++ b/target/i386/cpu.c | 19 | +++ b/tests/qtest/meson.build |
33 | @@ -XXX,XX +XXX,XX @@ static const X86CPUDefinition builtin_x86_defs[] = { | 20 | @@ -XXX,XX +XXX,XX @@ qtests_arm = \ |
34 | * none", but this is just for compatibility while libvirt isn't | 21 | (config_all_devices.has_key('CONFIG_CMSDK_APB_DUALTIMER') ? ['cmsdk-apb-dualtimer-test'] : []) + \ |
35 | * adapted to resolve CPU model versions before creating VMs. | 22 | (config_all_devices.has_key('CONFIG_CMSDK_APB_TIMER') ? ['cmsdk-apb-timer-test'] : []) + \ |
36 | * See "Runnability guarantee of CPU models" at | 23 | (config_all_devices.has_key('CONFIG_CMSDK_APB_WATCHDOG') ? ['cmsdk-apb-watchdog-test'] : []) + \ |
37 | - * docs/system/deprecated.rst. | 24 | - (config_all_devices.has_key('CONFIG_PFLASH_CFI02') ? ['pflash-cfi02-test'] : []) + \ |
38 | + * docs/about/deprecated.rst. | 25 | + (config_all_devices.has_key('CONFIG_PFLASH_CFI02') and |
39 | */ | 26 | + config_all_devices.has_key('CONFIG_MUSICPAL') ? ['pflash-cfi02-test'] : []) + \ |
40 | X86CPUVersion default_cpu_version = 1; | 27 | (config_all_devices.has_key('CONFIG_ASPEED_SOC') ? qtests_aspeed : []) + \ |
41 | 28 | (config_all_devices.has_key('CONFIG_NPCM7XX') ? qtests_npcm7xx : []) + \ | |
42 | diff --git a/MAINTAINERS b/MAINTAINERS | 29 | (config_all_devices.has_key('CONFIG_GENERIC_LOADER') ? ['hexloader-test'] : []) + \ |
43 | index XXXXXXX..XXXXXXX 100644 | 30 | (config_all_devices.has_key('CONFIG_TPM_TIS_I2C') ? ['tpm-tis-i2c-test'] : []) + \ |
44 | --- a/MAINTAINERS | 31 | + (config_all_devices.has_key('CONFIG_VEXPRESS') ? ['test-arm-mptimer'] : []) + \ |
45 | +++ b/MAINTAINERS | 32 | + (config_all_devices.has_key('CONFIG_MICROBIT') ? ['microbit-test'] : []) + \ |
46 | @@ -XXX,XX +XXX,XX @@ F: contrib/gitdm/* | 33 | ['arm-cpu-features', |
47 | 34 | - 'microbit-test', | |
48 | Incompatible changes | 35 | - 'test-arm-mptimer', |
49 | R: libvir-list@redhat.com | 36 | 'boot-serial-test'] |
50 | -F: docs/system/deprecated.rst | 37 | |
51 | +F: docs/about/deprecated.rst | 38 | # TODO: once aarch64 TCG is fixed on ARM 32 bit host, make bios-tables-test unconditional |
52 | |||
53 | Build System | ||
54 | ------------ | ||
55 | -- | 39 | -- |
56 | 2.20.1 | 40 | 2.34.1 |
57 | |||
58 | diff view generated by jsdifflib |
1 | The ISCR.ISRPENDING bit is set when an external interrupt is pending. | 1 | For M-profile, there is no guest-facing A-profile format FSR, but we |
---|---|---|---|
2 | This is true whether that external interrupt is enabled or not. | 2 | still use the env->exception.fsr field to pass fault information from |
3 | This means that we can't use 's->vectpending == 0' as a shortcut to | 3 | the point where a fault is raised to the code in |
4 | "ISRPENDING is zero", because s->vectpending indicates only the | 4 | arm_v7m_cpu_do_interrupt() which interprets it and sets the M-profile |
5 | highest priority pending enabled interrupt. | 5 | specific fault status registers. So it doesn't matter whether we |
6 | fill in env->exception.fsr in the short format or the LPAE format, as | ||
7 | long as both sides agree. As it happens arm_v7m_cpu_do_interrupt() | ||
8 | assumes short-form. | ||
6 | 9 | ||
7 | Remove the incorrect optimization so that if there is no pending | 10 | In compute_fsr_fsc() we weren't explicitly choosing short-form for |
8 | enabled interrupt we fall through to scanning through the whole | 11 | M-profile, but instead relied on it falling out in the wash because |
9 | interrupt array. | 12 | arm_s1_regime_using_lpae_format() would be false. This was broken in |
13 | commit 452c67a4 when we added v8R support, because we said "PMSAv8 is | ||
14 | always LPAE format" (as it is for v8R), forgetting that we were | ||
15 | implicitly using this code path on M-profile. At that point we would | ||
16 | hit a g_assert_not_reached(): | ||
17 | ERROR:../../target/arm/internals.h:549:arm_fi_to_lfsc: code should not be reached | ||
10 | 18 | ||
19 | #7 0x0000555555e055f7 in arm_fi_to_lfsc (fi=0x7fffecff9a90) at ../../target/arm/internals.h:549 | ||
20 | #8 0x0000555555e05a27 in compute_fsr_fsc (env=0x555557356670, fi=0x7fffecff9a90, target_el=1, mmu_idx=1, ret_fsc=0x7fffecff9a1c) | ||
21 | at ../../target/arm/tlb_helper.c:95 | ||
22 | #9 0x0000555555e05b62 in arm_deliver_fault (cpu=0x555557354800, addr=268961344, access_type=MMU_INST_FETCH, mmu_idx=1, fi=0x7fffecff9a90) | ||
23 | at ../../target/arm/tlb_helper.c:132 | ||
24 | #10 0x0000555555e06095 in arm_cpu_tlb_fill (cs=0x555557354800, address=268961344, size=1, access_type=MMU_INST_FETCH, mmu_idx=1, probe=false, retaddr=0) | ||
25 | at ../../target/arm/tlb_helper.c:260 | ||
26 | |||
27 | The specific assertion changed when commit fcc7404eff24b4c added | ||
28 | "assert not M-profile" to arm_is_secure_below_el3(), because the | ||
29 | conditions being checked in compute_fsr_fsc() include | ||
30 | arm_el_is_aa64(), which will end up calling arm_is_secure_below_el3() | ||
31 | and asserting before we try to call arm_fi_to_lfsc(): | ||
32 | |||
33 | #7 0x0000555555efaf43 in arm_is_secure_below_el3 (env=0x5555574665a0) at ../../target/arm/cpu.h:2396 | ||
34 | #8 0x0000555555efb103 in arm_is_el2_enabled (env=0x5555574665a0) at ../../target/arm/cpu.h:2448 | ||
35 | #9 0x0000555555efb204 in arm_el_is_aa64 (env=0x5555574665a0, el=1) at ../../target/arm/cpu.h:2509 | ||
36 | #10 0x0000555555efbdfd in compute_fsr_fsc (env=0x5555574665a0, fi=0x7fffecff99e0, target_el=1, mmu_idx=1, ret_fsc=0x7fffecff996c) | ||
37 | |||
38 | Avoid the assertion and the incorrect FSR format selection by | ||
39 | explicitly making M-profile use the short-format in this function. | ||
40 | |||
41 | Fixes: 452c67a42704 ("target/arm: Enable TTBCR_EAE for ARMv8-R AArch32")a | ||
42 | Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1658 | ||
43 | Cc: qemu-stable@nongnu.org | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 44 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
12 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 45 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
13 | Message-id: 20210723162146.5167-5-peter.maydell@linaro.org | 46 | Message-id: 20230523131726.866635-1-peter.maydell@linaro.org |
14 | --- | 47 | --- |
15 | hw/intc/armv7m_nvic.c | 9 ++++----- | 48 | target/arm/tcg/tlb_helper.c | 13 +++++++++++-- |
16 | 1 file changed, 4 insertions(+), 5 deletions(-) | 49 | 1 file changed, 11 insertions(+), 2 deletions(-) |
17 | 50 | ||
18 | diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c | 51 | diff --git a/target/arm/tcg/tlb_helper.c b/target/arm/tcg/tlb_helper.c |
19 | index XXXXXXX..XXXXXXX 100644 | 52 | index XXXXXXX..XXXXXXX 100644 |
20 | --- a/hw/intc/armv7m_nvic.c | 53 | --- a/target/arm/tcg/tlb_helper.c |
21 | +++ b/hw/intc/armv7m_nvic.c | 54 | +++ b/target/arm/tcg/tlb_helper.c |
22 | @@ -XXX,XX +XXX,XX @@ static bool nvic_isrpending(NVICState *s) | 55 | @@ -XXX,XX +XXX,XX @@ static uint32_t compute_fsr_fsc(CPUARMState *env, ARMMMUFaultInfo *fi, |
23 | { | 56 | ARMMMUIdx arm_mmu_idx = core_to_arm_mmu_idx(env, mmu_idx); |
24 | int irq; | 57 | uint32_t fsr, fsc; |
25 | 58 | ||
26 | - /* We can shortcut if the highest priority pending interrupt | 59 | - if (target_el == 2 || arm_el_is_aa64(env, target_el) || |
27 | - * happens to be external or if there is nothing pending. | 60 | - arm_s1_regime_using_lpae_format(env, arm_mmu_idx)) { |
28 | + /* | 61 | + /* |
29 | + * We can shortcut if the highest priority pending interrupt | 62 | + * For M-profile there is no guest-facing FSR. We compute a |
30 | + * happens to be external; if not we need to check the whole | 63 | + * short-form value for env->exception.fsr which we will then |
31 | + * vectors[] array. | 64 | + * examine in arm_v7m_cpu_do_interrupt(). In theory we could |
32 | */ | 65 | + * use the LPAE format instead as long as both bits of code agree |
33 | if (s->vectpending > NVIC_FIRST_IRQ) { | 66 | + * (and arm_fi_to_lfsc() handled the M-profile specific |
34 | return true; | 67 | + * ARMFault_QEMU_NSCExec and ARMFault_QEMU_SFault cases). |
35 | } | 68 | + */ |
36 | - if (s->vectpending == 0) { | 69 | + if (!arm_feature(env, ARM_FEATURE_M) && |
37 | - return false; | 70 | + (target_el == 2 || arm_el_is_aa64(env, target_el) || |
38 | - } | 71 | + arm_s1_regime_using_lpae_format(env, arm_mmu_idx))) { |
39 | 72 | /* | |
40 | for (irq = NVIC_FIRST_IRQ; irq < s->num_irq; irq++) { | 73 | * LPAE format fault status register : bottom 6 bits are |
41 | if (s->vectors[irq].pending) { | 74 | * status code in the same form as needed for syndrome |
42 | -- | 75 | -- |
43 | 2.20.1 | 76 | 2.34.1 |
44 | |||
45 | diff view generated by jsdifflib |
1 | For M-profile, we weren't reporting alignment faults triggered by the | 1 | From: Fabiano Rosas <farosas@suse.de> |
---|---|---|---|
2 | generic TCG code correctly to the guest. These get passed into | ||
3 | arm_v7m_cpu_do_interrupt() as an EXCP_DATA_ABORT with an A-profile | ||
4 | style exception.fsr value of 1. We didn't check for this, and so | ||
5 | they fell through into the default of "assume this is an MPU fault" | ||
6 | and were reported to the guest as a data access violation MPU fault. | ||
7 | 2 | ||
8 | Report these alignment faults as UsageFaults which set the UNALIGNED | 3 | We currently need to select ARM_V7M unconditionally when TCG is |
9 | bit in the UFSR. | 4 | present in the build because some translate.c helpers and the whole of |
5 | m_helpers.c are not yet under CONFIG_ARM_V7M. | ||
10 | 6 | ||
7 | Suggested-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
8 | Signed-off-by: Fabiano Rosas <farosas@suse.de> | ||
9 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
10 | Message-id: 20230523180525.29994-2-farosas@suse.de | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
12 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
13 | Message-id: 20210723162146.5167-4-peter.maydell@linaro.org | ||
14 | --- | 12 | --- |
15 | target/arm/m_helper.c | 8 ++++++++ | 13 | target/arm/Kconfig | 3 +++ |
16 | 1 file changed, 8 insertions(+) | 14 | 1 file changed, 3 insertions(+) |
17 | 15 | ||
18 | diff --git a/target/arm/m_helper.c b/target/arm/m_helper.c | 16 | diff --git a/target/arm/Kconfig b/target/arm/Kconfig |
19 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
20 | --- a/target/arm/m_helper.c | 18 | --- a/target/arm/Kconfig |
21 | +++ b/target/arm/m_helper.c | 19 | +++ b/target/arm/Kconfig |
22 | @@ -XXX,XX +XXX,XX @@ void arm_v7m_cpu_do_interrupt(CPUState *cs) | 20 | @@ -XXX,XX +XXX,XX @@ |
23 | env->v7m.sfsr |= R_V7M_SFSR_LSERR_MASK; | 21 | config ARM |
24 | break; | 22 | bool |
25 | case EXCP_UNALIGNED: | 23 | select ARM_COMPATIBLE_SEMIHOSTING if TCG |
26 | + /* Unaligned faults reported by M-profile aware code */ | 24 | + |
27 | armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE, env->v7m.secure); | 25 | + # We need to select this until we move m_helper.c and the |
28 | env->v7m.cfsr[env->v7m.secure] |= R_V7M_CFSR_UNALIGNED_MASK; | 26 | + # translate.c v7m helpers under ARM_V7M. |
29 | break; | 27 | select ARM_V7M if TCG |
30 | @@ -XXX,XX +XXX,XX @@ void arm_v7m_cpu_do_interrupt(CPUState *cs) | 28 | |
31 | } | 29 | config AARCH64 |
32 | armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_BUS, false); | ||
33 | break; | ||
34 | + case 0x1: /* Alignment fault reported by generic code */ | ||
35 | + qemu_log_mask(CPU_LOG_INT, | ||
36 | + "...really UsageFault with UFSR.UNALIGNED\n"); | ||
37 | + env->v7m.cfsr[env->v7m.secure] |= R_V7M_CFSR_UNALIGNED_MASK; | ||
38 | + armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE, | ||
39 | + env->v7m.secure); | ||
40 | + break; | ||
41 | default: | ||
42 | /* | ||
43 | * All other FSR values are either MPU faults or "can't happen | ||
44 | -- | 30 | -- |
45 | 2.20.1 | 31 | 2.34.1 |
46 | 32 | ||
47 | 33 | diff view generated by jsdifflib |
1 | In do_v7m_exception_exit(), we perform various checks as part of | 1 | From: Fabiano Rosas <farosas@suse.de> |
---|---|---|---|
2 | performing the exception return. If one of these checks fails, the | ||
3 | architecture requires that we take an appropriate exception on the | ||
4 | existing stackframe. We implement this by calling | ||
5 | v7m_exception_taken() to set up to take the new exception, and then | ||
6 | immediately returning from do_v7m_exception_exit() without proceeding | ||
7 | any further with the unstack-and-exception-return process. | ||
8 | 2 | ||
9 | In a couple of checks that are new in v8.1M, we forgot the "return" | 3 | When we moved the arm default CONFIGs into Kconfig and removed them |
10 | statement, with the effect that if bad code in the guest tripped over | 4 | from default.mak, we made it harder to identify which CONFIGs are |
11 | these checks we would set up to take a UsageFault exception but then | 5 | selected by default in case users want to disable them. |
12 | blunder on trying to also unstack and return from the original | ||
13 | exception, with the probable result that the guest would crash. | ||
14 | 6 | ||
15 | Add the missing return statements. | 7 | Bring back the default entries into default.mak, but keep them |
8 | commented out. This way users can keep their workflows of editing | ||
9 | default.mak to remove build options without needing to search through | ||
10 | Kconfig. | ||
16 | 11 | ||
12 | Reported-by: Thomas Huth <thuth@redhat.com> | ||
13 | Signed-off-by: Fabiano Rosas <farosas@suse.de> | ||
14 | Reviewed-by: Thomas Huth <thuth@redhat.com> | ||
15 | Message-id: 20230523180525.29994-3-farosas@suse.de | ||
17 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 16 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
18 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
19 | Message-id: 20210723162146.5167-3-peter.maydell@linaro.org | ||
20 | --- | 17 | --- |
21 | target/arm/m_helper.c | 2 ++ | 18 | configs/devices/aarch64-softmmu/default.mak | 6 ++++ |
22 | 1 file changed, 2 insertions(+) | 19 | configs/devices/arm-softmmu/default.mak | 40 +++++++++++++++++++++ |
20 | 2 files changed, 46 insertions(+) | ||
23 | 21 | ||
24 | diff --git a/target/arm/m_helper.c b/target/arm/m_helper.c | 22 | diff --git a/configs/devices/aarch64-softmmu/default.mak b/configs/devices/aarch64-softmmu/default.mak |
25 | index XXXXXXX..XXXXXXX 100644 | 23 | index XXXXXXX..XXXXXXX 100644 |
26 | --- a/target/arm/m_helper.c | 24 | --- a/configs/devices/aarch64-softmmu/default.mak |
27 | +++ b/target/arm/m_helper.c | 25 | +++ b/configs/devices/aarch64-softmmu/default.mak |
28 | @@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu) | 26 | @@ -XXX,XX +XXX,XX @@ |
29 | qemu_log_mask(CPU_LOG_INT, "...taking UsageFault on existing " | 27 | |
30 | "stackframe: NSACR prevents clearing FPU registers\n"); | 28 | # We support all the 32 bit boards so need all their config |
31 | v7m_exception_taken(cpu, excret, true, false); | 29 | include ../arm-softmmu/default.mak |
32 | + return; | 30 | + |
33 | } else if (!cpacr_pass) { | 31 | +# These are selected by default when TCG is enabled, uncomment them to |
34 | armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE, | 32 | +# keep out of the build. |
35 | exc_secure); | 33 | +# CONFIG_XLNX_ZYNQMP_ARM=n |
36 | @@ -XXX,XX +XXX,XX @@ static void do_v7m_exception_exit(ARMCPU *cpu) | 34 | +# CONFIG_XLNX_VERSAL=n |
37 | qemu_log_mask(CPU_LOG_INT, "...taking UsageFault on existing " | 35 | +# CONFIG_SBSA_REF=n |
38 | "stackframe: CPACR prevents clearing FPU registers\n"); | 36 | diff --git a/configs/devices/arm-softmmu/default.mak b/configs/devices/arm-softmmu/default.mak |
39 | v7m_exception_taken(cpu, excret, true, false); | 37 | index XXXXXXX..XXXXXXX 100644 |
40 | + return; | 38 | --- a/configs/devices/arm-softmmu/default.mak |
41 | } | 39 | +++ b/configs/devices/arm-softmmu/default.mak |
42 | } | 40 | @@ -XXX,XX +XXX,XX @@ |
43 | /* Clear s0..s15, FPSCR and VPR */ | 41 | # CONFIG_TEST_DEVICES=n |
42 | |||
43 | CONFIG_ARM_VIRT=y | ||
44 | + | ||
45 | +# These are selected by default when TCG is enabled, uncomment them to | ||
46 | +# keep out of the build. | ||
47 | +# CONFIG_CUBIEBOARD=n | ||
48 | +# CONFIG_EXYNOS4=n | ||
49 | +# CONFIG_HIGHBANK=n | ||
50 | +# CONFIG_INTEGRATOR=n | ||
51 | +# CONFIG_FSL_IMX31=n | ||
52 | +# CONFIG_MUSICPAL=n | ||
53 | +# CONFIG_MUSCA=n | ||
54 | +# CONFIG_CHEETAH=n | ||
55 | +# CONFIG_SX1=n | ||
56 | +# CONFIG_NSERIES=n | ||
57 | +# CONFIG_STELLARIS=n | ||
58 | +# CONFIG_STM32VLDISCOVERY=n | ||
59 | +# CONFIG_REALVIEW=n | ||
60 | +# CONFIG_VERSATILE=n | ||
61 | +# CONFIG_VEXPRESS=n | ||
62 | +# CONFIG_ZYNQ=n | ||
63 | +# CONFIG_MAINSTONE=n | ||
64 | +# CONFIG_GUMSTIX=n | ||
65 | +# CONFIG_SPITZ=n | ||
66 | +# CONFIG_TOSA=n | ||
67 | +# CONFIG_Z2=n | ||
68 | +# CONFIG_NPCM7XX=n | ||
69 | +# CONFIG_COLLIE=n | ||
70 | +# CONFIG_ASPEED_SOC=n | ||
71 | +# CONFIG_NETDUINO2=n | ||
72 | +# CONFIG_NETDUINOPLUS2=n | ||
73 | +# CONFIG_OLIMEX_STM32_H405=n | ||
74 | +# CONFIG_MPS2=n | ||
75 | +# CONFIG_RASPI=n | ||
76 | +# CONFIG_DIGIC=n | ||
77 | +# CONFIG_SABRELITE=n | ||
78 | +# CONFIG_EMCRAFT_SF2=n | ||
79 | +# CONFIG_MICROBIT=n | ||
80 | +# CONFIG_FSL_IMX25=n | ||
81 | +# CONFIG_FSL_IMX7=n | ||
82 | +# CONFIG_FSL_IMX6UL=n | ||
83 | +# CONFIG_ALLWINNER_H3=n | ||
44 | -- | 84 | -- |
45 | 2.20.1 | 85 | 2.34.1 |
46 | |||
47 | diff view generated by jsdifflib |
1 | The documentation of the -machine memory-backend has some minor | 1 | From: Fabiano Rosas <farosas@suse.de> |
---|---|---|---|
2 | formatting errors: | 2 | |
3 | * Misindentation of the initial line meant that the whole option | 3 | Replace the 'default y if TCG' pattern with 'default y; depends on |
4 | section is incorrectly indented in the HTML output compared to | 4 | TCG'. |
5 | the other -machine options | 5 | |
6 | * The examples weren't indented, which meant that they were formatted | 6 | That makes explict that there is a dependence on TCG and enabling |
7 | as plain run-on text including outputting the "::" as text. | 7 | these CONFIGs via .mak files without TCG present will fail earlier. |
8 | * The a) b) list has no rst-format markup so it is rendered as | 8 | |
9 | a single run-on paragraph | 9 | Suggested-by: Paolo Bonzini <pbonzini@redhat.com> |
10 | 10 | Signed-off-by: Fabiano Rosas <farosas@suse.de> | |
11 | Fix the formatting. | 11 | Reviewed-by: Thomas Huth <thuth@redhat.com> |
12 | 12 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> | |
13 | Message-id: 20230523180525.29994-4-farosas@suse.de | ||
13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
14 | Reviewed-by: Igor Mammedov <imammedo@redhat.com> | ||
15 | Message-id: 20210719105257.3599-1-peter.maydell@linaro.org | ||
16 | --- | 15 | --- |
17 | qemu-options.hx | 30 +++++++++++++++++------------- | 16 | hw/arm/Kconfig | 123 ++++++++++++++++++++++++++++++++----------------- |
18 | 1 file changed, 17 insertions(+), 13 deletions(-) | 17 | 1 file changed, 82 insertions(+), 41 deletions(-) |
19 | 18 | ||
20 | diff --git a/qemu-options.hx b/qemu-options.hx | 19 | diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig |
21 | index XXXXXXX..XXXXXXX 100644 | 20 | index XXXXXXX..XXXXXXX 100644 |
22 | --- a/qemu-options.hx | 21 | --- a/hw/arm/Kconfig |
23 | +++ b/qemu-options.hx | 22 | +++ b/hw/arm/Kconfig |
24 | @@ -XXX,XX +XXX,XX @@ SRST | 23 | @@ -XXX,XX +XXX,XX @@ config ARM_VIRT |
25 | Enables or disables ACPI Heterogeneous Memory Attribute Table | 24 | |
26 | (HMAT) support. The default is off. | 25 | config CHEETAH |
27 | 26 | bool | |
28 | - ``memory-backend='id'`` | 27 | - default y if TCG && ARM |
29 | + ``memory-backend='id'`` | 28 | + default y |
30 | An alternative to legacy ``-mem-path`` and ``mem-prealloc`` options. | 29 | + depends on TCG && ARM |
31 | Allows to use a memory backend as main RAM. | 30 | select OMAP |
32 | 31 | select TSC210X | |
33 | For example: | 32 | |
34 | :: | 33 | config CUBIEBOARD |
35 | - -object memory-backend-file,id=pc.ram,size=512M,mem-path=/hugetlbfs,prealloc=on,share=on | 34 | bool |
36 | - -machine memory-backend=pc.ram | 35 | - default y if TCG && ARM |
37 | - -m 512M | 36 | + default y |
38 | + | 37 | + depends on TCG && ARM |
39 | + -object memory-backend-file,id=pc.ram,size=512M,mem-path=/hugetlbfs,prealloc=on,share=on | 38 | select ALLWINNER_A10 |
40 | + -machine memory-backend=pc.ram | 39 | |
41 | + -m 512M | 40 | config DIGIC |
42 | 41 | bool | |
43 | Migration compatibility note: | 42 | - default y if TCG && ARM |
44 | - a) as backend id one shall use value of 'default-ram-id', advertised by | 43 | + default y |
45 | - machine type (available via ``query-machines`` QMP command), if migration | 44 | + depends on TCG && ARM |
46 | - to/from old QEMU (<5.0) is expected. | 45 | select PTIMER |
47 | - b) for machine types 4.0 and older, user shall | 46 | select PFLASH_CFI02 |
48 | - use ``x-use-canonical-path-for-ramblock-id=off`` backend option | 47 | |
49 | - if migration to/from old QEMU (<5.0) is expected. | 48 | config EXYNOS4 |
50 | + | 49 | bool |
51 | + * as backend id one shall use value of 'default-ram-id', advertised by | 50 | - default y if TCG && ARM |
52 | + machine type (available via ``query-machines`` QMP command), if migration | 51 | + default y |
53 | + to/from old QEMU (<5.0) is expected. | 52 | + depends on TCG && ARM |
54 | + * for machine types 4.0 and older, user shall | 53 | imply I2C_DEVICES |
55 | + use ``x-use-canonical-path-for-ramblock-id=off`` backend option | 54 | select A9MPCORE |
56 | + if migration to/from old QEMU (<5.0) is expected. | 55 | select I2C |
57 | + | 56 | @@ -XXX,XX +XXX,XX @@ config EXYNOS4 |
58 | For example: | 57 | |
59 | :: | 58 | config HIGHBANK |
60 | - -object memory-backend-ram,id=pc.ram,size=512M,x-use-canonical-path-for-ramblock-id=off | 59 | bool |
61 | - -machine memory-backend=pc.ram | 60 | - default y if TCG && ARM |
62 | - -m 512M | 61 | + default y |
63 | + | 62 | + depends on TCG && ARM |
64 | + -object memory-backend-ram,id=pc.ram,size=512M,x-use-canonical-path-for-ramblock-id=off | 63 | select A9MPCORE |
65 | + -machine memory-backend=pc.ram | 64 | select A15MPCORE |
66 | + -m 512M | 65 | select AHCI |
67 | ERST | 66 | @@ -XXX,XX +XXX,XX @@ config HIGHBANK |
68 | 67 | ||
69 | HXCOMM Deprecated by -machine | 68 | config INTEGRATOR |
69 | bool | ||
70 | - default y if TCG && ARM | ||
71 | + default y | ||
72 | + depends on TCG && ARM | ||
73 | select ARM_TIMER | ||
74 | select INTEGRATOR_DEBUG | ||
75 | select PL011 # UART | ||
76 | @@ -XXX,XX +XXX,XX @@ config INTEGRATOR | ||
77 | |||
78 | config MAINSTONE | ||
79 | bool | ||
80 | - default y if TCG && ARM | ||
81 | + default y | ||
82 | + depends on TCG && ARM | ||
83 | select PXA2XX | ||
84 | select PFLASH_CFI01 | ||
85 | select SMC91C111 | ||
86 | |||
87 | config MUSCA | ||
88 | bool | ||
89 | - default y if TCG && ARM | ||
90 | + default y | ||
91 | + depends on TCG && ARM | ||
92 | select ARMSSE | ||
93 | select PL011 | ||
94 | select PL031 | ||
95 | @@ -XXX,XX +XXX,XX @@ config MARVELL_88W8618 | ||
96 | |||
97 | config MUSICPAL | ||
98 | bool | ||
99 | - default y if TCG && ARM | ||
100 | + default y | ||
101 | + depends on TCG && ARM | ||
102 | select OR_IRQ | ||
103 | select BITBANG_I2C | ||
104 | select MARVELL_88W8618 | ||
105 | @@ -XXX,XX +XXX,XX @@ config MUSICPAL | ||
106 | |||
107 | config NETDUINO2 | ||
108 | bool | ||
109 | - default y if TCG && ARM | ||
110 | + default y | ||
111 | + depends on TCG && ARM | ||
112 | select STM32F205_SOC | ||
113 | |||
114 | config NETDUINOPLUS2 | ||
115 | bool | ||
116 | - default y if TCG && ARM | ||
117 | + default y | ||
118 | + depends on TCG && ARM | ||
119 | select STM32F405_SOC | ||
120 | |||
121 | config OLIMEX_STM32_H405 | ||
122 | bool | ||
123 | - default y if TCG && ARM | ||
124 | + default y | ||
125 | + depends on TCG && ARM | ||
126 | select STM32F405_SOC | ||
127 | |||
128 | config NSERIES | ||
129 | bool | ||
130 | - default y if TCG && ARM | ||
131 | + default y | ||
132 | + depends on TCG && ARM | ||
133 | select OMAP | ||
134 | select TMP105 # temperature sensor | ||
135 | select BLIZZARD # LCD/TV controller | ||
136 | @@ -XXX,XX +XXX,XX @@ config PXA2XX | ||
137 | |||
138 | config GUMSTIX | ||
139 | bool | ||
140 | - default y if TCG && ARM | ||
141 | + default y | ||
142 | + depends on TCG && ARM | ||
143 | select PFLASH_CFI01 | ||
144 | select SMC91C111 | ||
145 | select PXA2XX | ||
146 | |||
147 | config TOSA | ||
148 | bool | ||
149 | - default y if TCG && ARM | ||
150 | + default y | ||
151 | + depends on TCG && ARM | ||
152 | select ZAURUS # scoop | ||
153 | select MICRODRIVE | ||
154 | select PXA2XX | ||
155 | @@ -XXX,XX +XXX,XX @@ config TOSA | ||
156 | |||
157 | config SPITZ | ||
158 | bool | ||
159 | - default y if TCG && ARM | ||
160 | + default y | ||
161 | + depends on TCG && ARM | ||
162 | select ADS7846 # touch-screen controller | ||
163 | select MAX111X # A/D converter | ||
164 | select WM8750 # audio codec | ||
165 | @@ -XXX,XX +XXX,XX @@ config SPITZ | ||
166 | |||
167 | config Z2 | ||
168 | bool | ||
169 | - default y if TCG && ARM | ||
170 | + default y | ||
171 | + depends on TCG && ARM | ||
172 | select PFLASH_CFI01 | ||
173 | select WM8750 | ||
174 | select PL011 # UART | ||
175 | @@ -XXX,XX +XXX,XX @@ config Z2 | ||
176 | |||
177 | config REALVIEW | ||
178 | bool | ||
179 | - default y if TCG && ARM | ||
180 | + default y | ||
181 | + depends on TCG && ARM | ||
182 | imply PCI_DEVICES | ||
183 | imply PCI_TESTDEV | ||
184 | imply I2C_DEVICES | ||
185 | @@ -XXX,XX +XXX,XX @@ config REALVIEW | ||
186 | |||
187 | config SBSA_REF | ||
188 | bool | ||
189 | - default y if TCG && AARCH64 | ||
190 | + default y | ||
191 | + depends on TCG && AARCH64 | ||
192 | imply PCI_DEVICES | ||
193 | select AHCI | ||
194 | select ARM_SMMUV3 | ||
195 | @@ -XXX,XX +XXX,XX @@ config SBSA_REF | ||
196 | |||
197 | config SABRELITE | ||
198 | bool | ||
199 | - default y if TCG && ARM | ||
200 | + default y | ||
201 | + depends on TCG && ARM | ||
202 | select FSL_IMX6 | ||
203 | select SSI_M25P80 | ||
204 | |||
205 | config STELLARIS | ||
206 | bool | ||
207 | - default y if TCG && ARM | ||
208 | + default y | ||
209 | + depends on TCG && ARM | ||
210 | imply I2C_DEVICES | ||
211 | select ARM_V7M | ||
212 | select CMSDK_APB_WATCHDOG | ||
213 | @@ -XXX,XX +XXX,XX @@ config STELLARIS | ||
214 | |||
215 | config STM32VLDISCOVERY | ||
216 | bool | ||
217 | - default y if TCG && ARM | ||
218 | + default y | ||
219 | + depends on TCG && ARM | ||
220 | select STM32F100_SOC | ||
221 | |||
222 | config STRONGARM | ||
223 | @@ -XXX,XX +XXX,XX @@ config STRONGARM | ||
224 | |||
225 | config COLLIE | ||
226 | bool | ||
227 | - default y if TCG && ARM | ||
228 | + default y | ||
229 | + depends on TCG && ARM | ||
230 | select PFLASH_CFI01 | ||
231 | select ZAURUS # scoop | ||
232 | select STRONGARM | ||
233 | |||
234 | config SX1 | ||
235 | bool | ||
236 | - default y if TCG && ARM | ||
237 | + default y | ||
238 | + depends on TCG && ARM | ||
239 | select OMAP | ||
240 | |||
241 | config VERSATILE | ||
242 | bool | ||
243 | - default y if TCG && ARM | ||
244 | + default y | ||
245 | + depends on TCG && ARM | ||
246 | select ARM_TIMER # sp804 | ||
247 | select PFLASH_CFI01 | ||
248 | select LSI_SCSI_PCI | ||
249 | @@ -XXX,XX +XXX,XX @@ config VERSATILE | ||
250 | |||
251 | config VEXPRESS | ||
252 | bool | ||
253 | - default y if TCG && ARM | ||
254 | + default y | ||
255 | + depends on TCG && ARM | ||
256 | select A9MPCORE | ||
257 | select A15MPCORE | ||
258 | select ARM_MPTIMER | ||
259 | @@ -XXX,XX +XXX,XX @@ config VEXPRESS | ||
260 | |||
261 | config ZYNQ | ||
262 | bool | ||
263 | - default y if TCG && ARM | ||
264 | + default y | ||
265 | + depends on TCG && ARM | ||
266 | select A9MPCORE | ||
267 | select CADENCE # UART | ||
268 | select PFLASH_CFI02 | ||
269 | @@ -XXX,XX +XXX,XX @@ config ZYNQ | ||
270 | config ARM_V7M | ||
271 | bool | ||
272 | # currently v7M must be included in a TCG build due to translate.c | ||
273 | - default y if TCG && ARM | ||
274 | + default y | ||
275 | + depends on TCG && ARM | ||
276 | select PTIMER | ||
277 | |||
278 | config ALLWINNER_A10 | ||
279 | @@ -XXX,XX +XXX,XX @@ config ALLWINNER_A10 | ||
280 | |||
281 | config ALLWINNER_H3 | ||
282 | bool | ||
283 | - default y if TCG && ARM | ||
284 | + default y | ||
285 | + depends on TCG && ARM | ||
286 | select ALLWINNER_A10_PIT | ||
287 | select ALLWINNER_SUN8I_EMAC | ||
288 | select ALLWINNER_I2C | ||
289 | @@ -XXX,XX +XXX,XX @@ config ALLWINNER_H3 | ||
290 | |||
291 | config RASPI | ||
292 | bool | ||
293 | - default y if TCG && ARM | ||
294 | + default y | ||
295 | + depends on TCG && ARM | ||
296 | select FRAMEBUFFER | ||
297 | select PL011 # UART | ||
298 | select SDHCI | ||
299 | @@ -XXX,XX +XXX,XX @@ config STM32F405_SOC | ||
300 | |||
301 | config XLNX_ZYNQMP_ARM | ||
302 | bool | ||
303 | - default y if TCG && AARCH64 | ||
304 | + default y | ||
305 | + depends on TCG && AARCH64 | ||
306 | select AHCI | ||
307 | select ARM_GIC | ||
308 | select CADENCE | ||
309 | @@ -XXX,XX +XXX,XX @@ config XLNX_ZYNQMP_ARM | ||
310 | |||
311 | config XLNX_VERSAL | ||
312 | bool | ||
313 | - default y if TCG && AARCH64 | ||
314 | + default y | ||
315 | + depends on TCG && AARCH64 | ||
316 | select ARM_GIC | ||
317 | select PL011 | ||
318 | select CADENCE | ||
319 | @@ -XXX,XX +XXX,XX @@ config XLNX_VERSAL | ||
320 | |||
321 | config NPCM7XX | ||
322 | bool | ||
323 | - default y if TCG && ARM | ||
324 | + default y | ||
325 | + depends on TCG && ARM | ||
326 | select A9MPCORE | ||
327 | select ADM1272 | ||
328 | select ARM_GIC | ||
329 | @@ -XXX,XX +XXX,XX @@ config NPCM7XX | ||
330 | |||
331 | config FSL_IMX25 | ||
332 | bool | ||
333 | - default y if TCG && ARM | ||
334 | + default y | ||
335 | + depends on TCG && ARM | ||
336 | imply I2C_DEVICES | ||
337 | select IMX | ||
338 | select IMX_FEC | ||
339 | @@ -XXX,XX +XXX,XX @@ config FSL_IMX25 | ||
340 | |||
341 | config FSL_IMX31 | ||
342 | bool | ||
343 | - default y if TCG && ARM | ||
344 | + default y | ||
345 | + depends on TCG && ARM | ||
346 | imply I2C_DEVICES | ||
347 | select SERIAL | ||
348 | select IMX | ||
349 | @@ -XXX,XX +XXX,XX @@ config FSL_IMX6 | ||
350 | |||
351 | config ASPEED_SOC | ||
352 | bool | ||
353 | - default y if TCG && ARM | ||
354 | + default y | ||
355 | + depends on TCG && ARM | ||
356 | select DS1338 | ||
357 | select FTGMAC100 | ||
358 | select I2C | ||
359 | @@ -XXX,XX +XXX,XX @@ config ASPEED_SOC | ||
360 | |||
361 | config MPS2 | ||
362 | bool | ||
363 | - default y if TCG && ARM | ||
364 | + default y | ||
365 | + depends on TCG && ARM | ||
366 | imply I2C_DEVICES | ||
367 | select ARMSSE | ||
368 | select LAN9118 | ||
369 | @@ -XXX,XX +XXX,XX @@ config MPS2 | ||
370 | |||
371 | config FSL_IMX7 | ||
372 | bool | ||
373 | - default y if TCG && ARM | ||
374 | + default y | ||
375 | + depends on TCG && ARM | ||
376 | imply PCI_DEVICES | ||
377 | imply TEST_DEVICES | ||
378 | imply I2C_DEVICES | ||
379 | @@ -XXX,XX +XXX,XX @@ config ARM_SMMUV3 | ||
380 | |||
381 | config FSL_IMX6UL | ||
382 | bool | ||
383 | - default y if TCG && ARM | ||
384 | + default y | ||
385 | + depends on TCG && ARM | ||
386 | imply I2C_DEVICES | ||
387 | select A15MPCORE | ||
388 | select IMX | ||
389 | @@ -XXX,XX +XXX,XX @@ config FSL_IMX6UL | ||
390 | |||
391 | config MICROBIT | ||
392 | bool | ||
393 | - default y if TCG && ARM | ||
394 | + default y | ||
395 | + depends on TCG && ARM | ||
396 | select NRF51_SOC | ||
397 | |||
398 | config NRF51_SOC | ||
399 | @@ -XXX,XX +XXX,XX @@ config NRF51_SOC | ||
400 | |||
401 | config EMCRAFT_SF2 | ||
402 | bool | ||
403 | - default y if TCG && ARM | ||
404 | + default y | ||
405 | + depends on TCG && ARM | ||
406 | select MSF2 | ||
407 | select SSI_M25P80 | ||
408 | |||
70 | -- | 409 | -- |
71 | 2.20.1 | 410 | 2.34.1 |
72 | 411 | ||
73 | 412 | diff view generated by jsdifflib |
1 | For M-profile, unlike A-profile, the low 2 bits of SP are defined to be | 1 | From: Enze Li <lienze@kylinos.cn> |
---|---|---|---|
2 | RES0H, which is to say that they must be hardwired to zero so that | ||
3 | guest attempts to write non-zero values to them are ignored. | ||
4 | 2 | ||
5 | Implement this behaviour by masking out the low bits: | 3 | I noticed that in the latest version, the copyright string is still |
6 | * for writes to r13 by the gdbstub | 4 | 2022, even though 2023 is halfway through. This patch fixes that and |
7 | * for writes to any of the various flavours of SP via MSR | 5 | fixes the documentation along with it. |
8 | * for writes to r13 via store_reg() in generated code | ||
9 | 6 | ||
10 | Note that all the direct uses of cpu_R[] in translate.c are in places | 7 | Signed-off-by: Enze Li <lienze@kylinos.cn> |
11 | where the register is definitely not r13 (usually because that has | 8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
12 | been checked for as an UNDEFINED or UNPREDICTABLE case and handled as | 9 | Message-id: 20230525064345.1152801-1-lienze@kylinos.cn |
13 | UNDEF). | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | --- | ||
12 | docs/conf.py | 2 +- | ||
13 | include/qemu/help-texts.h | 2 +- | ||
14 | 2 files changed, 2 insertions(+), 2 deletions(-) | ||
14 | 15 | ||
15 | All the other writes to regs[13] in C code are either: | 16 | diff --git a/docs/conf.py b/docs/conf.py |
16 | * A-profile only code | ||
17 | * writes of values we can guarantee to be aligned, such as | ||
18 | - writes of previous-SP-value plus or minus a 4-aligned constant | ||
19 | - writes of the value in an SP limit register (which we already | ||
20 | enforce to be aligned) | ||
21 | |||
22 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
23 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
24 | Message-id: 20210723162146.5167-2-peter.maydell@linaro.org | ||
25 | --- | ||
26 | target/arm/gdbstub.c | 4 ++++ | ||
27 | target/arm/m_helper.c | 14 ++++++++------ | ||
28 | target/arm/translate.c | 3 +++ | ||
29 | 3 files changed, 15 insertions(+), 6 deletions(-) | ||
30 | |||
31 | diff --git a/target/arm/gdbstub.c b/target/arm/gdbstub.c | ||
32 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
33 | --- a/target/arm/gdbstub.c | 18 | --- a/docs/conf.py |
34 | +++ b/target/arm/gdbstub.c | 19 | +++ b/docs/conf.py |
35 | @@ -XXX,XX +XXX,XX @@ int arm_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n) | 20 | @@ -XXX,XX +XXX,XX @@ |
36 | 21 | ||
37 | if (n < 16) { | 22 | # General information about the project. |
38 | /* Core integer register. */ | 23 | project = u'QEMU' |
39 | + if (n == 13 && arm_feature(env, ARM_FEATURE_M)) { | 24 | -copyright = u'2022, The QEMU Project Developers' |
40 | + /* M profile SP low bits are always 0 */ | 25 | +copyright = u'2023, The QEMU Project Developers' |
41 | + tmp &= ~3; | 26 | author = u'The QEMU Project Developers' |
42 | + } | 27 | |
43 | env->regs[n] = tmp; | 28 | # The version info for the project you're documenting, acts as replacement for |
44 | return 4; | 29 | diff --git a/include/qemu/help-texts.h b/include/qemu/help-texts.h |
45 | } | ||
46 | diff --git a/target/arm/m_helper.c b/target/arm/m_helper.c | ||
47 | index XXXXXXX..XXXXXXX 100644 | 30 | index XXXXXXX..XXXXXXX 100644 |
48 | --- a/target/arm/m_helper.c | 31 | --- a/include/qemu/help-texts.h |
49 | +++ b/target/arm/m_helper.c | 32 | +++ b/include/qemu/help-texts.h |
50 | @@ -XXX,XX +XXX,XX @@ void HELPER(v7m_msr)(CPUARMState *env, uint32_t maskreg, uint32_t val) | 33 | @@ -XXX,XX +XXX,XX @@ |
51 | if (!env->v7m.secure) { | 34 | #define QEMU_HELP_TEXTS_H |
52 | return; | 35 | |
53 | } | 36 | /* Copyright string for -version arguments, About dialogs, etc */ |
54 | - env->v7m.other_ss_msp = val; | 37 | -#define QEMU_COPYRIGHT "Copyright (c) 2003-2022 " \ |
55 | + env->v7m.other_ss_msp = val & ~3; | 38 | +#define QEMU_COPYRIGHT "Copyright (c) 2003-2023 " \ |
56 | return; | 39 | "Fabrice Bellard and the QEMU Project developers" |
57 | case 0x89: /* PSP_NS */ | 40 | |
58 | if (!env->v7m.secure) { | 41 | /* Bug reporting information for --help arguments, About dialogs, etc */ |
59 | return; | ||
60 | } | ||
61 | - env->v7m.other_ss_psp = val; | ||
62 | + env->v7m.other_ss_psp = val & ~3; | ||
63 | return; | ||
64 | case 0x8a: /* MSPLIM_NS */ | ||
65 | if (!env->v7m.secure) { | ||
66 | @@ -XXX,XX +XXX,XX @@ void HELPER(v7m_msr)(CPUARMState *env, uint32_t maskreg, uint32_t val) | ||
67 | |||
68 | limit = is_psp ? env->v7m.psplim[false] : env->v7m.msplim[false]; | ||
69 | |||
70 | + val &= ~0x3; | ||
71 | + | ||
72 | if (val < limit) { | ||
73 | raise_exception_ra(env, EXCP_STKOF, 0, 1, GETPC()); | ||
74 | } | ||
75 | @@ -XXX,XX +XXX,XX @@ void HELPER(v7m_msr)(CPUARMState *env, uint32_t maskreg, uint32_t val) | ||
76 | break; | ||
77 | case 8: /* MSP */ | ||
78 | if (v7m_using_psp(env)) { | ||
79 | - env->v7m.other_sp = val; | ||
80 | + env->v7m.other_sp = val & ~3; | ||
81 | } else { | ||
82 | - env->regs[13] = val; | ||
83 | + env->regs[13] = val & ~3; | ||
84 | } | ||
85 | break; | ||
86 | case 9: /* PSP */ | ||
87 | if (v7m_using_psp(env)) { | ||
88 | - env->regs[13] = val; | ||
89 | + env->regs[13] = val & ~3; | ||
90 | } else { | ||
91 | - env->v7m.other_sp = val; | ||
92 | + env->v7m.other_sp = val & ~3; | ||
93 | } | ||
94 | break; | ||
95 | case 10: /* MSPLIM */ | ||
96 | diff --git a/target/arm/translate.c b/target/arm/translate.c | ||
97 | index XXXXXXX..XXXXXXX 100644 | ||
98 | --- a/target/arm/translate.c | ||
99 | +++ b/target/arm/translate.c | ||
100 | @@ -XXX,XX +XXX,XX @@ void store_reg(DisasContext *s, int reg, TCGv_i32 var) | ||
101 | */ | ||
102 | tcg_gen_andi_i32(var, var, s->thumb ? ~1 : ~3); | ||
103 | s->base.is_jmp = DISAS_JUMP; | ||
104 | + } else if (reg == 13 && arm_dc_feature(s, ARM_FEATURE_M)) { | ||
105 | + /* For M-profile SP bits [1:0] are always zero */ | ||
106 | + tcg_gen_andi_i32(var, var, ~3); | ||
107 | } | ||
108 | tcg_gen_mov_i32(cpu_R[reg], var); | ||
109 | tcg_temp_free_i32(var); | ||
110 | -- | 42 | -- |
111 | 2.20.1 | 43 | 2.34.1 |
112 | |||
113 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Marcin Juszkiewicz <marcin.juszkiewicz@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Mirror the behavour of /proc/sys/abi/sve_default_vector_length | 3 | Let add GIC information into DeviceTree as part of SBSA-REF versioning. |
4 | under the real linux kernel. We have no way of passing along | ||
5 | a real default across exec like the kernel can, but this is a | ||
6 | decent way of adjusting the startup vector length of a process. | ||
7 | 4 | ||
8 | Resolves: https://gitlab.com/qemu-project/qemu/-/issues/482 | 5 | Trusted Firmware will read it and provide to next firmware level. |
9 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 6 | |
7 | Bumps platform version to 0.1 one so we can check is node is present. | ||
8 | |||
9 | Signed-off-by: Marcin Juszkiewicz <marcin.juszkiewicz@linaro.org> | ||
10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
11 | Message-id: 20210723203344.968563-4-richard.henderson@linaro.org | ||
12 | [PMM: tweaked docs formatting, document -1 special-case, | ||
13 | added fixup patch from RTH mentioning QEMU's maximum veclen.] | ||
14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
15 | --- | 12 | --- |
16 | docs/system/arm/cpu-features.rst | 15 ++++++++ | 13 | hw/arm/sbsa-ref.c | 19 ++++++++++++++++++- |
17 | target/arm/cpu.h | 5 +++ | 14 | 1 file changed, 18 insertions(+), 1 deletion(-) |
18 | target/arm/cpu.c | 14 ++++++-- | ||
19 | target/arm/cpu64.c | 60 ++++++++++++++++++++++++++++++++ | ||
20 | 4 files changed, 92 insertions(+), 2 deletions(-) | ||
21 | 15 | ||
22 | diff --git a/docs/system/arm/cpu-features.rst b/docs/system/arm/cpu-features.rst | 16 | diff --git a/hw/arm/sbsa-ref.c b/hw/arm/sbsa-ref.c |
23 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
24 | --- a/docs/system/arm/cpu-features.rst | 18 | --- a/hw/arm/sbsa-ref.c |
25 | +++ b/docs/system/arm/cpu-features.rst | 19 | +++ b/hw/arm/sbsa-ref.c |
26 | @@ -XXX,XX +XXX,XX @@ verbose command lines. However, the recommended way to select vector | 20 | @@ -XXX,XX +XXX,XX @@ |
27 | lengths is to explicitly enable each desired length. Therefore only | 21 | #include "exec/hwaddr.h" |
28 | example's (1), (4), and (6) exhibit recommended uses of the properties. | 22 | #include "kvm_arm.h" |
29 | 23 | #include "hw/arm/boot.h" | |
30 | +SVE User-mode Default Vector Length Property | 24 | +#include "hw/arm/fdt.h" |
31 | +-------------------------------------------- | 25 | #include "hw/arm/smmuv3.h" |
26 | #include "hw/block/flash.h" | ||
27 | #include "hw/boards.h" | ||
28 | @@ -XXX,XX +XXX,XX @@ static uint64_t sbsa_ref_cpu_mp_affinity(SBSAMachineState *sms, int idx) | ||
29 | return arm_cpu_mp_affinity(idx, clustersz); | ||
30 | } | ||
31 | |||
32 | +static void sbsa_fdt_add_gic_node(SBSAMachineState *sms) | ||
33 | +{ | ||
34 | + char *nodename; | ||
32 | + | 35 | + |
33 | +For qemu-aarch64, the cpu property ``sve-default-vector-length=N`` is | 36 | + nodename = g_strdup_printf("/intc"); |
34 | +defined to mirror the Linux kernel parameter file | 37 | + qemu_fdt_add_subnode(sms->fdt, nodename); |
35 | +``/proc/sys/abi/sve_default_vector_length``. The default length, ``N``, | 38 | + qemu_fdt_setprop_sized_cells(sms->fdt, nodename, "reg", |
36 | +is in units of bytes and must be between 16 and 8192. | 39 | + 2, sbsa_ref_memmap[SBSA_GIC_DIST].base, |
37 | +If not specified, the default vector length is 64. | 40 | + 2, sbsa_ref_memmap[SBSA_GIC_DIST].size, |
41 | + 2, sbsa_ref_memmap[SBSA_GIC_REDIST].base, | ||
42 | + 2, sbsa_ref_memmap[SBSA_GIC_REDIST].size); | ||
38 | + | 43 | + |
39 | +If the default length is larger than the maximum vector length enabled, | 44 | + g_free(nodename); |
40 | +the actual vector length will be reduced. Note that the maximum vector | ||
41 | +length supported by QEMU is 256. | ||
42 | + | ||
43 | +If this property is set to ``-1`` then the default vector length | ||
44 | +is set to the maximum possible length. | ||
45 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h | ||
46 | index XXXXXXX..XXXXXXX 100644 | ||
47 | --- a/target/arm/cpu.h | ||
48 | +++ b/target/arm/cpu.h | ||
49 | @@ -XXX,XX +XXX,XX @@ struct ARMCPU { | ||
50 | /* Used to set the maximum vector length the cpu will support. */ | ||
51 | uint32_t sve_max_vq; | ||
52 | |||
53 | +#ifdef CONFIG_USER_ONLY | ||
54 | + /* Used to set the default vector length at process start. */ | ||
55 | + uint32_t sve_default_vq; | ||
56 | +#endif | ||
57 | + | ||
58 | /* | ||
59 | * In sve_vq_map each set bit is a supported vector length of | ||
60 | * (bit-number + 1) * 16 bytes, i.e. each bit number + 1 is the vector | ||
61 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c | ||
62 | index XXXXXXX..XXXXXXX 100644 | ||
63 | --- a/target/arm/cpu.c | ||
64 | +++ b/target/arm/cpu.c | ||
65 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_reset(DeviceState *dev) | ||
66 | env->cp15.cpacr_el1 = deposit64(env->cp15.cpacr_el1, 16, 2, 3); | ||
67 | /* with reasonable vector length */ | ||
68 | if (cpu_isar_feature(aa64_sve, cpu)) { | ||
69 | - env->vfp.zcr_el[1] = MIN(cpu->sve_max_vq - 1, 3); | ||
70 | + env->vfp.zcr_el[1] = | ||
71 | + aarch64_sve_zcr_get_valid_len(cpu, cpu->sve_default_vq - 1); | ||
72 | } | ||
73 | /* | ||
74 | * Enable TBI0 but not TBI1. | ||
75 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_initfn(Object *obj) | ||
76 | QLIST_INIT(&cpu->pre_el_change_hooks); | ||
77 | QLIST_INIT(&cpu->el_change_hooks); | ||
78 | |||
79 | -#ifndef CONFIG_USER_ONLY | ||
80 | +#ifdef CONFIG_USER_ONLY | ||
81 | +# ifdef TARGET_AARCH64 | ||
82 | + /* | ||
83 | + * The linux kernel defaults to 512-bit vectors, when sve is supported. | ||
84 | + * See documentation for /proc/sys/abi/sve_default_vector_length, and | ||
85 | + * our corresponding sve-default-vector-length cpu property. | ||
86 | + */ | ||
87 | + cpu->sve_default_vq = 4; | ||
88 | +# endif | ||
89 | +#else | ||
90 | /* Our inbound IRQ and FIQ lines */ | ||
91 | if (kvm_enabled()) { | ||
92 | /* VIRQ and VFIQ are unused with KVM but we add them to maintain | ||
93 | diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c | ||
94 | index XXXXXXX..XXXXXXX 100644 | ||
95 | --- a/target/arm/cpu64.c | ||
96 | +++ b/target/arm/cpu64.c | ||
97 | @@ -XXX,XX +XXX,XX @@ static void cpu_arm_set_sve(Object *obj, bool value, Error **errp) | ||
98 | cpu->isar.id_aa64pfr0 = t; | ||
99 | } | ||
100 | |||
101 | +#ifdef CONFIG_USER_ONLY | ||
102 | +/* Mirror linux /proc/sys/abi/sve_default_vector_length. */ | ||
103 | +static void cpu_arm_set_sve_default_vec_len(Object *obj, Visitor *v, | ||
104 | + const char *name, void *opaque, | ||
105 | + Error **errp) | ||
106 | +{ | ||
107 | + ARMCPU *cpu = ARM_CPU(obj); | ||
108 | + int32_t default_len, default_vq, remainder; | ||
109 | + | ||
110 | + if (!visit_type_int32(v, name, &default_len, errp)) { | ||
111 | + return; | ||
112 | + } | ||
113 | + | ||
114 | + /* Undocumented, but the kernel allows -1 to indicate "maximum". */ | ||
115 | + if (default_len == -1) { | ||
116 | + cpu->sve_default_vq = ARM_MAX_VQ; | ||
117 | + return; | ||
118 | + } | ||
119 | + | ||
120 | + default_vq = default_len / 16; | ||
121 | + remainder = default_len % 16; | ||
122 | + | ||
123 | + /* | ||
124 | + * Note that the 512 max comes from include/uapi/asm/sve_context.h | ||
125 | + * and is the maximum architectural width of ZCR_ELx.LEN. | ||
126 | + */ | ||
127 | + if (remainder || default_vq < 1 || default_vq > 512) { | ||
128 | + error_setg(errp, "cannot set sve-default-vector-length"); | ||
129 | + if (remainder) { | ||
130 | + error_append_hint(errp, "Vector length not a multiple of 16\n"); | ||
131 | + } else if (default_vq < 1) { | ||
132 | + error_append_hint(errp, "Vector length smaller than 16\n"); | ||
133 | + } else { | ||
134 | + error_append_hint(errp, "Vector length larger than %d\n", | ||
135 | + 512 * 16); | ||
136 | + } | ||
137 | + return; | ||
138 | + } | ||
139 | + | ||
140 | + cpu->sve_default_vq = default_vq; | ||
141 | +} | 45 | +} |
142 | + | 46 | /* |
143 | +static void cpu_arm_get_sve_default_vec_len(Object *obj, Visitor *v, | 47 | * Firmware on this machine only uses ACPI table to load OS, these limited |
144 | + const char *name, void *opaque, | 48 | * device tree nodes are just to let firmware know the info which varies from |
145 | + Error **errp) | 49 | @@ -XXX,XX +XXX,XX @@ static void create_fdt(SBSAMachineState *sms) |
146 | +{ | 50 | * fw compatibility. |
147 | + ARMCPU *cpu = ARM_CPU(obj); | 51 | */ |
148 | + int32_t value = cpu->sve_default_vq * 16; | 52 | qemu_fdt_setprop_cell(fdt, "/", "machine-version-major", 0); |
149 | + | 53 | - qemu_fdt_setprop_cell(fdt, "/", "machine-version-minor", 0); |
150 | + visit_type_int32(v, name, &value, errp); | 54 | + qemu_fdt_setprop_cell(fdt, "/", "machine-version-minor", 1); |
151 | +} | 55 | |
152 | +#endif | 56 | if (ms->numa_state->have_numa_distance) { |
153 | + | 57 | int size = nb_numa_nodes * nb_numa_nodes * 3 * sizeof(uint32_t); |
154 | void aarch64_add_sve_properties(Object *obj) | 58 | @@ -XXX,XX +XXX,XX @@ static void create_fdt(SBSAMachineState *sms) |
155 | { | 59 | |
156 | uint32_t vq; | 60 | g_free(nodename); |
157 | @@ -XXX,XX +XXX,XX @@ void aarch64_add_sve_properties(Object *obj) | ||
158 | object_property_add(obj, name, "bool", cpu_arm_get_sve_vq, | ||
159 | cpu_arm_set_sve_vq, NULL, NULL); | ||
160 | } | 61 | } |
161 | + | 62 | + |
162 | +#ifdef CONFIG_USER_ONLY | 63 | + sbsa_fdt_add_gic_node(sms); |
163 | + /* Mirror linux /proc/sys/abi/sve_default_vector_length. */ | ||
164 | + object_property_add(obj, "sve-default-vector-length", "int32", | ||
165 | + cpu_arm_get_sve_default_vec_len, | ||
166 | + cpu_arm_set_sve_default_vec_len, NULL, NULL); | ||
167 | +#endif | ||
168 | } | 64 | } |
169 | 65 | ||
170 | void arm_cpu_pauth_finalize(ARMCPU *cpu, Error **errp) | 66 | #define SBSA_FLASH_SECTOR_SIZE (256 * KiB) |
171 | -- | 67 | -- |
172 | 2.20.1 | 68 | 2.34.1 |
173 | |||
174 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | 1 | From: Marcin Juszkiewicz <marcin.juszkiewicz@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 3 | We moved from VGA to Bochs to have PCIe card. |
4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 4 | |
5 | Message-id: 20210726150953.1218690-1-f4bug@amsat.org | 5 | Signed-off-by: Marcin Juszkiewicz <marcin.juszkiewicz@linaro.org> |
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | --- | 8 | --- |
8 | hw/arm/nseries.c | 2 +- | 9 | docs/system/arm/sbsa.rst | 2 +- |
9 | 1 file changed, 1 insertion(+), 1 deletion(-) | 10 | 1 file changed, 1 insertion(+), 1 deletion(-) |
10 | 11 | ||
11 | diff --git a/hw/arm/nseries.c b/hw/arm/nseries.c | 12 | diff --git a/docs/system/arm/sbsa.rst b/docs/system/arm/sbsa.rst |
12 | index XXXXXXX..XXXXXXX 100644 | 13 | index XXXXXXX..XXXXXXX 100644 |
13 | --- a/hw/arm/nseries.c | 14 | --- a/docs/system/arm/sbsa.rst |
14 | +++ b/hw/arm/nseries.c | 15 | +++ b/docs/system/arm/sbsa.rst |
15 | @@ -XXX,XX +XXX,XX @@ static uint32_t mipid_txrx(void *opaque, uint32_t cmd, int len) | 16 | @@ -XXX,XX +XXX,XX @@ The sbsa-ref board supports: |
16 | default: | 17 | - System bus EHCI controller |
17 | bad_cmd: | 18 | - CDROM and hard disc on AHCI bus |
18 | qemu_log_mask(LOG_GUEST_ERROR, | 19 | - E1000E ethernet card on PCIe bus |
19 | - "%s: unknown command %02x\n", __func__, s->cmd); | 20 | - - VGA display adaptor on PCIe bus |
20 | + "%s: unknown command 0x%02x\n", __func__, s->cmd); | 21 | + - Bochs display adapter on PCIe bus |
21 | break; | 22 | - A generic SBSA watchdog device |
22 | } | ||
23 | 23 | ||
24 | -- | 24 | -- |
25 | 2.20.1 | 25 | 2.34.1 |
26 | |||
27 | diff view generated by jsdifflib |