qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
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 10:45:56 +0200	[thread overview]
Message-ID: <33dea247-aee7-4d0c-811f-e2734361cb33@linaro.org> (raw)
In-Reply-To: <c82abd30-72db-ba38-30eb-4a44950393ff@loongson.cn>

On 22/4/25 09:57, bibo mao wrote:
> 
> 
> On 2025/4/22 下午3:46, Philippe Mathieu-Daudé wrote:
>> 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/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()) {
> yeap, it works with --enable-debug --disable-tcg option.
> 
> I had thought that loongarch_get_addr_from_tlb should be defined if this 
> file is compiled with -O0 option. It is skipped even with -O0 option.
>      if  (0) {

'if (0)' skips at *compile* time, while 'if (tcg_enabled())' would
skip at *link* time, so we still need to prototype declaration to
compile the source file, but not the stub.

>          ret = loongarch_get_addr_from_tlb(env, physical, prot, address,
>                                            access_type, mmu_idx);
>      }
> 
> And thanks for your guidance.

You are welcome! The cleanups you are doing are not super interesting
(lot of code churn) but make the code easier to follow and maintain IMO.

> 
> Regards
> Bibo Mao



  reply	other threads:[~2025-04-22  8: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é
2025-04-22  7:57         ` bibo mao
2025-04-22  8:45           ` Philippe Mathieu-Daudé [this message]
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=33dea247-aee7-4d0c-811f-e2734361cb33@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).