1 | Just some bugfixes this time around. | 1 | A last small test of bug fixes before rc1. |
---|---|---|---|
2 | 2 | ||
3 | thanks | ||
3 | -- PMM | 4 | -- PMM |
4 | 5 | ||
5 | The following changes since commit 4215d3413272ad6d1c6c9d0234450b602e46a74c: | 6 | The following changes since commit ed8ad9728a9c0eec34db9dff61dfa2f1dd625637: |
6 | 7 | ||
7 | Merge remote-tracking branch 'remotes/dgibson/tags/ppc-for-5.1-20200727' into staging (2020-07-27 09:33:04 +0100) | 8 | Merge tag 'pull-tpm-2023-07-14-1' of https://github.com/stefanberger/qemu-tpm into staging (2023-07-15 14:54:04 +0100) |
8 | 9 | ||
9 | are available in the Git repository at: | 10 | are available in the Git repository at: |
10 | 11 | ||
11 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20200727 | 12 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20230717 |
12 | 13 | ||
13 | for you to fetch changes up to d4f6dda182e19afa75706936805e18397cb95f07: | 14 | for you to fetch changes up to c2c1c4a35c7c2b1a4140b0942b9797c857e476a4: |
14 | 15 | ||
15 | target/arm: Improve IMPDEF algorithm for IRG (2020-07-27 16:12:11 +0100) | 16 | hw/nvram: Avoid unnecessary Xilinx eFuse backstore write (2023-07-17 11:05:52 +0100) |
16 | 17 | ||
17 | ---------------------------------------------------------------- | 18 | ---------------------------------------------------------------- |
18 | target-arm queue: | 19 | target-arm queue: |
19 | * ACPI: Assert that we don't run out of the preallocated memory | 20 | * hw/arm/sbsa-ref: set 'slots' property of xhci |
20 | * hw/misc/aspeed_sdmc: Fix incorrect memory size | 21 | * linux-user: Remove pointless NULL check in clock_adjtime handling |
21 | * target/arm: Always pass cacheattr in S1_ptw_translate | 22 | * ptw: Fix S1_ptw_translate() debug path |
22 | * docs/system/arm/virt: Document 'mte' machine option | 23 | * ptw: Account for FEAT_RME when applying {N}SW, SA bits |
23 | * hw/arm/boot: Fix PAUTH, MTE for EL3 direct kernel boot | 24 | * accel/tcg: Zero-pad PC in TCG CPU exec trace lines |
24 | * target/arm: Improve IMPDEF algorithm for IRG | 25 | * hw/nvram: Avoid unnecessary Xilinx eFuse backstore write |
25 | 26 | ||
26 | ---------------------------------------------------------------- | 27 | ---------------------------------------------------------------- |
27 | Dongjiu Geng (1): | 28 | Peter Maydell (5): |
28 | ACPI: Assert that we don't run out of the preallocated memory | 29 | linux-user: Remove pointless NULL check in clock_adjtime handling |
30 | target/arm/ptw.c: Add comments to S1Translate struct fields | ||
31 | target/arm: Fix S1_ptw_translate() debug path | ||
32 | target/arm/ptw.c: Account for FEAT_RME when applying {N}SW, SA bits | ||
33 | accel/tcg: Zero-pad PC in TCG CPU exec trace lines | ||
29 | 34 | ||
30 | Peter Maydell (1): | 35 | Tong Ho (1): |
31 | docs/system/arm/virt: Document 'mte' machine option | 36 | hw/nvram: Avoid unnecessary Xilinx eFuse backstore write |
32 | 37 | ||
33 | Philippe Mathieu-Daudé (1): | 38 | Yuquan Wang (1): |
34 | hw/misc/aspeed_sdmc: Fix incorrect memory size | 39 | hw/arm/sbsa-ref: set 'slots' property of xhci |
35 | 40 | ||
36 | Richard Henderson (4): | 41 | accel/tcg/cpu-exec.c | 4 +-- |
37 | target/arm: Always pass cacheattr in S1_ptw_translate | 42 | accel/tcg/translate-all.c | 2 +- |
38 | hw/arm/boot: Fix PAUTH for EL3 direct kernel boot | 43 | hw/arm/sbsa-ref.c | 1 + |
39 | hw/arm/boot: Fix MTE for EL3 direct kernel boot | 44 | hw/nvram/xlnx-efuse.c | 11 ++++-- |
40 | target/arm: Improve IMPDEF algorithm for IRG | 45 | linux-user/syscall.c | 12 +++---- |
41 | 46 | target/arm/ptw.c | 90 +++++++++++++++++++++++++++++++++++++++++------ | |
42 | docs/system/arm/virt.rst | 4 ++++ | 47 | 6 files changed, 98 insertions(+), 22 deletions(-) |
43 | hw/acpi/ghes.c | 12 ++++-------- | ||
44 | hw/arm/boot.c | 6 ++++++ | ||
45 | hw/misc/aspeed_sdmc.c | 7 ++++--- | ||
46 | target/arm/helper.c | 19 ++++++------------- | ||
47 | target/arm/mte_helper.c | 37 ++++++++++++++++++++++++++++++------- | ||
48 | 6 files changed, 54 insertions(+), 31 deletions(-) | ||
49 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Yuquan Wang <wangyuquan1236@phytium.com.cn> |
---|---|---|---|
2 | 2 | ||
3 | When booting an EL3 cpu with -kernel, we set up EL3 and then | 3 | This extends the slots of xhci to 64, since the default xhci_sysbus |
4 | drop down to EL2. We need to enable access to v8.5-MemTag | 4 | just supports one slot. |
5 | tag allocation at EL3 before doing so. | ||
6 | 5 | ||
7 | Reported-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Signed-off-by: Wang Yuquan <wangyuquan1236@phytium.com.cn> |
8 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 7 | Signed-off-by: Chen Baozi <chenbaozi@phytium.com.cn> |
9 | Message-id: 20200724163853.504655-3-richard.henderson@linaro.org | 8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
10 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Reviewed-by: Marcin Juszkiewicz <marcin.juszkiewicz@linaro.org> |
10 | Tested-by: Marcin Juszkiewicz <marcin.juszkiewicz@linaro.org> | ||
11 | Message-id: 20230710063750.473510-2-wangyuquan1236@phytium.com.cn | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
12 | --- | 13 | --- |
13 | hw/arm/boot.c | 3 +++ | 14 | hw/arm/sbsa-ref.c | 1 + |
14 | 1 file changed, 3 insertions(+) | 15 | 1 file changed, 1 insertion(+) |
15 | 16 | ||
16 | diff --git a/hw/arm/boot.c b/hw/arm/boot.c | 17 | diff --git a/hw/arm/sbsa-ref.c b/hw/arm/sbsa-ref.c |
17 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/hw/arm/boot.c | 19 | --- a/hw/arm/sbsa-ref.c |
19 | +++ b/hw/arm/boot.c | 20 | +++ b/hw/arm/sbsa-ref.c |
20 | @@ -XXX,XX +XXX,XX @@ static void do_cpu_reset(void *opaque) | 21 | @@ -XXX,XX +XXX,XX @@ static void create_xhci(const SBSAMachineState *sms) |
21 | if (cpu_isar_feature(aa64_pauth, cpu)) { | 22 | hwaddr base = sbsa_ref_memmap[SBSA_XHCI].base; |
22 | env->cp15.scr_el3 |= SCR_API | SCR_APK; | 23 | int irq = sbsa_ref_irqmap[SBSA_XHCI]; |
23 | } | 24 | DeviceState *dev = qdev_new(TYPE_XHCI_SYSBUS); |
24 | + if (cpu_isar_feature(aa64_mte, cpu)) { | 25 | + qdev_prop_set_uint32(dev, "slots", XHCI_MAXSLOTS); |
25 | + env->cp15.scr_el3 |= SCR_ATA; | 26 | |
26 | + } | 27 | sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal); |
27 | /* AArch64 kernels never boot in secure mode */ | 28 | sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, base); |
28 | assert(!info->secure_boot); | ||
29 | /* This hook is only supported for AArch32 currently: | ||
30 | -- | 29 | -- |
31 | 2.20.1 | 30 | 2.34.1 |
32 | |||
33 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | In the code for TARGET_NR_clock_adjtime, we set the pointer phtx to |
---|---|---|---|
2 | the address of the local variable htx. This means it can never be | ||
3 | NULL, but later in the code we check it for NULL anyway. Coverity | ||
4 | complains about this (CID 1507683) because the NULL check comes after | ||
5 | a call to clock_adjtime() that assumes it is non-NULL. | ||
2 | 6 | ||
3 | When booting an EL3 cpu with -kernel, we set up EL3 and then | 7 | Since phtx is always &htx, and is used only in three places, it's not |
4 | drop down to EL2. We need to enable access to v8.3-PAuth | 8 | really necessary. Remove it, bringing the code structure in to line |
5 | keys and instructions at EL3 before doing so. | 9 | with that for TARGET_NR_clock_adjtime64, which already uses a simple |
10 | '&htx' when it wants a pointer to 'htx'. | ||
6 | 11 | ||
7 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20200724163853.504655-2-richard.henderson@linaro.org | ||
9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
13 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
14 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
15 | Message-id: 20230623144410.1837261-1-peter.maydell@linaro.org | ||
11 | --- | 16 | --- |
12 | hw/arm/boot.c | 3 +++ | 17 | linux-user/syscall.c | 12 +++++------- |
13 | 1 file changed, 3 insertions(+) | 18 | 1 file changed, 5 insertions(+), 7 deletions(-) |
14 | 19 | ||
15 | diff --git a/hw/arm/boot.c b/hw/arm/boot.c | 20 | diff --git a/linux-user/syscall.c b/linux-user/syscall.c |
16 | index XXXXXXX..XXXXXXX 100644 | 21 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/hw/arm/boot.c | 22 | --- a/linux-user/syscall.c |
18 | +++ b/hw/arm/boot.c | 23 | +++ b/linux-user/syscall.c |
19 | @@ -XXX,XX +XXX,XX @@ static void do_cpu_reset(void *opaque) | 24 | @@ -XXX,XX +XXX,XX @@ static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1, |
20 | } else { | 25 | #if defined(TARGET_NR_clock_adjtime) && defined(CONFIG_CLOCK_ADJTIME) |
21 | env->pstate = PSTATE_MODE_EL1h; | 26 | case TARGET_NR_clock_adjtime: |
22 | } | 27 | { |
23 | + if (cpu_isar_feature(aa64_pauth, cpu)) { | 28 | - struct timex htx, *phtx = &htx; |
24 | + env->cp15.scr_el3 |= SCR_API | SCR_APK; | 29 | + struct timex htx; |
25 | + } | 30 | |
26 | /* AArch64 kernels never boot in secure mode */ | 31 | - if (target_to_host_timex(phtx, arg2) != 0) { |
27 | assert(!info->secure_boot); | 32 | + if (target_to_host_timex(&htx, arg2) != 0) { |
28 | /* This hook is only supported for AArch32 currently: | 33 | return -TARGET_EFAULT; |
34 | } | ||
35 | - ret = get_errno(clock_adjtime(arg1, phtx)); | ||
36 | - if (!is_error(ret) && phtx) { | ||
37 | - if (host_to_target_timex(arg2, phtx) != 0) { | ||
38 | - return -TARGET_EFAULT; | ||
39 | - } | ||
40 | + ret = get_errno(clock_adjtime(arg1, &htx)); | ||
41 | + if (!is_error(ret) && host_to_target_timex(arg2, &htx)) { | ||
42 | + return -TARGET_EFAULT; | ||
43 | } | ||
44 | } | ||
45 | return ret; | ||
29 | -- | 46 | -- |
30 | 2.20.1 | 47 | 2.34.1 |
31 | 48 | ||
32 | 49 | diff view generated by jsdifflib |
1 | Commit 6a0b7505f1fd6769c which added documentation of the virt board | 1 | Add comments to the in_* fields in the S1Translate struct |
---|---|---|---|
2 | crossed in the post with commit 6f4e1405b91da0d0 which added a new | 2 | that explain what they're doing. |
3 | 'mte' machine option. Update the docs to include the new option. | ||
4 | 3 | ||
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
6 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
6 | Message-id: 20230710152130.3928330-2-peter.maydell@linaro.org | ||
8 | --- | 7 | --- |
9 | docs/system/arm/virt.rst | 4 ++++ | 8 | target/arm/ptw.c | 40 ++++++++++++++++++++++++++++++++++++++++ |
10 | 1 file changed, 4 insertions(+) | 9 | 1 file changed, 40 insertions(+) |
11 | 10 | ||
12 | diff --git a/docs/system/arm/virt.rst b/docs/system/arm/virt.rst | 11 | diff --git a/target/arm/ptw.c b/target/arm/ptw.c |
13 | index XXXXXXX..XXXXXXX 100644 | 12 | index XXXXXXX..XXXXXXX 100644 |
14 | --- a/docs/system/arm/virt.rst | 13 | --- a/target/arm/ptw.c |
15 | +++ b/docs/system/arm/virt.rst | 14 | +++ b/target/arm/ptw.c |
16 | @@ -XXX,XX +XXX,XX @@ virtualization | 15 | @@ -XXX,XX +XXX,XX @@ |
17 | Set ``on``/``off`` to enable/disable emulating a guest CPU which implements the | 16 | #endif |
18 | Arm Virtualization Extensions. The default is ``off``. | 17 | |
19 | 18 | typedef struct S1Translate { | |
20 | +mte | 19 | + /* |
21 | + Set ``on``/``off`` to enable/disable emulating a guest CPU which implements the | 20 | + * in_mmu_idx : specifies which TTBR, TCR, etc to use for the walk. |
22 | + Arm Memory Tagging Extensions. The default is ``off``. | 21 | + * Together with in_space, specifies the architectural translation regime. |
23 | + | 22 | + */ |
24 | highmem | 23 | ARMMMUIdx in_mmu_idx; |
25 | Set ``on``/``off`` to enable/disable placing devices and RAM in physical | 24 | + /* |
26 | address space above 32 bits. The default is ``on`` for machine types | 25 | + * in_ptw_idx: specifies which mmuidx to use for the actual |
26 | + * page table descriptor load operations. This will be one of the | ||
27 | + * ARMMMUIdx_Stage2* or one of the ARMMMUIdx_Phys_* indexes. | ||
28 | + * If a Secure ptw is "downgraded" to NonSecure by an NSTable bit, | ||
29 | + * this field is updated accordingly. | ||
30 | + */ | ||
31 | ARMMMUIdx in_ptw_idx; | ||
32 | + /* | ||
33 | + * in_space: the security space for this walk. This plus | ||
34 | + * the in_mmu_idx specify the architectural translation regime. | ||
35 | + * If a Secure ptw is "downgraded" to NonSecure by an NSTable bit, | ||
36 | + * this field is updated accordingly. | ||
37 | + * | ||
38 | + * Note that the security space for the in_ptw_idx may be different | ||
39 | + * from that for the in_mmu_idx. We do not need to explicitly track | ||
40 | + * the in_ptw_idx security space because: | ||
41 | + * - if the in_ptw_idx is an ARMMMUIdx_Phys_* then the mmuidx | ||
42 | + * itself specifies the security space | ||
43 | + * - if the in_ptw_idx is an ARMMMUIdx_Stage2* then the security | ||
44 | + * space used for ptw reads is the same as that of the security | ||
45 | + * space of the stage 1 translation for all cases except where | ||
46 | + * stage 1 is Secure; in that case the only possibilities for | ||
47 | + * the ptw read are Secure and NonSecure, and the in_ptw_idx | ||
48 | + * value being Stage2 vs Stage2_S distinguishes those. | ||
49 | + */ | ||
50 | ARMSecuritySpace in_space; | ||
51 | + /* | ||
52 | + * in_secure: whether the translation regime is a Secure one. | ||
53 | + * This is always equal to arm_space_is_secure(in_space). | ||
54 | + * If a Secure ptw is "downgraded" to NonSecure by an NSTable bit, | ||
55 | + * this field is updated accordingly. | ||
56 | + */ | ||
57 | bool in_secure; | ||
58 | + /* | ||
59 | + * in_debug: is this a QEMU debug access (gdbstub, etc)? Debug | ||
60 | + * accesses will not update the guest page table access flags | ||
61 | + * and will not change the state of the softmmu TLBs. | ||
62 | + */ | ||
63 | bool in_debug; | ||
64 | /* | ||
65 | * If this is stage 2 of a stage 1+2 page table walk, then this must | ||
27 | -- | 66 | -- |
28 | 2.20.1 | 67 | 2.34.1 |
29 | |||
30 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | In commit fe4a5472ccd6 we rearranged the logic in S1_ptw_translate() |
---|---|---|---|
2 | so that the debug-access "call get_phys_addr_*" codepath is used both | ||
3 | when S1 is doing ptw reads from stage 2 and when it is doing ptw | ||
4 | reads from physical memory. However, we didn't update the | ||
5 | calculation of s2ptw->in_space and s2ptw->in_secure to account for | ||
6 | the "ptw reads from physical memory" case. This meant that debug | ||
7 | accesses when in Secure state broke. | ||
2 | 8 | ||
3 | When we changed the interface of get_phys_addr_lpae to require | 9 | Create a new function S2_security_space() which returns the |
4 | the cacheattr parameter, this spot was missed. The compiler is | 10 | correct security space to use for the ptw load, and use it to |
5 | unable to detect the use of NULL vs the nonnull attribute here. | 11 | determine the correct .in_secure and .in_space fields for the |
12 | stage 2 lookup for the ptw load. | ||
6 | 13 | ||
7 | Fixes: 7e98e21c098 | 14 | Reported-by: Jean-Philippe Brucker <jean-philippe@linaro.org> |
8 | Reported-by: Jan Kiszka <jan.kiszka@siemens.com> | 15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
9 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | 16 | Tested-by: Jean-Philippe Brucker <jean-philippe@linaro.org> |
10 | Tested-by: Jan Kiszka <jan.kiskza@siemens.com> | 17 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
11 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 18 | Message-id: 20230710152130.3928330-3-peter.maydell@linaro.org |
19 | Fixes: fe4a5472ccd6 ("target/arm: Use get_phys_addr_with_struct in S1_ptw_translate") | ||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 20 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
13 | --- | 21 | --- |
14 | target/arm/helper.c | 19 ++++++------------- | 22 | target/arm/ptw.c | 37 ++++++++++++++++++++++++++++++++----- |
15 | 1 file changed, 6 insertions(+), 13 deletions(-) | 23 | 1 file changed, 32 insertions(+), 5 deletions(-) |
16 | 24 | ||
17 | diff --git a/target/arm/helper.c b/target/arm/helper.c | 25 | diff --git a/target/arm/ptw.c b/target/arm/ptw.c |
18 | index XXXXXXX..XXXXXXX 100644 | 26 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/target/arm/helper.c | 27 | --- a/target/arm/ptw.c |
20 | +++ b/target/arm/helper.c | 28 | +++ b/target/arm/ptw.c |
21 | @@ -XXX,XX +XXX,XX @@ static hwaddr S1_ptw_translate(CPUARMState *env, ARMMMUIdx mmu_idx, | 29 | @@ -XXX,XX +XXX,XX @@ static bool S2_attrs_are_device(uint64_t hcr, uint8_t attrs) |
22 | int s2prot; | 30 | } |
23 | int ret; | 31 | } |
24 | ARMCacheAttrs cacheattrs = {}; | 32 | |
25 | - ARMCacheAttrs *pcacheattrs = NULL; | 33 | +static ARMSecuritySpace S2_security_space(ARMSecuritySpace s1_space, |
26 | - | 34 | + ARMMMUIdx s2_mmu_idx) |
27 | - if (env->cp15.hcr_el2 & HCR_PTW) { | 35 | +{ |
28 | - /* | 36 | + /* |
29 | - * PTW means we must fault if this S1 walk touches S2 Device | 37 | + * Return the security space to use for stage 2 when doing |
30 | - * memory; otherwise we don't care about the attributes and can | 38 | + * the S1 page table descriptor load. |
31 | - * save the S2 translation the effort of computing them. | 39 | + */ |
32 | - */ | 40 | + if (regime_is_stage2(s2_mmu_idx)) { |
33 | - pcacheattrs = &cacheattrs; | 41 | + /* |
34 | - } | 42 | + * The security space for ptw reads is almost always the same |
35 | 43 | + * as that of the security space of the stage 1 translation. | |
36 | ret = get_phys_addr_lpae(env, addr, MMU_DATA_LOAD, ARMMMUIdx_Stage2, | 44 | + * The only exception is when stage 1 is Secure; in that case |
37 | false, | 45 | + * the ptw read might be to the Secure or the NonSecure space |
38 | &s2pa, &txattrs, &s2prot, &s2size, fi, | 46 | + * (but never Realm or Root), and the s2_mmu_idx tells us which. |
39 | - pcacheattrs); | 47 | + * Root translations are always single-stage. |
40 | + &cacheattrs); | 48 | + */ |
41 | if (ret) { | 49 | + if (s1_space == ARMSS_Secure) { |
42 | assert(fi->type != ARMFault_None); | 50 | + return arm_secure_to_space(s2_mmu_idx == ARMMMUIdx_Stage2_S); |
43 | fi->s2addr = addr; | 51 | + } else { |
44 | @@ -XXX,XX +XXX,XX @@ static hwaddr S1_ptw_translate(CPUARMState *env, ARMMMUIdx mmu_idx, | 52 | + assert(s2_mmu_idx != ARMMMUIdx_Stage2_S); |
45 | fi->s1ptw = true; | 53 | + assert(s1_space != ARMSS_Root); |
46 | return ~0; | 54 | + return s1_space; |
47 | } | 55 | + } |
48 | - if (pcacheattrs && (pcacheattrs->attrs & 0xf0) == 0) { | 56 | + } else { |
49 | - /* Access was to Device memory: generate Permission fault */ | 57 | + /* ptw loads are from phys: the mmu idx itself says which space */ |
50 | + if ((env->cp15.hcr_el2 & HCR_PTW) && (cacheattrs.attrs & 0xf0) == 0) { | 58 | + return arm_phys_to_space(s2_mmu_idx); |
51 | + /* | 59 | + } |
52 | + * PTW set and S1 walk touched S2 Device memory: | 60 | +} |
53 | + * generate Permission fault. | 61 | + |
54 | + */ | 62 | /* Translate a S1 pagetable walk through S2 if needed. */ |
55 | fi->type = ARMFault_Permission; | 63 | static bool S1_ptw_translate(CPUARMState *env, S1Translate *ptw, |
56 | fi->s2addr = addr; | 64 | hwaddr addr, ARMMMUFaultInfo *fi) |
57 | fi->stage2 = true; | 65 | { |
66 | - ARMSecuritySpace space = ptw->in_space; | ||
67 | bool is_secure = ptw->in_secure; | ||
68 | ARMMMUIdx mmu_idx = ptw->in_mmu_idx; | ||
69 | ARMMMUIdx s2_mmu_idx = ptw->in_ptw_idx; | ||
70 | @@ -XXX,XX +XXX,XX @@ static bool S1_ptw_translate(CPUARMState *env, S1Translate *ptw, | ||
71 | * From gdbstub, do not use softmmu so that we don't modify the | ||
72 | * state of the cpu at all, including softmmu tlb contents. | ||
73 | */ | ||
74 | + ARMSecuritySpace s2_space = S2_security_space(ptw->in_space, s2_mmu_idx); | ||
75 | S1Translate s2ptw = { | ||
76 | .in_mmu_idx = s2_mmu_idx, | ||
77 | .in_ptw_idx = ptw_idx_for_stage_2(env, s2_mmu_idx), | ||
78 | - .in_secure = s2_mmu_idx == ARMMMUIdx_Stage2_S, | ||
79 | - .in_space = (s2_mmu_idx == ARMMMUIdx_Stage2_S ? ARMSS_Secure | ||
80 | - : space == ARMSS_Realm ? ARMSS_Realm | ||
81 | - : ARMSS_NonSecure), | ||
82 | + .in_secure = arm_space_is_secure(s2_space), | ||
83 | + .in_space = s2_space, | ||
84 | .in_debug = true, | ||
85 | }; | ||
86 | GetPhysAddrResult s2 = { }; | ||
58 | -- | 87 | -- |
59 | 2.20.1 | 88 | 2.34.1 |
60 | |||
61 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | In get_phys_addr_twostage() the code that applies the effects of |
---|---|---|---|
2 | VSTCR.{SA,SW} and VTCR.{NSA,NSW} only updates result->f.attrs.secure. | ||
3 | Now we also have f.attrs.space for FEAT_RME, we need to keep the two | ||
4 | in sync. | ||
2 | 5 | ||
3 | When GCR_EL1.RRND==1, the choosing of the random value is IMPDEF, | 6 | These bits only have an effect for Secure space translations, not |
4 | and the kernel is not expected to have set RGSR_EL1. Force a | 7 | for Root, so use the input in_space field to determine whether to |
5 | non-zero value into SEED, so that we do not continually return | 8 | apply them rather than the input is_secure. This doesn't actually |
6 | the same tag. | 9 | make a difference because Root translations are never two-stage, |
10 | but it's a little clearer. | ||
7 | 11 | ||
8 | Reported-by: Vincenzo Frascino <vincenzo.frascino@arm.com> | ||
9 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
10 | Message-id: 20200724163853.504655-4-richard.henderson@linaro.org | ||
11 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
13 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
14 | Message-id: 20230710152130.3928330-4-peter.maydell@linaro.org | ||
13 | --- | 15 | --- |
14 | target/arm/mte_helper.c | 37 ++++++++++++++++++++++++++++++------- | 16 | target/arm/ptw.c | 13 ++++++++----- |
15 | 1 file changed, 30 insertions(+), 7 deletions(-) | 17 | 1 file changed, 8 insertions(+), 5 deletions(-) |
16 | 18 | ||
17 | diff --git a/target/arm/mte_helper.c b/target/arm/mte_helper.c | 19 | diff --git a/target/arm/ptw.c b/target/arm/ptw.c |
18 | index XXXXXXX..XXXXXXX 100644 | 20 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/target/arm/mte_helper.c | 21 | --- a/target/arm/ptw.c |
20 | +++ b/target/arm/mte_helper.c | 22 | +++ b/target/arm/ptw.c |
21 | @@ -XXX,XX +XXX,XX @@ | 23 | @@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_twostage(CPUARMState *env, S1Translate *ptw, |
22 | #include "exec/ram_addr.h" | 24 | hwaddr ipa; |
23 | #include "exec/cpu_ldst.h" | 25 | int s1_prot, s1_lgpgsz; |
24 | #include "exec/helper-proto.h" | 26 | bool is_secure = ptw->in_secure; |
25 | +#include "qapi/error.h" | 27 | + ARMSecuritySpace in_space = ptw->in_space; |
26 | +#include "qemu/guest-random.h" | 28 | bool ret, ipa_secure; |
27 | 29 | ARMCacheAttrs cacheattrs1; | |
28 | 30 | ARMSecuritySpace ipa_space; | |
29 | static int choose_nonexcluded_tag(int tag, int offset, uint16_t exclude) | 31 | @@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_twostage(CPUARMState *env, S1Translate *ptw, |
30 | @@ -XXX,XX +XXX,XX @@ static uint8_t *allocation_tag_mem(CPUARMState *env, int ptr_mmu_idx, | 32 | * Check if IPA translates to secure or non-secure PA space. |
31 | 33 | * Note that VSTCR overrides VTCR and {N}SW overrides {N}SA. | |
32 | uint64_t HELPER(irg)(CPUARMState *env, uint64_t rn, uint64_t rm) | 34 | */ |
33 | { | 35 | - result->f.attrs.secure = |
34 | - int rtag; | 36 | - (is_secure |
35 | - | 37 | - && !(env->cp15.vstcr_el2 & (VSTCR_SA | VSTCR_SW)) |
36 | - /* | 38 | - && (ipa_secure |
37 | - * Our IMPDEF choice for GCR_EL1.RRND==1 is to behave as if | 39 | - || !(env->cp15.vtcr_el2 & (VTCR_NSA | VTCR_NSW)))); |
38 | - * GCR_EL1.RRND==0, always producing deterministic results. | 40 | + if (in_space == ARMSS_Secure) { |
39 | - */ | 41 | + result->f.attrs.secure = |
40 | uint16_t exclude = extract32(rm | env->cp15.gcr_el1, 0, 16); | 42 | + !(env->cp15.vstcr_el2 & (VSTCR_SA | VSTCR_SW)) |
41 | + int rrnd = extract32(env->cp15.gcr_el1, 16, 1); | 43 | + && (ipa_secure |
42 | int start = extract32(env->cp15.rgsr_el1, 0, 4); | 44 | + || !(env->cp15.vtcr_el2 & (VTCR_NSA | VTCR_NSW))); |
43 | int seed = extract32(env->cp15.rgsr_el1, 8, 16); | 45 | + result->f.attrs.space = arm_secure_to_space(result->f.attrs.secure); |
44 | - int offset, i; | ||
45 | + int offset, i, rtag; | ||
46 | + | ||
47 | + /* | ||
48 | + * Our IMPDEF choice for GCR_EL1.RRND==1 is to continue to use the | ||
49 | + * deterministic algorithm. Except that with RRND==1 the kernel is | ||
50 | + * not required to have set RGSR_EL1.SEED != 0, which is required for | ||
51 | + * the deterministic algorithm to function. So we force a non-zero | ||
52 | + * SEED for that case. | ||
53 | + */ | ||
54 | + if (unlikely(seed == 0) && rrnd) { | ||
55 | + do { | ||
56 | + Error *err = NULL; | ||
57 | + uint16_t two; | ||
58 | + | ||
59 | + if (qemu_guest_getrandom(&two, sizeof(two), &err) < 0) { | ||
60 | + /* | ||
61 | + * Failed, for unknown reasons in the crypto subsystem. | ||
62 | + * Best we can do is log the reason and use a constant seed. | ||
63 | + */ | ||
64 | + qemu_log_mask(LOG_UNIMP, "IRG: Crypto failure: %s\n", | ||
65 | + error_get_pretty(err)); | ||
66 | + error_free(err); | ||
67 | + two = 1; | ||
68 | + } | ||
69 | + seed = two; | ||
70 | + } while (seed == 0); | ||
71 | + } | 46 | + } |
72 | 47 | ||
73 | /* RandomTag */ | 48 | return false; |
74 | for (i = offset = 0; i < 4; ++i) { | 49 | } |
75 | -- | 50 | -- |
76 | 2.20.1 | 51 | 2.34.1 |
77 | |||
78 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | 1 | In commit f0a08b0913befbd we changed the type of the PC from |
---|---|---|---|
2 | target_ulong to vaddr. In doing so we inadvertently dropped the | ||
3 | zero-padding on the PC in trace lines (the second item inside the [] | ||
4 | in these lines). They used to look like this on AArch64, for | ||
5 | instance: | ||
2 | 6 | ||
3 | The SDRAM Memory Controller has a 32-bit address bus, thus | 7 | Trace 0: 0x7f2260000100 [00000000/0000000040000000/00000061/ff200000] |
4 | supports up to 4 GiB of DRAM. There is a signed to unsigned | ||
5 | conversion error with the AST2600 maximum memory size: | ||
6 | 8 | ||
7 | (uint64_t)(2048 << 20) = (uint64_t)(-2147483648) | 9 | and now they look like this: |
8 | = 0xffffffff40000000 | 10 | Trace 0: 0x7f4f50000100 [00000000/40000000/00000061/ff200000] |
9 | = 16 EiB - 2 GiB | ||
10 | 11 | ||
11 | Fix by using the IEC suffixes which are usually safer, and add | 12 | and if the PC happens to be somewhere low like 0x5000 |
12 | an assertion check to verify the memory is valid. This would have | 13 | then the field is shown as /5000/. |
13 | caught this bug: | ||
14 | 14 | ||
15 | $ qemu-system-arm -M ast2600-evb | 15 | This is because TARGET_FMT_lx is a "%08x" or "%016x" specifier, |
16 | qemu-system-arm: hw/misc/aspeed_sdmc.c:258: aspeed_sdmc_realize: Assertion `asc->max_ram_size < 4 * GiB' failed. | 16 | depending on TARGET_LONG_SIZE, whereas VADDR_PRIx is just PRIx64 |
17 | Aborted (core dumped) | 17 | with no width specifier. |
18 | 18 | ||
19 | Fixes: 1550d72679 ("aspeed/sdmc: Add AST2600 support") | 19 | Restore the zero-padding by adding an 016 width specifier to |
20 | Reviewed-by: Cédric Le Goater <clg@kaod.org> | 20 | this tracing and a couple of others that were similarly recently |
21 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 21 | changed to use VADDR_PRIx without a width specifier. |
22 | |||
23 | We can't unfortunately restore the "32-bit guests are padded to | ||
24 | 8 hex digits and 64-bit guests to 16 hex digits" behaviour so | ||
25 | easily. | ||
26 | |||
27 | Fixes: f0a08b0913befbd ("accel/tcg/cpu-exec.c: Widen pc to vaddr") | ||
22 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 28 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
29 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
30 | Reviewed-by: Anton Johansson <anjo@rev.ng> | ||
31 | Message-id: 20230711165434.4123674-1-peter.maydell@linaro.org | ||
23 | --- | 32 | --- |
24 | hw/misc/aspeed_sdmc.c | 7 ++++--- | 33 | accel/tcg/cpu-exec.c | 4 ++-- |
25 | 1 file changed, 4 insertions(+), 3 deletions(-) | 34 | accel/tcg/translate-all.c | 2 +- |
35 | 2 files changed, 3 insertions(+), 3 deletions(-) | ||
26 | 36 | ||
27 | diff --git a/hw/misc/aspeed_sdmc.c b/hw/misc/aspeed_sdmc.c | 37 | diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c |
28 | index XXXXXXX..XXXXXXX 100644 | 38 | index XXXXXXX..XXXXXXX 100644 |
29 | --- a/hw/misc/aspeed_sdmc.c | 39 | --- a/accel/tcg/cpu-exec.c |
30 | +++ b/hw/misc/aspeed_sdmc.c | 40 | +++ b/accel/tcg/cpu-exec.c |
31 | @@ -XXX,XX +XXX,XX @@ static void aspeed_sdmc_realize(DeviceState *dev, Error **errp) | 41 | @@ -XXX,XX +XXX,XX @@ static void log_cpu_exec(vaddr pc, CPUState *cpu, |
32 | AspeedSDMCState *s = ASPEED_SDMC(dev); | 42 | if (qemu_log_in_addr_range(pc)) { |
33 | AspeedSDMCClass *asc = ASPEED_SDMC_GET_CLASS(s); | 43 | qemu_log_mask(CPU_LOG_EXEC, |
34 | 44 | "Trace %d: %p [%08" PRIx64 | |
35 | + assert(asc->max_ram_size < 4 * GiB); /* 32-bit address bus */ | 45 | - "/%" VADDR_PRIx "/%08x/%08x] %s\n", |
36 | s->max_ram_size = asc->max_ram_size; | 46 | + "/%016" VADDR_PRIx "/%08x/%08x] %s\n", |
37 | 47 | cpu->cpu_index, tb->tc.ptr, tb->cs_base, pc, | |
38 | memory_region_init_io(&s->iomem, OBJECT(s), &aspeed_sdmc_ops, s, | 48 | tb->flags, tb->cflags, lookup_symbol(pc)); |
39 | @@ -XXX,XX +XXX,XX @@ static void aspeed_2400_sdmc_class_init(ObjectClass *klass, void *data) | 49 | |
40 | AspeedSDMCClass *asc = ASPEED_SDMC_CLASS(klass); | 50 | @@ -XXX,XX +XXX,XX @@ cpu_tb_exec(CPUState *cpu, TranslationBlock *itb, int *tb_exit) |
41 | 51 | if (qemu_loglevel_mask(CPU_LOG_EXEC)) { | |
42 | dc->desc = "ASPEED 2400 SDRAM Memory Controller"; | 52 | vaddr pc = log_pc(cpu, last_tb); |
43 | - asc->max_ram_size = 512 << 20; | 53 | if (qemu_log_in_addr_range(pc)) { |
44 | + asc->max_ram_size = 512 * MiB; | 54 | - qemu_log("Stopped execution of TB chain before %p [%" |
45 | asc->compute_conf = aspeed_2400_sdmc_compute_conf; | 55 | + qemu_log("Stopped execution of TB chain before %p [%016" |
46 | asc->write = aspeed_2400_sdmc_write; | 56 | VADDR_PRIx "] %s\n", |
47 | asc->valid_ram_sizes = aspeed_2400_ram_sizes; | 57 | last_tb->tc.ptr, pc, lookup_symbol(pc)); |
48 | @@ -XXX,XX +XXX,XX @@ static void aspeed_2500_sdmc_class_init(ObjectClass *klass, void *data) | 58 | } |
49 | AspeedSDMCClass *asc = ASPEED_SDMC_CLASS(klass); | 59 | diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c |
50 | 60 | index XXXXXXX..XXXXXXX 100644 | |
51 | dc->desc = "ASPEED 2500 SDRAM Memory Controller"; | 61 | --- a/accel/tcg/translate-all.c |
52 | - asc->max_ram_size = 1024 << 20; | 62 | +++ b/accel/tcg/translate-all.c |
53 | + asc->max_ram_size = 1 * GiB; | 63 | @@ -XXX,XX +XXX,XX @@ void cpu_io_recompile(CPUState *cpu, uintptr_t retaddr) |
54 | asc->compute_conf = aspeed_2500_sdmc_compute_conf; | 64 | if (qemu_loglevel_mask(CPU_LOG_EXEC)) { |
55 | asc->write = aspeed_2500_sdmc_write; | 65 | vaddr pc = log_pc(cpu, tb); |
56 | asc->valid_ram_sizes = aspeed_2500_ram_sizes; | 66 | if (qemu_log_in_addr_range(pc)) { |
57 | @@ -XXX,XX +XXX,XX @@ static void aspeed_2600_sdmc_class_init(ObjectClass *klass, void *data) | 67 | - qemu_log("cpu_io_recompile: rewound execution of TB to %" |
58 | AspeedSDMCClass *asc = ASPEED_SDMC_CLASS(klass); | 68 | + qemu_log("cpu_io_recompile: rewound execution of TB to %016" |
59 | 69 | VADDR_PRIx "\n", pc); | |
60 | dc->desc = "ASPEED 2600 SDRAM Memory Controller"; | 70 | } |
61 | - asc->max_ram_size = 2048 << 20; | 71 | } |
62 | + asc->max_ram_size = 2 * GiB; | ||
63 | asc->compute_conf = aspeed_2600_sdmc_compute_conf; | ||
64 | asc->write = aspeed_2600_sdmc_write; | ||
65 | asc->valid_ram_sizes = aspeed_2600_ram_sizes; | ||
66 | -- | 72 | -- |
67 | 2.20.1 | 73 | 2.34.1 |
68 | 74 | ||
69 | 75 | diff view generated by jsdifflib |
1 | From: Dongjiu Geng <gengdongjiu@huawei.com> | 1 | From: Tong Ho <tong.ho@amd.com> |
---|---|---|---|
2 | 2 | ||
3 | data_length is a constant value, so we use assert instead of | 3 | Add a check in the bit-set operation to write the backstore |
4 | condition check. | 4 | only if the affected bit is 0 before. |
5 | 5 | ||
6 | Signed-off-by: Dongjiu Geng <gengdongjiu@huawei.com> | 6 | With this in place, there will be no need for callers to |
7 | Message-id: 20200622113146.33421-1-gengdongjiu@huawei.com | 7 | do the checking in order to avoid unnecessary writes. |
8 | Reviewed-by: Michael S. Tsirkin <mst@redhat.com> | 8 | |
9 | Signed-off-by: Tong Ho <tong.ho@amd.com> | ||
10 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
11 | Reviewed-by: Francisco Iglesias <frasse.iglesias@gmail.com> | ||
12 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | --- | 14 | --- |
11 | hw/acpi/ghes.c | 12 ++++-------- | 15 | hw/nvram/xlnx-efuse.c | 11 +++++++++-- |
12 | 1 file changed, 4 insertions(+), 8 deletions(-) | 16 | 1 file changed, 9 insertions(+), 2 deletions(-) |
13 | 17 | ||
14 | diff --git a/hw/acpi/ghes.c b/hw/acpi/ghes.c | 18 | diff --git a/hw/nvram/xlnx-efuse.c b/hw/nvram/xlnx-efuse.c |
15 | index XXXXXXX..XXXXXXX 100644 | 19 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/hw/acpi/ghes.c | 20 | --- a/hw/nvram/xlnx-efuse.c |
17 | +++ b/hw/acpi/ghes.c | 21 | +++ b/hw/nvram/xlnx-efuse.c |
18 | @@ -XXX,XX +XXX,XX @@ static int acpi_ghes_record_mem_error(uint64_t error_block_address, | 22 | @@ -XXX,XX +XXX,XX @@ static bool efuse_ro_bits_find(XlnxEFuse *s, uint32_t k) |
19 | 23 | ||
20 | /* This is the length if adding a new generic error data entry*/ | 24 | bool xlnx_efuse_set_bit(XlnxEFuse *s, unsigned int bit) |
21 | data_length = ACPI_GHES_DATA_LENGTH + ACPI_GHES_MEM_CPER_LENGTH; | 25 | { |
22 | - | 26 | + uint32_t set, *row; |
23 | /* | 27 | + |
24 | - * Check whether it will run out of the preallocated memory if adding a new | 28 | if (efuse_ro_bits_find(s, bit)) { |
25 | - * generic error data entry | 29 | g_autofree char *path = object_get_canonical_path(OBJECT(s)); |
26 | + * It should not run out of the preallocated memory if adding a new generic | 30 | |
27 | + * error data entry | 31 | @@ -XXX,XX +XXX,XX @@ bool xlnx_efuse_set_bit(XlnxEFuse *s, unsigned int bit) |
28 | */ | 32 | return false; |
29 | - if ((data_length + ACPI_GHES_GESB_SIZE) > ACPI_GHES_MAX_RAW_DATA_LENGTH) { | 33 | } |
30 | - error_report("Not enough memory to record new CPER!!!"); | 34 | |
31 | - g_array_free(block, true); | 35 | - s->fuse32[bit / 32] |= 1 << (bit % 32); |
32 | - return -1; | 36 | - efuse_bdrv_sync(s, bit); |
33 | - } | 37 | + /* Avoid back-end write unless there is a real update */ |
34 | + assert((data_length + ACPI_GHES_GESB_SIZE) <= | 38 | + row = &s->fuse32[bit / 32]; |
35 | + ACPI_GHES_MAX_RAW_DATA_LENGTH); | 39 | + set = 1 << (bit % 32); |
36 | 40 | + if (!(set & *row)) { | |
37 | /* Build the new generic error status block header */ | 41 | + *row |= set; |
38 | acpi_ghes_generic_error_status(block, ACPI_GEBS_UNCORRECTABLE, | 42 | + efuse_bdrv_sync(s, bit); |
43 | + } | ||
44 | return true; | ||
45 | } | ||
46 | |||
39 | -- | 47 | -- |
40 | 2.20.1 | 48 | 2.34.1 |
41 | 49 | ||
42 | 50 | diff view generated by jsdifflib |