From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: bibo mao <maobibo@loongson.cn>, Song Gao <gaosong@loongson.cn>,
Richard Henderson <richard.henderson@linaro.org>
Cc: qemu-devel@nongnu.org
Subject: Re: [PATCH v3 6/9] target/loongarch: Define function loongarch_get_addr_from_tlb() non-static
Date: Tue, 22 Apr 2025 09:46:08 +0200 [thread overview]
Message-ID: <7cf5d9df-2b09-4ec6-88f5-abf219fa8a80@linaro.org> (raw)
In-Reply-To: <b73e6439-2435-f064-2f07-24b10b9dd2a1@loongson.cn>
On 22/4/25 09:39, bibo mao wrote:
>
>
> On 2025/4/22 下午3:18, Philippe Mathieu-Daudé wrote:
>> On 22/4/25 04:57, Bibo Mao wrote:
>>> Define function loongarch_get_addr_from_tlb() non-static, and add its
>>> definition in header file tcg/tcg_loongarch.h
>>>
>>> Signed-off-by: Bibo Mao <maobibo@loongson.cn>
>>> ---
>>> target/loongarch/cpu_helper.c | 10 ++--------
>>> target/loongarch/tcg/tcg_loongarch.h | 16 ++++++++++++++++
>>> 2 files changed, 18 insertions(+), 8 deletions(-)
>>>
>>> diff --git a/target/loongarch/cpu_helper.c b/target/loongarch/
>>> cpu_helper.c
>>> index 5db64a45cc..7636b2c265 100644
>>> --- a/target/loongarch/cpu_helper.c
>>> +++ b/target/loongarch/cpu_helper.c
>>> @@ -11,6 +11,7 @@
>>> #include "cpu.h"
>>> #include "internals.h"
>>> #include "cpu-csr.h"
>>> +#include "tcg/tcg_loongarch.h"
>>> #ifdef CONFIG_TCG
>>> static int loongarch_map_tlb_entry(CPULoongArchState *env, hwaddr
>>> *physical,
>>> @@ -142,7 +143,7 @@ bool loongarch_tlb_search(CPULoongArchState *env,
>>> target_ulong vaddr,
>>> return false;
>>> }
>>> -static int loongarch_get_addr_from_tlb(CPULoongArchState *env,
>>> hwaddr *physical,
>>> +int loongarch_get_addr_from_tlb(CPULoongArchState *env, hwaddr
>>> *physical,
>>> int *prot, target_ulong
>>> address,
>>> MMUAccessType access_type,
>>> int mmu_idx)
>>> {
>>> @@ -156,13 +157,6 @@ static int
>>> loongarch_get_addr_from_tlb(CPULoongArchState *env, hwaddr *physical,
>>> return TLBRET_NOMATCH;
>>> }
>>> -#else
>>> -static int loongarch_get_addr_from_tlb(CPULoongArchState *env,
>>> hwaddr *physical,
>>> - int *prot, target_ulong address,
>>> - MMUAccessType access_type,
>>> int mmu_idx)
>>> -{
>>> - return TLBRET_NOMATCH;
>>> -}
>>> #endif
>>> void get_dir_base_width(CPULoongArchState *env, uint64_t *dir_base,
>>> diff --git a/target/loongarch/tcg/tcg_loongarch.h b/target/loongarch/
>>> tcg/tcg_loongarch.h
>>> index da2539e995..69a93bfc3e 100644
>>> --- a/target/loongarch/tcg/tcg_loongarch.h
>>> +++ b/target/loongarch/tcg/tcg_loongarch.h
>>> @@ -6,7 +6,23 @@
>>> */
>>> #ifndef TARGET_LOONGARCH_TCG_LOONGARCH_H
>>> #define TARGET_LOONGARCH_TCG_LOONGARCH_H
>>> +#include "cpu.h"
>>> void loongarch_csr_translate_init(void);
>>> +#ifdef CONFIG_TCG
>>> +int loongarch_get_addr_from_tlb(CPULoongArchState *env, hwaddr
>>> *physical,
>>> + int *prot, target_ulong address,
>>> + MMUAccessType access_type, int
>>> mmu_idx);
>>> +#else
>>> +static inline int loongarch_get_addr_from_tlb(CPULoongArchState *env,
>>> + hwaddr *physical,
>>> + int *prot,
>>> target_ulong address,
>>> + MMUAccessType
>>> access_type,
>>> + int mmu_idx)
>>> +{
>>> + return TLBRET_NOMATCH;
>>
>> CONFIG_TCG should always be defined when including tcg/tcg_loongarch.h.
>
> If so, there will be no stub function declaration with
> loongarch_get_addr_from_tlb(). *#ifdef CONFIG_TCG* needs be added in c
> files such as:
>
> static int loongarch_map_address(CPULoongArchState *env, hwaddr *physical,
> int *prot, target_ulong address,
> MMUAccessType access_type, int mmu_idx,
> int is_debug)
> {
> int ret;
>
> *#ifdef CONFIG_TCG*
> if (!kvm_enabled()) {
Maybe what we want here is:
if (tcg_enabled()) {
?
> ret = loongarch_get_addr_from_tlb(env, physical, prot, address,
> access_type, mmu_idx);
> if (ret != TLBRET_NOMATCH) {
> return ret;
> }
> }
> *#endif*
>
> My original thought is to add stub function and remove *#ifdef
> CONFIG_TCG* in c file.
>
> Regards
> Bibo Mao
>
>>
>>> +}
>>> +#endif
>>> +
>>> #endif /* TARGET_LOONGARCH_TCG_LOONGARCH_H */
>>
>
next prev parent reply other threads:[~2025-04-22 7:46 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-22 2:57 [PATCH v3 0/9] target/loongarch: Code cleanup with function loongarch_map_address Bibo Mao
2025-04-22 2:57 ` [PATCH v3 1/9] target/loongarch: Move header file helper.h to directory tcg Bibo Mao
2025-04-22 2:57 ` [PATCH v3 2/9] target/loongarch: Add function loongarch_get_addr_from_tlb Bibo Mao
2025-04-22 2:57 ` [PATCH v3 3/9] target/loongarch: Move function get_dir_base_width to common directory Bibo Mao
2025-04-22 2:57 ` [PATCH v3 4/9] target/loongarch: Add stub function loongarch_get_addr_from_tlb Bibo Mao
2025-04-22 2:57 ` [PATCH v3 5/9] target/loongarch: Set function loongarch_map_address() with common code Bibo Mao
2025-04-22 2:57 ` [PATCH v3 6/9] target/loongarch: Define function loongarch_get_addr_from_tlb() non-static Bibo Mao
2025-04-22 7:18 ` Philippe Mathieu-Daudé
2025-04-22 7:39 ` bibo mao
2025-04-22 7:46 ` Philippe Mathieu-Daudé [this message]
2025-04-22 7:57 ` bibo mao
2025-04-22 8:45 ` Philippe Mathieu-Daudé
2025-04-22 2:57 ` [PATCH v3 7/9] target/loongarch: Move function loongarch_tlb_search to directory tcg Bibo Mao
2025-04-22 7:14 ` Philippe Mathieu-Daudé
2025-04-22 2:57 ` [PATCH v3 8/9] target/loongarch: Add static definition with function loongarch_tlb_search() Bibo Mao
2025-04-22 7:14 ` Philippe Mathieu-Daudé
2025-04-22 2:57 ` [PATCH v3 9/9] target/loongarch: Move definition of TCG specified function to tcg directory Bibo Mao
2025-04-22 7:16 ` Philippe Mathieu-Daudé
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=7cf5d9df-2b09-4ec6-88f5-abf219fa8a80@linaro.org \
--to=philmd@linaro.org \
--cc=gaosong@loongson.cn \
--cc=maobibo@loongson.cn \
--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 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).