qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Richard Henderson <richard.henderson@linaro.org>
To: Song Gao <gaosong@loongson.cn>, qemu-devel@nongnu.org
Cc: maobibo@loongson.cn, philmd@linaro.org
Subject: Re: [PATCH v2 5/5] target/loongarch/tcg: Add hardware page table walker support
Date: Tue, 5 Nov 2024 14:27:20 +0000	[thread overview]
Message-ID: <23534a10-ea21-47ee-b31f-0ce9185e6545@linaro.org> (raw)
In-Reply-To: <20241010063536.2276871-6-gaosong@loongson.cn>

On 10/10/24 07:35, Song Gao wrote:
> +        base = get_pte_base(env, address);
> +
> +        /* 0:64bit, 1:128bit, 2:192bit, 3:256bit */
> +        shift = FIELD_EX64(env->CSR_PWCL, CSR_PWCL, PTEWIDTH);
> +        shift = (shift + 1) * 3;
> +        ptindex = (address >> ptbase) & ((1 << ptwidth) -1);
> +        ptoffset = ptindex << shift;
> +        tmp0 = base | ptoffset;

This is a guest virtual address.

> +      retry:
> +        old_val = ldq_phys(cs->as, tmp0) & TARGET_PHYS_MASK;

Fine.

> +        if (old_val != new_val) {
> +            cur_val = qatomic_cmpxchg((uint64_t *)tmp0, old_val, new_val);

This uses a host address.  The cast, and the resulting reference, are incorrect.

This is why Arm and x86 structure things differently, using a different tlb index to 
resolve the host address.  This allows the result to be cached like any other address 
resolution.

Riscv does something a bit simpler, using address_space_translate to resolve the host address.

Most of the rest of this patch set is going to need review from loongson employees, since 
I've not seen public documentation in english for this feature.

r~


  reply	other threads:[~2024-11-05 14:27 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-10  6:35 [PATCH v2 0/5] LoongArch/tcg: Add hardware page table walker support Song Gao
2024-10-10  6:35 ` [PATCH v2 1/5] target/loongarch: Add a new cpu_type la664 Song Gao
2024-10-10  6:35 ` [PATCH v2 2/5] target/loongarch: Add do_lddir/ldpte() Song Gao
2024-10-10  6:35 ` [PATCH v2 3/5] target/loongarch: Add do_fill_tlb_entry() Song Gao
2024-10-10  6:35 ` [PATCH v2 4/5] target/loongarch: Add get_random_tlb_index() Song Gao
2024-10-10  6:35 ` [PATCH v2 5/5] target/loongarch/tcg: Add hardware page table walker support Song Gao
2024-11-05 14:27   ` Richard Henderson [this message]
2024-11-07 12:41     ` gaosong
2024-10-22 11:56 ` [PATCH v2 0/5] LoongArch/tcg: " gaosong

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=23534a10-ea21-47ee-b31f-0ce9185e6545@linaro.org \
    --to=richard.henderson@linaro.org \
    --cc=gaosong@loongson.cn \
    --cc=maobibo@loongson.cn \
    --cc=philmd@linaro.org \
    --cc=qemu-devel@nongnu.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).