From: Jonathan Cameron via <qemu-arm@nongnu.org>
To: Richard Henderson <richard.henderson@linaro.org>
Cc: qemu-devel@nongnu.org, qemu-arm@nongnu.org,
"Philippe Mathieu-Daudé" <philmd@linaro.org>,
"Idan Horowitz" <idan.horowitz@gmail.com>,
linuxarm@huawei.com
Subject: Re: [PATCH v3 5/6] target/arm: Do memory type alignment check when translation disabled
Date: Tue, 16 Apr 2024 16:11:11 +0100 [thread overview]
Message-ID: <20240416161111.0000607c@huawei.com> (raw)
In-Reply-To: <20240301204110.656742-6-richard.henderson@linaro.org>
On Fri, 1 Mar 2024 10:41:09 -1000
Richard Henderson <richard.henderson@linaro.org> wrote:
> If translation is disabled, the default memory type is Device, which
> requires alignment checking. This is more optimally done early via
> the MemOp given to the TCG memory operation.
>
> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> Reported-by: Idan Horowitz <idan.horowitz@gmail.com>
> Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1204
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Hi Richard.
I noticed some tests I was running stopped booting with master.
(it's a fun and complex stack of QEMU + kvm on QEMU for vCPU Hotplug kernel work,
but this is the host booting)
EDK2 build from upstream as of somepoint last week.
Bisects to this patch.
qemu-system-aarch64 -M virt,gic-version=3,virtualization=true -m 4g,maxmem=8G,slots=8 -cpu cortex-a76 -smp cpus=4,threads=2,clusters=2,sockets=1 \
-kernel Image \
-drive if=none,file=full.qcow2,format=qcow2,id=hd \
-device ioh3420,id=root_port1 -device virtio-blk-pci,drive=hd \
-netdev user,id=mynet,hostfwd=tcp::5555-:22 -device virtio-net-pci,netdev=mynet,id=bob \
-nographic -no-reboot -append 'earlycon root=/dev/vda2 fsck.mode=skip tp_printk' \
-monitor telnet:127.0.0.1:1235,server,nowait -bios QEMU_EFI.fd \
-object memory-backend-ram,size=4G,id=mem0 \
-numa node,nodeid=0,cpus=0-3,memdev=mem0
Symptoms: Nothing on console from edk2 which is built in debug mode so is normally very noisy.
No sign of anything much happening at all :(
Jonathan
> ---
> target/arm/tcg/hflags.c | 34 ++++++++++++++++++++++++++++++++--
> 1 file changed, 32 insertions(+), 2 deletions(-)
>
> diff --git a/target/arm/tcg/hflags.c b/target/arm/tcg/hflags.c
> index 8e5d35d922..5da1b0fc1d 100644
> --- a/target/arm/tcg/hflags.c
> +++ b/target/arm/tcg/hflags.c
> @@ -26,6 +26,35 @@ static inline bool fgt_svc(CPUARMState *env, int el)
> FIELD_EX64(env->cp15.fgt_exec[FGTREG_HFGITR], HFGITR_EL2, SVC_EL1);
> }
>
> +/* Return true if memory alignment should be enforced. */
> +static bool aprofile_require_alignment(CPUARMState *env, int el, uint64_t sctlr)
> +{
> +#ifdef CONFIG_USER_ONLY
> + return false;
> +#else
> + /* Check the alignment enable bit. */
> + if (sctlr & SCTLR_A) {
> + return true;
> + }
> +
> + /*
> + * If translation is disabled, then the default memory type is
> + * Device(-nGnRnE) instead of Normal, which requires that alignment
> + * be enforced. Since this affects all ram, it is most efficient
> + * to handle this during translation.
> + */
> + if (sctlr & SCTLR_M) {
> + /* Translation enabled: memory type in PTE via MAIR_ELx. */
> + return false;
> + }
> + if (el < 2 && (arm_hcr_el2_eff(env) & (HCR_DC | HCR_VM))) {
> + /* Stage 2 translation enabled: memory type in PTE. */
> + return false;
> + }
> + return true;
> +#endif
> +}
> +
> static CPUARMTBFlags rebuild_hflags_common(CPUARMState *env, int fp_el,
> ARMMMUIdx mmu_idx,
> CPUARMTBFlags flags)
> @@ -121,8 +150,9 @@ static CPUARMTBFlags rebuild_hflags_a32(CPUARMState *env, int fp_el,
> {
> CPUARMTBFlags flags = {};
> int el = arm_current_el(env);
> + uint64_t sctlr = arm_sctlr(env, el);
>
> - if (arm_sctlr(env, el) & SCTLR_A) {
> + if (aprofile_require_alignment(env, el, sctlr)) {
> DP_TBFLAG_ANY(flags, ALIGN_MEM, 1);
> }
>
> @@ -223,7 +253,7 @@ static CPUARMTBFlags rebuild_hflags_a64(CPUARMState *env, int el, int fp_el,
>
> sctlr = regime_sctlr(env, stage1);
>
> - if (sctlr & SCTLR_A) {
> + if (aprofile_require_alignment(env, el, sctlr)) {
> DP_TBFLAG_ANY(flags, ALIGN_MEM, 1);
> }
>
WARNING: multiple messages have this Message-ID (diff)
From: Jonathan Cameron via <qemu-devel@nongnu.org>
To: Richard Henderson <richard.henderson@linaro.org>
Cc: qemu-devel@nongnu.org, qemu-arm@nongnu.org,
"Philippe Mathieu-Daudé" <philmd@linaro.org>,
"Idan Horowitz" <idan.horowitz@gmail.com>,
linuxarm@huawei.com
Subject: Re: [PATCH v3 5/6] target/arm: Do memory type alignment check when translation disabled
Date: Tue, 16 Apr 2024 16:11:11 +0100 [thread overview]
Message-ID: <20240416161111.0000607c@huawei.com> (raw)
In-Reply-To: <20240301204110.656742-6-richard.henderson@linaro.org>
On Fri, 1 Mar 2024 10:41:09 -1000
Richard Henderson <richard.henderson@linaro.org> wrote:
> If translation is disabled, the default memory type is Device, which
> requires alignment checking. This is more optimally done early via
> the MemOp given to the TCG memory operation.
>
> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> Reported-by: Idan Horowitz <idan.horowitz@gmail.com>
> Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1204
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Hi Richard.
I noticed some tests I was running stopped booting with master.
(it's a fun and complex stack of QEMU + kvm on QEMU for vCPU Hotplug kernel work,
but this is the host booting)
EDK2 build from upstream as of somepoint last week.
Bisects to this patch.
qemu-system-aarch64 -M virt,gic-version=3,virtualization=true -m 4g,maxmem=8G,slots=8 -cpu cortex-a76 -smp cpus=4,threads=2,clusters=2,sockets=1 \
-kernel Image \
-drive if=none,file=full.qcow2,format=qcow2,id=hd \
-device ioh3420,id=root_port1 -device virtio-blk-pci,drive=hd \
-netdev user,id=mynet,hostfwd=tcp::5555-:22 -device virtio-net-pci,netdev=mynet,id=bob \
-nographic -no-reboot -append 'earlycon root=/dev/vda2 fsck.mode=skip tp_printk' \
-monitor telnet:127.0.0.1:1235,server,nowait -bios QEMU_EFI.fd \
-object memory-backend-ram,size=4G,id=mem0 \
-numa node,nodeid=0,cpus=0-3,memdev=mem0
Symptoms: Nothing on console from edk2 which is built in debug mode so is normally very noisy.
No sign of anything much happening at all :(
Jonathan
> ---
> target/arm/tcg/hflags.c | 34 ++++++++++++++++++++++++++++++++--
> 1 file changed, 32 insertions(+), 2 deletions(-)
>
> diff --git a/target/arm/tcg/hflags.c b/target/arm/tcg/hflags.c
> index 8e5d35d922..5da1b0fc1d 100644
> --- a/target/arm/tcg/hflags.c
> +++ b/target/arm/tcg/hflags.c
> @@ -26,6 +26,35 @@ static inline bool fgt_svc(CPUARMState *env, int el)
> FIELD_EX64(env->cp15.fgt_exec[FGTREG_HFGITR], HFGITR_EL2, SVC_EL1);
> }
>
> +/* Return true if memory alignment should be enforced. */
> +static bool aprofile_require_alignment(CPUARMState *env, int el, uint64_t sctlr)
> +{
> +#ifdef CONFIG_USER_ONLY
> + return false;
> +#else
> + /* Check the alignment enable bit. */
> + if (sctlr & SCTLR_A) {
> + return true;
> + }
> +
> + /*
> + * If translation is disabled, then the default memory type is
> + * Device(-nGnRnE) instead of Normal, which requires that alignment
> + * be enforced. Since this affects all ram, it is most efficient
> + * to handle this during translation.
> + */
> + if (sctlr & SCTLR_M) {
> + /* Translation enabled: memory type in PTE via MAIR_ELx. */
> + return false;
> + }
> + if (el < 2 && (arm_hcr_el2_eff(env) & (HCR_DC | HCR_VM))) {
> + /* Stage 2 translation enabled: memory type in PTE. */
> + return false;
> + }
> + return true;
> +#endif
> +}
> +
> static CPUARMTBFlags rebuild_hflags_common(CPUARMState *env, int fp_el,
> ARMMMUIdx mmu_idx,
> CPUARMTBFlags flags)
> @@ -121,8 +150,9 @@ static CPUARMTBFlags rebuild_hflags_a32(CPUARMState *env, int fp_el,
> {
> CPUARMTBFlags flags = {};
> int el = arm_current_el(env);
> + uint64_t sctlr = arm_sctlr(env, el);
>
> - if (arm_sctlr(env, el) & SCTLR_A) {
> + if (aprofile_require_alignment(env, el, sctlr)) {
> DP_TBFLAG_ANY(flags, ALIGN_MEM, 1);
> }
>
> @@ -223,7 +253,7 @@ static CPUARMTBFlags rebuild_hflags_a64(CPUARMState *env, int el, int fp_el,
>
> sctlr = regime_sctlr(env, stage1);
>
> - if (sctlr & SCTLR_A) {
> + if (aprofile_require_alignment(env, el, sctlr)) {
> DP_TBFLAG_ANY(flags, ALIGN_MEM, 1);
> }
>
next prev parent reply other threads:[~2024-04-16 15:11 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-01 20:41 [PATCH v3 0/6] target/arm: Do memory alignment check for device memory Richard Henderson
2024-03-01 20:41 ` [PATCH v3 1/6] target/arm: Support 32-byte alignment in pow2_align Richard Henderson
2024-03-01 20:41 ` [PATCH v3 2/6] exec/memattrs: Remove target_tlb_bit* Richard Henderson
2024-03-01 20:41 ` [PATCH v3 3/6] accel/tcg: Add tlb_fill_flags to CPUTLBEntryFull Richard Henderson
2024-03-01 20:41 ` [PATCH v3 4/6] accel/tcg: Add TLB_CHECK_ALIGNED Richard Henderson
2024-03-01 20:41 ` [PATCH v3 5/6] target/arm: Do memory type alignment check when translation disabled Richard Henderson
2024-04-16 15:11 ` Jonathan Cameron via [this message]
2024-04-16 15:11 ` Jonathan Cameron via
2024-04-17 20:07 ` Richard Henderson
2024-04-18 8:15 ` Jonathan Cameron via
2024-04-18 8:15 ` Jonathan Cameron via
2024-04-18 17:40 ` Jonathan Cameron via
2024-04-18 17:40 ` Jonathan Cameron via
2024-04-19 11:52 ` [edk2-devel] " Gerd Hoffmann
2024-04-19 16:09 ` Jonathan Cameron via
2024-04-19 16:09 ` Jonathan Cameron via
2024-04-19 16:36 ` Ard Biesheuvel
2024-04-19 17:38 ` Ard Biesheuvel
2024-04-22 15:26 ` Clément Chigot
2024-04-22 15:47 ` Richard Henderson
2024-04-22 15:59 ` Peter Maydell
2024-03-01 20:41 ` [PATCH v3 6/6] target/arm: Do memory type alignment check when translation enabled Richard Henderson
2024-03-04 17:10 ` Peter Maydell
2024-03-04 17:27 ` Richard Henderson
2024-03-04 17:12 ` [PATCH v3 0/6] target/arm: Do memory alignment check for device memory Peter Maydell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240416161111.0000607c@huawei.com \
--to=qemu-arm@nongnu.org \
--cc=Jonathan.Cameron@huawei.com \
--cc=idan.horowitz@gmail.com \
--cc=linuxarm@huawei.com \
--cc=philmd@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.