[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v2 5/7] xen/arm: Add handler for cp15 ID registers


  • To: Bertrand Marquis <Bertrand.Marquis@xxxxxxx>
  • From: Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>
  • Date: Tue, 1 Dec 2020 12:07:13 +0000
  • Accept-language: en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=epam.com; dmarc=pass action=none header.from=epam.com; dkim=pass header.d=epam.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Qocu+7lHskqhuFd/LzqK8s14GfpI/b9CwmrpPIzJKeA=; b=oA+V8iiNU/k6+W4JToS6p+gQHUPgLPVGmWw8ZvtYUyb4q+1CEQFRlKdcfgwV6AswfVto0JvqEI0NtRN0sGVu+N4GF8qickGCt1Aifm62rI6+X82O4GugYCQwKocfkw+aH4kSzvXG0XU7dU5kUucG9sU6GErwzftcyxD4EmqY5yuZERfMVyESqg0hZ/WBH76X64VQw57cvs3qFuJahA81i//2yAUmlGF8Hi9WGqCxApNnmbJ6RoMZCwRjfpT7Kb0rcTxPnqnodiU56WxocxbFhN1GjqfGhlfYGCJ2pLjDrQLkw8afVt0ZKxSkbA+2DSU6xt5ZpeW+Ukb6fT55FDqAhQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cz4kDwEKeEu6pQ3AacVRJjSxWH2zYzbjEwpWvGdNkEkex22SmPrulL/jxmFbEfmv+k3z6howfm8FdJlF2LR2ogAyvuafy1NPFMjYJamRbIGJY+l15BLx6R2MBEBKhIg9aFjsyX+rjJeBfRpgZk6355RvSZWEmT5GjqgeIJslEbMZlFQDjyPRTEykFosajjKF5Xs/kDHfyDk+g1opW7Bq31IH0zmAIqTfV8cKEKszlmbigYA4h1ywWlFc/zww9KKy7+BDl6SugRfSmlTBzqTJL0GmYpjYwQnfIvVR9+xl9h8TPSyKl9/PR7xurFnK4K9e9sbvuiqLcUHhNf0xbUuXlg==
  • Authentication-results: arm.com; dkim=none (message not signed) header.d=none;arm.com; dmarc=none action=none header.from=epam.com;
  • Cc: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>
  • Delivery-date: Tue, 01 Dec 2020 12:07:37 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHWxyRSFk5jpSQ9QE+NXR5AM1rL5qnhIUQAgAD/vgCAAAW1AA==
  • Thread-topic: [PATCH v2 5/7] xen/arm: Add handler for cp15 ID registers

Hi,

Bertrand Marquis writes:

> Hi,
>
>> On 30 Nov 2020, at 20:31, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx> 
>> wrote:
>> 
>> 
>> Bertrand Marquis writes:
>> 
>>> Add support for emulation of cp15 based ID registers (on arm32 or when
>>> running a 32bit guest on arm64).
>>> The handlers are returning the values stored in the guest_cpuinfo
>>> structure.
>>> In the current status the MVFR registers are no supported.
>> 
>> It is unclear what will happen with registers that are not covered by
>> guest_cpuinfo structure. According to ARM ARM, it is implementation
>> defined if such accesses will be trapped. On other hand, there are many
>> registers which are RAZ. So, good behaving guest can try to read one of
>> that registers and it will get undefined instruction exception, instead
>> of just reading all zeroes.
>
> This is true in the status of this patch but this is solved by the next patch
> which is adding proper handling of those registers (add CP10 exception
> support), at least for MVFR ones.
>
> From ARM ARM point of view, I did handle all registers listed I think.
> If you think some are missing please point me to them as O do not
> completely understand what are the “registers not covered” unless
> you mean the MVFR ones.

Well, I may be wrong for aarch32 case, but for aarch64, there are number
of reserved registers in IDs range. Those registers should read as
zero. You can find them in the section "C5.1.6 op0==0b11, Moves to and
from non-debug System registers and Special-purpose registers" of ARM
DDI 0487B.a. Check out "Table C5-6 System instruction encodings for
non-Debug System register accesses".


>> 
>>> Signed-off-by: Bertrand Marquis <bertrand.marquis@xxxxxxx>
>>> ---
>>> Changes in V2: rebase
>>> ---
>>> xen/arch/arm/vcpreg.c | 35 +++++++++++++++++++++++++++++++++++
>>> 1 file changed, 35 insertions(+)
>>> 
>>> diff --git a/xen/arch/arm/vcpreg.c b/xen/arch/arm/vcpreg.c
>>> index cdc91cdf5b..d0c6406f34 100644
>>> --- a/xen/arch/arm/vcpreg.c
>>> +++ b/xen/arch/arm/vcpreg.c
>>> @@ -155,6 +155,14 @@ TVM_REG32(CONTEXTIDR, CONTEXTIDR_EL1)
>>>         break;                                                      \
>>>     }
>>> 
>>> +/* Macro to generate easily case for ID co-processor emulation */
>>> +#define GENERATE_TID3_INFO(reg,field,offset)                        \
>>> +    case HSR_CPREG32(reg):                                          \
>>> +    {                                                               \
>>> +        return handle_ro_read_val(regs, regidx, cp32.read, hsr,     \
>>> +                          1, guest_cpuinfo.field.bits[offset]);     \
>>> +    }
>>> +
>>> void do_cp15_32(struct cpu_user_regs *regs, const union hsr hsr)
>>> {
>>>     const struct hsr_cp32 cp32 = hsr.cp32;
>>> @@ -286,6 +294,33 @@ void do_cp15_32(struct cpu_user_regs *regs, const 
>>> union hsr hsr)
>>>          */
>>>         return handle_raz_wi(regs, regidx, cp32.read, hsr, 1);
>>> 
>>> +    /*
>>> +     * HCR_EL2.TID3
>>> +     *
>>> +     * This is trapping most Identification registers used by a guest
>>> +     * to identify the processor features
>>> +     */
>>> +    GENERATE_TID3_INFO(ID_PFR0, pfr32, 0)
>>> +    GENERATE_TID3_INFO(ID_PFR1, pfr32, 1)
>>> +    GENERATE_TID3_INFO(ID_PFR2, pfr32, 2)
>>> +    GENERATE_TID3_INFO(ID_DFR0, dbg32, 0)
>>> +    GENERATE_TID3_INFO(ID_DFR1, dbg32, 1)
>>> +    GENERATE_TID3_INFO(ID_AFR0, aux32, 0)
>>> +    GENERATE_TID3_INFO(ID_MMFR0, mm32, 0)
>>> +    GENERATE_TID3_INFO(ID_MMFR1, mm32, 1)
>>> +    GENERATE_TID3_INFO(ID_MMFR2, mm32, 2)
>>> +    GENERATE_TID3_INFO(ID_MMFR3, mm32, 3)
>>> +    GENERATE_TID3_INFO(ID_MMFR4, mm32, 4)
>>> +    GENERATE_TID3_INFO(ID_MMFR5, mm32, 5)
>>> +    GENERATE_TID3_INFO(ID_ISAR0, isa32, 0)
>>> +    GENERATE_TID3_INFO(ID_ISAR1, isa32, 1)
>>> +    GENERATE_TID3_INFO(ID_ISAR2, isa32, 2)
>>> +    GENERATE_TID3_INFO(ID_ISAR3, isa32, 3)
>>> +    GENERATE_TID3_INFO(ID_ISAR4, isa32, 4)
>>> +    GENERATE_TID3_INFO(ID_ISAR5, isa32, 5)
>>> +    GENERATE_TID3_INFO(ID_ISAR6, isa32, 6)
>>> +    /* MVFR registers are in cp10 no cp15 */
>>> +
>>>     /*
>>>      * HCR_EL2.TIDCP
>>>      *
>> 
>> 
>> -- 
>> Volodymyr Babchuk at EPAM


-- 
Volodymyr Babchuk at EPAM

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.