All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Auger <eric.auger@redhat.com>
To: Khushit Shah <khushit.shah@nutanix.com>
Cc: "qemu-devel@nongnu.org" <qemu-devel@nongnu.org>,
	"qemu-arm@nongnu.org" <qemu-arm@nongnu.org>,
	"kvmarm@lists.linux.dev" <kvmarm@lists.linux.dev>,
	"cohuck@redhat.com" <cohuck@redhat.com>,
	"peter.maydell@linaro.org" <peter.maydell@linaro.org>,
	"richard.henderson@linaro.org" <richard.henderson@linaro.org>,
	"maz@kernel.org" <maz@kernel.org>,
	"oliver.upton@linux.dev" <oliver.upton@linux.dev>,
	"berrange@redhat.com" <berrange@redhat.com>,
	"abologna@redhat.com" <abologna@redhat.com>,
	"jdenemar@redhat.com" <jdenemar@redhat.com>,
	"gshan@redhat.com" <gshan@redhat.com>,
	"skolothumtho@nvidia.com" <skolothumtho@nvidia.com>,
	"sebott@redhat.com" <sebott@redhat.com>,
	"armbru@redhat.com" <armbru@redhat.com>,
	"philmd@linaro.org" <philmd@linaro.org>,
	"yangjinqian1@huawei.com" <yangjinqian1@huawei.com>,
	Shaju Abraham <shaju.abraham@nutanix.com>,
	Mark Cave-Ayland <mark.caveayland@nutanix.com>,
	Prerna Saxena <prerna.saxena@nutanix.com>
Subject: Re: [RFC PATCH v3 07/19] target/arm/kvm: handle special ID registers cases when reading from KVM
Date: Fri, 14 Aug 2026 15:55:36 +0200	[thread overview]
Message-ID: <d77fc9f7-3057-4dc0-b29e-dc7bdfa0d5a2@redhat.com> (raw)
In-Reply-To: <34D1F8A9-C40F-4BA4-80F8-FC611EBCC732@nutanix.com>



On 8/3/26 5:52 PM, Khushit Shah wrote:
>
>> On 22 Jul 2026, at 6:02 PM, Eric Auger <eric.auger@redhat.com> wrote:
>>
>> !-------------------------------------------------------------------|
>>  CAUTION: External Email
>>
>> |-------------------------------------------------------------------!
>>
>> Hi Khushit,
>>
>> On 7/16/26 11:38 PM, Khushit Shah wrote:
>>> The generic KVM_GET_ONE_REG loop cannot correctly read a handful of
>>> ID registers, so specially handle those:
>>>
>>> - DCZID_EL0: No fine grain trap exists, hence not tracked by KVM.
>>>  It is EL0-readable and untrapped, so read it directly with MRS.
>>>
>>> - CCSIDR_EL1/CCSIDR2_EL1: not plain ID registers, their value is
>>>  selected by CSSELR_EL1. KVM only exposes them via the DEMUX API
>>>  (KVM_REG_ARM_DEMUX_ID_CCSIDR), so there is no single value to read
>>>  here. Skip them.
>>>
>>> - SMIDR_EL1: KVM does not support SME, so there is no meaningful host
>>>  value. Skip it.
>>>
>>> - GMID_EL1: not in KVM's sys_reg_descs[] and, being an EL1 register,
>>>  cannot be read from userspace via MRS either. The guest reads the
>>>  raw host value; this is a genuine miss when MTE is enabled.
>>>
>>> Signed-off-by: Khushit Shah <khushit.shah@nutanix.com>
>>> ---
>>> target/arm/kvm.c | 53 ++++++++++++++++++++++++++++++++++++++++--------
>>> 1 file changed, 44 insertions(+), 9 deletions(-)
>>>
>>> diff --git a/target/arm/kvm.c b/target/arm/kvm.c
>>> index 42ff731f6e..6974e5c551 100644
>>> --- a/target/arm/kvm.c
>>> +++ b/target/arm/kvm.c
>>> @@ -311,15 +311,50 @@ static int get_host_cpu_idregs(int fd, ARMHostCPUFeatures *ahcf)
>>>         int ret;
>>>
>>>         reg = &ahcf->isar.idregs[i];
>>> -        ret = read_sys_reg64(fd, reg, idregs_sysreg_to_kvm_reg(sysreg));
>>> -        if (ret) {
>>> -            if (errno == ENOENT) {
>>> -                warn_report("%s error reading value of host %s register "
>>> -                                "(ENOENT)", __func__, sysregdesc->name);
>>> -            } else {
>>> -                error_report("%s error reading value of host %s register"
>>> -                            " (%m)", __func__, sysregdesc->name);
>>> -                err = ret;
>>> +        switch (i) {
>>> +        case DCZID_EL0_IDX:
>>> +            /*
>>> +             * DCZID_EL0 is not in KVM's sys_reg_descs[], so
>>> +             * KVM_GET_ONE_REG will fail. Read it directly from
>>> +             * hardware since KVM doesn't trap guest reads of it.
>>> +             */
>>> +            asm volatile("mrs %0, DCZID_EL0" : "=r" (*reg));
>>> +            break;
>>> +        case CCSIDR_EL1_IDX:
>>> +        case CCSIDR2_EL1_IDX:
>>> +            /*
>>> +             * CCSIDR_EL1 is not a plain ID register: the value it
>>> +             * returns is selected by CSSELR_EL1, so there is no single
>>> +             * value to capture here. It is exposed to userspace only via
>>> +             * the DEMUX API (KVM_REG_ARM_DEMUX_ID_CCSIDR), indexed by
>>> +             * CSSELR. Skip reading it here as there is no meaningful host
>>> +             * value to read.
>>> +             */
>> I think you should rely on prerequisite
>> [PATCH v4 3/3] arm/kvm: get demuxed ID registers from kvm
> Currently I am just skipping those as anyway KVM exposes a very
> barebone Cache topology.
>
> Agreed on using DEMUX regs, in case we want to support exopsing some other
> “config”.
>
> Also on this point, I don’t know if CCSIDR_EL1/CCSIDR2_EL1 should
> be part of idregs[], we already have a ccsidr[], maybe this can be fixed
> in your series.

OK i will investigate this.

Thanks

Eric
>
>>> +            break;
>>> +        case SMIDR_EL1_IDX:
>>> +            /*
>>> +             * As SME is not yet supported by KVM, ignore reading SMIDR_EL1
>>> +             */
>>> +             break;
>>> +        case GMID_EL1_IDX:
>>> +            /*
>>> +             * GMID_EL1 is not in KVM's sys_reg_descs[] and guest reads
>>> +             * the raw host value. But as it is an EL1 register, we cannot
>>> +             * read it directly. This is a genuine miss when MTE is
>>> +             * enabled for the guest.
>>> +             */
>>> +            break;
>>> +        default:
>>> +            ret = read_sys_reg64(fd, reg, idregs_sysreg_to_kvm_reg(sysreg));
>>> +            if (ret) {
>>> +                if (errno == ENOENT) {
>>> +                    warn_report("%s error reading value of host %s register "
>>> +                                    "(ENOENT)", __func__, sysregdesc->name);
>> trace point
> Noted.
>
> Warm Regards,
> Khushit
>>> +                } else {
>>> +                    error_report("%s error reading value of host %s register"
>>> +                                " (%m)", __func__, sysregdesc->name);
>>> +                    err = ret;
>>> +                }
>>>             }
>>>         }
>>>         trace_get_host_cpu_idregs(sysregdesc->name, *reg);
>> Thanks
>>
>> Eric
>



  reply	other threads:[~2026-08-14 13:56 UTC|newest]

Thread overview: 76+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-16 21:38 [RFC PATCH v3 00/19] named CPU models for Arm64 on KVM Khushit Shah
2026-07-16 21:38 ` [RFC PATCH v3 01/19] target/arm/sysreg: regenerate cpu-sysregs.h.inc Khushit Shah
2026-07-20 12:11   ` Eric Auger
2026-08-03 14:22     ` Khushit Shah
2026-07-16 21:38 ` [RFC PATCH v3 02/19] scripts: bug fixes in update-aarch64-cpu-sysreg-properties Khushit Shah
2026-07-20 14:24   ` Eric Auger
2026-08-03 14:32     ` Khushit Shah
2026-08-14 13:45       ` Eric Auger
2026-08-18  9:43         ` Khushit Shah
2026-08-20 16:00           ` Eric Auger
2026-07-16 21:38 ` [RFC PATCH v3 03/19] target/arm: regenerate cpu-idregs.h.inc Khushit Shah
2026-07-20 14:39   ` Eric Auger
2026-08-03 14:34     ` Khushit Shah
2026-07-16 21:38 ` [RFC PATCH v3 04/19] target/arm: expose all ID regs fields as properties Khushit Shah
2026-07-21 14:44   ` Eric Auger
2026-08-03 15:05     ` Khushit Shah
2026-08-14 13:54       ` Eric Auger
2026-08-18  9:46         ` Khushit Shah
2026-08-20 15:40           ` Eric Auger
2026-07-16 21:38 ` [RFC PATCH v3 05/19] target/arm/kvm: enable writable implementation ID registers Khushit Shah
2026-07-21 15:03   ` Eric Auger
2026-08-03 15:46     ` Khushit Shah
2026-07-16 21:38 ` [RFC PATCH v3 06/19] target/arm/kvm: Read all ID registers from KVM Khushit Shah
2026-07-22  6:54   ` Eric Auger
2026-08-03 15:47     ` Khushit Shah
2026-07-16 21:38 ` [RFC PATCH v3 07/19] target/arm/kvm: handle special ID registers cases when reading " Khushit Shah
2026-07-22 12:32   ` Eric Auger
2026-08-03 15:52     ` Khushit Shah
2026-08-14 13:55       ` Eric Auger [this message]
2026-07-16 21:38 ` [RFC PATCH v3 08/19] target/arm/kvm: Handle writeback for special ID register fields Khushit Shah
2026-07-22 12:05   ` Eric Auger
2026-07-26 13:56     ` Eric Auger
2026-07-26 13:56       ` Eric Auger via qemu development
2026-07-26 13:56       ` Eric Auger via
2026-08-03 16:03     ` Khushit Shah
2026-08-14 14:04       ` Eric Auger
2026-08-18  9:43         ` Khushit Shah
2026-07-16 21:38 ` [RFC PATCH v3 09/19] target/arm: Add named cpu model infra + graviton3 named model Khushit Shah
2026-07-26 13:14   ` Eric Auger
2026-07-26 13:34   ` Eric Auger
2026-08-05 11:35     ` Khushit Shah
2026-08-14 15:40       ` Eric Auger
2026-08-18  9:45         ` Khushit Shah
2026-07-16 21:38 ` [RFC PATCH v3 10/19] target/arm: Add Nvidia Grace " Khushit Shah
2026-07-16 21:38 ` [RFC PATCH v3 11/19] target/arm: fix sve and pauth finalize for named cpu models Khushit Shah
2026-07-16 21:38 ` [RFC PATCH v3 12/19] target/arm: Introduce stub files required for qmp support Khushit Shah
2026-07-16 21:38 ` [RFC PATCH v3 13/19] target/arm/qmp: add named models and properties to cpu-model-expansion Khushit Shah
2026-07-16 21:38 ` [RFC PATCH v3 14/19] target/arm/kvm: compute supported values for ID register fields Khushit Shah
2026-07-26 14:22   ` Eric Auger
2026-08-05  9:58     ` Khushit Shah
2026-08-14 15:34       ` Eric Auger
2026-08-18  9:44         ` Khushit Shah
2026-07-16 21:38 ` [RFC PATCH v3 15/19] target/arm/kvm: introduce kvm_arm_get_host_isar helper Khushit Shah
2026-07-16 21:38 ` [RFC PATCH v3 16/19] qmp: add query-cpu-props-info command Khushit Shah
2026-07-20 13:21   ` Markus Armbruster
2026-08-03 16:05     ` Khushit Shah
2026-08-04  6:05       ` Markus Armbruster
2026-08-04  6:07         ` Khushit Shah
2026-08-04  6:30           ` Khushit Shah
2026-08-04  6:51             ` Markus Armbruster
2026-08-05  6:48               ` Khushit Shah
2026-08-05  6:58                 ` Markus Armbruster
2026-08-05  7:32                   ` Khushit Shah
2026-08-05 13:22                     ` Markus Armbruster
2026-08-06  9:24                       ` Khushit Shah
2026-08-20 16:00                         ` Eric Auger
2026-08-04  6:45   ` Markus Armbruster
2026-08-05  6:47     ` Khushit Shah
2026-08-05  6:57       ` Markus Armbruster
2026-08-05  7:32         ` Khushit Shah
2026-08-14 13:38       ` Eric Auger
2026-08-18  9:46         ` Khushit Shah
2026-08-20 16:01           ` Eric Auger
2026-07-16 21:38 ` [RFC PATCH v3 17/19] target/arm: Report 0 as supported for ID fields gated by vCPU init flags Khushit Shah
2026-07-16 21:38 ` [RFC PATCH v3 18/19] target/arm/qmp: hook blockers in query-cpu-definitions Khushit Shah
2026-07-16 21:38 ` [RFC PATCH v3 19/19] target/arm/kvm: fix host model writeback when kernel supports EL2 Khushit Shah

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=d77fc9f7-3057-4dc0-b29e-dc7bdfa0d5a2@redhat.com \
    --to=eric.auger@redhat.com \
    --cc=abologna@redhat.com \
    --cc=armbru@redhat.com \
    --cc=berrange@redhat.com \
    --cc=cohuck@redhat.com \
    --cc=gshan@redhat.com \
    --cc=jdenemar@redhat.com \
    --cc=khushit.shah@nutanix.com \
    --cc=kvmarm@lists.linux.dev \
    --cc=mark.caveayland@nutanix.com \
    --cc=maz@kernel.org \
    --cc=oliver.upton@linux.dev \
    --cc=peter.maydell@linaro.org \
    --cc=philmd@linaro.org \
    --cc=prerna.saxena@nutanix.com \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.org \
    --cc=sebott@redhat.com \
    --cc=shaju.abraham@nutanix.com \
    --cc=skolothumtho@nvidia.com \
    --cc=yangjinqian1@huawei.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.