[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <cead582c-ebc4-e8cf-2326-349933e11afd@loongson.cn>
Date: Thu, 13 Apr 2023 19:52:58 +0800
From: Tianrui Zhao <zhaotianrui@...ngson.cn>
To: Xi Ruoyao <xry111@...111.site>, kernel test robot <lkp@...el.com>,
Paolo Bonzini <pbonzini@...hat.com>
Cc: oe-kbuild-all@...ts.linux.dev, Huacai Chen <chenhuacai@...nel.org>,
WANG Xuerui <kernel@...0n.name>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
loongarch@...ts.linux.dev, linux-kernel@...r.kernel.org,
kvm@...r.kernel.org, Jens Axboe <axboe@...nel.dk>,
Mark Brown <broonie@...nel.org>,
Alex Deucher <alexander.deucher@....com>,
Oliver Upton <oliver.upton@...ux.dev>, maobibo@...ngson.cn
Subject: Re: [PATCH v6 29/30] LoongArch: KVM: Enable kvm config and add the
makefile
在 2023年04月13日 16:33, Xi Ruoyao 写道:
> On Thu, 2023-04-13 at 15:32 +0800, kernel test robot wrote:
>
>> vim +/asm +244 arch/loongarch/include/asm/loongarch.h
>>
>> f2ac457a61389b Huacai Chen 2022-05-31 238
>> 2c87b678639d25 Tianrui Zhao 2023-04-12 239 /* GCSR */
>> 2c87b678639d25 Tianrui Zhao 2023-04-12 240 static inline u64 gcsr_read(u32 reg)
> Try __always_inline instead of inline because this "function" will
> definitely break up if it's not inlined.
>
> And I guess we should have something like:
>
> extern u64 __compiletime_error("gcsr_read parameter is not a constant")
> __gcsr_read_non_const(void);
>
> static __always_inline u64 gcsr_read(u32 reg)
> {
> u64 val = 0;
>
> if (!__builtin_constant_p(reg))
> return __gcsr_read_non_const();
>
> asm volatile (
> ... ...
>
> Or perhaps we should just rewrite gcsr_read to a macro.
>
>> 2c87b678639d25 Tianrui Zhao 2023-04-12 241 {
>> 2c87b678639d25 Tianrui Zhao 2023-04-12 242 u64 val = 0;
>> 2c87b678639d25 Tianrui Zhao 2023-04-12 243 /* Instructions will be available in binutils later */
>> 2c87b678639d25 Tianrui Zhao 2023-04-12 @244 asm volatile (
>> 2c87b678639d25 Tianrui Zhao 2023-04-12 245 "parse_r __reg, %[val]\n\t"
>> 2c87b678639d25 Tianrui Zhao 2023-04-12 246 /*
>> 2c87b678639d25 Tianrui Zhao 2023-04-12 247 * read val from guest csr register %[reg]
>> 2c87b678639d25 Tianrui Zhao 2023-04-12 248 * gcsrrd %[val], %[reg]
>> 2c87b678639d25 Tianrui Zhao 2023-04-12 249 */
>> 2c87b678639d25 Tianrui Zhao 2023-04-12 250 ".word 0x5 << 24 | %[reg] << 10 | 0 << 5 | __reg\n\t"
>> 2c87b678639d25 Tianrui Zhao 2023-04-12 251 : [val] "+r" (val)
>> 2c87b678639d25 Tianrui Zhao 2023-04-12 252 : [reg] "i" (reg)
>> 2c87b678639d25 Tianrui Zhao 2023-04-12 253 : "memory");
>> 2c87b678639d25 Tianrui Zhao 2023-04-12 254
>> 2c87b678639d25 Tianrui Zhao 2023-04-12 255 return val;
>> 2c87b678639d25 Tianrui Zhao 2023-04-12 256 }
>> 2c87b678639d25 Tianrui Zhao 2023-04-12 257
>>
Thanks, it really should use __always_inline there, and I will reconsider to fix this function mistakes about compiling.
Thanks
Tianrui Zhao
Powered by blists - more mailing lists