Documentation/virt/kvm/api.rst | 2 +- arch/loongarch/kvm/vcpu.c | 87 ++++++++++++++++++++++++++++++++++ 2 files changed, 88 insertions(+), 1 deletion(-)
This ioctl can be used by the userspace applications to determine which
(special) registers are get/set-able in a meaningful way.
This can be very useful for cross-platform VMMs so that they do not have
to hardcode register indices for each supported architectures.
Signed-off-by: Zixing Liu <liushuyu@aosc.io>
---
Documentation/virt/kvm/api.rst | 2 +-
arch/loongarch/kvm/vcpu.c | 87 ++++++++++++++++++++++++++++++++++
2 files changed, 88 insertions(+), 1 deletion(-)
diff --git a/Documentation/virt/kvm/api.rst b/Documentation/virt/kvm/api.rst
index 01a3abef8abb..f46dd8be282f 100644
--- a/Documentation/virt/kvm/api.rst
+++ b/Documentation/virt/kvm/api.rst
@@ -3603,7 +3603,7 @@ VCPU matching underlying host.
---------------------
:Capability: basic
-:Architectures: arm64, mips, riscv, x86 (if KVM_CAP_ONE_REG)
+:Architectures: arm64, loongarch, mips, riscv, x86 (if KVM_CAP_ONE_REG)
:Type: vcpu ioctl
:Parameters: struct kvm_reg_list (in/out)
:Returns: 0 on success; -1 on error
diff --git a/arch/loongarch/kvm/vcpu.c b/arch/loongarch/kvm/vcpu.c
index 656b954c1134..bd855ee20ee2 100644
--- a/arch/loongarch/kvm/vcpu.c
+++ b/arch/loongarch/kvm/vcpu.c
@@ -3,6 +3,7 @@
* Copyright (C) 2020-2023 Loongson Technology Corporation Limited
*/
+#include "asm/kvm_host.h"
#include <linux/kvm_host.h>
#include <asm/fpu.h>
#include <asm/lbt.h>
@@ -14,6 +15,8 @@
#define CREATE_TRACE_POINTS
#include "trace.h"
+#define NUM_LBT_REGS 6
+
const struct _kvm_stats_desc kvm_vcpu_stats_desc[] = {
KVM_GENERIC_VCPU_STATS(),
STATS_DESC_COUNTER(VCPU, int_exits),
@@ -1186,6 +1189,72 @@ static int kvm_loongarch_vcpu_set_attr(struct kvm_vcpu *vcpu,
return ret;
}
+static int kvm_loongarch_walk_csrs(struct kvm_vcpu *vcpu, u64 __user *uindices)
+{
+ unsigned int i, count;
+
+ for (i = 0, count = 0; i < CSR_MAX_NUMS; i++) {
+ if (!(get_gcsr_flag(i) & (SW_GCSR | HW_GCSR)))
+ continue;
+ if (i >= LOONGARCH_CSR_PERFCTRL0 && i <= LOONGARCH_CSR_PERFCNTR3) {
+ /* Skip PMU CSRs if not supported by the guest */
+ if (!kvm_guest_has_pmu(&vcpu->arch))
+ continue;
+ }
+ const u64 reg = KVM_IOC_CSRID(i);
+ if (uindices && put_user(reg, uindices++))
+ return -EFAULT;
+ count++;
+ }
+
+ return count;
+}
+
+static unsigned long kvm_loongarch_num_regs(struct kvm_vcpu *vcpu)
+{
+ /* +1 for the KVM_REG_LOONGARCH_COUNTER register */
+ unsigned long res =
+ kvm_loongarch_walk_csrs(vcpu, NULL) + KVM_MAX_CPUCFG_REGS + 1;
+
+ if (kvm_guest_has_lbt(&vcpu->arch))
+ res += NUM_LBT_REGS;
+
+ return res;
+}
+
+static int kvm_loongarch_copy_reg_indices(struct kvm_vcpu *vcpu,
+ u64 __user *uindices)
+{
+ u64 reg;
+ unsigned int i;
+
+ i = kvm_loongarch_walk_csrs(vcpu, uindices);
+ if (i < 0)
+ return i;
+ uindices += i;
+
+ for (i = 0; i < KVM_MAX_CPUCFG_REGS; i++) {
+ reg = KVM_IOC_CPUCFG(i);
+ if (put_user(reg, uindices++))
+ return -EFAULT;
+ }
+
+ reg = KVM_REG_LOONGARCH_COUNTER;
+ if (put_user(reg, uindices++))
+ return -EFAULT;
+
+ if (!kvm_guest_has_lbt(&vcpu->arch))
+ return 0;
+
+ for (i = 1; i <= NUM_LBT_REGS; i++) {
+ reg = (KVM_REG_LOONGARCH_LBT | KVM_REG_SIZE_U64 | i);
+ if (put_user(reg, uindices++))
+ return -EFAULT;
+ }
+
+ return 0;
+}
+
long kvm_arch_vcpu_ioctl(struct file *filp,
unsigned int ioctl, unsigned long arg)
{
@@ -1251,6 +1320,24 @@ long kvm_arch_vcpu_ioctl(struct file *filp,
r = kvm_loongarch_vcpu_set_attr(vcpu, &attr);
break;
}
+ case KVM_GET_REG_LIST: {
+ struct kvm_reg_list __user *user_list = argp;
+ struct kvm_reg_list reg_list;
+ unsigned n;
+
+ r = -EFAULT;
+ if (copy_from_user(®_list, user_list, sizeof(reg_list)))
+ break;
+ n = reg_list.n;
+ reg_list.n = kvm_loongarch_num_regs(vcpu);
+ if (copy_to_user(user_list, ®_list, sizeof(reg_list)))
+ break;
+ r = -E2BIG;
+ if (n < reg_list.n)
+ break;
+ r = kvm_loongarch_copy_reg_indices(vcpu, user_list->reg);
+ break;
+ }
default:
r = -ENOIOCTLCMD;
break;
--
2.53.0
Hi Zixing,
Thanks for doing this.
On 2026/2/4 下午7:36, Zixing Liu wrote:
> This ioctl can be used by the userspace applications to determine which
> (special) registers are get/set-able in a meaningful way.
>
> This can be very useful for cross-platform VMMs so that they do not have
> to hardcode register indices for each supported architectures.
>
> Signed-off-by: Zixing Liu <liushuyu@aosc.io>
> ---
> Documentation/virt/kvm/api.rst | 2 +-
> arch/loongarch/kvm/vcpu.c | 87 ++++++++++++++++++++++++++++++++++
> 2 files changed, 88 insertions(+), 1 deletion(-)
>
> diff --git a/Documentation/virt/kvm/api.rst b/Documentation/virt/kvm/api.rst
> index 01a3abef8abb..f46dd8be282f 100644
> --- a/Documentation/virt/kvm/api.rst
> +++ b/Documentation/virt/kvm/api.rst
> @@ -3603,7 +3603,7 @@ VCPU matching underlying host.
> ---------------------
>
> :Capability: basic
> -:Architectures: arm64, mips, riscv, x86 (if KVM_CAP_ONE_REG)
> +:Architectures: arm64, loongarch, mips, riscv, x86 (if KVM_CAP_ONE_REG)
> :Type: vcpu ioctl
> :Parameters: struct kvm_reg_list (in/out)
> :Returns: 0 on success; -1 on error
> diff --git a/arch/loongarch/kvm/vcpu.c b/arch/loongarch/kvm/vcpu.c
> index 656b954c1134..bd855ee20ee2 100644
> --- a/arch/loongarch/kvm/vcpu.c
> +++ b/arch/loongarch/kvm/vcpu.c
> @@ -3,6 +3,7 @@
> * Copyright (C) 2020-2023 Loongson Technology Corporation Limited
> */
>
> +#include "asm/kvm_host.h"
Had better put after #include <asm/fpu.h>, and keep alphabetical order.
> #include <linux/kvm_host.h>
> #include <asm/fpu.h>
> #include <asm/lbt.h>
> @@ -14,6 +15,8 @@
> #define CREATE_TRACE_POINTS
> #include "trace.h"
>
> +#define NUM_LBT_REGS 6
> +
> const struct _kvm_stats_desc kvm_vcpu_stats_desc[] = {
> KVM_GENERIC_VCPU_STATS(),
> STATS_DESC_COUNTER(VCPU, int_exits),
> @@ -1186,6 +1189,72 @@ static int kvm_loongarch_vcpu_set_attr(struct kvm_vcpu *vcpu,
> return ret;
> }
>
> +static int kvm_loongarch_walk_csrs(struct kvm_vcpu *vcpu, u64 __user *uindices)
> +{
> + unsigned int i, count;
> +
> + for (i = 0, count = 0; i < CSR_MAX_NUMS; i++) {
> + if (!(get_gcsr_flag(i) & (SW_GCSR | HW_GCSR)))
> + continue;
> + if (i >= LOONGARCH_CSR_PERFCTRL0 && i <= LOONGARCH_CSR_PERFCNTR3) {
> + /* Skip PMU CSRs if not supported by the guest */
> + if (!kvm_guest_has_pmu(&vcpu->arch))
> + continue;
> + }
This is workable, gcsr_flag can be changed with structure, and new
element "int required_features" added. However it does not matter, it
can be done in later.
CSR registers relative with msgint feature can be done with this method
also.
How about debug/watch CSR registers? can it be skipped also? the same
MERR CSR registers with LOONGARCH_CSR_MERR*.
The CSR register list difference can be checked with
kvm_loongarch_get_csr() in qemu VMM, with website
https://gitlab.com/qemu-project/qemu/-/blob/master/target/loongarch/kvm/kvm.c?ref_type=heads
Regards
Bibo Mao
> + const u64 reg = KVM_IOC_CSRID(i);
> + if (uindices && put_user(reg, uindices++))
> + return -EFAULT;
> + count++;
> + }
> +
> + return count;
> +}
> +
> +static unsigned long kvm_loongarch_num_regs(struct kvm_vcpu *vcpu)
> +{
> + /* +1 for the KVM_REG_LOONGARCH_COUNTER register */
> + unsigned long res =
> + kvm_loongarch_walk_csrs(vcpu, NULL) + KVM_MAX_CPUCFG_REGS + 1;
> +
> + if (kvm_guest_has_lbt(&vcpu->arch))
> + res += NUM_LBT_REGS;
> +
> + return res;
> +}
> +
> +static int kvm_loongarch_copy_reg_indices(struct kvm_vcpu *vcpu,
> + u64 __user *uindices)
> +{
> + u64 reg;
> + unsigned int i;
> +
> + i = kvm_loongarch_walk_csrs(vcpu, uindices);
> + if (i < 0)
> + return i;
> + uindices += i;
> +
> + for (i = 0; i < KVM_MAX_CPUCFG_REGS; i++) {
> + reg = KVM_IOC_CPUCFG(i);
> + if (put_user(reg, uindices++))
> + return -EFAULT;
> + }
> +
> + reg = KVM_REG_LOONGARCH_COUNTER;
> + if (put_user(reg, uindices++))
> + return -EFAULT;
> +
> + if (!kvm_guest_has_lbt(&vcpu->arch))
> + return 0;
> +
> + for (i = 1; i <= NUM_LBT_REGS; i++) {
> + reg = (KVM_REG_LOONGARCH_LBT | KVM_REG_SIZE_U64 | i);
> + if (put_user(reg, uindices++))
> + return -EFAULT;
> + }
> +
> + return 0;
> +}
> +
> long kvm_arch_vcpu_ioctl(struct file *filp,
> unsigned int ioctl, unsigned long arg)
> {
> @@ -1251,6 +1320,24 @@ long kvm_arch_vcpu_ioctl(struct file *filp,
> r = kvm_loongarch_vcpu_set_attr(vcpu, &attr);
> break;
> }
> + case KVM_GET_REG_LIST: {
> + struct kvm_reg_list __user *user_list = argp;
> + struct kvm_reg_list reg_list;
> + unsigned n;
> +
> + r = -EFAULT;
> + if (copy_from_user(®_list, user_list, sizeof(reg_list)))
> + break;
> + n = reg_list.n;
> + reg_list.n = kvm_loongarch_num_regs(vcpu);
> + if (copy_to_user(user_list, ®_list, sizeof(reg_list)))
> + break;
> + r = -E2BIG;
> + if (n < reg_list.n)
> + break;
> + r = kvm_loongarch_copy_reg_indices(vcpu, user_list->reg);
> + break;
> + }
> default:
> r = -ENOIOCTLCMD;
> break;
>
Hi Bibo,
> Hi Zixing,
>
> Thanks for doing this.
>
> On 2026/2/4 下午7:36, Zixing Liu wrote:
>> This ioctl can be used by the userspace applications to determine which
>> (special) registers are get/set-able in a meaningful way.
>>
>> This can be very useful for cross-platform VMMs so that they do not have
>> to hardcode register indices for each supported architectures.
>>
>> Signed-off-by: Zixing Liu <liushuyu@aosc.io>
>> ---
>> Documentation/virt/kvm/api.rst | 2 +-
>> arch/loongarch/kvm/vcpu.c | 87 ++++++++++++++++++++++++++++++++++
>> 2 files changed, 88 insertions(+), 1 deletion(-)
>>
>> diff --git a/Documentation/virt/kvm/api.rst
>> b/Documentation/virt/kvm/api.rst
>> index 01a3abef8abb..f46dd8be282f 100644
>> --- a/Documentation/virt/kvm/api.rst
>> +++ b/Documentation/virt/kvm/api.rst
>> @@ -3603,7 +3603,7 @@ VCPU matching underlying host.
>> ---------------------
>> :Capability: basic
>> -:Architectures: arm64, mips, riscv, x86 (if KVM_CAP_ONE_REG)
>> +:Architectures: arm64, loongarch, mips, riscv, x86 (if KVM_CAP_ONE_REG)
>> :Type: vcpu ioctl
>> :Parameters: struct kvm_reg_list (in/out)
>> :Returns: 0 on success; -1 on error
>> diff --git a/arch/loongarch/kvm/vcpu.c b/arch/loongarch/kvm/vcpu.c
>> index 656b954c1134..bd855ee20ee2 100644
>> --- a/arch/loongarch/kvm/vcpu.c
>> +++ b/arch/loongarch/kvm/vcpu.c
>> @@ -3,6 +3,7 @@
>> * Copyright (C) 2020-2023 Loongson Technology Corporation Limited
>> */
>> +#include "asm/kvm_host.h"
> Had better put after #include <asm/fpu.h>, and keep alphabetical order.
>> #include <linux/kvm_host.h>
>> #include <asm/fpu.h>
>> #include <asm/lbt.h>
>> @@ -14,6 +15,8 @@
>> #define CREATE_TRACE_POINTS
>> #include "trace.h"
>> +#define NUM_LBT_REGS 6
>> +
>> const struct _kvm_stats_desc kvm_vcpu_stats_desc[] = {
>> KVM_GENERIC_VCPU_STATS(),
>> STATS_DESC_COUNTER(VCPU, int_exits),
>> @@ -1186,6 +1189,72 @@ static int kvm_loongarch_vcpu_set_attr(struct
>> kvm_vcpu *vcpu,
>> return ret;
>> }
>> +static int kvm_loongarch_walk_csrs(struct kvm_vcpu *vcpu, u64
>> __user *uindices)
>> +{
>> + unsigned int i, count;
>> +
>> + for (i = 0, count = 0; i < CSR_MAX_NUMS; i++) {
>> + if (!(get_gcsr_flag(i) & (SW_GCSR | HW_GCSR)))
>> + continue;
>> + if (i >= LOONGARCH_CSR_PERFCTRL0 && i <=
>> LOONGARCH_CSR_PERFCNTR3) {
>> + /* Skip PMU CSRs if not supported by the guest */
>> + if (!kvm_guest_has_pmu(&vcpu->arch))
>> + continue;
>> + }
> This is workable, gcsr_flag can be changed with structure, and new
> element "int required_features" added. However it does not matter, it
> can be done in later.
>
> CSR registers relative with msgint feature can be done with this
> method also.
>
> How about debug/watch CSR registers? can it be skipped also? the same
> MERR CSR registers with LOONGARCH_CSR_MERR*.
>
> The CSR register list difference can be checked with
> kvm_loongarch_get_csr() in qemu VMM, with website
> https://gitlab.com/qemu-project/qemu/-/blob/master/target/loongarch/kvm/kvm.c?ref_type=heads
>
Do you think for KVM guests, the only CSRs need to be saved are listed
at
https://gitlab.com/qemu-project/qemu/-/blob/master/target/loongarch/kvm/kvm.c?ref_type=heads#L375-544?
Then the concern about embedding a big list will become valid again.
What do you think?
> Regards
> Bibo Mao
Thanks,
Zixing
>> + const u64 reg = KVM_IOC_CSRID(i);
>> + if (uindices && put_user(reg, uindices++))
>> + return -EFAULT;
>> + count++;
>> + }
>> +
>> + return count;
>> +}
>> +
>> +static unsigned long kvm_loongarch_num_regs(struct kvm_vcpu *vcpu)
>> +{
>> + /* +1 for the KVM_REG_LOONGARCH_COUNTER register */
>> + unsigned long res =
>> + kvm_loongarch_walk_csrs(vcpu, NULL) + KVM_MAX_CPUCFG_REGS + 1;
>> +
>> + if (kvm_guest_has_lbt(&vcpu->arch))
>> + res += NUM_LBT_REGS;
>> +
>> + return res;
>> +}
>> +
>> +static int kvm_loongarch_copy_reg_indices(struct kvm_vcpu *vcpu,
>> + u64 __user *uindices)
>> +{
>> + u64 reg;
>> + unsigned int i;
>> +
>> + i = kvm_loongarch_walk_csrs(vcpu, uindices);
>> + if (i < 0)
>> + return i;
>> + uindices += i;
>> +
>> + for (i = 0; i < KVM_MAX_CPUCFG_REGS; i++) {
>> + reg = KVM_IOC_CPUCFG(i);
>> + if (put_user(reg, uindices++))
>> + return -EFAULT;
>> + }
>> +
>> + reg = KVM_REG_LOONGARCH_COUNTER;
>> + if (put_user(reg, uindices++))
>> + return -EFAULT;
>> +
>> + if (!kvm_guest_has_lbt(&vcpu->arch))
>> + return 0;
>> +
>> + for (i = 1; i <= NUM_LBT_REGS; i++) {
>> + reg = (KVM_REG_LOONGARCH_LBT | KVM_REG_SIZE_U64 | i);
>> + if (put_user(reg, uindices++))
>> + return -EFAULT;
>> + }
>> +
>> + return 0;
>> +}
>> +
>> long kvm_arch_vcpu_ioctl(struct file *filp,
>> unsigned int ioctl, unsigned long arg)
>> {
>> @@ -1251,6 +1320,24 @@ long kvm_arch_vcpu_ioctl(struct file *filp,
>> r = kvm_loongarch_vcpu_set_attr(vcpu, &attr);
>> break;
>> }
>> + case KVM_GET_REG_LIST: {
>> + struct kvm_reg_list __user *user_list = argp;
>> + struct kvm_reg_list reg_list;
>> + unsigned n;
>> +
>> + r = -EFAULT;
>> + if (copy_from_user(®_list, user_list, sizeof(reg_list)))
>> + break;
>> + n = reg_list.n;
>> + reg_list.n = kvm_loongarch_num_regs(vcpu);
>> + if (copy_to_user(user_list, ®_list, sizeof(reg_list)))
>> + break;
>> + r = -E2BIG;
>> + if (n < reg_list.n)
>> + break;
>> + r = kvm_loongarch_copy_reg_indices(vcpu, user_list->reg);
>> + break;
>> + }
>> default:
>> r = -ENOIOCTLCMD;
>> break;
>>
>
On 2026/2/5 上午9:50, liushuyu wrote:
> Hi Bibo,
>
>> Hi Zixing,
>>
>> Thanks for doing this.
>>
>> On 2026/2/4 下午7:36, Zixing Liu wrote:
>>> This ioctl can be used by the userspace applications to determine which
>>> (special) registers are get/set-able in a meaningful way.
>>>
>>> This can be very useful for cross-platform VMMs so that they do not have
>>> to hardcode register indices for each supported architectures.
>>>
>>> Signed-off-by: Zixing Liu <liushuyu@aosc.io>
>>> ---
>>> Documentation/virt/kvm/api.rst | 2 +-
>>> arch/loongarch/kvm/vcpu.c | 87 ++++++++++++++++++++++++++++++++++
>>> 2 files changed, 88 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/Documentation/virt/kvm/api.rst
>>> b/Documentation/virt/kvm/api.rst
>>> index 01a3abef8abb..f46dd8be282f 100644
>>> --- a/Documentation/virt/kvm/api.rst
>>> +++ b/Documentation/virt/kvm/api.rst
>>> @@ -3603,7 +3603,7 @@ VCPU matching underlying host.
>>> ---------------------
>>> :Capability: basic
>>> -:Architectures: arm64, mips, riscv, x86 (if KVM_CAP_ONE_REG)
>>> +:Architectures: arm64, loongarch, mips, riscv, x86 (if KVM_CAP_ONE_REG)
>>> :Type: vcpu ioctl
>>> :Parameters: struct kvm_reg_list (in/out)
>>> :Returns: 0 on success; -1 on error
>>> diff --git a/arch/loongarch/kvm/vcpu.c b/arch/loongarch/kvm/vcpu.c
>>> index 656b954c1134..bd855ee20ee2 100644
>>> --- a/arch/loongarch/kvm/vcpu.c
>>> +++ b/arch/loongarch/kvm/vcpu.c
>>> @@ -3,6 +3,7 @@
>>> * Copyright (C) 2020-2023 Loongson Technology Corporation Limited
>>> */
>>> +#include "asm/kvm_host.h"
>> Had better put after #include <asm/fpu.h>, and keep alphabetical order.
>>> #include <linux/kvm_host.h>
>>> #include <asm/fpu.h>
>>> #include <asm/lbt.h>
>>> @@ -14,6 +15,8 @@
>>> #define CREATE_TRACE_POINTS
>>> #include "trace.h"
>>> +#define NUM_LBT_REGS 6
>>> +
>>> const struct _kvm_stats_desc kvm_vcpu_stats_desc[] = {
>>> KVM_GENERIC_VCPU_STATS(),
>>> STATS_DESC_COUNTER(VCPU, int_exits),
>>> @@ -1186,6 +1189,72 @@ static int kvm_loongarch_vcpu_set_attr(struct
>>> kvm_vcpu *vcpu,
>>> return ret;
>>> }
>>> +static int kvm_loongarch_walk_csrs(struct kvm_vcpu *vcpu, u64
>>> __user *uindices)
>>> +{
>>> + unsigned int i, count;
>>> +
>>> + for (i = 0, count = 0; i < CSR_MAX_NUMS; i++) {
>>> + if (!(get_gcsr_flag(i) & (SW_GCSR | HW_GCSR)))
>>> + continue;
>>> + if (i >= LOONGARCH_CSR_PERFCTRL0 && i <=
>>> LOONGARCH_CSR_PERFCNTR3) {
>>> + /* Skip PMU CSRs if not supported by the guest */
>>> + if (!kvm_guest_has_pmu(&vcpu->arch))
>>> + continue;
>>> + }
>> This is workable, gcsr_flag can be changed with structure, and new
>> element "int required_features" added. However it does not matter, it
>> can be done in later.
>>
>> CSR registers relative with msgint feature can be done with this
>> method also.
>>
>> How about debug/watch CSR registers? can it be skipped also? the same
>> MERR CSR registers with LOONGARCH_CSR_MERR*.
>>
>> The CSR register list difference can be checked with
>> kvm_loongarch_get_csr() in qemu VMM, with website
>> https://gitlab.com/qemu-project/qemu/-/blob/master/target/loongarch/kvm/kvm.c?ref_type=heads
>>
> Do you think for KVM guests, the only CSRs need to be saved are listed
> at
> https://gitlab.com/qemu-project/qemu/-/blob/master/target/loongarch/kvm/kvm.c?ref_type=heads#L375-544?
yes, I think so.
>
> Then the concern about embedding a big list will become valid again.
There is no obvious error with bigger list from the present, however
from performance or unexpected compatible issue, the smaller is better.
With new feature or new hardware, then the register list will become bigger.
Regards
Bibo Mao
> What do you think?
>
>> Regards
>> Bibo Mao
>
> Thanks,
>
> Zixing
>
>>> + const u64 reg = KVM_IOC_CSRID(i);
>>> + if (uindices && put_user(reg, uindices++))
>>> + return -EFAULT;
>>> + count++;
>>> + }
>>> +
>>> + return count;
>>> +}
>>> +
>>> +static unsigned long kvm_loongarch_num_regs(struct kvm_vcpu *vcpu)
>>> +{
>>> + /* +1 for the KVM_REG_LOONGARCH_COUNTER register */
>>> + unsigned long res =
>>> + kvm_loongarch_walk_csrs(vcpu, NULL) + KVM_MAX_CPUCFG_REGS + 1;
>>> +
>>> + if (kvm_guest_has_lbt(&vcpu->arch))
>>> + res += NUM_LBT_REGS;
>>> +
>>> + return res;
>>> +}
>>> +
>>> +static int kvm_loongarch_copy_reg_indices(struct kvm_vcpu *vcpu,
>>> + u64 __user *uindices)
>>> +{
>>> + u64 reg;
>>> + unsigned int i;
>>> +
>>> + i = kvm_loongarch_walk_csrs(vcpu, uindices);
>>> + if (i < 0)
>>> + return i;
>>> + uindices += i;
>>> +
>>> + for (i = 0; i < KVM_MAX_CPUCFG_REGS; i++) {
>>> + reg = KVM_IOC_CPUCFG(i);
>>> + if (put_user(reg, uindices++))
>>> + return -EFAULT;
>>> + }
>>> +
>>> + reg = KVM_REG_LOONGARCH_COUNTER;
>>> + if (put_user(reg, uindices++))
>>> + return -EFAULT;
>>> +
>>> + if (!kvm_guest_has_lbt(&vcpu->arch))
>>> + return 0;
>>> +
>>> + for (i = 1; i <= NUM_LBT_REGS; i++) {
>>> + reg = (KVM_REG_LOONGARCH_LBT | KVM_REG_SIZE_U64 | i);
>>> + if (put_user(reg, uindices++))
>>> + return -EFAULT;
>>> + }
>>> +
>>> + return 0;
>>> +}
>>> +
>>> long kvm_arch_vcpu_ioctl(struct file *filp,
>>> unsigned int ioctl, unsigned long arg)
>>> {
>>> @@ -1251,6 +1320,24 @@ long kvm_arch_vcpu_ioctl(struct file *filp,
>>> r = kvm_loongarch_vcpu_set_attr(vcpu, &attr);
>>> break;
>>> }
>>> + case KVM_GET_REG_LIST: {
>>> + struct kvm_reg_list __user *user_list = argp;
>>> + struct kvm_reg_list reg_list;
>>> + unsigned n;
>>> +
>>> + r = -EFAULT;
>>> + if (copy_from_user(®_list, user_list, sizeof(reg_list)))
>>> + break;
>>> + n = reg_list.n;
>>> + reg_list.n = kvm_loongarch_num_regs(vcpu);
>>> + if (copy_to_user(user_list, ®_list, sizeof(reg_list)))
>>> + break;
>>> + r = -E2BIG;
>>> + if (n < reg_list.n)
>>> + break;
>>> + r = kvm_loongarch_copy_reg_indices(vcpu, user_list->reg);
>>> + break;
>>> + }
>>> default:
>>> r = -ENOIOCTLCMD;
>>> break;
>>>
>>
Hi Zixing,
kernel test robot noticed the following build errors:
[auto build test ERROR on kvm/queue]
[also build test ERROR on kvm/next linus/master v6.19-rc8]
[cannot apply to kvm/linux-next next-20260204]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Zixing-Liu/KVM-Add-KVM_GET_REG_LIST-ioctl-for-LoongArch/20260204-193844
base: https://git.kernel.org/pub/scm/virt/kvm/kvm.git queue
patch link: https://lore.kernel.org/r/20260204113601.912413-1-liushuyu%40aosc.io
patch subject: [PATCH v4] KVM: Add KVM_GET_REG_LIST ioctl for LoongArch
config: loongarch-randconfig-002-20260204 (https://download.01.org/0day-ci/archive/20260205/202602050419.lwzj2i73-lkp@intel.com/config)
compiler: loongarch64-linux-gcc (GCC) 15.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260205/202602050419.lwzj2i73-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202602050419.lwzj2i73-lkp@intel.com/
All error/warnings (new ones prefixed by >>):
In file included from arch/loongarch/include/asm/kvm_mmu.h:9,
from arch/loongarch/include/asm/kvm_host.h:21,
from arch/loongarch/kvm/vcpu.c:6:
>> include/linux/kvm_host.h:389:30: error: field 'arch' has incomplete type
389 | struct kvm_vcpu_arch arch;
| ^~~~
>> include/linux/kvm_host.h:390:30: error: field 'stat' has incomplete type
390 | struct kvm_vcpu_stat stat;
| ^~~~
include/linux/kvm_host.h:601:37: error: field 'arch' has incomplete type
601 | struct kvm_arch_memory_slot arch;
| ^~~~
include/linux/kvm_host.h:831:28: error: field 'stat' has incomplete type
831 | struct kvm_vm_stat stat;
| ^~~~
include/linux/kvm_host.h:832:25: error: field 'arch' has incomplete type
832 | struct kvm_arch arch;
| ^~~~
include/linux/kvm_host.h: In function 'kvm_get_vcpu_by_id':
>> include/linux/kvm_host.h:1023:18: error: 'KVM_MAX_VCPUS' undeclared (first use in this function); did you mean 'KVM_MAX_VCPU_IDS'?
1023 | if (id < KVM_MAX_VCPUS)
| ^~~~~~~~~~~~~
| KVM_MAX_VCPU_IDS
include/linux/kvm_host.h:1023:18: note: each undeclared identifier is reported only once for each function it appears in
arch/loongarch/include/asm/kvm_host.h: At top level:
>> arch/loongarch/include/asm/kvm_host.h:46:9: warning: 'KVM_DIRTY_LOG_MANUAL_CAPS' redefined
46 | #define KVM_DIRTY_LOG_MANUAL_CAPS \
| ^~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/kvm_host.h:643:9: note: this is the location of the previous definition
643 | #define KVM_DIRTY_LOG_MANUAL_CAPS KVM_DIRTY_LOG_MANUAL_PROTECT_ENABLE
| ^~~~~~~~~~~~~~~~~~~~~~~~~
>> arch/loongarch/include/asm/kvm_host.h:337:20: error: static declaration of 'kvm_arch_memslots_updated' follows non-static declaration
337 | static inline void kvm_arch_memslots_updated(struct kvm *kvm, u64 gen) {}
| ^~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/kvm_host.h:1237:6: note: previous declaration of 'kvm_arch_memslots_updated' with type 'void(struct kvm *, u64)' {aka 'void(struct kvm *, long long unsigned int)'}
1237 | void kvm_arch_memslots_updated(struct kvm *kvm, u64 gen);
| ^~~~~~~~~~~~~~~~~~~~~~~~~
>> arch/loongarch/include/asm/kvm_host.h:338:20: error: static declaration of 'kvm_arch_vcpu_blocking' follows non-static declaration
338 | static inline void kvm_arch_vcpu_blocking(struct kvm_vcpu *vcpu) {}
| ^~~~~~~~~~~~~~~~~~~~~~
include/linux/kvm_host.h:1522:6: note: previous declaration of 'kvm_arch_vcpu_blocking' with type 'void(struct kvm_vcpu *)'
1522 | void kvm_arch_vcpu_blocking(struct kvm_vcpu *vcpu);
| ^~~~~~~~~~~~~~~~~~~~~~
>> arch/loongarch/include/asm/kvm_host.h:339:20: error: static declaration of 'kvm_arch_vcpu_unblocking' follows non-static declaration
339 | static inline void kvm_arch_vcpu_unblocking(struct kvm_vcpu *vcpu) {}
| ^~~~~~~~~~~~~~~~~~~~~~~~
include/linux/kvm_host.h:1523:6: note: previous declaration of 'kvm_arch_vcpu_unblocking' with type 'void(struct kvm_vcpu *)'
1523 | void kvm_arch_vcpu_unblocking(struct kvm_vcpu *vcpu);
| ^~~~~~~~~~~~~~~~~~~~~~~~
>> arch/loongarch/include/asm/kvm_host.h:341:20: error: static declaration of 'kvm_arch_free_memslot' follows non-static declaration
341 | static inline void kvm_arch_free_memslot(struct kvm *kvm, struct kvm_memory_slot *slot) {}
| ^~~~~~~~~~~~~~~~~~~~~
include/linux/kvm_host.h:1236:6: note: previous declaration of 'kvm_arch_free_memslot' with type 'void(struct kvm *, struct kvm_memory_slot *)'
1236 | void kvm_arch_free_memslot(struct kvm *kvm, struct kvm_memory_slot *slot);
| ^~~~~~~~~~~~~~~~~~~~~
In file included from arch/loongarch/include/asm/kvm_csr.h:12,
from arch/loongarch/kvm/trace.h:10,
from arch/loongarch/kvm/vcpu.c:16:
arch/loongarch/include/asm/kvm_vcpu.h: In function 'kvm_read_reg':
>> arch/loongarch/include/asm/kvm_vcpu.h:120:69: warning: parameter 'num' set but not used [-Wunused-but-set-parameter]
120 | static inline unsigned long kvm_read_reg(struct kvm_vcpu *vcpu, int num)
| ~~~~^~~
arch/loongarch/include/asm/kvm_vcpu.h: In function 'kvm_write_reg':
arch/loongarch/include/asm/kvm_vcpu.h:125:61: warning: parameter 'num' set but not used [-Wunused-but-set-parameter]
125 | static inline void kvm_write_reg(struct kvm_vcpu *vcpu, int num, unsigned long val)
| ~~~~^~~
In file included from include/linux/string.h:386,
from include/linux/bitmap.h:13,
from include/linux/cpumask.h:11,
from arch/loongarch/include/asm/kvm_host.h:9:
arch/loongarch/kvm/vcpu.c: In function 'kvm_set_one_reg':
include/linux/fortify-string.h:503:65: warning: left-hand operand of comma expression has no effect [-Wunused-value]
503 | fortify_memset_chk(__fortify_size, p_size, p_size_field), \
| ^
include/linux/fortify-string.h:512:25: note: in expansion of macro '__fortify_memset_chk'
512 | #define memset(p, c, s) __fortify_memset_chk(p, c, s, \
| ^~~~~~~~~~~~~~~~~~~~
arch/loongarch/kvm/vcpu.c:920:25: note: in expansion of macro 'memset'
920 | memset(&vcpu->arch.irq_pending, 0, sizeof(vcpu->arch.irq_pending));
| ^~~~~~
include/linux/fortify-string.h:503:65: warning: left-hand operand of comma expression has no effect [-Wunused-value]
503 | fortify_memset_chk(__fortify_size, p_size, p_size_field), \
| ^
include/linux/fortify-string.h:512:25: note: in expansion of macro '__fortify_memset_chk'
512 | #define memset(p, c, s) __fortify_memset_chk(p, c, s, \
| ^~~~~~~~~~~~~~~~~~~~
arch/loongarch/kvm/vcpu.c:921:25: note: in expansion of macro 'memset'
921 | memset(&vcpu->arch.irq_clear, 0, sizeof(vcpu->arch.irq_clear));
| ^~~~~~
In file included from include/asm-generic/barrier.h:16,
from arch/loongarch/include/asm/barrier.h:137,
from arch/loongarch/include/asm/atomic.h:11,
from include/linux/atomic.h:7,
from include/linux/cpumask.h:10:
arch/loongarch/kvm/vcpu.c: In function 'kvm_arch_vcpu_ioctl_get_regs':
>> include/linux/compiler.h:201:82: error: expression in static assertion is not an integer
201 | #define __BUILD_BUG_ON_ZERO_MSG(e, msg, ...) ((int)sizeof(struct {_Static_assert(!(e), msg);}))
| ^
include/linux/compiler.h:206:33: note: in expansion of macro '__BUILD_BUG_ON_ZERO_MSG'
206 | #define __must_be_array(a) __BUILD_BUG_ON_ZERO_MSG(!__is_array(a), \
| ^~~~~~~~~~~~~~~~~~~~~~~
include/linux/array_size.h:11:59: note: in expansion of macro '__must_be_array'
11 | #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr))
| ^~~~~~~~~~~~~~~
arch/loongarch/kvm/vcpu.c:975:25: note: in expansion of macro 'ARRAY_SIZE'
975 | for (i = 0; i < ARRAY_SIZE(vcpu->arch.gprs); i++)
| ^~~~~~~~~~
arch/loongarch/kvm/vcpu.c: In function 'kvm_arch_vcpu_ioctl_set_regs':
>> include/linux/compiler.h:201:82: error: expression in static assertion is not an integer
201 | #define __BUILD_BUG_ON_ZERO_MSG(e, msg, ...) ((int)sizeof(struct {_Static_assert(!(e), msg);}))
| ^
include/linux/compiler.h:206:33: note: in expansion of macro '__BUILD_BUG_ON_ZERO_MSG'
206 | #define __must_be_array(a) __BUILD_BUG_ON_ZERO_MSG(!__is_array(a), \
| ^~~~~~~~~~~~~~~~~~~~~~~
include/linux/array_size.h:11:59: note: in expansion of macro '__must_be_array'
11 | #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr))
| ^~~~~~~~~~~~~~~
arch/loongarch/kvm/vcpu.c:987:25: note: in expansion of macro 'ARRAY_SIZE'
987 | for (i = 1; i < ARRAY_SIZE(vcpu->arch.gprs); i++)
| ^~~~~~~~~~
--
In file included from arch/loongarch/include/asm/kvm_mmu.h:9,
from arch/loongarch/include/asm/kvm_host.h:21,
from vcpu.c:6:
>> include/linux/kvm_host.h:389:30: error: field 'arch' has incomplete type
389 | struct kvm_vcpu_arch arch;
| ^~~~
>> include/linux/kvm_host.h:390:30: error: field 'stat' has incomplete type
390 | struct kvm_vcpu_stat stat;
| ^~~~
include/linux/kvm_host.h:601:37: error: field 'arch' has incomplete type
601 | struct kvm_arch_memory_slot arch;
| ^~~~
include/linux/kvm_host.h:831:28: error: field 'stat' has incomplete type
831 | struct kvm_vm_stat stat;
| ^~~~
include/linux/kvm_host.h:832:25: error: field 'arch' has incomplete type
832 | struct kvm_arch arch;
| ^~~~
include/linux/kvm_host.h: In function 'kvm_get_vcpu_by_id':
>> include/linux/kvm_host.h:1023:18: error: 'KVM_MAX_VCPUS' undeclared (first use in this function); did you mean 'KVM_MAX_VCPU_IDS'?
1023 | if (id < KVM_MAX_VCPUS)
| ^~~~~~~~~~~~~
| KVM_MAX_VCPU_IDS
include/linux/kvm_host.h:1023:18: note: each undeclared identifier is reported only once for each function it appears in
arch/loongarch/include/asm/kvm_host.h: At top level:
>> arch/loongarch/include/asm/kvm_host.h:46:9: warning: 'KVM_DIRTY_LOG_MANUAL_CAPS' redefined
46 | #define KVM_DIRTY_LOG_MANUAL_CAPS \
| ^~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/kvm_host.h:643:9: note: this is the location of the previous definition
643 | #define KVM_DIRTY_LOG_MANUAL_CAPS KVM_DIRTY_LOG_MANUAL_PROTECT_ENABLE
| ^~~~~~~~~~~~~~~~~~~~~~~~~
>> arch/loongarch/include/asm/kvm_host.h:337:20: error: static declaration of 'kvm_arch_memslots_updated' follows non-static declaration
337 | static inline void kvm_arch_memslots_updated(struct kvm *kvm, u64 gen) {}
| ^~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/kvm_host.h:1237:6: note: previous declaration of 'kvm_arch_memslots_updated' with type 'void(struct kvm *, u64)' {aka 'void(struct kvm *, long long unsigned int)'}
1237 | void kvm_arch_memslots_updated(struct kvm *kvm, u64 gen);
| ^~~~~~~~~~~~~~~~~~~~~~~~~
>> arch/loongarch/include/asm/kvm_host.h:338:20: error: static declaration of 'kvm_arch_vcpu_blocking' follows non-static declaration
338 | static inline void kvm_arch_vcpu_blocking(struct kvm_vcpu *vcpu) {}
| ^~~~~~~~~~~~~~~~~~~~~~
include/linux/kvm_host.h:1522:6: note: previous declaration of 'kvm_arch_vcpu_blocking' with type 'void(struct kvm_vcpu *)'
1522 | void kvm_arch_vcpu_blocking(struct kvm_vcpu *vcpu);
| ^~~~~~~~~~~~~~~~~~~~~~
>> arch/loongarch/include/asm/kvm_host.h:339:20: error: static declaration of 'kvm_arch_vcpu_unblocking' follows non-static declaration
339 | static inline void kvm_arch_vcpu_unblocking(struct kvm_vcpu *vcpu) {}
| ^~~~~~~~~~~~~~~~~~~~~~~~
include/linux/kvm_host.h:1523:6: note: previous declaration of 'kvm_arch_vcpu_unblocking' with type 'void(struct kvm_vcpu *)'
1523 | void kvm_arch_vcpu_unblocking(struct kvm_vcpu *vcpu);
| ^~~~~~~~~~~~~~~~~~~~~~~~
>> arch/loongarch/include/asm/kvm_host.h:341:20: error: static declaration of 'kvm_arch_free_memslot' follows non-static declaration
341 | static inline void kvm_arch_free_memslot(struct kvm *kvm, struct kvm_memory_slot *slot) {}
| ^~~~~~~~~~~~~~~~~~~~~
include/linux/kvm_host.h:1236:6: note: previous declaration of 'kvm_arch_free_memslot' with type 'void(struct kvm *, struct kvm_memory_slot *)'
1236 | void kvm_arch_free_memslot(struct kvm *kvm, struct kvm_memory_slot *slot);
| ^~~~~~~~~~~~~~~~~~~~~
In file included from arch/loongarch/include/asm/kvm_csr.h:12,
from trace.h:10,
from vcpu.c:16:
arch/loongarch/include/asm/kvm_vcpu.h: In function 'kvm_read_reg':
>> arch/loongarch/include/asm/kvm_vcpu.h:120:69: warning: parameter 'num' set but not used [-Wunused-but-set-parameter]
120 | static inline unsigned long kvm_read_reg(struct kvm_vcpu *vcpu, int num)
| ~~~~^~~
arch/loongarch/include/asm/kvm_vcpu.h: In function 'kvm_write_reg':
arch/loongarch/include/asm/kvm_vcpu.h:125:61: warning: parameter 'num' set but not used [-Wunused-but-set-parameter]
125 | static inline void kvm_write_reg(struct kvm_vcpu *vcpu, int num, unsigned long val)
| ~~~~^~~
In file included from include/linux/string.h:386,
from include/linux/bitmap.h:13,
from include/linux/cpumask.h:11,
from arch/loongarch/include/asm/kvm_host.h:9:
vcpu.c: In function 'kvm_set_one_reg':
include/linux/fortify-string.h:503:65: warning: left-hand operand of comma expression has no effect [-Wunused-value]
503 | fortify_memset_chk(__fortify_size, p_size, p_size_field), \
| ^
include/linux/fortify-string.h:512:25: note: in expansion of macro '__fortify_memset_chk'
512 | #define memset(p, c, s) __fortify_memset_chk(p, c, s, \
| ^~~~~~~~~~~~~~~~~~~~
vcpu.c:920:25: note: in expansion of macro 'memset'
920 | memset(&vcpu->arch.irq_pending, 0, sizeof(vcpu->arch.irq_pending));
| ^~~~~~
include/linux/fortify-string.h:503:65: warning: left-hand operand of comma expression has no effect [-Wunused-value]
503 | fortify_memset_chk(__fortify_size, p_size, p_size_field), \
| ^
include/linux/fortify-string.h:512:25: note: in expansion of macro '__fortify_memset_chk'
512 | #define memset(p, c, s) __fortify_memset_chk(p, c, s, \
| ^~~~~~~~~~~~~~~~~~~~
vcpu.c:921:25: note: in expansion of macro 'memset'
921 | memset(&vcpu->arch.irq_clear, 0, sizeof(vcpu->arch.irq_clear));
| ^~~~~~
In file included from include/asm-generic/barrier.h:16,
from arch/loongarch/include/asm/barrier.h:137,
from arch/loongarch/include/asm/atomic.h:11,
from include/linux/atomic.h:7,
from include/linux/cpumask.h:10:
vcpu.c: In function 'kvm_arch_vcpu_ioctl_get_regs':
>> include/linux/compiler.h:201:82: error: expression in static assertion is not an integer
201 | #define __BUILD_BUG_ON_ZERO_MSG(e, msg, ...) ((int)sizeof(struct {_Static_assert(!(e), msg);}))
| ^
include/linux/compiler.h:206:33: note: in expansion of macro '__BUILD_BUG_ON_ZERO_MSG'
206 | #define __must_be_array(a) __BUILD_BUG_ON_ZERO_MSG(!__is_array(a), \
| ^~~~~~~~~~~~~~~~~~~~~~~
include/linux/array_size.h:11:59: note: in expansion of macro '__must_be_array'
11 | #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr))
| ^~~~~~~~~~~~~~~
vcpu.c:975:25: note: in expansion of macro 'ARRAY_SIZE'
975 | for (i = 0; i < ARRAY_SIZE(vcpu->arch.gprs); i++)
| ^~~~~~~~~~
vcpu.c: In function 'kvm_arch_vcpu_ioctl_set_regs':
>> include/linux/compiler.h:201:82: error: expression in static assertion is not an integer
201 | #define __BUILD_BUG_ON_ZERO_MSG(e, msg, ...) ((int)sizeof(struct {_Static_assert(!(e), msg);}))
| ^
include/linux/compiler.h:206:33: note: in expansion of macro '__BUILD_BUG_ON_ZERO_MSG'
206 | #define __must_be_array(a) __BUILD_BUG_ON_ZERO_MSG(!__is_array(a), \
| ^~~~~~~~~~~~~~~~~~~~~~~
include/linux/array_size.h:11:59: note: in expansion of macro '__must_be_array'
11 | #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr))
| ^~~~~~~~~~~~~~~
vcpu.c:987:25: note: in expansion of macro 'ARRAY_SIZE'
987 | for (i = 1; i < ARRAY_SIZE(vcpu->arch.gprs); i++)
| ^~~~~~~~~~
vim +/arch +389 include/linux/kvm_host.h
af585b921e5d1e9 include/linux/kvm_host.h Gleb Natapov 2010-10-14 372
4c088493c8d07e4 include/linux/kvm_host.h Raghavendra K T 2012-07-18 373 #ifdef CONFIG_HAVE_KVM_CPU_RELAX_INTERCEPT
4c088493c8d07e4 include/linux/kvm_host.h Raghavendra K T 2012-07-18 374 /*
4c088493c8d07e4 include/linux/kvm_host.h Raghavendra K T 2012-07-18 375 * Cpu relax intercept or pause loop exit optimization
4c088493c8d07e4 include/linux/kvm_host.h Raghavendra K T 2012-07-18 376 * in_spin_loop: set when a vcpu does a pause loop exit
4c088493c8d07e4 include/linux/kvm_host.h Raghavendra K T 2012-07-18 377 * or cpu relax intercepted.
4c088493c8d07e4 include/linux/kvm_host.h Raghavendra K T 2012-07-18 378 * dy_eligible: indicates whether vcpu is eligible for directed yield.
4c088493c8d07e4 include/linux/kvm_host.h Raghavendra K T 2012-07-18 379 */
4c088493c8d07e4 include/linux/kvm_host.h Raghavendra K T 2012-07-18 380 struct {
4c088493c8d07e4 include/linux/kvm_host.h Raghavendra K T 2012-07-18 381 bool in_spin_loop;
4c088493c8d07e4 include/linux/kvm_host.h Raghavendra K T 2012-07-18 382 bool dy_eligible;
4c088493c8d07e4 include/linux/kvm_host.h Raghavendra K T 2012-07-18 383 } spin_loop;
4c088493c8d07e4 include/linux/kvm_host.h Raghavendra K T 2012-07-18 384 #endif
a6816314af5749c include/linux/kvm_host.h David Matlack 2024-05-03 385 bool wants_to_run;
3a08a8f9f0936e1 include/linux/kvm_host.h Raghavendra K T 2013-03-04 386 bool preempted;
d73eb57b80b98ae include/linux/kvm_host.h Wanpeng Li 2019-07-18 387 bool ready;
d1ae567fb8b5594 include/linux/kvm_host.h Sean Christopherson 2024-05-21 388 bool scheduled_out;
d657a98e3c20537 drivers/kvm/kvm.h Zhang Xiantao 2007-12-14 @389 struct kvm_vcpu_arch arch;
ce55c049459cff0 include/linux/kvm_host.h Jing Zhang 2021-06-18 @390 struct kvm_vcpu_stat stat;
ce55c049459cff0 include/linux/kvm_host.h Jing Zhang 2021-06-18 391 char stats_id[KVM_STATS_NAME_SIZE];
fb04a1eddb1a65b include/linux/kvm_host.h Peter Xu 2020-09-30 392 struct kvm_dirty_ring dirty_ring;
fe22ed827c5b60b include/linux/kvm_host.h David Matlack 2021-08-04 393
fe22ed827c5b60b include/linux/kvm_host.h David Matlack 2021-08-04 394 /*
a54d806688fe1e4 include/linux/kvm_host.h Maciej S. Szmigiero 2021-12-06 395 * The most recently used memslot by this vCPU and the slots generation
a54d806688fe1e4 include/linux/kvm_host.h Maciej S. Szmigiero 2021-12-06 396 * for which it is valid.
a54d806688fe1e4 include/linux/kvm_host.h Maciej S. Szmigiero 2021-12-06 397 * No wraparound protection is needed since generations won't overflow in
a54d806688fe1e4 include/linux/kvm_host.h Maciej S. Szmigiero 2021-12-06 398 * thousands of years, even assuming 1M memslot operations per second.
fe22ed827c5b60b include/linux/kvm_host.h David Matlack 2021-08-04 399 */
a54d806688fe1e4 include/linux/kvm_host.h Maciej S. Szmigiero 2021-12-06 400 struct kvm_memory_slot *last_used_slot;
a54d806688fe1e4 include/linux/kvm_host.h Maciej S. Szmigiero 2021-12-06 401 u64 last_used_slot_gen;
d657a98e3c20537 drivers/kvm/kvm.h Zhang Xiantao 2007-12-14 402 };
d657a98e3c20537 drivers/kvm/kvm.h Zhang Xiantao 2007-12-14 403
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
Hi Zixing,
kernel test robot noticed the following build errors:
[auto build test ERROR on kvm/queue]
[also build test ERROR on kvm/next linus/master v6.19-rc8]
[cannot apply to kvm/linux-next next-20260204]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Zixing-Liu/KVM-Add-KVM_GET_REG_LIST-ioctl-for-LoongArch/20260204-193844
base: https://git.kernel.org/pub/scm/virt/kvm/kvm.git queue
patch link: https://lore.kernel.org/r/20260204113601.912413-1-liushuyu%40aosc.io
patch subject: [PATCH v4] KVM: Add KVM_GET_REG_LIST ioctl for LoongArch
config: loongarch-defconfig (https://download.01.org/0day-ci/archive/20260205/202602050229.BAdKUB3a-lkp@intel.com/config)
compiler: clang version 19.1.7 (https://github.com/llvm/llvm-project cd708029e0b2869e80abe31ddb175f7c35361f90)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260205/202602050229.BAdKUB3a-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202602050229.BAdKUB3a-lkp@intel.com/
All error/warnings (new ones prefixed by >>):
In file included from arch/loongarch/kvm/vcpu.c:6:
In file included from arch/loongarch/include/asm/kvm_host.h:21:
In file included from arch/loongarch/include/asm/kvm_mmu.h:9:
>> include/linux/kvm_host.h:389:23: error: field has incomplete type 'struct kvm_vcpu_arch'
389 | struct kvm_vcpu_arch arch;
| ^
include/linux/kvm_host.h:389:9: note: forward declaration of 'struct kvm_vcpu_arch'
389 | struct kvm_vcpu_arch arch;
| ^
>> include/linux/kvm_host.h:390:23: error: field has incomplete type 'struct kvm_vcpu_stat'
390 | struct kvm_vcpu_stat stat;
| ^
include/linux/kvm_host.h:390:9: note: forward declaration of 'struct kvm_vcpu_stat'
390 | struct kvm_vcpu_stat stat;
| ^
>> include/linux/kvm_host.h:601:30: error: field has incomplete type 'struct kvm_arch_memory_slot'
601 | struct kvm_arch_memory_slot arch;
| ^
include/linux/kvm_host.h:601:9: note: forward declaration of 'struct kvm_arch_memory_slot'
601 | struct kvm_arch_memory_slot arch;
| ^
>> include/linux/kvm_host.h:831:21: error: field has incomplete type 'struct kvm_vm_stat'
831 | struct kvm_vm_stat stat;
| ^
include/linux/kvm_host.h:831:9: note: forward declaration of 'struct kvm_vm_stat'
831 | struct kvm_vm_stat stat;
| ^
>> include/linux/kvm_host.h:832:18: error: field has incomplete type 'struct kvm_arch'
832 | struct kvm_arch arch;
| ^
include/linux/kvm_host.h:832:9: note: forward declaration of 'struct kvm_arch'
832 | struct kvm_arch arch;
| ^
>> include/linux/kvm_host.h:1023:11: error: use of undeclared identifier 'KVM_MAX_VCPUS'
1023 | if (id < KVM_MAX_VCPUS)
| ^
In file included from arch/loongarch/kvm/vcpu.c:6:
>> arch/loongarch/include/asm/kvm_host.h:46:9: warning: 'KVM_DIRTY_LOG_MANUAL_CAPS' macro redefined [-Wmacro-redefined]
46 | #define KVM_DIRTY_LOG_MANUAL_CAPS \
| ^
include/linux/kvm_host.h:643:9: note: previous definition is here
643 | #define KVM_DIRTY_LOG_MANUAL_CAPS KVM_DIRTY_LOG_MANUAL_PROTECT_ENABLE
| ^
>> arch/loongarch/kvm/vcpu.c:48:10: error: assigning to 'struct kvm_context *' from incompatible type 'void'
48 | context = this_cpu_ptr(vcpu->kvm->arch.vmcs);
| ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
arch/loongarch/kvm/vcpu.c:63:10: error: assigning to 'struct kvm_context *' from incompatible type 'void'
63 | context = this_cpu_ptr(vcpu->kvm->arch.vmcs);
| ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
arch/loongarch/kvm/vcpu.c:1669:11: error: assigning to 'struct kvm_context *' from incompatible type 'void'
1669 | context = per_cpu_ptr(vcpu->kvm->arch.vmcs, cpu);
| ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
arch/loongarch/kvm/vcpu.c:1691:10: error: assigning to 'struct kvm_context *' from incompatible type 'void'
1691 | context = per_cpu_ptr(vcpu->kvm->arch.vmcs, cpu);
| ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 warning and 10 errors generated.
vim +389 include/linux/kvm_host.h
af585b921e5d1e include/linux/kvm_host.h Gleb Natapov 2010-10-14 372
4c088493c8d07e include/linux/kvm_host.h Raghavendra K T 2012-07-18 373 #ifdef CONFIG_HAVE_KVM_CPU_RELAX_INTERCEPT
4c088493c8d07e include/linux/kvm_host.h Raghavendra K T 2012-07-18 374 /*
4c088493c8d07e include/linux/kvm_host.h Raghavendra K T 2012-07-18 375 * Cpu relax intercept or pause loop exit optimization
4c088493c8d07e include/linux/kvm_host.h Raghavendra K T 2012-07-18 376 * in_spin_loop: set when a vcpu does a pause loop exit
4c088493c8d07e include/linux/kvm_host.h Raghavendra K T 2012-07-18 377 * or cpu relax intercepted.
4c088493c8d07e include/linux/kvm_host.h Raghavendra K T 2012-07-18 378 * dy_eligible: indicates whether vcpu is eligible for directed yield.
4c088493c8d07e include/linux/kvm_host.h Raghavendra K T 2012-07-18 379 */
4c088493c8d07e include/linux/kvm_host.h Raghavendra K T 2012-07-18 380 struct {
4c088493c8d07e include/linux/kvm_host.h Raghavendra K T 2012-07-18 381 bool in_spin_loop;
4c088493c8d07e include/linux/kvm_host.h Raghavendra K T 2012-07-18 382 bool dy_eligible;
4c088493c8d07e include/linux/kvm_host.h Raghavendra K T 2012-07-18 383 } spin_loop;
4c088493c8d07e include/linux/kvm_host.h Raghavendra K T 2012-07-18 384 #endif
a6816314af5749 include/linux/kvm_host.h David Matlack 2024-05-03 385 bool wants_to_run;
3a08a8f9f0936e include/linux/kvm_host.h Raghavendra K T 2013-03-04 386 bool preempted;
d73eb57b80b98a include/linux/kvm_host.h Wanpeng Li 2019-07-18 387 bool ready;
d1ae567fb8b559 include/linux/kvm_host.h Sean Christopherson 2024-05-21 388 bool scheduled_out;
d657a98e3c2053 drivers/kvm/kvm.h Zhang Xiantao 2007-12-14 @389 struct kvm_vcpu_arch arch;
ce55c049459cff include/linux/kvm_host.h Jing Zhang 2021-06-18 @390 struct kvm_vcpu_stat stat;
ce55c049459cff include/linux/kvm_host.h Jing Zhang 2021-06-18 391 char stats_id[KVM_STATS_NAME_SIZE];
fb04a1eddb1a65 include/linux/kvm_host.h Peter Xu 2020-09-30 392 struct kvm_dirty_ring dirty_ring;
fe22ed827c5b60 include/linux/kvm_host.h David Matlack 2021-08-04 393
fe22ed827c5b60 include/linux/kvm_host.h David Matlack 2021-08-04 394 /*
a54d806688fe1e include/linux/kvm_host.h Maciej S. Szmigiero 2021-12-06 395 * The most recently used memslot by this vCPU and the slots generation
a54d806688fe1e include/linux/kvm_host.h Maciej S. Szmigiero 2021-12-06 396 * for which it is valid.
a54d806688fe1e include/linux/kvm_host.h Maciej S. Szmigiero 2021-12-06 397 * No wraparound protection is needed since generations won't overflow in
a54d806688fe1e include/linux/kvm_host.h Maciej S. Szmigiero 2021-12-06 398 * thousands of years, even assuming 1M memslot operations per second.
fe22ed827c5b60 include/linux/kvm_host.h David Matlack 2021-08-04 399 */
a54d806688fe1e include/linux/kvm_host.h Maciej S. Szmigiero 2021-12-06 400 struct kvm_memory_slot *last_used_slot;
a54d806688fe1e include/linux/kvm_host.h Maciej S. Szmigiero 2021-12-06 401 u64 last_used_slot_gen;
d657a98e3c2053 drivers/kvm/kvm.h Zhang Xiantao 2007-12-14 402 };
d657a98e3c2053 drivers/kvm/kvm.h Zhang Xiantao 2007-12-14 403
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
© 2016 - 2026 Red Hat, Inc.