All of lore.kernel.org
 help / color / mirror / Atom feed
From: Luca Fancellu <Luca.Fancellu@arm.com>
To: Jan Beulich <jbeulich@suse.com>
Cc: Julien Grall <julien@xen.org>,
	Xen-devel <xen-devel@lists.xenproject.org>,
	Bertrand Marquis <Bertrand.Marquis@arm.com>,
	Wei Chen <Wei.Chen@arm.com>,
	Stefano Stabellini <sstabellini@kernel.org>,
	Volodymyr Babchuk <Volodymyr_Babchuk@epam.com>
Subject: Re: [PATCH v6 01/12] xen/arm: enable SVE extension for Xen
Date: Mon, 22 May 2023 08:43:21 +0000	[thread overview]
Message-ID: <8A5D1D62-0FCF-4A2F-8B09-D216002D168C@arm.com> (raw)
In-Reply-To: <a21f2917-052a-ddb5-3de5-1ea58cb55252@suse.com>



> On 22 May 2023, at 08:50, Jan Beulich <jbeulich@suse.com> wrote:
> 
> On 19.05.2023 16:46, Julien Grall wrote:
>> On 19/05/2023 15:26, Luca Fancellu wrote:
>>>> On 18 May 2023, at 10:35, Julien Grall <julien@xen.org> wrote:
>>>>> +/*
>>>>> + * Arm SVE feature code
>>>>> + *
>>>>> + * Copyright (C) 2022 ARM Ltd.
>>>>> + */
>>>>> +
>>>>> +#include <xen/types.h>
>>>>> +#include <asm/arm64/sve.h>
>>>>> +#include <asm/arm64/sysregs.h>
>>>>> +#include <asm/processor.h>
>>>>> +#include <asm/system.h>
>>>>> +
>>>>> +extern unsigned int sve_get_hw_vl(void);
>>>>> +
>>>>> +register_t compute_max_zcr(void)
>>>>> +{
>>>>> +    register_t cptr_bits = get_default_cptr_flags();
>>>>> +    register_t zcr = vl_to_zcr(SVE_VL_MAX_BITS);
>>>>> +    unsigned int hw_vl;
>>>>> +
>>>>> +    /* Remove trap for SVE resources */
>>>>> +    WRITE_SYSREG(cptr_bits & ~HCPTR_CP(8), CPTR_EL2);
>>>>> +    isb();
>>>>> +
>>>>> +    /*
>>>>> +     * Set the maximum SVE vector length, doing that we will know the VL
>>>>> +     * supported by the platform, calling sve_get_hw_vl()
>>>>> +     */
>>>>> +    WRITE_SYSREG(zcr, ZCR_EL2);
>>>> 
>>>> From my reading of the Arm (D19-6331, ARM DDI 0487J.a), a direct write to a system register would need to be followed by an context synchronization event (e.g. isb()) before the software can rely on the value.
>>>> 
>>>> In this situation, AFAICT, the instruciton in sve_get_hw_vl() will use the content of ZCR_EL2. So don't we need an ISB() here?
>>> 
>>> From what I’ve read in the manual for ZCR_ELx:
>>> 
>>> An indirect read of ZCR_EL2.LEN appears to occur in program order relative to a direct write of
>>> the same register, without the need for explicit synchronization
>>> 
>>> I’ve interpreted it as “there is no need to sync before write” and I’ve looked into Linux and it does not
>>> Appear any synchronisation mechanism after a write to that register, but if I am wrong I can for sure
>>> add an isb if you prefer.
>> 
>> Ah, I was reading the generic section about synchronization and didn't 
>> realize there was a paragraph in the ZCR_EL2 section as well.
>> 
>> Reading the new section, I agree with your understanding. The isb() is 
>> not necessary.
> 
> And RDVL counts as an "indirect read"? I'm pretty sure "normal" SVE insn
> use is falling in that category, but RDVL might also be viewed as more
> similar to MRS in this regard? While the construct CurrentVL is used in
> either case, I'm still not sure this goes without saying.

Hi Jan,

Looking into the Linux code, in function vec_probe_vqs(...) in arch/arm64/kernel/fpsimd.c,
ZCR_EL1 is written, without synchronisation, and afterwards RDVL is used.

I think ZCR_EL2 has the same behaviour.

Cheers,
Luca

> 
> Jan


  reply	other threads:[~2023-05-22  8:44 UTC|newest]

Thread overview: 56+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-24  6:02 [PATCH v6 00/12] SVE feature for arm guests Luca Fancellu
2023-04-24  6:02 ` [PATCH v6 01/12] xen/arm: enable SVE extension for Xen Luca Fancellu
2023-05-18  9:35   ` Julien Grall
2023-05-19 14:26     ` Luca Fancellu
2023-05-19 14:46       ` Julien Grall
2023-05-19 14:51         ` Luca Fancellu
2023-05-19 15:00           ` Julien Grall
2023-05-19 15:13             ` Luca Fancellu
2023-05-19 15:17               ` Julien Grall
2023-05-22  7:50         ` Jan Beulich
2023-05-22  8:43           ` Luca Fancellu [this message]
2023-05-22  9:30             ` Julien Grall
2023-05-22  9:35               ` Luca Fancellu
2023-04-24  6:02 ` [PATCH v6 02/12] xen/arm: add SVE vector length field to the domain Luca Fancellu
2023-05-18  9:48   ` Julien Grall
2023-04-24  6:02 ` [PATCH v6 03/12] xen/arm: Expose SVE feature to the guest Luca Fancellu
2023-05-18  9:51   ` Julien Grall
2023-04-24  6:02 ` [PATCH v6 04/12] xen/arm: add SVE exception class handling Luca Fancellu
2023-05-18  9:55   ` Julien Grall
2023-04-24  6:02 ` [PATCH v6 05/12] arm/sve: save/restore SVE context switch Luca Fancellu
2023-05-18 18:27   ` Julien Grall
2023-05-19 17:35     ` Luca Fancellu
2023-05-19 17:52       ` Julien Grall
2023-05-18 18:30   ` Julien Grall
2023-05-22 10:20     ` Luca Fancellu
2023-05-22 12:41       ` Jan Beulich
2023-05-22 12:43         ` Luca Fancellu
2023-04-24  6:02 ` [PATCH v6 06/12] xen/common: add dom0 xen command line argument for Arm Luca Fancellu
2023-04-24  6:02 ` [PATCH v6 07/12] xen: enable Dom0 to use SVE feature Luca Fancellu
2023-04-24 11:34   ` Jan Beulich
2023-04-24 14:00     ` Luca Fancellu
2023-04-24 14:05       ` Jan Beulich
2023-04-24 14:57         ` Luca Fancellu
2023-04-24 15:06           ` Jan Beulich
2023-04-24 15:18             ` Luca Fancellu
2023-04-24 15:25               ` Jan Beulich
2023-04-24 15:34                 ` Luca Fancellu
2023-04-24 15:41                   ` Jan Beulich
2023-04-24 15:43                     ` Luca Fancellu
2023-04-24 16:10                       ` Jan Beulich
2023-04-25  6:04                         ` Luca Fancellu
2023-05-18 18:39                           ` Julien Grall
2023-04-24  6:02 ` [PATCH v6 08/12] xen/physinfo: encode Arm SVE vector length in arch_capabilities Luca Fancellu
2023-04-24  6:02 ` [PATCH v6 09/12] tools: add physinfo arch_capabilities handling for Arm Luca Fancellu
2023-05-02 16:13   ` Anthony PERARD
2023-05-03  9:23     ` Luca Fancellu
2023-05-05 16:44       ` Anthony PERARD
2023-05-05 16:56         ` Luca Fancellu
2023-04-24  6:02 ` [PATCH v6 10/12] xen/tools: add sve parameter in XL configuration Luca Fancellu
2023-05-02 17:06   ` Anthony PERARD
2023-05-02 19:54     ` Luca Fancellu
2023-05-05 16:23       ` Anthony PERARD
2023-05-05 16:36         ` Luca Fancellu
2023-04-24  6:02 ` [PATCH v6 11/12] xen/arm: add sve property for dom0less domUs Luca Fancellu
2023-04-24  6:02 ` [PATCH v6 12/12] xen/changelog: Add SVE and "dom0" options to the changelog for Arm Luca Fancellu
2023-04-24  7:22   ` Henry Wang

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=8A5D1D62-0FCF-4A2F-8B09-D216002D168C@arm.com \
    --to=luca.fancellu@arm.com \
    --cc=Bertrand.Marquis@arm.com \
    --cc=Volodymyr_Babchuk@epam.com \
    --cc=Wei.Chen@arm.com \
    --cc=jbeulich@suse.com \
    --cc=julien@xen.org \
    --cc=sstabellini@kernel.org \
    --cc=xen-devel@lists.xenproject.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 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.