1 | The following changes since commit ad1b4ec39caa5b3f17cbd8160283a03a3dcfe2ae: | 1 | Hi; here's the latest batch of arm changes. The big thing |
---|---|---|---|
2 | in here is the SMMUv3 changes to add stage-2 translation support. | ||
2 | 3 | ||
3 | Merge remote-tracking branch 'remotes/kraxel/tags/input-20180515-pull-request' into staging (2018-05-15 12:50:06 +0100) | 4 | thanks |
5 | -- PMM | ||
6 | |||
7 | The following changes since commit aa9bbd865502ed517624ab6fe7d4b5d89ca95e43: | ||
8 | |||
9 | Merge tag 'pull-ppc-20230528' of https://gitlab.com/danielhb/qemu into staging (2023-05-29 14:31:52 -0700) | ||
4 | 10 | ||
5 | are available in the Git repository at: | 11 | are available in the Git repository at: |
6 | 12 | ||
7 | git://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20180515 | 13 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20230530 |
8 | 14 | ||
9 | for you to fetch changes up to ae7651804748c6b479d5ae09aeac4edb9c44f76e: | 15 | for you to fetch changes up to b03d0d4f531a8b867e0aac1fab0b876903015680: |
10 | 16 | ||
11 | tcg: Optionally log FPU state in TCG -d cpu logging (2018-05-15 14:58:44 +0100) | 17 | docs: sbsa: correct graphics card name (2023-05-30 13:32:46 +0100) |
12 | 18 | ||
13 | ---------------------------------------------------------------- | 19 | ---------------------------------------------------------------- |
14 | target-arm queue: | 20 | target-arm queue: |
15 | * Fix coverity nit in int_to_float code | 21 | * fsl-imx6: Add SNVS support for i.MX6 boards |
16 | * Don't set Invalid for float-to-int(MAXINT) | 22 | * smmuv3: Add support for stage 2 translations |
17 | * Fix fp_status_f16 tininess before rounding | 23 | * hw/dma/xilinx_axidma: Check DMASR.HALTED to prevent infinite loop |
18 | * Add various missing insns from the v8.2-FP16 extension | 24 | * hw/arm/xlnx-zynqmp: fix unsigned error when checking the RPUs number |
19 | * Fix sqrt_f16 exception raising | 25 | * cleanups for recent Kconfig changes |
20 | * sdcard: Correct CRC16 offset in sd_function_switch() | 26 | * target/arm: Explicitly select short-format FSR for M-profile |
21 | * tcg: Optionally log FPU state in TCG -d cpu logging | 27 | * tests/qtest: Run arm-specific tests only if the required machine is available |
28 | * hw/arm/sbsa-ref: add GIC node into DT | ||
29 | * docs: sbsa: correct graphics card name | ||
30 | * Update copyright dates to 2023 | ||
22 | 31 | ||
23 | ---------------------------------------------------------------- | 32 | ---------------------------------------------------------------- |
24 | Alex Bennée (5): | 33 | Clément Chigot (1): |
25 | fpu/softfloat: int_to_float ensure r fully initialised | 34 | hw/arm/xlnx-zynqmp: fix unsigned error when checking the RPUs number |
26 | target/arm: Implement FCMP for fp16 | ||
27 | target/arm: Implement FCSEL for fp16 | ||
28 | target/arm: Implement FMOV (immediate) for fp16 | ||
29 | target/arm: Fix sqrt_f16 exception raising | ||
30 | 35 | ||
31 | Peter Maydell (3): | 36 | Enze Li (1): |
32 | fpu/softfloat: Don't set Invalid for float-to-int(MAXINT) | 37 | Update copyright dates to 2023 |
33 | target/arm: Fix fp_status_f16 tininess before rounding | ||
34 | tcg: Optionally log FPU state in TCG -d cpu logging | ||
35 | 38 | ||
36 | Philippe Mathieu-Daudé (1): | 39 | Fabiano Rosas (3): |
37 | sdcard: Correct CRC16 offset in sd_function_switch() | 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 | ||
38 | 43 | ||
39 | Richard Henderson (7): | 44 | Marcin Juszkiewicz (2): |
40 | target/arm: Implement FMOV (general) for fp16 | 45 | hw/arm/sbsa-ref: add GIC node into DT |
41 | target/arm: Early exit after unallocated_encoding in disas_fp_int_conv | 46 | docs: sbsa: correct graphics card name |
42 | target/arm: Implement FCVT (scalar, integer) for fp16 | ||
43 | target/arm: Implement FCVT (scalar, fixed-point) for fp16 | ||
44 | target/arm: Introduce and use read_fp_hreg | ||
45 | target/arm: Implement FP data-processing (2 source) for fp16 | ||
46 | target/arm: Implement FP data-processing (3 source) for fp16 | ||
47 | 47 | ||
48 | include/qemu/log.h | 1 + | 48 | Mostafa Saleh (10): |
49 | target/arm/helper-a64.h | 2 + | 49 | hw/arm/smmuv3: Add missing fields for IDR0 |
50 | target/arm/helper.h | 6 + | 50 | hw/arm/smmuv3: Update translation config to hold stage-2 |
51 | accel/tcg/cpu-exec.c | 9 +- | 51 | hw/arm/smmuv3: Refactor stage-1 PTW |
52 | fpu/softfloat.c | 6 +- | 52 | hw/arm/smmuv3: Add page table walk for stage-2 |
53 | hw/sd/sd.c | 2 +- | 53 | hw/arm/smmuv3: Parse STE config for stage-2 |
54 | target/arm/cpu.c | 2 + | 54 | hw/arm/smmuv3: Make TLB lookup work for stage-2 |
55 | target/arm/helper-a64.c | 10 ++ | 55 | hw/arm/smmuv3: Add VMID to TLB tagging |
56 | target/arm/helper.c | 38 +++- | 56 | hw/arm/smmuv3: Add CMDs related to stage-2 |
57 | target/arm/translate-a64.c | 421 ++++++++++++++++++++++++++++++++++++++------- | 57 | hw/arm/smmuv3: Add stage-2 support in iova notifier |
58 | util/log.c | 2 + | 58 | hw/arm/smmuv3: Add knob to choose translation stage and enable stage-2 |
59 | 11 files changed, 428 insertions(+), 71 deletions(-) | ||
60 | 59 | ||
60 | Peter Maydell (1): | ||
61 | target/arm: Explicitly select short-format FSR for M-profile | ||
62 | |||
63 | Thomas Huth (1): | ||
64 | tests/qtest: Run arm-specific tests only if the required machine is available | ||
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 |
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | 1 | From: Vitaly Cheptsov <cheptsov@ispras.ru> |
---|---|---|---|
2 | 2 | ||
3 | Per the Physical Layer Simplified Spec. "4.3.10.4 Switch Function Status": | 3 | SNVS is supported on both i.MX6 and i.MX6UL and is needed |
4 | to support shutdown on the board. | ||
4 | 5 | ||
5 | The block length is predefined to 512 bits | 6 | Cc: Peter Maydell <peter.maydell@linaro.org> (odd fixer:SABRELITE / i.MX6) |
6 | 7 | Cc: Jean-Christophe Dubois <jcd@tribudubois.net> (reviewer:SABRELITE / i.MX6) | |
7 | and "4.10.2 SD Status": | 8 | Cc: qemu-arm@nongnu.org (open list:SABRELITE / i.MX6) |
8 | 9 | Cc: qemu-devel@nongnu.org (open list:All patches CC here) | |
9 | The SD Status contains status bits that are related to the SD Memory Card | 10 | Signed-off-by: Vitaly Cheptsov <cheptsov@ispras.ru> |
10 | proprietary features and may be used for future application-specific usage. | 11 | Message-id: 20230515095015.66860-1-cheptsov@ispras.ru |
11 | The size of the SD Status is one data block of 512 bit. The content of this | ||
12 | register is transmitted to the Host over the DAT bus along with a 16-bit CRC. | ||
13 | |||
14 | Thus the 16-bit CRC goes at offset 64. | ||
15 | |||
16 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
17 | Message-id: 20180509060104.4458-3-f4bug@amsat.org | ||
18 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 12 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
19 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
20 | --- | 14 | --- |
21 | hw/sd/sd.c | 2 +- | 15 | include/hw/arm/fsl-imx6.h | 2 ++ |
22 | 1 file changed, 1 insertion(+), 1 deletion(-) | 16 | hw/arm/fsl-imx6.c | 8 ++++++++ |
17 | 2 files changed, 10 insertions(+) | ||
23 | 18 | ||
24 | diff --git a/hw/sd/sd.c b/hw/sd/sd.c | 19 | diff --git a/include/hw/arm/fsl-imx6.h b/include/hw/arm/fsl-imx6.h |
25 | index XXXXXXX..XXXXXXX 100644 | 20 | index XXXXXXX..XXXXXXX 100644 |
26 | --- a/hw/sd/sd.c | 21 | --- a/include/hw/arm/fsl-imx6.h |
27 | +++ b/hw/sd/sd.c | 22 | +++ b/include/hw/arm/fsl-imx6.h |
28 | @@ -XXX,XX +XXX,XX @@ static void sd_function_switch(SDState *sd, uint32_t arg) | 23 | @@ -XXX,XX +XXX,XX @@ |
29 | sd->data[14 + (i >> 1)] = new_func << ((i * 4) & 4); | 24 | #include "hw/cpu/a9mpcore.h" |
30 | } | 25 | #include "hw/misc/imx6_ccm.h" |
31 | memset(&sd->data[17], 0, 47); | 26 | #include "hw/misc/imx6_src.h" |
32 | - stw_be_p(sd->data + 65, sd_crc16(sd->data, 64)); | 27 | +#include "hw/misc/imx7_snvs.h" |
33 | + stw_be_p(sd->data + 64, sd_crc16(sd->data, 64)); | 28 | #include "hw/watchdog/wdt_imx2.h" |
34 | } | 29 | #include "hw/char/imx_serial.h" |
35 | 30 | #include "hw/timer/imx_gpt.h" | |
36 | static inline bool sd_wp_addr(SDState *sd, uint64_t addr) | 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 | */ | ||
37 | -- | 65 | -- |
38 | 2.17.0 | 66 | 2.34.1 |
39 | |||
40 | diff view generated by jsdifflib |
1 | In commit d81ce0ef2c4f105 we added an extra float_status field | 1 | From: Mostafa Saleh <smostafa@google.com> |
---|---|---|---|
2 | fp_status_fp16 for Arm, but forgot to initialize it correctly | ||
3 | by setting it to float_tininess_before_rounding. This currently | ||
4 | will only cause problems for the new V8_FP16 feature, since the | ||
5 | float-to-float conversion code doesn't use it yet. The effect | ||
6 | would be that we failed to set the Underflow IEEE exception flag | ||
7 | in all the cases where we should. | ||
8 | 2 | ||
9 | Add the missing initialization. | 3 | In preparation for adding stage-2 support. |
4 | Add IDR0 fields related to stage-2. | ||
10 | 5 | ||
11 | Fixes: d81ce0ef2c4f105 | 6 | VMID16: 16-bit VMID supported. |
12 | Cc: qemu-stable@nongnu.org | 7 | S2P: Stage-2 translation supported. |
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> | 13 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
14 | Reviewed-by: Alex Bennée <alex.bennee@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 | ||
15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 19 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
16 | Message-id: 20180512004311.9299-16-richard.henderson@linaro.org | ||
17 | --- | 20 | --- |
18 | target/arm/cpu.c | 2 ++ | 21 | hw/arm/smmuv3-internal.h | 2 ++ |
19 | 1 file changed, 2 insertions(+) | 22 | 1 file changed, 2 insertions(+) |
20 | 23 | ||
21 | diff --git a/target/arm/cpu.c b/target/arm/cpu.c | 24 | diff --git a/hw/arm/smmuv3-internal.h b/hw/arm/smmuv3-internal.h |
22 | index XXXXXXX..XXXXXXX 100644 | 25 | index XXXXXXX..XXXXXXX 100644 |
23 | --- a/target/arm/cpu.c | 26 | --- a/hw/arm/smmuv3-internal.h |
24 | +++ b/target/arm/cpu.c | 27 | +++ b/hw/arm/smmuv3-internal.h |
25 | @@ -XXX,XX +XXX,XX @@ static void arm_cpu_reset(CPUState *s) | 28 | @@ -XXX,XX +XXX,XX @@ typedef enum SMMUTranslationStatus { |
26 | &env->vfp.fp_status); | 29 | /* MMIO Registers */ |
27 | set_float_detect_tininess(float_tininess_before_rounding, | 30 | |
28 | &env->vfp.standard_fp_status); | 31 | REG32(IDR0, 0x0) |
29 | + set_float_detect_tininess(float_tininess_before_rounding, | 32 | + FIELD(IDR0, S2P, 0 , 1) |
30 | + &env->vfp.fp_status_f16); | 33 | FIELD(IDR0, S1P, 1 , 1) |
31 | #ifndef CONFIG_USER_ONLY | 34 | FIELD(IDR0, TTF, 2 , 2) |
32 | if (kvm_enabled()) { | 35 | FIELD(IDR0, COHACC, 4 , 1) |
33 | kvm_arm_reset_vcpu(cpu); | 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) | ||
34 | -- | 41 | -- |
35 | 2.17.0 | 42 | 2.34.1 |
36 | |||
37 | 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 |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Mostafa Saleh <smostafa@google.com> |
---|---|---|---|
2 | 2 | ||
3 | We missed all of the scalar fp16 fma operations. | 3 | In preparation for adding stage-2 support, add Stage-2 PTW code. |
4 | 4 | Only Aarch64 format is supported as stage-1. | |
5 | Cc: qemu-stable@nongnu.org | 5 | |
6 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | 6 | Nesting stage-1 and stage-2 is not supported right now. |
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 7 | |
8 | Tested-by: Alex Bennée <alex.bennee@linaro.org> | 8 | HTTU is not supported, SW is expected to maintain the Access flag. |
9 | Message-id: 20180512003217.9105-8-richard.henderson@linaro.org | 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 | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 42 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | --- | 43 | --- |
12 | target/arm/translate-a64.c | 48 ++++++++++++++++++++++++++++++++++++++ | 44 | hw/arm/smmu-internal.h | 35 ++++++++++ |
13 | 1 file changed, 48 insertions(+) | 45 | hw/arm/smmu-common.c | 142 ++++++++++++++++++++++++++++++++++++++++- |
14 | 46 | 2 files changed, 176 insertions(+), 1 deletion(-) | |
15 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | 47 | |
48 | diff --git a/hw/arm/smmu-internal.h b/hw/arm/smmu-internal.h | ||
16 | index XXXXXXX..XXXXXXX 100644 | 49 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/target/arm/translate-a64.c | 50 | --- a/hw/arm/smmu-internal.h |
18 | +++ b/target/arm/translate-a64.c | 51 | +++ b/hw/arm/smmu-internal.h |
19 | @@ -XXX,XX +XXX,XX @@ static void handle_fp_3src_double(DisasContext *s, bool o0, bool o1, | 52 | @@ -XXX,XX +XXX,XX @@ |
20 | tcg_temp_free_i64(tcg_res); | 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); | ||
21 | } | 73 | } |
22 | 74 | ||
23 | +/* Floating-point data-processing (3 source) - half precision */ | 75 | +/* FEAT_LPA2 and FEAT_TTST are not implemented. */ |
24 | +static void handle_fp_3src_half(DisasContext *s, bool o0, bool o1, | 76 | +static inline int get_start_level(int sl0 , int granule_sz) |
25 | + int rd, int rn, int rm, int ra) | ||
26 | +{ | 77 | +{ |
27 | + TCGv_i32 tcg_op1, tcg_op2, tcg_op3; | 78 | + /* ARM DDI0487I.a: Table D8-12. */ |
28 | + TCGv_i32 tcg_res = tcg_temp_new_i32(); | 79 | + if (granule_sz == 12) { |
29 | + TCGv_ptr fpst = get_fpstatus_ptr(true); | 80 | + return 2 - sl0; |
30 | + | 81 | + } |
31 | + tcg_op1 = read_fp_hreg(s, rn); | 82 | + /* ARM DDI0487I.a: Table D8-22 and Table D8-31. */ |
32 | + tcg_op2 = read_fp_hreg(s, rm); | 83 | + return 3 - sl0; |
33 | + tcg_op3 = read_fp_hreg(s, ra); | 84 | +} |
34 | + | 85 | + |
35 | + /* These are fused multiply-add, and must be done as one | 86 | +/* |
36 | + * floating point operation with no rounding between the | 87 | + * Index in a concatenated first level stage-2 page table. |
37 | + * multiplication and addition steps. | 88 | + * ARM DDI0487I.a: D8.2.2 Concatenated translation tables. |
38 | + * NB that doing the negations here as separate steps is | 89 | + */ |
39 | + * correct : an input NaN should come out with its sign bit | 90 | +static inline int pgd_concat_idx(int start_level, int granule_sz, |
40 | + * flipped if it is a negated-input. | 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 | ||
41 | + */ | 98 | + */ |
42 | + if (o1 == true) { | 99 | + int shift = level_shift(start_level - 1, granule_sz); |
43 | + tcg_gen_xori_i32(tcg_op3, tcg_op3, 0x8000); | 100 | + |
44 | + } | 101 | + ret = ipa >> shift; |
45 | + | 102 | + return ret; |
46 | + if (o0 != o1) { | ||
47 | + tcg_gen_xori_i32(tcg_op1, tcg_op1, 0x8000); | ||
48 | + } | ||
49 | + | ||
50 | + gen_helper_advsimd_muladdh(tcg_res, tcg_op1, tcg_op2, tcg_op3, fpst); | ||
51 | + | ||
52 | + write_fp_sreg(s, rd, tcg_res); | ||
53 | + | ||
54 | + tcg_temp_free_ptr(fpst); | ||
55 | + tcg_temp_free_i32(tcg_op1); | ||
56 | + tcg_temp_free_i32(tcg_op2); | ||
57 | + tcg_temp_free_i32(tcg_op3); | ||
58 | + tcg_temp_free_i32(tcg_res); | ||
59 | +} | 103 | +} |
60 | + | 104 | + |
61 | /* Floating point data-processing (3 source) | 105 | #define SMMU_IOTLB_ASID(key) ((key).asid) |
62 | * 31 30 29 28 24 23 22 21 20 16 15 14 10 9 5 4 0 | 106 | |
63 | * +---+---+---+-----------+------+----+------+----+------+------+------+ | 107 | typedef struct SMMUIOTLBPageInvInfo { |
64 | @@ -XXX,XX +XXX,XX @@ static void disas_fp_3src(DisasContext *s, uint32_t insn) | 108 | diff --git a/hw/arm/smmu-common.c b/hw/arm/smmu-common.c |
65 | } | 109 | index XXXXXXX..XXXXXXX 100644 |
66 | handle_fp_3src_double(s, o0, o1, rd, rn, rm, ra); | 110 | --- a/hw/arm/smmu-common.c |
67 | break; | 111 | +++ b/hw/arm/smmu-common.c |
68 | + case 3: | 112 | @@ -XXX,XX +XXX,XX @@ error: |
69 | + if (!arm_dc_feature(s, ARM_FEATURE_V8_FP16)) { | 113 | return -EINVAL; |
70 | + unallocated_encoding(s); | 114 | } |
71 | + return; | 115 | |
72 | + } | 116 | +/** |
73 | + if (!fp_access_check(s)) { | 117 | + * smmu_ptw_64_s2 - VMSAv8-64 Walk of the page tables for a given ipa |
74 | + return; | 118 | + * for stage-2. |
75 | + } | 119 | + * @cfg: translation config |
76 | + handle_fp_3src_half(s, o0, o1, rd, rn, rm, ra); | 120 | + * @ipa: ipa to translate |
77 | + break; | 121 | + * @perm: access type |
78 | default: | 122 | + * @tlbe: SMMUTLBEntry (out) |
79 | unallocated_encoding(s); | 123 | + * @info: handle to an error info |
80 | } | 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 | /** | ||
81 | -- | 268 | -- |
82 | 2.17.0 | 269 | 2.34.1 |
83 | |||
84 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Mostafa Saleh <smostafa@google.com> |
---|---|---|---|
2 | 2 | ||
3 | We missed all of the scalar fp16 binary operations. | 3 | Parse stage-2 configuration from STE and populate it in SMMUS2Cfg. |
4 | 4 | Validity of field values are checked when possible. | |
5 | Cc: qemu-stable@nongnu.org | 5 | |
6 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | 6 | Only AA64 tables are supported and Small Translation Tables (STT) are |
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 7 | not supported. |
8 | Tested-by: Alex Bennée <alex.bennee@linaro.org> | 8 | |
9 | Message-id: 20180512003217.9105-7-richard.henderson@linaro.org | 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 | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 29 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | --- | 30 | --- |
12 | target/arm/translate-a64.c | 65 ++++++++++++++++++++++++++++++++++++++ | 31 | hw/arm/smmuv3-internal.h | 10 +- |
13 | 1 file changed, 65 insertions(+) | 32 | include/hw/arm/smmu-common.h | 1 + |
14 | 33 | include/hw/arm/smmuv3.h | 3 + | |
15 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | 34 | hw/arm/smmuv3.c | 181 +++++++++++++++++++++++++++++++++-- |
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/translate-a64.c | 39 | --- a/hw/arm/smmuv3-internal.h |
18 | +++ b/target/arm/translate-a64.c | 40 | +++ b/hw/arm/smmuv3-internal.h |
19 | @@ -XXX,XX +XXX,XX @@ static void handle_fp_2src_double(DisasContext *s, int opcode, | 41 | @@ -XXX,XX +XXX,XX @@ typedef struct CD { |
20 | tcg_temp_free_i64(tcg_res); | 42 | #define STE_S2TG(x) extract32((x)->word[5], 14, 2) |
43 | #define STE_S2PS(x) extract32((x)->word[5], 16, 3) | ||
44 | #define STE_S2AA64(x) extract32((x)->word[5], 19, 1) | ||
45 | -#define STE_S2HD(x) extract32((x)->word[5], 24, 1) | ||
46 | -#define STE_S2HA(x) extract32((x)->word[5], 25, 1) | ||
47 | -#define STE_S2S(x) extract32((x)->word[5], 26, 1) | ||
48 | +#define STE_S2ENDI(x) extract32((x)->word[5], 20, 1) | ||
49 | +#define STE_S2AFFD(x) extract32((x)->word[5], 21, 1) | ||
50 | +#define STE_S2HD(x) extract32((x)->word[5], 23, 1) | ||
51 | +#define STE_S2HA(x) extract32((x)->word[5], 24, 1) | ||
52 | +#define STE_S2S(x) extract32((x)->word[5], 25, 1) | ||
53 | +#define STE_S2R(x) extract32((x)->word[5], 26, 1) | ||
54 | + | ||
55 | #define STE_CTXPTR(x) \ | ||
56 | ({ \ | ||
57 | unsigned long addr; \ | ||
58 | diff --git a/include/hw/arm/smmu-common.h b/include/hw/arm/smmu-common.h | ||
59 | index XXXXXXX..XXXXXXX 100644 | ||
60 | --- a/include/hw/arm/smmu-common.h | ||
61 | +++ b/include/hw/arm/smmu-common.h | ||
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, | ||
97 | return 0; | ||
21 | } | 98 | } |
22 | 99 | ||
23 | +/* Floating-point data-processing (2 source) - half precision */ | 100 | +/* |
24 | +static void handle_fp_2src_half(DisasContext *s, int opcode, | 101 | + * Max valid value is 39 when SMMU_IDR3.STT == 0. |
25 | + int rd, int rn, int rm) | 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) | ||
26 | +{ | 110 | +{ |
27 | + TCGv_i32 tcg_op1; | 111 | + if (cfg->s2cfg.tsz > 39) { |
28 | + TCGv_i32 tcg_op2; | 112 | + return false; |
29 | + TCGv_i32 tcg_res; | 113 | + } |
30 | + TCGv_ptr fpst; | 114 | + |
31 | + | 115 | + if (cfg->s2cfg.granule_sz == 16) { |
32 | + tcg_res = tcg_temp_new_i32(); | 116 | + return (cfg->s2cfg.tsz >= 64 - oas2bits(SMMU_IDR5_OAS)); |
33 | + fpst = get_fpstatus_ptr(true); | 117 | + } |
34 | + tcg_op1 = read_fp_hreg(s, rn); | 118 | + |
35 | + tcg_op2 = read_fp_hreg(s, rm); | 119 | + return (cfg->s2cfg.tsz >= MAX(64 - oas2bits(SMMU_IDR5_OAS), 16)); |
36 | + | 120 | +} |
37 | + switch (opcode) { | 121 | + |
38 | + case 0x0: /* FMUL */ | 122 | +/* |
39 | + gen_helper_advsimd_mulh(tcg_res, tcg_op1, tcg_op2, fpst); | 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; | ||
40 | + break; | 153 | + break; |
41 | + case 0x1: /* FDIV */ | 154 | + case 0x1: /* 64KB */ |
42 | + gen_helper_advsimd_divh(tcg_res, tcg_op1, tcg_op2, fpst); | 155 | + cfg->s2cfg.granule_sz = 16; |
43 | + break; | 156 | + break; |
44 | + case 0x2: /* FADD */ | 157 | + case 0x2: /* 16KB */ |
45 | + gen_helper_advsimd_addh(tcg_res, tcg_op1, tcg_op2, fpst); | 158 | + cfg->s2cfg.granule_sz = 14; |
46 | + break; | ||
47 | + case 0x3: /* FSUB */ | ||
48 | + gen_helper_advsimd_subh(tcg_res, tcg_op1, tcg_op2, fpst); | ||
49 | + break; | ||
50 | + case 0x4: /* FMAX */ | ||
51 | + gen_helper_advsimd_maxh(tcg_res, tcg_op1, tcg_op2, fpst); | ||
52 | + break; | ||
53 | + case 0x5: /* FMIN */ | ||
54 | + gen_helper_advsimd_minh(tcg_res, tcg_op1, tcg_op2, fpst); | ||
55 | + break; | ||
56 | + case 0x6: /* FMAXNM */ | ||
57 | + gen_helper_advsimd_maxnumh(tcg_res, tcg_op1, tcg_op2, fpst); | ||
58 | + break; | ||
59 | + case 0x7: /* FMINNM */ | ||
60 | + gen_helper_advsimd_minnumh(tcg_res, tcg_op1, tcg_op2, fpst); | ||
61 | + break; | ||
62 | + case 0x8: /* FNMUL */ | ||
63 | + gen_helper_advsimd_mulh(tcg_res, tcg_op1, tcg_op2, fpst); | ||
64 | + tcg_gen_xori_i32(tcg_res, tcg_res, 0x8000); | ||
65 | + break; | 159 | + break; |
66 | + default: | 160 | + default: |
67 | + g_assert_not_reached(); | 161 | + qemu_log_mask(LOG_GUEST_ERROR, |
68 | + } | 162 | + "SMMUv3 bad STE S2TG: %x\n", STE_S2TG(ste)); |
69 | + | 163 | + goto bad_ste; |
70 | + write_fp_sreg(s, rd, tcg_res); | 164 | + } |
71 | + | 165 | + |
72 | + tcg_temp_free_ptr(fpst); | 166 | + cfg->s2cfg.vttb = STE_S2TTB(ste); |
73 | + tcg_temp_free_i32(tcg_op1); | 167 | + |
74 | + tcg_temp_free_i32(tcg_op2); | 168 | + cfg->s2cfg.sl0 = STE_S2SL0(ste); |
75 | + tcg_temp_free_i32(tcg_res); | 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; | ||
76 | +} | 227 | +} |
77 | + | 228 | + |
78 | /* Floating point data-processing (2 source) | 229 | /* Returns < 0 in case of invalid STE, 0 otherwise */ |
79 | * 31 30 29 28 24 23 22 21 20 16 15 12 11 10 9 5 4 0 | 230 | static int decode_ste(SMMUv3State *s, SMMUTransCfg *cfg, |
80 | * +---+---+---+-----------+------+---+------+--------+-----+------+------+ | 231 | STE *ste, SMMUEventInfo *event) |
81 | @@ -XXX,XX +XXX,XX @@ static void disas_fp_2src(DisasContext *s, uint32_t insn) | 232 | { |
82 | } | 233 | uint32_t config; |
83 | handle_fp_2src_double(s, opcode, rd, rn, rm); | 234 | + int ret; |
84 | break; | 235 | |
85 | + case 3: | 236 | if (!STE_VALID(ste)) { |
86 | + if (!arm_dc_feature(s, ARM_FEATURE_V8_FP16)) { | 237 | if (!event->inval_ste_allowed) { |
87 | + unallocated_encoding(s); | 238 | @@ -XXX,XX +XXX,XX @@ static int decode_ste(SMMUv3State *s, SMMUTransCfg *cfg, |
88 | + return; | 239 | return 0; |
240 | } | ||
241 | |||
242 | - if (STE_CFG_S2_ENABLED(config)) { | ||
243 | - qemu_log_mask(LOG_UNIMP, "SMMUv3 does not support stage 2 yet\n"); | ||
244 | + /* | ||
245 | + * If a stage is enabled in SW while not advertised, throw bad ste | ||
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; | ||
89 | + } | 274 | + } |
90 | + if (!fp_access_check(s)) { | 275 | + } |
91 | + return; | 276 | |
92 | + } | 277 | if (STE_S1CDMAX(ste) != 0) { |
93 | + handle_fp_2src_half(s, opcode, rd, rn, rm); | 278 | qemu_log_mask(LOG_UNIMP, |
94 | + break; | 279 | @@ -XXX,XX +XXX,XX @@ static IOMMUTLBEntry smmuv3_translate(IOMMUMemoryRegion *mr, hwaddr addr, |
95 | default: | 280 | if (cached_entry) { |
96 | unallocated_encoding(s); | 281 | if ((flag & IOMMU_WO) && !(cached_entry->entry.perm & IOMMU_WO)) { |
97 | } | 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; | ||
98 | -- | 327 | -- |
99 | 2.17.0 | 328 | 2.34.1 |
100 | |||
101 | 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 |
1 | From: Alex Bennée <alex.bennee@linaro.org> | 1 | From: Mostafa Saleh <smostafa@google.com> |
---|---|---|---|
2 | 2 | ||
3 | All the hard work is already done by vfp_expand_imm, we just need to | 3 | Allow TLB to be tagged with VMID. |
4 | make sure we pick up the correct size. | 4 | |
5 | 5 | If stage-1 is only supported, VMID is set to -1 and ignored from STE | |
6 | Cc: qemu-stable@nongnu.org | 6 | and CMD_TLBI_NH* cmds. |
7 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 7 | |
8 | Signed-off-by: Alex Bennée <alex.bennee@linaro.org> | 8 | Update smmu_iotlb_insert trace event to have vmid. |
9 | Tested-by: Alex Bennée <alex.bennee@linaro.org> | 9 | |
10 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 10 | Signed-off-by: Mostafa Saleh <smostafa@google.com> |
11 | Message-id: 20180512003217.9105-11-richard.henderson@linaro.org | 11 | Reviewed-by: Eric Auger <eric.auger@redhat.com> |
12 | [rth: Merge unallocated_encoding check with TCGMemOp conversion.] | 12 | Tested-by: Eric Auger <eric.auger@redhat.com> |
13 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 13 | Tested-by: Jean-Philippe Brucker <jean-philippe@linaro.org> |
14 | Message-id: 20230516203327.2051088-8-smostafa@google.com | ||
14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
15 | --- | 16 | --- |
16 | target/arm/translate-a64.c | 20 +++++++++++++++++--- | 17 | hw/arm/smmu-internal.h | 2 ++ |
17 | 1 file changed, 17 insertions(+), 3 deletions(-) | 18 | include/hw/arm/smmu-common.h | 5 +++-- |
18 | 19 | hw/arm/smmu-common.c | 36 ++++++++++++++++++++++-------------- | |
19 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | 20 | hw/arm/smmuv3.c | 12 +++++++++--- |
20 | index XXXXXXX..XXXXXXX 100644 | 21 | hw/arm/trace-events | 6 +++--- |
21 | --- a/target/arm/translate-a64.c | 22 | 5 files changed, 39 insertions(+), 22 deletions(-) |
22 | +++ b/target/arm/translate-a64.c | 23 | |
23 | @@ -XXX,XX +XXX,XX @@ static void disas_fp_imm(DisasContext *s, uint32_t insn) | 24 | diff --git a/hw/arm/smmu-internal.h b/hw/arm/smmu-internal.h |
24 | { | 25 | index XXXXXXX..XXXXXXX 100644 |
25 | int rd = extract32(insn, 0, 5); | 26 | --- a/hw/arm/smmu-internal.h |
26 | int imm8 = extract32(insn, 13, 8); | 27 | +++ b/hw/arm/smmu-internal.h |
27 | - int is_double = extract32(insn, 22, 2); | 28 | @@ -XXX,XX +XXX,XX @@ static inline int pgd_concat_idx(int start_level, int granule_sz, |
28 | + int type = extract32(insn, 22, 2); | 29 | } |
29 | uint64_t imm; | 30 | |
30 | TCGv_i64 tcg_res; | 31 | #define SMMU_IOTLB_ASID(key) ((key).asid) |
31 | + TCGMemOp sz; | 32 | +#define SMMU_IOTLB_VMID(key) ((key).vmid) |
32 | 33 | ||
33 | - if (is_double > 1) { | 34 | typedef struct SMMUIOTLBPageInvInfo { |
34 | + switch (type) { | 35 | int asid; |
35 | + case 0: | 36 | + int vmid; |
36 | + sz = MO_32; | 37 | uint64_t iova; |
37 | + break; | 38 | uint64_t mask; |
38 | + case 1: | 39 | } SMMUIOTLBPageInvInfo; |
39 | + sz = MO_64; | 40 | diff --git a/include/hw/arm/smmu-common.h b/include/hw/arm/smmu-common.h |
40 | + break; | 41 | index XXXXXXX..XXXXXXX 100644 |
41 | + case 3: | 42 | --- a/include/hw/arm/smmu-common.h |
42 | + sz = MO_16; | 43 | +++ b/include/hw/arm/smmu-common.h |
43 | + if (arm_dc_feature(s, ARM_FEATURE_V8_FP16)) { | 44 | @@ -XXX,XX +XXX,XX @@ typedef struct SMMUPciBus { |
44 | + break; | 45 | typedef struct SMMUIOTLBKey { |
45 | + } | 46 | uint64_t iova; |
46 | + /* fallthru */ | 47 | uint16_t asid; |
47 | + default: | 48 | + uint16_t vmid; |
48 | unallocated_encoding(s); | 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); | ||
49 | return; | 216 | return; |
50 | } | 217 | } |
51 | @@ -XXX,XX +XXX,XX @@ static void disas_fp_imm(DisasContext *s, uint32_t insn) | 218 | |
52 | return; | 219 | @@ -XXX,XX +XXX,XX @@ static void smmuv3_s1_range_inval(SMMUState *s, Cmd *cmd) |
53 | } | 220 | num_pages = (mask + 1) >> granule; |
54 | 221 | trace_smmuv3_s1_range_inval(vmid, asid, addr, tg, num_pages, ttl, leaf); | |
55 | - imm = vfp_expand_imm(MO_32 + is_double, imm8); | 222 | smmuv3_inv_notifiers_iova(s, asid, addr, tg, num_pages); |
56 | + imm = vfp_expand_imm(sz, imm8); | 223 | - smmu_iotlb_inv_iova(s, asid, addr, tg, num_pages, ttl); |
57 | 224 | + smmu_iotlb_inv_iova(s, asid, vmid, addr, tg, num_pages, ttl); | |
58 | tcg_res = tcg_const_i64(imm); | 225 | addr += mask + 1; |
59 | write_fp_dreg(s, rd, tcg_res); | 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)" | ||
60 | -- | 245 | -- |
61 | 2.17.0 | 246 | 2.34.1 |
62 | |||
63 | diff view generated by jsdifflib |
1 | From: Alex Bennée <alex.bennee@linaro.org> | 1 | From: Mostafa Saleh <smostafa@google.com> |
---|---|---|---|
2 | 2 | ||
3 | These where missed out from the rest of the half-precision work. | 3 | CMD_TLBI_S2_IPA: As S1+S2 is not enabled, for now this can be the |
4 | 4 | same as CMD_TLBI_NH_VAA. | |
5 | Cc: qemu-stable@nongnu.org | 5 | |
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 6 | CMD_TLBI_S12_VMALL: Added new function to invalidate TLB by VMID. |
7 | Signed-off-by: Alex Bennée <alex.bennee@linaro.org> | 7 | |
8 | Tested-by: Alex Bennée <alex.bennee@linaro.org> | 8 | For stage-1 only commands, add a check to throw CERROR_ILL if used |
9 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 9 | when stage-1 is not supported. |
10 | Message-id: 20180512003217.9105-9-richard.henderson@linaro.org | 10 | |
11 | [rth: Diagnose lack of FP16 before fp_access_check] | 11 | Reviewed-by: Eric Auger <eric.auger@redhat.com> |
12 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 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 | ||
13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 16 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
14 | --- | 17 | --- |
15 | target/arm/helper-a64.h | 2 + | 18 | include/hw/arm/smmu-common.h | 1 + |
16 | target/arm/helper-a64.c | 10 +++++ | 19 | hw/arm/smmu-common.c | 16 +++++++++++ |
17 | target/arm/translate-a64.c | 88 ++++++++++++++++++++++++++++++-------- | 20 | hw/arm/smmuv3.c | 55 ++++++++++++++++++++++++++++++------ |
18 | 3 files changed, 83 insertions(+), 17 deletions(-) | 21 | hw/arm/trace-events | 4 ++- |
19 | 22 | 4 files changed, 67 insertions(+), 9 deletions(-) | |
20 | diff --git a/target/arm/helper-a64.h b/target/arm/helper-a64.h | 23 | |
21 | index XXXXXXX..XXXXXXX 100644 | 24 | diff --git a/include/hw/arm/smmu-common.h b/include/hw/arm/smmu-common.h |
22 | --- a/target/arm/helper-a64.h | 25 | index XXXXXXX..XXXXXXX 100644 |
23 | +++ b/target/arm/helper-a64.h | 26 | --- a/include/hw/arm/smmu-common.h |
24 | @@ -XXX,XX +XXX,XX @@ | 27 | +++ b/include/hw/arm/smmu-common.h |
25 | DEF_HELPER_FLAGS_2(udiv64, TCG_CALL_NO_RWG_SE, i64, i64, i64) | 28 | @@ -XXX,XX +XXX,XX @@ SMMUIOTLBKey smmu_get_iotlb_key(uint16_t asid, uint16_t vmid, uint64_t iova, |
26 | DEF_HELPER_FLAGS_2(sdiv64, TCG_CALL_NO_RWG_SE, s64, s64, s64) | 29 | uint8_t tg, uint8_t level); |
27 | DEF_HELPER_FLAGS_1(rbit64, TCG_CALL_NO_RWG_SE, i64, i64) | 30 | void smmu_iotlb_inv_all(SMMUState *s); |
28 | +DEF_HELPER_3(vfp_cmph_a64, i64, f16, f16, ptr) | 31 | void smmu_iotlb_inv_asid(SMMUState *s, uint16_t asid); |
29 | +DEF_HELPER_3(vfp_cmpeh_a64, i64, f16, f16, ptr) | 32 | +void smmu_iotlb_inv_vmid(SMMUState *s, uint16_t vmid); |
30 | DEF_HELPER_3(vfp_cmps_a64, i64, f32, f32, ptr) | 33 | void smmu_iotlb_inv_iova(SMMUState *s, int asid, int vmid, dma_addr_t iova, |
31 | DEF_HELPER_3(vfp_cmpes_a64, i64, f32, f32, ptr) | 34 | uint8_t tg, uint64_t num_pages, uint8_t ttl); |
32 | DEF_HELPER_3(vfp_cmpd_a64, i64, f64, f64, ptr) | 35 | |
33 | diff --git a/target/arm/helper-a64.c b/target/arm/helper-a64.c | 36 | diff --git a/hw/arm/smmu-common.c b/hw/arm/smmu-common.c |
34 | index XXXXXXX..XXXXXXX 100644 | 37 | index XXXXXXX..XXXXXXX 100644 |
35 | --- a/target/arm/helper-a64.c | 38 | --- a/hw/arm/smmu-common.c |
36 | +++ b/target/arm/helper-a64.c | 39 | +++ b/hw/arm/smmu-common.c |
37 | @@ -XXX,XX +XXX,XX @@ static inline uint32_t float_rel_to_flags(int res) | 40 | @@ -XXX,XX +XXX,XX @@ static gboolean smmu_hash_remove_by_asid(gpointer key, gpointer value, |
38 | return flags; | 41 | |
42 | return SMMU_IOTLB_ASID(*iotlb_key) == asid; | ||
39 | } | 43 | } |
40 | 44 | + | |
41 | +uint64_t HELPER(vfp_cmph_a64)(float16 x, float16 y, void *fp_status) | 45 | +static gboolean smmu_hash_remove_by_vmid(gpointer key, gpointer value, |
46 | + gpointer user_data) | ||
42 | +{ | 47 | +{ |
43 | + return float_rel_to_flags(float16_compare_quiet(x, y, fp_status)); | 48 | + uint16_t vmid = *(uint16_t *)user_data; |
49 | + SMMUIOTLBKey *iotlb_key = (SMMUIOTLBKey *)key; | ||
50 | + | ||
51 | + return SMMU_IOTLB_VMID(*iotlb_key) == vmid; | ||
44 | +} | 52 | +} |
45 | + | 53 | + |
46 | +uint64_t HELPER(vfp_cmpeh_a64)(float16 x, float16 y, void *fp_status) | 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) | ||
47 | +{ | 62 | +{ |
48 | + return float_rel_to_flags(float16_compare(x, y, fp_status)); | 63 | + trace_smmu_iotlb_inv_vmid(vmid); |
64 | + g_hash_table_foreach_remove(s->iotlb, smmu_hash_remove_by_vmid, &vmid); | ||
49 | +} | 65 | +} |
50 | + | 66 | + |
51 | uint64_t HELPER(vfp_cmps_a64)(float32 x, float32 y, void *fp_status) | 67 | /* VMSAv8-64 Translation */ |
52 | { | 68 | |
53 | return float_rel_to_flags(float32_compare_quiet(x, y, fp_status)); | 69 | /** |
54 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | 70 | diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c |
55 | index XXXXXXX..XXXXXXX 100644 | 71 | index XXXXXXX..XXXXXXX 100644 |
56 | --- a/target/arm/translate-a64.c | 72 | --- a/hw/arm/smmuv3.c |
57 | +++ b/target/arm/translate-a64.c | 73 | +++ b/hw/arm/smmuv3.c |
58 | @@ -XXX,XX +XXX,XX @@ static void disas_data_proc_reg(DisasContext *s, uint32_t insn) | 74 | @@ -XXX,XX +XXX,XX @@ static void smmuv3_inv_notifiers_iova(SMMUState *s, int asid, dma_addr_t iova, |
59 | } | 75 | } |
60 | } | 76 | } |
61 | 77 | ||
62 | -static void handle_fp_compare(DisasContext *s, bool is_double, | 78 | -static void smmuv3_s1_range_inval(SMMUState *s, Cmd *cmd) |
63 | +static void handle_fp_compare(DisasContext *s, int size, | 79 | +static void smmuv3_range_inval(SMMUState *s, Cmd *cmd) |
64 | unsigned int rn, unsigned int rm, | ||
65 | bool cmp_with_zero, bool signal_all_nans) | ||
66 | { | 80 | { |
67 | TCGv_i64 tcg_flags = tcg_temp_new_i64(); | 81 | dma_addr_t end, addr = CMD_ADDR(cmd); |
68 | - TCGv_ptr fpst = get_fpstatus_ptr(false); | 82 | uint8_t type = CMD_TYPE(cmd); |
69 | + TCGv_ptr fpst = get_fpstatus_ptr(size == MO_16); | 83 | @@ -XXX,XX +XXX,XX @@ static void smmuv3_s1_range_inval(SMMUState *s, Cmd *cmd) |
70 | 84 | } | |
71 | - if (is_double) { | 85 | |
72 | + if (size == MO_64) { | 86 | if (!tg) { |
73 | TCGv_i64 tcg_vn, tcg_vm; | 87 | - trace_smmuv3_s1_range_inval(vmid, asid, addr, tg, 1, ttl, leaf); |
74 | 88 | + trace_smmuv3_range_inval(vmid, asid, addr, tg, 1, ttl, leaf); | |
75 | tcg_vn = read_fp_dreg(s, rn); | 89 | smmuv3_inv_notifiers_iova(s, asid, addr, tg, 1); |
76 | @@ -XXX,XX +XXX,XX @@ static void handle_fp_compare(DisasContext *s, bool is_double, | 90 | smmu_iotlb_inv_iova(s, asid, vmid, addr, tg, 1, ttl); |
77 | tcg_temp_free_i64(tcg_vn); | 91 | return; |
78 | tcg_temp_free_i64(tcg_vm); | 92 | @@ -XXX,XX +XXX,XX @@ static void smmuv3_s1_range_inval(SMMUState *s, Cmd *cmd) |
79 | } else { | 93 | uint64_t mask = dma_aligned_pow2_mask(addr, end, 64); |
80 | - TCGv_i32 tcg_vn, tcg_vm; | 94 | |
81 | + TCGv_i32 tcg_vn = tcg_temp_new_i32(); | 95 | num_pages = (mask + 1) >> granule; |
82 | + TCGv_i32 tcg_vm = tcg_temp_new_i32(); | 96 | - trace_smmuv3_s1_range_inval(vmid, asid, addr, tg, num_pages, ttl, leaf); |
83 | 97 | + trace_smmuv3_range_inval(vmid, asid, addr, tg, num_pages, ttl, leaf); | |
84 | - tcg_vn = read_fp_sreg(s, rn); | 98 | smmuv3_inv_notifiers_iova(s, asid, addr, tg, num_pages); |
85 | + read_vec_element_i32(s, tcg_vn, rn, 0, size); | 99 | smmu_iotlb_inv_iova(s, asid, vmid, addr, tg, num_pages, ttl); |
86 | if (cmp_with_zero) { | 100 | addr += mask + 1; |
87 | - tcg_vm = tcg_const_i32(0); | 101 | @@ -XXX,XX +XXX,XX @@ static int smmuv3_cmdq_consume(SMMUv3State *s) |
88 | + tcg_gen_movi_i32(tcg_vm, 0); | 102 | { |
89 | } else { | 103 | uint16_t asid = CMD_ASID(&cmd); |
90 | - tcg_vm = read_fp_sreg(s, rm); | 104 | |
91 | + read_vec_element_i32(s, tcg_vm, rm, 0, size); | 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; | ||
92 | } | 114 | } |
93 | - if (signal_all_nans) { | 115 | case SMMU_CMD_TLBI_NH_ALL: |
94 | - gen_helper_vfp_cmpes_a64(tcg_flags, tcg_vn, tcg_vm, fpst); | 116 | + if (!STAGE1_SUPPORTED(s)) { |
95 | - } else { | 117 | + cmd_error = SMMU_CERROR_ILL; |
96 | - gen_helper_vfp_cmps_a64(tcg_flags, tcg_vn, tcg_vm, fpst); | 118 | + break; |
97 | + | 119 | + } |
98 | + switch (size) { | 120 | + QEMU_FALLTHROUGH; |
99 | + case MO_32: | 121 | case SMMU_CMD_TLBI_NSNH_ALL: |
100 | + if (signal_all_nans) { | 122 | trace_smmuv3_cmdq_tlbi_nh(); |
101 | + gen_helper_vfp_cmpes_a64(tcg_flags, tcg_vn, tcg_vm, fpst); | 123 | smmu_inv_notifiers_all(&s->smmu_state); |
102 | + } else { | 124 | @@ -XXX,XX +XXX,XX @@ static int smmuv3_cmdq_consume(SMMUv3State *s) |
103 | + gen_helper_vfp_cmps_a64(tcg_flags, tcg_vn, tcg_vm, fpst); | 125 | break; |
104 | + } | 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); | ||
105 | + break; | 134 | + break; |
106 | + case MO_16: | 135 | + case SMMU_CMD_TLBI_S12_VMALL: |
107 | + if (signal_all_nans) { | 136 | + { |
108 | + gen_helper_vfp_cmpeh_a64(tcg_flags, tcg_vn, tcg_vm, fpst); | 137 | + uint16_t vmid = CMD_VMID(&cmd); |
109 | + } else { | 138 | + |
110 | + gen_helper_vfp_cmph_a64(tcg_flags, tcg_vn, tcg_vm, fpst); | 139 | + if (!STAGE2_SUPPORTED(s)) { |
111 | + } | 140 | + cmd_error = SMMU_CERROR_ILL; |
112 | + break; | 141 | + break; |
113 | + default: | 142 | + } |
114 | + g_assert_not_reached(); | 143 | + |
115 | } | 144 | + trace_smmuv3_cmdq_tlbi_s12_vmid(vmid); |
116 | + | 145 | + smmu_inv_notifiers_all(&s->smmu_state); |
117 | tcg_temp_free_i32(tcg_vn); | 146 | + smmu_iotlb_inv_vmid(bs, vmid); |
118 | tcg_temp_free_i32(tcg_vm); | ||
119 | } | ||
120 | @@ -XXX,XX +XXX,XX @@ static void handle_fp_compare(DisasContext *s, bool is_double, | ||
121 | static void disas_fp_compare(DisasContext *s, uint32_t insn) | ||
122 | { | ||
123 | unsigned int mos, type, rm, op, rn, opc, op2r; | ||
124 | + int size; | ||
125 | |||
126 | mos = extract32(insn, 29, 3); | ||
127 | - type = extract32(insn, 22, 2); /* 0 = single, 1 = double */ | ||
128 | + type = extract32(insn, 22, 2); | ||
129 | rm = extract32(insn, 16, 5); | ||
130 | op = extract32(insn, 14, 2); | ||
131 | rn = extract32(insn, 5, 5); | ||
132 | opc = extract32(insn, 3, 2); | ||
133 | op2r = extract32(insn, 0, 3); | ||
134 | |||
135 | - if (mos || op || op2r || type > 1) { | ||
136 | + if (mos || op || op2r) { | ||
137 | + unallocated_encoding(s); | ||
138 | + return; | ||
139 | + } | ||
140 | + | ||
141 | + switch (type) { | ||
142 | + case 0: | ||
143 | + size = MO_32; | ||
144 | + break; | ||
145 | + case 1: | ||
146 | + size = MO_64; | ||
147 | + break; | ||
148 | + case 3: | ||
149 | + size = MO_16; | ||
150 | + if (arm_dc_feature(s, ARM_FEATURE_V8_FP16)) { | ||
151 | + break; | 147 | + break; |
152 | + } | 148 | + } |
153 | + /* fallthru */ | 149 | + case SMMU_CMD_TLBI_S2_IPA: |
154 | + default: | 150 | + if (!STAGE2_SUPPORTED(s)) { |
155 | unallocated_encoding(s); | 151 | + cmd_error = SMMU_CERROR_ILL; |
156 | return; | 152 | + break; |
157 | } | 153 | + } |
158 | @@ -XXX,XX +XXX,XX @@ static void disas_fp_compare(DisasContext *s, uint32_t insn) | 154 | + /* |
159 | return; | 155 | + * As currently only either s1 or s2 are supported |
160 | } | 156 | + * we can reuse same function for s2. |
161 | 157 | + */ | |
162 | - handle_fp_compare(s, type, rn, rm, opc & 1, opc & 2); | 158 | + smmuv3_range_inval(bs, &cmd); |
163 | + handle_fp_compare(s, size, rn, rm, opc & 1, opc & 2); | 159 | break; |
164 | } | 160 | case SMMU_CMD_TLBI_EL3_ALL: |
165 | 161 | case SMMU_CMD_TLBI_EL3_VA: | |
166 | /* Floating point conditional compare | 162 | @@ -XXX,XX +XXX,XX @@ static int smmuv3_cmdq_consume(SMMUv3State *s) |
167 | @@ -XXX,XX +XXX,XX @@ static void disas_fp_ccomp(DisasContext *s, uint32_t insn) | 163 | case SMMU_CMD_TLBI_EL2_ASID: |
168 | unsigned int mos, type, rm, cond, rn, op, nzcv; | 164 | case SMMU_CMD_TLBI_EL2_VA: |
169 | TCGv_i64 tcg_flags; | 165 | case SMMU_CMD_TLBI_EL2_VAA: |
170 | TCGLabel *label_continue = NULL; | 166 | - case SMMU_CMD_TLBI_S12_VMALL: |
171 | + int size; | 167 | - case SMMU_CMD_TLBI_S2_IPA: |
172 | 168 | case SMMU_CMD_ATC_INV: | |
173 | mos = extract32(insn, 29, 3); | 169 | case SMMU_CMD_PRI_RESP: |
174 | - type = extract32(insn, 22, 2); /* 0 = single, 1 = double */ | 170 | case SMMU_CMD_RESUME: |
175 | + type = extract32(insn, 22, 2); | 171 | @@ -XXX,XX +XXX,XX @@ static int smmuv3_cmdq_consume(SMMUv3State *s) |
176 | rm = extract32(insn, 16, 5); | 172 | break; |
177 | cond = extract32(insn, 12, 4); | 173 | default: |
178 | rn = extract32(insn, 5, 5); | 174 | cmd_error = SMMU_CERROR_ILL; |
179 | op = extract32(insn, 4, 1); | 175 | - qemu_log_mask(LOG_GUEST_ERROR, |
180 | nzcv = extract32(insn, 0, 4); | 176 | - "Illegal command type: %d\n", CMD_TYPE(&cmd)); |
181 | 177 | break; | |
182 | - if (mos || type > 1) { | 178 | } |
183 | + if (mos) { | 179 | qemu_mutex_unlock(&s->mutex); |
184 | + unallocated_encoding(s); | 180 | if (cmd_error) { |
185 | + return; | 181 | + if (cmd_error == SMMU_CERROR_ILL) { |
186 | + } | 182 | + qemu_log_mask(LOG_GUEST_ERROR, |
187 | + | 183 | + "Illegal command type: %d\n", CMD_TYPE(&cmd)); |
188 | + switch (type) { | 184 | + } |
189 | + case 0: | 185 | break; |
190 | + size = MO_32; | 186 | } |
191 | + break; | 187 | /* |
192 | + case 1: | 188 | diff --git a/hw/arm/trace-events b/hw/arm/trace-events |
193 | + size = MO_64; | 189 | index XXXXXXX..XXXXXXX 100644 |
194 | + break; | 190 | --- a/hw/arm/trace-events |
195 | + case 3: | 191 | +++ b/hw/arm/trace-events |
196 | + size = MO_16; | 192 | @@ -XXX,XX +XXX,XX @@ smmu_ptw_block_pte(int stage, int level, uint64_t baseaddr, uint64_t pteaddr, ui |
197 | + if (arm_dc_feature(s, ARM_FEATURE_V8_FP16)) { | 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 |
198 | + break; | 194 | smmu_iotlb_inv_all(void) "IOTLB invalidate all" |
199 | + } | 195 | smmu_iotlb_inv_asid(uint16_t asid) "IOTLB invalidate asid=%d" |
200 | + /* fallthru */ | 196 | +smmu_iotlb_inv_vmid(uint16_t vmid) "IOTLB invalidate vmid=%d" |
201 | + default: | 197 | smmu_iotlb_inv_iova(uint16_t asid, uint64_t addr) "IOTLB invalidate asid=%d addr=0x%"PRIx64 |
202 | unallocated_encoding(s); | 198 | smmu_inv_notifiers_mr(const char *name) "iommu mr=%s" |
203 | return; | 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" |
204 | } | 200 | @@ -XXX,XX +XXX,XX @@ smmuv3_cmdq_cfgi_ste_range(int start, int end) "start=0x%x - end=0x%x" |
205 | @@ -XXX,XX +XXX,XX @@ static void disas_fp_ccomp(DisasContext *s, uint32_t insn) | 201 | smmuv3_cmdq_cfgi_cd(uint32_t sid) "sid=0x%x" |
206 | gen_set_label(label_match); | 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)" |
207 | } | 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)" |
208 | 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" | |
209 | - handle_fp_compare(s, type, rn, rm, false, op); | 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" |
210 | + handle_fp_compare(s, size, rn, rm, false, op); | 206 | smmuv3_cmdq_tlbi_nh(void) "" |
211 | 207 | smmuv3_cmdq_tlbi_nh_asid(uint16_t asid) "asid=%d" | |
212 | if (cond < 0x0e) { | 208 | +smmuv3_cmdq_tlbi_s12_vmid(uint16_t vmid) "vmid=%d" |
213 | gen_set_label(label_continue); | 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" | ||
214 | -- | 212 | -- |
215 | 2.17.0 | 213 | 2.34.1 |
216 | |||
217 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Mostafa Saleh <smostafa@google.com> |
---|---|---|---|
2 | 2 | ||
3 | Adding the fp16 moves to/from general registers. | 3 | In smmuv3_notify_iova, read the granule based on translation stage |
4 | and use VMID if valid value is sent. | ||
4 | 5 | ||
5 | Cc: qemu-stable@nongnu.org | 6 | Signed-off-by: Mostafa Saleh <smostafa@google.com> |
6 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 7 | Reviewed-by: Eric Auger <eric.auger@redhat.com> |
7 | Tested-by: Alex Bennée <alex.bennee@linaro.org> | 8 | Tested-by: Eric Auger <eric.auger@redhat.com> |
8 | Message-id: 20180512003217.9105-2-richard.henderson@linaro.org | 9 | Tested-by: Jean-Philippe Brucker <jean-philippe@linaro.org> |
9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Message-id: 20230516203327.2051088-10-smostafa@google.com |
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | --- | 12 | --- |
12 | target/arm/translate-a64.c | 21 +++++++++++++++++++++ | 13 | hw/arm/smmuv3.c | 39 ++++++++++++++++++++++++++------------- |
13 | 1 file changed, 21 insertions(+) | 14 | hw/arm/trace-events | 2 +- |
15 | 2 files changed, 27 insertions(+), 14 deletions(-) | ||
14 | 16 | ||
15 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | 17 | diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c |
16 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/target/arm/translate-a64.c | 19 | --- a/hw/arm/smmuv3.c |
18 | +++ b/target/arm/translate-a64.c | 20 | +++ b/hw/arm/smmuv3.c |
19 | @@ -XXX,XX +XXX,XX @@ static void handle_fmov(DisasContext *s, int rd, int rn, int type, bool itof) | 21 | @@ -XXX,XX +XXX,XX @@ epilogue: |
20 | tcg_gen_st_i64(tcg_rn, cpu_env, fp_reg_hi_offset(s, rd)); | 22 | * @mr: IOMMU mr region handle |
21 | clear_vec_high(s, true, rd); | 23 | * @n: notifier to be called |
22 | break; | 24 | * @asid: address space ID or negative value if we don't care |
23 | + case 3: | 25 | + * @vmid: virtual machine ID or negative value if we don't care |
24 | + /* 16 bit */ | 26 | * @iova: iova |
25 | + tmp = tcg_temp_new_i64(); | 27 | * @tg: translation granule (if communicated through range invalidation) |
26 | + tcg_gen_ext16u_i64(tmp, tcg_rn); | 28 | * @num_pages: number of @granule sized pages (if tg != 0), otherwise 1 |
27 | + write_fp_dreg(s, rd, tmp); | 29 | */ |
28 | + tcg_temp_free_i64(tmp); | 30 | static void smmuv3_notify_iova(IOMMUMemoryRegion *mr, |
29 | + break; | 31 | IOMMUNotifier *n, |
30 | + default: | 32 | - int asid, dma_addr_t iova, |
31 | + g_assert_not_reached(); | 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) | ||
37 | { | ||
38 | SMMUDevice *sdev = container_of(mr, SMMUDevice, iommu); | ||
39 | IOMMUTLBEvent event; | ||
40 | uint8_t granule; | ||
41 | + SMMUv3State *s = sdev->smmu; | ||
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; | ||
32 | } | 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; | ||
55 | + | ||
56 | + if (STAGE1_SUPPORTED(s)) { | ||
57 | + tt = select_tt(cfg, iova); | ||
58 | + if (!tt) { | ||
59 | + return; | ||
60 | + } | ||
61 | + granule = tt->granule_sz; | ||
62 | + } else { | ||
63 | + granule = cfg->s2cfg.granule_sz; | ||
64 | + } | ||
65 | + | ||
33 | } else { | 66 | } else { |
34 | TCGv_i64 tcg_rd = cpu_reg(s, rd); | 67 | granule = tg * 2 + 10; |
35 | @@ -XXX,XX +XXX,XX @@ static void handle_fmov(DisasContext *s, int rd, int rn, int type, bool itof) | 68 | } |
36 | /* 64 bits from top half */ | 69 | @@ -XXX,XX +XXX,XX @@ static void smmuv3_notify_iova(IOMMUMemoryRegion *mr, |
37 | tcg_gen_ld_i64(tcg_rd, cpu_env, fp_reg_hi_offset(s, rn)); | 70 | memory_region_notify_iommu_one(n, &event); |
38 | break; | 71 | } |
39 | + case 3: | 72 | |
40 | + /* 16 bit */ | 73 | -/* invalidate an asid/iova range tuple in all mr's */ |
41 | + tcg_gen_ld16u_i64(tcg_rd, cpu_env, fp_reg_offset(s, rn, MO_16)); | 74 | -static void smmuv3_inv_notifiers_iova(SMMUState *s, int asid, dma_addr_t iova, |
42 | + break; | 75 | - uint8_t tg, uint64_t num_pages) |
43 | + default: | 76 | +/* invalidate an asid/vmid/iova range tuple in all mr's */ |
44 | + g_assert_not_reached(); | 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); | ||
45 | } | 95 | } |
46 | } | 96 | } |
47 | } | 97 | } |
48 | @@ -XXX,XX +XXX,XX @@ static void disas_fp_int_conv(DisasContext *s, uint32_t insn) | 98 | @@ -XXX,XX +XXX,XX @@ static void smmuv3_range_inval(SMMUState *s, Cmd *cmd) |
49 | case 0xa: /* 64 bit */ | 99 | |
50 | case 0xd: /* 64 bit to top half of quad */ | 100 | if (!tg) { |
51 | break; | 101 | trace_smmuv3_range_inval(vmid, asid, addr, tg, 1, ttl, leaf); |
52 | + case 0x6: /* 16-bit float, 32-bit int */ | 102 | - smmuv3_inv_notifiers_iova(s, asid, addr, tg, 1); |
53 | + case 0xe: /* 16-bit float, 64-bit int */ | 103 | + smmuv3_inv_notifiers_iova(s, asid, vmid, addr, tg, 1); |
54 | + if (arm_dc_feature(s, ARM_FEATURE_V8_FP16)) { | 104 | smmu_iotlb_inv_iova(s, asid, vmid, addr, tg, 1, ttl); |
55 | + break; | 105 | return; |
56 | + } | 106 | } |
57 | + /* fallthru */ | 107 | @@ -XXX,XX +XXX,XX @@ static void smmuv3_range_inval(SMMUState *s, Cmd *cmd) |
58 | default: | 108 | |
59 | /* all other sf/type/rmode combinations are invalid */ | 109 | num_pages = (mask + 1) >> granule; |
60 | unallocated_encoding(s); | 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 | |||
61 | -- | 127 | -- |
62 | 2.17.0 | 128 | 2.34.1 |
63 | |||
64 | diff view generated by jsdifflib |
1 | From: Alex Bennée <alex.bennee@linaro.org> | 1 | From: Mostafa Saleh <smostafa@google.com> |
---|---|---|---|
2 | 2 | ||
3 | These were missed out from the rest of the half-precision work. | 3 | As everything is in place, we can use a new system property to |
4 | advertise which stage is supported and remove bad_ste from STE | ||
5 | stage2 config. | ||
4 | 6 | ||
5 | Cc: qemu-stable@nongnu.org | 7 | The property added arm-smmuv3.stage can have 3 values: |
6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 8 | - "1": Stage-1 only is advertised. |
7 | Signed-off-by: Alex Bennée <alex.bennee@linaro.org> | 9 | - "2": Stage-2 only is advertised. |
8 | Tested-by: Alex Bennée <alex.bennee@linaro.org> | 10 | |
9 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 11 | If not passed or an unsupported value is passed, it will default to |
10 | Message-id: 20180512003217.9105-10-richard.henderson@linaro.org | 12 | stage-1. |
11 | [rth: Fix erroneous check vs type] | 13 | |
12 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 14 | Advertise VMID16. |
15 | |||
16 | Don't try to decode CD, if stage-2 is configured. | ||
17 | |||
18 | Reviewed-by: Eric Auger <eric.auger@redhat.com> | ||
19 | Signed-off-by: Mostafa Saleh <smostafa@google.com> | ||
20 | Tested-by: Eric Auger <eric.auger@redhat.com> | ||
21 | Tested-by: Jean-Philippe Brucker <jean-philippe@linaro.org> | ||
22 | Message-id: 20230516203327.2051088-11-smostafa@google.com | ||
13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 23 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
14 | --- | 24 | --- |
15 | target/arm/translate-a64.c | 31 +++++++++++++++++++++++++------ | 25 | include/hw/arm/smmuv3.h | 1 + |
16 | 1 file changed, 25 insertions(+), 6 deletions(-) | 26 | hw/arm/smmuv3.c | 32 ++++++++++++++++++++++---------- |
27 | 2 files changed, 23 insertions(+), 10 deletions(-) | ||
17 | 28 | ||
18 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | 29 | diff --git a/include/hw/arm/smmuv3.h b/include/hw/arm/smmuv3.h |
19 | index XXXXXXX..XXXXXXX 100644 | 30 | index XXXXXXX..XXXXXXX 100644 |
20 | --- a/target/arm/translate-a64.c | 31 | --- a/include/hw/arm/smmuv3.h |
21 | +++ b/target/arm/translate-a64.c | 32 | +++ b/include/hw/arm/smmuv3.h |
22 | @@ -XXX,XX +XXX,XX @@ static void disas_fp_csel(DisasContext *s, uint32_t insn) | 33 | @@ -XXX,XX +XXX,XX @@ struct SMMUv3State { |
23 | unsigned int mos, type, rm, cond, rn, rd; | 34 | |
24 | TCGv_i64 t_true, t_false, t_zero; | 35 | qemu_irq irq[4]; |
25 | DisasCompare64 c; | 36 | QemuMutex mutex; |
26 | + TCGMemOp sz; | 37 | + char *stage; |
27 | 38 | }; | |
28 | mos = extract32(insn, 29, 3); | 39 | |
29 | - type = extract32(insn, 22, 2); /* 0 = single, 1 = double */ | 40 | typedef enum { |
30 | + type = extract32(insn, 22, 2); | 41 | diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c |
31 | rm = extract32(insn, 16, 5); | 42 | index XXXXXXX..XXXXXXX 100644 |
32 | cond = extract32(insn, 12, 4); | 43 | --- a/hw/arm/smmuv3.c |
33 | rn = extract32(insn, 5, 5); | 44 | +++ b/hw/arm/smmuv3.c |
34 | rd = extract32(insn, 0, 5); | 45 | @@ -XXX,XX +XXX,XX @@ |
35 | 46 | #include "hw/irq.h" | |
36 | - if (mos || type > 1) { | 47 | #include "hw/sysbus.h" |
37 | + if (mos) { | 48 | #include "migration/vmstate.h" |
38 | + unallocated_encoding(s); | 49 | +#include "hw/qdev-properties.h" |
39 | + return; | 50 | #include "hw/qdev-core.h" |
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) | ||
56 | { | ||
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); | ||
40 | + } | 67 | + } |
41 | + | 68 | + |
42 | + switch (type) { | 69 | s->idr[0] = FIELD_DP32(s->idr[0], IDR0, TTF, 2); /* AArch64 PTW only */ |
43 | + case 0: | 70 | s->idr[0] = FIELD_DP32(s->idr[0], IDR0, COHACC, 1); /* IO coherent */ |
44 | + sz = MO_32; | 71 | s->idr[0] = FIELD_DP32(s->idr[0], IDR0, ASID16, 1); /* 16-bit ASID */ |
45 | + break; | 72 | + s->idr[0] = FIELD_DP32(s->idr[0], IDR0, VMID16, 1); /* 16-bit VMID */ |
46 | + case 1: | 73 | s->idr[0] = FIELD_DP32(s->idr[0], IDR0, TTENDIAN, 2); /* little endian */ |
47 | + sz = MO_64; | 74 | s->idr[0] = FIELD_DP32(s->idr[0], IDR0, STALL_MODEL, 1); /* No stall */ |
48 | + break; | 75 | /* terminated transaction will always be aborted/error returned */ |
49 | + case 3: | 76 | @@ -XXX,XX +XXX,XX @@ static int decode_ste_s2_cfg(SMMUTransCfg *cfg, STE *ste) |
50 | + sz = MO_16; | 77 | goto bad_ste; |
51 | + if (arm_dc_feature(s, ARM_FEATURE_V8_FP16)) { | ||
52 | + break; | ||
53 | + } | ||
54 | + /* fallthru */ | ||
55 | + default: | ||
56 | unallocated_encoding(s); | ||
57 | return; | ||
58 | } | 78 | } |
59 | @@ -XXX,XX +XXX,XX @@ static void disas_fp_csel(DisasContext *s, uint32_t insn) | 79 | |
60 | return; | 80 | - /* This is still here as stage 2 has not been fully enabled yet. */ |
81 | - qemu_log_mask(LOG_UNIMP, "SMMUv3 does not support stage 2 yet\n"); | ||
82 | - goto bad_ste; | ||
83 | - | ||
84 | return 0; | ||
85 | |||
86 | bad_ste: | ||
87 | @@ -XXX,XX +XXX,XX @@ static int smmuv3_decode_config(IOMMUMemoryRegion *mr, SMMUTransCfg *cfg, | ||
88 | return ret; | ||
61 | } | 89 | } |
62 | 90 | ||
63 | - /* Zero extend sreg inputs to 64 bits now. */ | 91 | - if (cfg->aborted || cfg->bypassed) { |
64 | + /* Zero extend sreg & hreg inputs to 64 bits now. */ | 92 | + if (cfg->aborted || cfg->bypassed || (cfg->stage == 2)) { |
65 | t_true = tcg_temp_new_i64(); | 93 | return 0; |
66 | t_false = tcg_temp_new_i64(); | 94 | } |
67 | - read_vec_element(s, t_true, rn, 0, type ? MO_64 : MO_32); | 95 | |
68 | - read_vec_element(s, t_false, rm, 0, type ? MO_64 : MO_32); | 96 | @@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_smmuv3 = { |
69 | + read_vec_element(s, t_true, rn, 0, sz); | 97 | } |
70 | + read_vec_element(s, t_false, rm, 0, sz); | 98 | }; |
71 | 99 | ||
72 | a64_test_cc(&c, cond); | 100 | +static Property smmuv3_properties[] = { |
73 | t_zero = tcg_const_i64(0); | 101 | + /* |
74 | @@ -XXX,XX +XXX,XX @@ static void disas_fp_csel(DisasContext *s, uint32_t insn) | 102 | + * Stages of translation advertised. |
75 | tcg_temp_free_i64(t_false); | 103 | + * "1": Stage 1 |
76 | a64_free_cc(&c); | 104 | + * "2": Stage 2 |
77 | 105 | + * Defaults to stage 1 | |
78 | - /* Note that sregs write back zeros to the high bits, | 106 | + */ |
79 | + /* Note that sregs & hregs write back zeros to the high bits, | 107 | + DEFINE_PROP_STRING("stage", SMMUv3State, stage), |
80 | and we've already done the zero-extension. */ | 108 | + DEFINE_PROP_END_OF_LIST() |
81 | write_fp_dreg(s, rd, t_true); | 109 | +}; |
82 | tcg_temp_free_i64(t_true); | 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); | ||
119 | } | ||
120 | |||
121 | static int smmuv3_notify_flag_changed(IOMMUMemoryRegion *iommu, | ||
83 | -- | 122 | -- |
84 | 2.17.0 | 123 | 2.34.1 |
85 | |||
86 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Tommy Wu <tommy.wu@sifive.com> |
---|---|---|---|
2 | 2 | ||
3 | Cc: qemu-stable@nongnu.org | 3 | When we receive a packet from the xilinx_axienet and then try to s2mem |
4 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 4 | through the xilinx_axidma, if the descriptor ring buffer is full in the |
5 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 5 | xilinx axidma driver, we’ll assert the DMASR.HALTED in the |
6 | Tested-by: Alex Bennée <alex.bennee@linaro.org> | 6 | function : stream_process_s2mem and return 0. In the end, we’ll be stuck in |
7 | Message-id: 20180512003217.9105-6-richard.henderson@linaro.org | 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 | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 17 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
9 | --- | 18 | --- |
10 | target/arm/translate-a64.c | 30 ++++++++++++++---------------- | 19 | hw/dma/xilinx_axidma.c | 11 ++++++++--- |
11 | 1 file changed, 14 insertions(+), 16 deletions(-) | 20 | 1 file changed, 8 insertions(+), 3 deletions(-) |
12 | 21 | ||
13 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | 22 | diff --git a/hw/dma/xilinx_axidma.c b/hw/dma/xilinx_axidma.c |
14 | index XXXXXXX..XXXXXXX 100644 | 23 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/target/arm/translate-a64.c | 24 | --- a/hw/dma/xilinx_axidma.c |
16 | +++ b/target/arm/translate-a64.c | 25 | +++ b/hw/dma/xilinx_axidma.c |
17 | @@ -XXX,XX +XXX,XX @@ static TCGv_i32 read_fp_sreg(DisasContext *s, int reg) | 26 | @@ -XXX,XX +XXX,XX @@ static inline int stream_idle(struct Stream *s) |
18 | return v; | 27 | return !!(s->regs[R_DMASR] & DMASR_IDLE); |
19 | } | 28 | } |
20 | 29 | ||
21 | +static TCGv_i32 read_fp_hreg(DisasContext *s, int reg) | 30 | +static inline int stream_halted(struct Stream *s) |
22 | +{ | 31 | +{ |
23 | + TCGv_i32 v = tcg_temp_new_i32(); | 32 | + return !!(s->regs[R_DMASR] & DMASR_HALTED); |
24 | + | ||
25 | + tcg_gen_ld16u_i32(v, cpu_env, fp_reg_offset(s, reg, MO_16)); | ||
26 | + return v; | ||
27 | +} | 33 | +} |
28 | + | 34 | + |
29 | /* Clear the bits above an N-bit vector, for N = (is_q ? 128 : 64). | 35 | static void stream_reset(struct Stream *s) |
30 | * If SVE is not enabled, then there are only 128 bits in the vector. | ||
31 | */ | ||
32 | @@ -XXX,XX +XXX,XX @@ static void disas_fp_csel(DisasContext *s, uint32_t insn) | ||
33 | static void handle_fp_1src_half(DisasContext *s, int opcode, int rd, int rn) | ||
34 | { | 36 | { |
35 | TCGv_ptr fpst = NULL; | 37 | s->regs[R_DMASR] = DMASR_HALTED; /* starts up halted. */ |
36 | - TCGv_i32 tcg_op = tcg_temp_new_i32(); | 38 | @@ -XXX,XX +XXX,XX @@ static void stream_process_mem2s(struct Stream *s, StreamSink *tx_data_dev, |
37 | + TCGv_i32 tcg_op = read_fp_hreg(s, rn); | 39 | uint64_t addr; |
38 | TCGv_i32 tcg_res = tcg_temp_new_i32(); | 40 | bool eop; |
39 | 41 | ||
40 | - read_vec_element_i32(s, tcg_op, rn, 0, MO_16); | 42 | - if (!stream_running(s) || stream_idle(s)) { |
41 | - | 43 | + if (!stream_running(s) || stream_idle(s) || stream_halted(s)) { |
42 | switch (opcode) { | 44 | return; |
43 | case 0x0: /* FMOV */ | ||
44 | tcg_gen_mov_i32(tcg_res, tcg_op); | ||
45 | @@ -XXX,XX +XXX,XX @@ static void disas_simd_scalar_three_reg_diff(DisasContext *s, uint32_t insn) | ||
46 | tcg_temp_free_i64(tcg_op2); | ||
47 | tcg_temp_free_i64(tcg_res); | ||
48 | } else { | ||
49 | - TCGv_i32 tcg_op1 = tcg_temp_new_i32(); | ||
50 | - TCGv_i32 tcg_op2 = tcg_temp_new_i32(); | ||
51 | + TCGv_i32 tcg_op1 = read_fp_hreg(s, rn); | ||
52 | + TCGv_i32 tcg_op2 = read_fp_hreg(s, rm); | ||
53 | TCGv_i64 tcg_res = tcg_temp_new_i64(); | ||
54 | |||
55 | - read_vec_element_i32(s, tcg_op1, rn, 0, MO_16); | ||
56 | - read_vec_element_i32(s, tcg_op2, rm, 0, MO_16); | ||
57 | - | ||
58 | gen_helper_neon_mull_s16(tcg_res, tcg_op1, tcg_op2); | ||
59 | gen_helper_neon_addl_saturate_s32(tcg_res, cpu_env, tcg_res, tcg_res); | ||
60 | |||
61 | @@ -XXX,XX +XXX,XX @@ static void disas_simd_scalar_three_reg_same_fp16(DisasContext *s, | ||
62 | |||
63 | fpst = get_fpstatus_ptr(true); | ||
64 | |||
65 | - tcg_op1 = tcg_temp_new_i32(); | ||
66 | - tcg_op2 = tcg_temp_new_i32(); | ||
67 | + tcg_op1 = read_fp_hreg(s, rn); | ||
68 | + tcg_op2 = read_fp_hreg(s, rm); | ||
69 | tcg_res = tcg_temp_new_i32(); | ||
70 | |||
71 | - read_vec_element_i32(s, tcg_op1, rn, 0, MO_16); | ||
72 | - read_vec_element_i32(s, tcg_op2, rm, 0, MO_16); | ||
73 | - | ||
74 | switch (fpopcode) { | ||
75 | case 0x03: /* FMULX */ | ||
76 | gen_helper_advsimd_mulxh(tcg_res, tcg_op1, tcg_op2, fpst); | ||
77 | @@ -XXX,XX +XXX,XX @@ static void disas_simd_two_reg_misc_fp16(DisasContext *s, uint32_t insn) | ||
78 | } | 45 | } |
79 | 46 | ||
80 | if (is_scalar) { | 47 | @@ -XXX,XX +XXX,XX @@ static size_t stream_process_s2mem(struct Stream *s, unsigned char *buf, |
81 | - TCGv_i32 tcg_op = tcg_temp_new_i32(); | 48 | unsigned int rxlen; |
82 | + TCGv_i32 tcg_op = read_fp_hreg(s, rn); | 49 | size_t pos = 0; |
83 | TCGv_i32 tcg_res = tcg_temp_new_i32(); | 50 | |
84 | 51 | - if (!stream_running(s) || stream_idle(s)) { | |
85 | - read_vec_element_i32(s, tcg_op, rn, 0, MO_16); | 52 | + if (!stream_running(s) || stream_idle(s) || stream_halted(s)) { |
86 | - | 53 | return 0; |
87 | switch (fpop) { | 54 | } |
88 | case 0x1a: /* FCVTNS */ | 55 | |
89 | case 0x1b: /* FCVTMS */ | 56 | @@ -XXX,XX +XXX,XX @@ xilinx_axidma_data_stream_can_push(StreamSink *obj, |
57 | XilinxAXIDMAStreamSink *ds = XILINX_AXI_DMA_DATA_STREAM(obj); | ||
58 | struct Stream *s = &ds->dma->streams[1]; | ||
59 | |||
60 | - if (!stream_running(s) || stream_idle(s)) { | ||
61 | + if (!stream_running(s) || stream_idle(s) || stream_halted(s)) { | ||
62 | ds->dma->notify = notify; | ||
63 | ds->dma->notify_opaque = notify_opaque; | ||
64 | return false; | ||
90 | -- | 65 | -- |
91 | 2.17.0 | 66 | 2.34.1 |
92 | 67 | ||
93 | 68 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Clément Chigot <chigot@adacore.com> |
---|---|---|---|
2 | 2 | ||
3 | No sense in emitting code after the exception. | 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) | ||
4 | 12 | ||
5 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 13 | Signed-off-by: Clément Chigot <chigot@adacore.com> |
6 | Tested-by: Alex Bennée <alex.bennee@linaro.org> | 14 | Reviewed-by: Francisco Iglesias <frasse.iglesias@gmail.com> |
7 | Message-id: 20180512003217.9105-3-richard.henderson@linaro.org | 15 | Tested-by: Francisco Iglesias <frasse.iglesias@gmail.com> |
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 16 | Message-id: 20230524143714.565792-1-chigot@adacore.com |
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 17 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | --- | 18 | --- |
11 | target/arm/translate-a64.c | 2 +- | 19 | hw/arm/xlnx-zynqmp.c | 2 +- |
12 | 1 file changed, 1 insertion(+), 1 deletion(-) | 20 | 1 file changed, 1 insertion(+), 1 deletion(-) |
13 | 21 | ||
14 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | 22 | diff --git a/hw/arm/xlnx-zynqmp.c b/hw/arm/xlnx-zynqmp.c |
15 | index XXXXXXX..XXXXXXX 100644 | 23 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/target/arm/translate-a64.c | 24 | --- a/hw/arm/xlnx-zynqmp.c |
17 | +++ b/target/arm/translate-a64.c | 25 | +++ b/hw/arm/xlnx-zynqmp.c |
18 | @@ -XXX,XX +XXX,XX @@ static void disas_fp_int_conv(DisasContext *s, uint32_t insn) | 26 | @@ -XXX,XX +XXX,XX @@ static void xlnx_zynqmp_create_rpu(MachineState *ms, XlnxZynqMPState *s, |
19 | default: | 27 | const char *boot_cpu, Error **errp) |
20 | /* all other sf/type/rmode combinations are invalid */ | 28 | { |
21 | unallocated_encoding(s); | 29 | int i; |
22 | - break; | 30 | - int num_rpus = MIN(ms->smp.cpus - XLNX_ZYNQMP_NUM_APU_CPUS, |
23 | + return; | 31 | + int num_rpus = MIN((int)(ms->smp.cpus - XLNX_ZYNQMP_NUM_APU_CPUS), |
24 | } | 32 | XLNX_ZYNQMP_NUM_RPU_CPUS); |
25 | 33 | ||
26 | if (!fp_access_check(s)) { | 34 | if (num_rpus <= 0) { |
27 | -- | 35 | -- |
28 | 2.17.0 | 36 | 2.34.1 |
29 | 37 | ||
30 | 38 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Thomas Huth <thuth@redhat.com> | ||
1 | 2 | ||
3 | pflash-cfi02-test.c always uses the "musicpal" machine for testing, | ||
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. | ||
7 | |||
8 | Signed-off-by: Thomas Huth <thuth@redhat.com> | ||
9 | Reviewed-by: Fabiano Rosas <farosas@suse.de> | ||
10 | Message-id: 20230524080600.1618137-1-thuth@redhat.com | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
12 | --- | ||
13 | tests/qtest/meson.build | 7 ++++--- | ||
14 | 1 file changed, 4 insertions(+), 3 deletions(-) | ||
15 | |||
16 | diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build | ||
17 | index XXXXXXX..XXXXXXX 100644 | ||
18 | --- a/tests/qtest/meson.build | ||
19 | +++ b/tests/qtest/meson.build | ||
20 | @@ -XXX,XX +XXX,XX @@ qtests_arm = \ | ||
21 | (config_all_devices.has_key('CONFIG_CMSDK_APB_DUALTIMER') ? ['cmsdk-apb-dualtimer-test'] : []) + \ | ||
22 | (config_all_devices.has_key('CONFIG_CMSDK_APB_TIMER') ? ['cmsdk-apb-timer-test'] : []) + \ | ||
23 | (config_all_devices.has_key('CONFIG_CMSDK_APB_WATCHDOG') ? ['cmsdk-apb-watchdog-test'] : []) + \ | ||
24 | - (config_all_devices.has_key('CONFIG_PFLASH_CFI02') ? ['pflash-cfi02-test'] : []) + \ | ||
25 | + (config_all_devices.has_key('CONFIG_PFLASH_CFI02') and | ||
26 | + config_all_devices.has_key('CONFIG_MUSICPAL') ? ['pflash-cfi02-test'] : []) + \ | ||
27 | (config_all_devices.has_key('CONFIG_ASPEED_SOC') ? qtests_aspeed : []) + \ | ||
28 | (config_all_devices.has_key('CONFIG_NPCM7XX') ? qtests_npcm7xx : []) + \ | ||
29 | (config_all_devices.has_key('CONFIG_GENERIC_LOADER') ? ['hexloader-test'] : []) + \ | ||
30 | (config_all_devices.has_key('CONFIG_TPM_TIS_I2C') ? ['tpm-tis-i2c-test'] : []) + \ | ||
31 | + (config_all_devices.has_key('CONFIG_VEXPRESS') ? ['test-arm-mptimer'] : []) + \ | ||
32 | + (config_all_devices.has_key('CONFIG_MICROBIT') ? ['microbit-test'] : []) + \ | ||
33 | ['arm-cpu-features', | ||
34 | - 'microbit-test', | ||
35 | - 'test-arm-mptimer', | ||
36 | 'boot-serial-test'] | ||
37 | |||
38 | # TODO: once aarch64 TCG is fixed on ARM 32 bit host, make bios-tables-test unconditional | ||
39 | -- | ||
40 | 2.34.1 | diff view generated by jsdifflib |
1 | Usually the logging of the CPU state produced by -d cpu is sufficient | 1 | For M-profile, there is no guest-facing A-profile format FSR, but we |
---|---|---|---|
2 | to diagnose problems, but sometimes you want to see the state of | 2 | still use the env->exception.fsr field to pass fault information from |
3 | the floating point registers as well. We don't want to enable that | 3 | the point where a fault is raised to the code in |
4 | by default as it adds a lot of extra data to the log; instead, | 4 | arm_v7m_cpu_do_interrupt() which interprets it and sets the M-profile |
5 | allow it to be optionally enabled via -d fpu. | 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 | ||
10 | In compute_fsr_fsc() we weren't explicitly choosing short-form for | ||
11 | M-profile, but instead relied on it falling out in the wash because | ||
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 | ||
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 | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 44 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 45 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
9 | Message-id: 20180510130024.31678-1-peter.maydell@linaro.org | 46 | Message-id: 20230523131726.866635-1-peter.maydell@linaro.org |
10 | --- | 47 | --- |
11 | include/qemu/log.h | 1 + | 48 | target/arm/tcg/tlb_helper.c | 13 +++++++++++-- |
12 | accel/tcg/cpu-exec.c | 9 ++++++--- | 49 | 1 file changed, 11 insertions(+), 2 deletions(-) |
13 | util/log.c | 2 ++ | ||
14 | 3 files changed, 9 insertions(+), 3 deletions(-) | ||
15 | 50 | ||
16 | diff --git a/include/qemu/log.h b/include/qemu/log.h | 51 | diff --git a/target/arm/tcg/tlb_helper.c b/target/arm/tcg/tlb_helper.c |
17 | index XXXXXXX..XXXXXXX 100644 | 52 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/include/qemu/log.h | 53 | --- a/target/arm/tcg/tlb_helper.c |
19 | +++ b/include/qemu/log.h | 54 | +++ b/target/arm/tcg/tlb_helper.c |
20 | @@ -XXX,XX +XXX,XX @@ static inline bool qemu_log_separate(void) | 55 | @@ -XXX,XX +XXX,XX @@ static uint32_t compute_fsr_fsc(CPUARMState *env, ARMMMUFaultInfo *fi, |
21 | #define CPU_LOG_PAGE (1 << 14) | 56 | ARMMMUIdx arm_mmu_idx = core_to_arm_mmu_idx(env, mmu_idx); |
22 | /* LOG_TRACE (1 << 15) is defined in log-for-trace.h */ | 57 | uint32_t fsr, fsc; |
23 | #define CPU_LOG_TB_OP_IND (1 << 16) | 58 | |
24 | +#define CPU_LOG_TB_FPU (1 << 17) | 59 | - if (target_el == 2 || arm_el_is_aa64(env, target_el) || |
25 | 60 | - arm_s1_regime_using_lpae_format(env, arm_mmu_idx)) { | |
26 | /* Lock output for a series of related logs. Since this is not needed | 61 | + /* |
27 | * for a single qemu_log / qemu_log_mask / qemu_log_mask_and_addr, we | 62 | + * For M-profile there is no guest-facing FSR. We compute a |
28 | diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c | 63 | + * short-form value for env->exception.fsr which we will then |
29 | index XXXXXXX..XXXXXXX 100644 | 64 | + * examine in arm_v7m_cpu_do_interrupt(). In theory we could |
30 | --- a/accel/tcg/cpu-exec.c | 65 | + * use the LPAE format instead as long as both bits of code agree |
31 | +++ b/accel/tcg/cpu-exec.c | 66 | + * (and arm_fi_to_lfsc() handled the M-profile specific |
32 | @@ -XXX,XX +XXX,XX @@ static inline tcg_target_ulong cpu_tb_exec(CPUState *cpu, TranslationBlock *itb) | 67 | + * ARMFault_QEMU_NSCExec and ARMFault_QEMU_SFault cases). |
33 | if (qemu_loglevel_mask(CPU_LOG_TB_CPU) | 68 | + */ |
34 | && qemu_log_in_addr_range(itb->pc)) { | 69 | + if (!arm_feature(env, ARM_FEATURE_M) && |
35 | qemu_log_lock(); | 70 | + (target_el == 2 || arm_el_is_aa64(env, target_el) || |
36 | + int flags = 0; | 71 | + arm_s1_regime_using_lpae_format(env, arm_mmu_idx))) { |
37 | + if (qemu_loglevel_mask(CPU_LOG_TB_FPU)) { | 72 | /* |
38 | + flags |= CPU_DUMP_FPU; | 73 | * LPAE format fault status register : bottom 6 bits are |
39 | + } | 74 | * status code in the same form as needed for syndrome |
40 | #if defined(TARGET_I386) | ||
41 | - log_cpu_state(cpu, CPU_DUMP_CCOP); | ||
42 | -#else | ||
43 | - log_cpu_state(cpu, 0); | ||
44 | + flags |= CPU_DUMP_CCOP; | ||
45 | #endif | ||
46 | + log_cpu_state(cpu, flags); | ||
47 | qemu_log_unlock(); | ||
48 | } | ||
49 | #endif /* DEBUG_DISAS */ | ||
50 | diff --git a/util/log.c b/util/log.c | ||
51 | index XXXXXXX..XXXXXXX 100644 | ||
52 | --- a/util/log.c | ||
53 | +++ b/util/log.c | ||
54 | @@ -XXX,XX +XXX,XX @@ const QEMULogItem qemu_log_items[] = { | ||
55 | "show trace before each executed TB (lots of logs)" }, | ||
56 | { CPU_LOG_TB_CPU, "cpu", | ||
57 | "show CPU registers before entering a TB (lots of logs)" }, | ||
58 | + { CPU_LOG_TB_FPU, "fpu", | ||
59 | + "include FPU registers in the 'cpu' logging" }, | ||
60 | { CPU_LOG_MMU, "mmu", | ||
61 | "log MMU-related activities" }, | ||
62 | { CPU_LOG_PCALL, "pcall", | ||
63 | -- | 75 | -- |
64 | 2.17.0 | 76 | 2.34.1 |
65 | |||
66 | diff view generated by jsdifflib |
1 | From: Alex Bennée <alex.bennee@linaro.org> | 1 | From: Fabiano Rosas <farosas@suse.de> |
---|---|---|---|
2 | 2 | ||
3 | We are meant to explicitly pass fpst, not cpu_env. | 3 | We currently need to select ARM_V7M unconditionally when TCG is |
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. | ||
4 | 6 | ||
5 | Cc: qemu-stable@nongnu.org | 7 | Suggested-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
6 | Signed-off-by: Alex Bennée <alex.bennee@linaro.org> | 8 | Signed-off-by: Fabiano Rosas <farosas@suse.de> |
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 9 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 10 | Message-id: 20230523180525.29994-2-farosas@suse.de |
9 | Tested-by: Alex Bennée <alex.bennee@linaro.org> | ||
10 | Message-id: 20180512003217.9105-12-richard.henderson@linaro.org | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
12 | --- | 12 | --- |
13 | target/arm/translate-a64.c | 3 ++- | 13 | target/arm/Kconfig | 3 +++ |
14 | 1 file changed, 2 insertions(+), 1 deletion(-) | 14 | 1 file changed, 3 insertions(+) |
15 | 15 | ||
16 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | 16 | diff --git a/target/arm/Kconfig b/target/arm/Kconfig |
17 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/target/arm/translate-a64.c | 18 | --- a/target/arm/Kconfig |
19 | +++ b/target/arm/translate-a64.c | 19 | +++ b/target/arm/Kconfig |
20 | @@ -XXX,XX +XXX,XX @@ static void handle_fp_1src_half(DisasContext *s, int opcode, int rd, int rn) | 20 | @@ -XXX,XX +XXX,XX @@ |
21 | tcg_gen_xori_i32(tcg_res, tcg_op, 0x8000); | 21 | config ARM |
22 | break; | 22 | bool |
23 | case 0x3: /* FSQRT */ | 23 | select ARM_COMPATIBLE_SEMIHOSTING if TCG |
24 | - gen_helper_sqrt_f16(tcg_res, tcg_op, cpu_env); | 24 | + |
25 | + fpst = get_fpstatus_ptr(true); | 25 | + # We need to select this until we move m_helper.c and the |
26 | + gen_helper_sqrt_f16(tcg_res, tcg_op, fpst); | 26 | + # translate.c v7m helpers under ARM_V7M. |
27 | break; | 27 | select ARM_V7M if TCG |
28 | case 0x8: /* FRINTN */ | 28 | |
29 | case 0x9: /* FRINTP */ | 29 | config AARCH64 |
30 | -- | 30 | -- |
31 | 2.17.0 | 31 | 2.34.1 |
32 | 32 | ||
33 | 33 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: Fabiano Rosas <farosas@suse.de> | ||
1 | 2 | ||
3 | When we moved the arm default CONFIGs into Kconfig and removed them | ||
4 | from default.mak, we made it harder to identify which CONFIGs are | ||
5 | selected by default in case users want to disable them. | ||
6 | |||
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. | ||
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 | ||
16 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
17 | --- | ||
18 | configs/devices/aarch64-softmmu/default.mak | 6 ++++ | ||
19 | configs/devices/arm-softmmu/default.mak | 40 +++++++++++++++++++++ | ||
20 | 2 files changed, 46 insertions(+) | ||
21 | |||
22 | diff --git a/configs/devices/aarch64-softmmu/default.mak b/configs/devices/aarch64-softmmu/default.mak | ||
23 | index XXXXXXX..XXXXXXX 100644 | ||
24 | --- a/configs/devices/aarch64-softmmu/default.mak | ||
25 | +++ b/configs/devices/aarch64-softmmu/default.mak | ||
26 | @@ -XXX,XX +XXX,XX @@ | ||
27 | |||
28 | # We support all the 32 bit boards so need all their config | ||
29 | include ../arm-softmmu/default.mak | ||
30 | + | ||
31 | +# These are selected by default when TCG is enabled, uncomment them to | ||
32 | +# keep out of the build. | ||
33 | +# CONFIG_XLNX_ZYNQMP_ARM=n | ||
34 | +# CONFIG_XLNX_VERSAL=n | ||
35 | +# CONFIG_SBSA_REF=n | ||
36 | diff --git a/configs/devices/arm-softmmu/default.mak b/configs/devices/arm-softmmu/default.mak | ||
37 | index XXXXXXX..XXXXXXX 100644 | ||
38 | --- a/configs/devices/arm-softmmu/default.mak | ||
39 | +++ b/configs/devices/arm-softmmu/default.mak | ||
40 | @@ -XXX,XX +XXX,XX @@ | ||
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 | ||
84 | -- | ||
85 | 2.34.1 | diff view generated by jsdifflib |
1 | In float-to-integer conversion, if the floating point input | 1 | From: Fabiano Rosas <farosas@suse.de> |
---|---|---|---|
2 | converts exactly to the largest or smallest integer that | 2 | |
3 | fits in to the result type, this is not an overflow. | 3 | Replace the 'default y if TCG' pattern with 'default y; depends on |
4 | In this situation we were producing the correct result value, | 4 | TCG'. |
5 | but were incorrectly setting the Invalid flag. | 5 | |
6 | For example for Arm A64, "FCVTAS w0, d0" on an input of | 6 | That makes explict that there is a dependence on TCG and enabling |
7 | 0x41dfffffffc00000 should produce 0x7fffffff and set no flags. | 7 | these CONFIGs via .mak files without TCG present will fail earlier. |
8 | 8 | ||
9 | Fix the boundary case to take the right half of the if() | 9 | Suggested-by: Paolo Bonzini <pbonzini@redhat.com> |
10 | statements. | 10 | Signed-off-by: Fabiano Rosas <farosas@suse.de> |
11 | 11 | Reviewed-by: Thomas Huth <thuth@redhat.com> | |
12 | This fixes a regression from 2.11 introduced by the softfloat | 12 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
13 | refactoring. | 13 | Message-id: 20230523180525.29994-4-farosas@suse.de |
14 | |||
15 | Cc: qemu-stable@nongnu.org | ||
16 | Fixes: ab52f973a50 | ||
17 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 14 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
18 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
19 | Message-id: 20180510140141.12120-1-peter.maydell@linaro.org | ||
20 | --- | 15 | --- |
21 | fpu/softfloat.c | 4 ++-- | 16 | hw/arm/Kconfig | 123 ++++++++++++++++++++++++++++++++----------------- |
22 | 1 file changed, 2 insertions(+), 2 deletions(-) | 17 | 1 file changed, 82 insertions(+), 41 deletions(-) |
23 | 18 | ||
24 | diff --git a/fpu/softfloat.c b/fpu/softfloat.c | 19 | diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig |
25 | index XXXXXXX..XXXXXXX 100644 | 20 | index XXXXXXX..XXXXXXX 100644 |
26 | --- a/fpu/softfloat.c | 21 | --- a/hw/arm/Kconfig |
27 | +++ b/fpu/softfloat.c | 22 | +++ b/hw/arm/Kconfig |
28 | @@ -XXX,XX +XXX,XX @@ static int64_t round_to_int_and_pack(FloatParts in, int rmode, | 23 | @@ -XXX,XX +XXX,XX @@ config ARM_VIRT |
29 | r = UINT64_MAX; | 24 | |
30 | } | 25 | config CHEETAH |
31 | if (p.sign) { | 26 | bool |
32 | - if (r < -(uint64_t) min) { | 27 | - default y if TCG && ARM |
33 | + if (r <= -(uint64_t) min) { | 28 | + default y |
34 | return -r; | 29 | + depends on TCG && ARM |
35 | } else { | 30 | select OMAP |
36 | s->float_exception_flags = orig_flags | float_flag_invalid; | 31 | select TSC210X |
37 | return min; | 32 | |
38 | } | 33 | config CUBIEBOARD |
39 | } else { | 34 | bool |
40 | - if (r < max) { | 35 | - default y if TCG && ARM |
41 | + if (r <= max) { | 36 | + default y |
42 | return r; | 37 | + depends on TCG && ARM |
43 | } else { | 38 | select ALLWINNER_A10 |
44 | s->float_exception_flags = orig_flags | float_flag_invalid; | 39 | |
40 | config DIGIC | ||
41 | bool | ||
42 | - default y if TCG && ARM | ||
43 | + default y | ||
44 | + depends on TCG && ARM | ||
45 | select PTIMER | ||
46 | select PFLASH_CFI02 | ||
47 | |||
48 | config EXYNOS4 | ||
49 | bool | ||
50 | - default y if TCG && ARM | ||
51 | + default y | ||
52 | + depends on TCG && ARM | ||
53 | imply I2C_DEVICES | ||
54 | select A9MPCORE | ||
55 | select I2C | ||
56 | @@ -XXX,XX +XXX,XX @@ config EXYNOS4 | ||
57 | |||
58 | config HIGHBANK | ||
59 | bool | ||
60 | - default y if TCG && ARM | ||
61 | + default y | ||
62 | + depends on TCG && ARM | ||
63 | select A9MPCORE | ||
64 | select A15MPCORE | ||
65 | select AHCI | ||
66 | @@ -XXX,XX +XXX,XX @@ config HIGHBANK | ||
67 | |||
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 | |||
45 | -- | 409 | -- |
46 | 2.17.0 | 410 | 2.34.1 |
47 | 411 | ||
48 | 412 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Enze Li <lienze@kylinos.cn> |
---|---|---|---|
2 | 2 | ||
3 | Cc: qemu-stable@nongnu.org | 3 | I noticed that in the latest version, the copyright string is still |
4 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | 4 | 2022, even though 2023 is halfway through. This patch fixes that and |
5 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 5 | fixes the documentation along with it. |
6 | Tested-by: Alex Bennée <alex.bennee@linaro.org> | 6 | |
7 | Message-id: 20180512003217.9105-5-richard.henderson@linaro.org | 7 | Signed-off-by: Enze Li <lienze@kylinos.cn> |
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | Message-id: 20230525064345.1152801-1-lienze@kylinos.cn | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
9 | --- | 11 | --- |
10 | target/arm/translate-a64.c | 17 +++++++++++++++-- | 12 | docs/conf.py | 2 +- |
11 | 1 file changed, 15 insertions(+), 2 deletions(-) | 13 | include/qemu/help-texts.h | 2 +- |
14 | 2 files changed, 2 insertions(+), 2 deletions(-) | ||
12 | 15 | ||
13 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | 16 | diff --git a/docs/conf.py b/docs/conf.py |
14 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
15 | --- a/target/arm/translate-a64.c | 18 | --- a/docs/conf.py |
16 | +++ b/target/arm/translate-a64.c | 19 | +++ b/docs/conf.py |
17 | @@ -XXX,XX +XXX,XX @@ static void disas_fp_fixed_conv(DisasContext *s, uint32_t insn) | 20 | @@ -XXX,XX +XXX,XX @@ |
18 | bool sf = extract32(insn, 31, 1); | 21 | |
19 | bool itof; | 22 | # General information about the project. |
20 | 23 | project = u'QEMU' | |
21 | - if (sbit || (type > 1) | 24 | -copyright = u'2022, The QEMU Project Developers' |
22 | - || (!sf && scale < 32)) { | 25 | +copyright = u'2023, The QEMU Project Developers' |
23 | + if (sbit || (!sf && scale < 32)) { | 26 | author = u'The QEMU Project Developers' |
24 | + unallocated_encoding(s); | 27 | |
25 | + return; | 28 | # The version info for the project you're documenting, acts as replacement for |
26 | + } | 29 | diff --git a/include/qemu/help-texts.h b/include/qemu/help-texts.h |
27 | + | 30 | index XXXXXXX..XXXXXXX 100644 |
28 | + switch (type) { | 31 | --- a/include/qemu/help-texts.h |
29 | + case 0: /* float32 */ | 32 | +++ b/include/qemu/help-texts.h |
30 | + case 1: /* float64 */ | 33 | @@ -XXX,XX +XXX,XX @@ |
31 | + break; | 34 | #define QEMU_HELP_TEXTS_H |
32 | + case 3: /* float16 */ | 35 | |
33 | + if (arm_dc_feature(s, ARM_FEATURE_V8_FP16)) { | 36 | /* Copyright string for -version arguments, About dialogs, etc */ |
34 | + break; | 37 | -#define QEMU_COPYRIGHT "Copyright (c) 2003-2022 " \ |
35 | + } | 38 | +#define QEMU_COPYRIGHT "Copyright (c) 2003-2023 " \ |
36 | + /* fallthru */ | 39 | "Fabrice Bellard and the QEMU Project developers" |
37 | + default: | 40 | |
38 | unallocated_encoding(s); | 41 | /* Bug reporting information for --help arguments, About dialogs, etc */ |
39 | return; | ||
40 | } | ||
41 | -- | 42 | -- |
42 | 2.17.0 | 43 | 2.34.1 |
43 | |||
44 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Marcin Juszkiewicz <marcin.juszkiewicz@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Cc: qemu-stable@nongnu.org | 3 | Let add GIC information into DeviceTree as part of SBSA-REF versioning. |
4 | Reviewed-by: Alex Bennée <alex.bennee@linaro.org> | 4 | |
5 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 5 | Trusted Firmware will read it and provide to next firmware level. |
6 | Tested-by: Alex Bennée <alex.bennee@linaro.org> | 6 | |
7 | Message-id: 20180512003217.9105-4-richard.henderson@linaro.org | 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> | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
9 | --- | 12 | --- |
10 | target/arm/helper.h | 6 +++ | 13 | hw/arm/sbsa-ref.c | 19 ++++++++++++++++++- |
11 | target/arm/helper.c | 38 ++++++++++++++- | 14 | 1 file changed, 18 insertions(+), 1 deletion(-) |
12 | target/arm/translate-a64.c | 96 +++++++++++++++++++++++++++++++------- | ||
13 | 3 files changed, 122 insertions(+), 18 deletions(-) | ||
14 | 15 | ||
15 | diff --git a/target/arm/helper.h b/target/arm/helper.h | 16 | diff --git a/hw/arm/sbsa-ref.c b/hw/arm/sbsa-ref.c |
16 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/target/arm/helper.h | 18 | --- a/hw/arm/sbsa-ref.c |
18 | +++ b/target/arm/helper.h | 19 | +++ b/hw/arm/sbsa-ref.c |
19 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_3(vfp_touhd_round_to_zero, i64, f64, i32, ptr) | 20 | @@ -XXX,XX +XXX,XX @@ |
20 | DEF_HELPER_3(vfp_tould_round_to_zero, i64, f64, i32, ptr) | 21 | #include "exec/hwaddr.h" |
21 | DEF_HELPER_3(vfp_touhh, i32, f16, i32, ptr) | 22 | #include "kvm_arm.h" |
22 | DEF_HELPER_3(vfp_toshh, i32, f16, i32, ptr) | 23 | #include "hw/arm/boot.h" |
23 | +DEF_HELPER_3(vfp_toulh, i32, f16, i32, ptr) | 24 | +#include "hw/arm/fdt.h" |
24 | +DEF_HELPER_3(vfp_toslh, i32, f16, i32, ptr) | 25 | #include "hw/arm/smmuv3.h" |
25 | +DEF_HELPER_3(vfp_touqh, i64, f16, i32, ptr) | 26 | #include "hw/block/flash.h" |
26 | +DEF_HELPER_3(vfp_tosqh, i64, f16, i32, ptr) | 27 | #include "hw/boards.h" |
27 | DEF_HELPER_3(vfp_toshs, i32, f32, i32, ptr) | 28 | @@ -XXX,XX +XXX,XX @@ static uint64_t sbsa_ref_cpu_mp_affinity(SBSAMachineState *sms, int idx) |
28 | DEF_HELPER_3(vfp_tosls, i32, f32, i32, ptr) | 29 | return arm_cpu_mp_affinity(idx, clustersz); |
29 | DEF_HELPER_3(vfp_tosqs, i64, f32, i32, ptr) | ||
30 | @@ -XXX,XX +XXX,XX @@ DEF_HELPER_3(vfp_ultod, f64, i64, i32, ptr) | ||
31 | DEF_HELPER_3(vfp_uqtod, f64, i64, i32, ptr) | ||
32 | DEF_HELPER_3(vfp_sltoh, f16, i32, i32, ptr) | ||
33 | DEF_HELPER_3(vfp_ultoh, f16, i32, i32, ptr) | ||
34 | +DEF_HELPER_3(vfp_sqtoh, f16, i64, i32, ptr) | ||
35 | +DEF_HELPER_3(vfp_uqtoh, f16, i64, i32, ptr) | ||
36 | |||
37 | DEF_HELPER_FLAGS_2(set_rmode, TCG_CALL_NO_RWG, i32, i32, ptr) | ||
38 | DEF_HELPER_FLAGS_2(set_neon_rmode, TCG_CALL_NO_RWG, i32, i32, env) | ||
39 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
40 | index XXXXXXX..XXXXXXX 100644 | ||
41 | --- a/target/arm/helper.c | ||
42 | +++ b/target/arm/helper.c | ||
43 | @@ -XXX,XX +XXX,XX @@ VFP_CONV_FIX_A64(uq, s, 32, 64, uint64) | ||
44 | #undef VFP_CONV_FIX_A64 | ||
45 | |||
46 | /* Conversion to/from f16 can overflow to infinity before/after scaling. | ||
47 | - * Therefore we convert to f64 (which does not round), scale, | ||
48 | - * and then convert f64 to f16 (which may round). | ||
49 | + * Therefore we convert to f64, scale, and then convert f64 to f16; or | ||
50 | + * vice versa for conversion to integer. | ||
51 | + * | ||
52 | + * For 16- and 32-bit integers, the conversion to f64 never rounds. | ||
53 | + * For 64-bit integers, any integer that would cause rounding will also | ||
54 | + * overflow to f16 infinity, so there is no double rounding problem. | ||
55 | */ | ||
56 | |||
57 | static float16 do_postscale_fp16(float64 f, int shift, float_status *fpst) | ||
58 | @@ -XXX,XX +XXX,XX @@ float16 HELPER(vfp_ultoh)(uint32_t x, uint32_t shift, void *fpst) | ||
59 | return do_postscale_fp16(uint32_to_float64(x, fpst), shift, fpst); | ||
60 | } | 30 | } |
61 | 31 | ||
62 | +float16 HELPER(vfp_sqtoh)(uint64_t x, uint32_t shift, void *fpst) | 32 | +static void sbsa_fdt_add_gic_node(SBSAMachineState *sms) |
63 | +{ | 33 | +{ |
64 | + return do_postscale_fp16(int64_to_float64(x, fpst), shift, fpst); | 34 | + char *nodename; |
35 | + | ||
36 | + nodename = g_strdup_printf("/intc"); | ||
37 | + qemu_fdt_add_subnode(sms->fdt, nodename); | ||
38 | + qemu_fdt_setprop_sized_cells(sms->fdt, nodename, "reg", | ||
39 | + 2, sbsa_ref_memmap[SBSA_GIC_DIST].base, | ||
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); | ||
43 | + | ||
44 | + g_free(nodename); | ||
65 | +} | 45 | +} |
46 | /* | ||
47 | * Firmware on this machine only uses ACPI table to load OS, these limited | ||
48 | * device tree nodes are just to let firmware know the info which varies from | ||
49 | @@ -XXX,XX +XXX,XX @@ static void create_fdt(SBSAMachineState *sms) | ||
50 | * fw compatibility. | ||
51 | */ | ||
52 | qemu_fdt_setprop_cell(fdt, "/", "machine-version-major", 0); | ||
53 | - qemu_fdt_setprop_cell(fdt, "/", "machine-version-minor", 0); | ||
54 | + qemu_fdt_setprop_cell(fdt, "/", "machine-version-minor", 1); | ||
55 | |||
56 | if (ms->numa_state->have_numa_distance) { | ||
57 | int size = nb_numa_nodes * nb_numa_nodes * 3 * sizeof(uint32_t); | ||
58 | @@ -XXX,XX +XXX,XX @@ static void create_fdt(SBSAMachineState *sms) | ||
59 | |||
60 | g_free(nodename); | ||
61 | } | ||
66 | + | 62 | + |
67 | +float16 HELPER(vfp_uqtoh)(uint64_t x, uint32_t shift, void *fpst) | 63 | + sbsa_fdt_add_gic_node(sms); |
68 | +{ | ||
69 | + return do_postscale_fp16(uint64_to_float64(x, fpst), shift, fpst); | ||
70 | +} | ||
71 | + | ||
72 | static float64 do_prescale_fp16(float16 f, int shift, float_status *fpst) | ||
73 | { | ||
74 | if (unlikely(float16_is_any_nan(f))) { | ||
75 | @@ -XXX,XX +XXX,XX @@ uint32_t HELPER(vfp_touhh)(float16 x, uint32_t shift, void *fpst) | ||
76 | return float64_to_uint16(do_prescale_fp16(x, shift, fpst), fpst); | ||
77 | } | 64 | } |
78 | 65 | ||
79 | +uint32_t HELPER(vfp_toslh)(float16 x, uint32_t shift, void *fpst) | 66 | #define SBSA_FLASH_SECTOR_SIZE (256 * KiB) |
80 | +{ | ||
81 | + return float64_to_int32(do_prescale_fp16(x, shift, fpst), fpst); | ||
82 | +} | ||
83 | + | ||
84 | +uint32_t HELPER(vfp_toulh)(float16 x, uint32_t shift, void *fpst) | ||
85 | +{ | ||
86 | + return float64_to_uint32(do_prescale_fp16(x, shift, fpst), fpst); | ||
87 | +} | ||
88 | + | ||
89 | +uint64_t HELPER(vfp_tosqh)(float16 x, uint32_t shift, void *fpst) | ||
90 | +{ | ||
91 | + return float64_to_int64(do_prescale_fp16(x, shift, fpst), fpst); | ||
92 | +} | ||
93 | + | ||
94 | +uint64_t HELPER(vfp_touqh)(float16 x, uint32_t shift, void *fpst) | ||
95 | +{ | ||
96 | + return float64_to_uint64(do_prescale_fp16(x, shift, fpst), fpst); | ||
97 | +} | ||
98 | + | ||
99 | /* Set the current fp rounding mode and return the old one. | ||
100 | * The argument is a softfloat float_round_ value. | ||
101 | */ | ||
102 | diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c | ||
103 | index XXXXXXX..XXXXXXX 100644 | ||
104 | --- a/target/arm/translate-a64.c | ||
105 | +++ b/target/arm/translate-a64.c | ||
106 | @@ -XXX,XX +XXX,XX @@ static void handle_fpfpcvt(DisasContext *s, int rd, int rn, int opcode, | ||
107 | bool itof, int rmode, int scale, int sf, int type) | ||
108 | { | ||
109 | bool is_signed = !(opcode & 1); | ||
110 | - bool is_double = type; | ||
111 | TCGv_ptr tcg_fpstatus; | ||
112 | - TCGv_i32 tcg_shift; | ||
113 | + TCGv_i32 tcg_shift, tcg_single; | ||
114 | + TCGv_i64 tcg_double; | ||
115 | |||
116 | - tcg_fpstatus = get_fpstatus_ptr(false); | ||
117 | + tcg_fpstatus = get_fpstatus_ptr(type == 3); | ||
118 | |||
119 | tcg_shift = tcg_const_i32(64 - scale); | ||
120 | |||
121 | @@ -XXX,XX +XXX,XX @@ static void handle_fpfpcvt(DisasContext *s, int rd, int rn, int opcode, | ||
122 | tcg_int = tcg_extend; | ||
123 | } | ||
124 | |||
125 | - if (is_double) { | ||
126 | - TCGv_i64 tcg_double = tcg_temp_new_i64(); | ||
127 | + switch (type) { | ||
128 | + case 1: /* float64 */ | ||
129 | + tcg_double = tcg_temp_new_i64(); | ||
130 | if (is_signed) { | ||
131 | gen_helper_vfp_sqtod(tcg_double, tcg_int, | ||
132 | tcg_shift, tcg_fpstatus); | ||
133 | @@ -XXX,XX +XXX,XX @@ static void handle_fpfpcvt(DisasContext *s, int rd, int rn, int opcode, | ||
134 | } | ||
135 | write_fp_dreg(s, rd, tcg_double); | ||
136 | tcg_temp_free_i64(tcg_double); | ||
137 | - } else { | ||
138 | - TCGv_i32 tcg_single = tcg_temp_new_i32(); | ||
139 | + break; | ||
140 | + | ||
141 | + case 0: /* float32 */ | ||
142 | + tcg_single = tcg_temp_new_i32(); | ||
143 | if (is_signed) { | ||
144 | gen_helper_vfp_sqtos(tcg_single, tcg_int, | ||
145 | tcg_shift, tcg_fpstatus); | ||
146 | @@ -XXX,XX +XXX,XX @@ static void handle_fpfpcvt(DisasContext *s, int rd, int rn, int opcode, | ||
147 | } | ||
148 | write_fp_sreg(s, rd, tcg_single); | ||
149 | tcg_temp_free_i32(tcg_single); | ||
150 | + break; | ||
151 | + | ||
152 | + case 3: /* float16 */ | ||
153 | + tcg_single = tcg_temp_new_i32(); | ||
154 | + if (is_signed) { | ||
155 | + gen_helper_vfp_sqtoh(tcg_single, tcg_int, | ||
156 | + tcg_shift, tcg_fpstatus); | ||
157 | + } else { | ||
158 | + gen_helper_vfp_uqtoh(tcg_single, tcg_int, | ||
159 | + tcg_shift, tcg_fpstatus); | ||
160 | + } | ||
161 | + write_fp_sreg(s, rd, tcg_single); | ||
162 | + tcg_temp_free_i32(tcg_single); | ||
163 | + break; | ||
164 | + | ||
165 | + default: | ||
166 | + g_assert_not_reached(); | ||
167 | } | ||
168 | } else { | ||
169 | TCGv_i64 tcg_int = cpu_reg(s, rd); | ||
170 | @@ -XXX,XX +XXX,XX @@ static void handle_fpfpcvt(DisasContext *s, int rd, int rn, int opcode, | ||
171 | |||
172 | gen_helper_set_rmode(tcg_rmode, tcg_rmode, tcg_fpstatus); | ||
173 | |||
174 | - if (is_double) { | ||
175 | - TCGv_i64 tcg_double = read_fp_dreg(s, rn); | ||
176 | + switch (type) { | ||
177 | + case 1: /* float64 */ | ||
178 | + tcg_double = read_fp_dreg(s, rn); | ||
179 | if (is_signed) { | ||
180 | if (!sf) { | ||
181 | gen_helper_vfp_tosld(tcg_int, tcg_double, | ||
182 | @@ -XXX,XX +XXX,XX @@ static void handle_fpfpcvt(DisasContext *s, int rd, int rn, int opcode, | ||
183 | tcg_shift, tcg_fpstatus); | ||
184 | } | ||
185 | } | ||
186 | + if (!sf) { | ||
187 | + tcg_gen_ext32u_i64(tcg_int, tcg_int); | ||
188 | + } | ||
189 | tcg_temp_free_i64(tcg_double); | ||
190 | - } else { | ||
191 | - TCGv_i32 tcg_single = read_fp_sreg(s, rn); | ||
192 | + break; | ||
193 | + | ||
194 | + case 0: /* float32 */ | ||
195 | + tcg_single = read_fp_sreg(s, rn); | ||
196 | if (sf) { | ||
197 | if (is_signed) { | ||
198 | gen_helper_vfp_tosqs(tcg_int, tcg_single, | ||
199 | @@ -XXX,XX +XXX,XX @@ static void handle_fpfpcvt(DisasContext *s, int rd, int rn, int opcode, | ||
200 | tcg_temp_free_i32(tcg_dest); | ||
201 | } | ||
202 | tcg_temp_free_i32(tcg_single); | ||
203 | + break; | ||
204 | + | ||
205 | + case 3: /* float16 */ | ||
206 | + tcg_single = read_fp_sreg(s, rn); | ||
207 | + if (sf) { | ||
208 | + if (is_signed) { | ||
209 | + gen_helper_vfp_tosqh(tcg_int, tcg_single, | ||
210 | + tcg_shift, tcg_fpstatus); | ||
211 | + } else { | ||
212 | + gen_helper_vfp_touqh(tcg_int, tcg_single, | ||
213 | + tcg_shift, tcg_fpstatus); | ||
214 | + } | ||
215 | + } else { | ||
216 | + TCGv_i32 tcg_dest = tcg_temp_new_i32(); | ||
217 | + if (is_signed) { | ||
218 | + gen_helper_vfp_toslh(tcg_dest, tcg_single, | ||
219 | + tcg_shift, tcg_fpstatus); | ||
220 | + } else { | ||
221 | + gen_helper_vfp_toulh(tcg_dest, tcg_single, | ||
222 | + tcg_shift, tcg_fpstatus); | ||
223 | + } | ||
224 | + tcg_gen_extu_i32_i64(tcg_int, tcg_dest); | ||
225 | + tcg_temp_free_i32(tcg_dest); | ||
226 | + } | ||
227 | + tcg_temp_free_i32(tcg_single); | ||
228 | + break; | ||
229 | + | ||
230 | + default: | ||
231 | + g_assert_not_reached(); | ||
232 | } | ||
233 | |||
234 | gen_helper_set_rmode(tcg_rmode, tcg_rmode, tcg_fpstatus); | ||
235 | tcg_temp_free_i32(tcg_rmode); | ||
236 | - | ||
237 | - if (!sf) { | ||
238 | - tcg_gen_ext32u_i64(tcg_int, tcg_int); | ||
239 | - } | ||
240 | } | ||
241 | |||
242 | tcg_temp_free_ptr(tcg_fpstatus); | ||
243 | @@ -XXX,XX +XXX,XX @@ static void disas_fp_int_conv(DisasContext *s, uint32_t insn) | ||
244 | /* actual FP conversions */ | ||
245 | bool itof = extract32(opcode, 1, 1); | ||
246 | |||
247 | - if (type > 1 || (rmode != 0 && opcode > 1)) { | ||
248 | + if (rmode != 0 && opcode > 1) { | ||
249 | + unallocated_encoding(s); | ||
250 | + return; | ||
251 | + } | ||
252 | + switch (type) { | ||
253 | + case 0: /* float32 */ | ||
254 | + case 1: /* float64 */ | ||
255 | + break; | ||
256 | + case 3: /* float16 */ | ||
257 | + if (arm_dc_feature(s, ARM_FEATURE_V8_FP16)) { | ||
258 | + break; | ||
259 | + } | ||
260 | + /* fallthru */ | ||
261 | + default: | ||
262 | unallocated_encoding(s); | ||
263 | return; | ||
264 | } | ||
265 | -- | 67 | -- |
266 | 2.17.0 | 68 | 2.34.1 |
267 | |||
268 | diff view generated by jsdifflib |
1 | From: Alex Bennée <alex.bennee@linaro.org> | 1 | From: Marcin Juszkiewicz <marcin.juszkiewicz@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Reported by Coverity (CID1390635). We ensure this for uint_to_float | 3 | We moved from VGA to Bochs to have PCIe card. |
4 | later on so we might as well mirror that. | ||
5 | 4 | ||
6 | Signed-off-by: Alex Bennée <alex.bennee@linaro.org> | 5 | Signed-off-by: Marcin Juszkiewicz <marcin.juszkiewicz@linaro.org> |
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | --- | 8 | --- |
11 | fpu/softfloat.c | 2 +- | 9 | docs/system/arm/sbsa.rst | 2 +- |
12 | 1 file changed, 1 insertion(+), 1 deletion(-) | 10 | 1 file changed, 1 insertion(+), 1 deletion(-) |
13 | 11 | ||
14 | diff --git a/fpu/softfloat.c b/fpu/softfloat.c | 12 | diff --git a/docs/system/arm/sbsa.rst b/docs/system/arm/sbsa.rst |
15 | index XXXXXXX..XXXXXXX 100644 | 13 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/fpu/softfloat.c | 14 | --- a/docs/system/arm/sbsa.rst |
17 | +++ b/fpu/softfloat.c | 15 | +++ b/docs/system/arm/sbsa.rst |
18 | @@ -XXX,XX +XXX,XX @@ FLOAT_TO_UINT(64, 64) | 16 | @@ -XXX,XX +XXX,XX @@ The sbsa-ref board supports: |
19 | 17 | - System bus EHCI controller | |
20 | static FloatParts int_to_float(int64_t a, float_status *status) | 18 | - CDROM and hard disc on AHCI bus |
21 | { | 19 | - E1000E ethernet card on PCIe bus |
22 | - FloatParts r; | 20 | - - VGA display adaptor on PCIe bus |
23 | + FloatParts r = {}; | 21 | + - Bochs display adapter on PCIe bus |
24 | if (a == 0) { | 22 | - A generic SBSA watchdog device |
25 | r.cls = float_class_zero; | 23 | |
26 | r.sign = false; | ||
27 | -- | 24 | -- |
28 | 2.17.0 | 25 | 2.34.1 |
29 | |||
30 | diff view generated by jsdifflib |