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

Re: [PATCH] xen/arm: Missing N1/A76/A75 FP registers in vCPU context switch


  • To: Andre Przywara <Andre.Przywara@xxxxxxx>
  • From: Bertrand Marquis <Bertrand.Marquis@xxxxxxx>
  • Date: Tue, 18 Aug 2020 10:13:25 +0000
  • Accept-language: en-GB, en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.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=IJAwlNitfESwp3RkXmgWf1FI/hzfBj+Az27VJrEcyhk=; b=Hb3B8HoJaYpDcFAjthRk+M6uYnojDe4/7YEWzmERizJECCIJJp27OEVjwLu9tF7U0tcYVYjUof45/ShqWX4qNAplFLjzS8mWy4fePuysN9fN4LeaybnnzLHTP4SSjm7dVkQ2IpR+diwjP/lMwD17lXzxSN6WuPGAvaCQNmabTewpvx5eGsxH+H9Auegtqxilip3XTiSPwEs4xjAam1UCfaDQco+cm/t0hGQs4BqS5uOj/P3APXns9xBbuTo2fVH1JCqpGpAcnASvIEeBf58RAu7EkIXPuekntY03XEQnM2bAKooJtfZftTQMYKUi9ux5diBjyrjMGYocIhzgbM04fg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GSEjQsx/4hZW0JKFFvWzKna6BecQ1fvdYwu8OfJbxyn/JUshtICQj19WQHBjqV73zj2BOXYUIhMNQX4ad0wXQJ+0OKUUXYDuRx+8V637F52ulWQh2CLLzW8xt+n6mvwN5rqFGkNvK1P8pS6QpS+SsMI1QNgP8HVS0AuaFgGkQRwwtv22Of2ZW/NbWCw7c4O/kJxflQkABmPv1FOkcbSfkX5GsPbMGNVpnzLKuSzZLyZapkHNDT4I9X3pyfNkteZyiUlHGKOn457SL3auOdnuUtGi4w19TWWLzhn1inrc7/9G0W8t+0qTr5gw0O6TL4SDCDeaL4wR7AqWVrkUuBaHOw==
  • Authentication-results-original: arm.com; dkim=none (message not signed) header.d=none;arm.com; dmarc=none action=none header.from=arm.com;
  • Cc: Wei Chen <Wei.Chen@xxxxxxx>, Xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Steve Capper <Steve.Capper@xxxxxxx>, Kaly Xin <Kaly.Xin@xxxxxxx>, nd <nd@xxxxxxx>
  • Delivery-date: Tue, 18 Aug 2020 10:14:09 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Nodisclaimer: true
  • Original-authentication-results: arm.com; dkim=none (message not signed) header.d=none;arm.com; dmarc=none action=none header.from=arm.com;
  • Thread-index: AQHWdQ1DgIquqcpHPEOT+qWxYeHAMqk9lfsAgAAC9ACAAAS3AIAACKkA
  • Thread-topic: [PATCH] xen/arm: Missing N1/A76/A75 FP registers in vCPU context switch


> On 18 Aug 2020, at 10:42, André Przywara <andre.przywara@xxxxxxx> wrote:
> 
> On 18/08/2020 10:25, Bertrand Marquis wrote:
> 
> Hi,
> 
>>> On 18 Aug 2020, at 10:14, André Przywara <andre.przywara@xxxxxxx> wrote:
>>> 
>>> On 18/08/2020 04:11, Wei Chen wrote:
>>> 
>>> Hi Wei,
>>> 
>>>> Xen has cpu_has_fp/cpu_has_simd to detect whether the CPU supports
>>>> FP/SIMD or not. But currently, this two MACROs only consider value 0
>>>> of ID_AA64PFR0_EL1.FP/SIMD as FP/SIMD features enabled. But for CPUs
>>>> that support FP/SIMD and half-precision floating-point features, the
>>>> ID_AA64PFR0_EL1.FP/SIMD are 1. For these CPUs, xen will treat them as
>>>> no FP/SIMD support. In this case, the vfp_save/restore_state will not
>>>> take effect.
>>>> 
>>>> Unfortunately, Cortex-N1/A76/A75 are the CPUs support FP/SIMD and
>>>> half-precision floatiing-point. Their ID_AA64PFR0_EL1.FP/SMID are 1
>>>> (see Arm ARM DDI0487F.b, D13.2.64). In this case, on N1/A76/A75
>>>> platforms, Xen will always miss the float pointer registers save/restore.
>>>> If different vCPUs are running on the same pCPU, the float pointer
>>>> registers will be corrupted randomly.
>>> 
>>> That's a good catch, thanks for working this out!
>>> 
>>> One thing below...
>>> 
>>>> This patch fixes Xen on these new cores.
>>>> 
>>>> Signed-off-by: Wei Chen <wei.chen@xxxxxxx>
>>>> ---
>>>> xen/include/asm-arm/cpufeature.h | 4 ++--
>>>> 1 file changed, 2 insertions(+), 2 deletions(-)
>>>> 
>>>> diff --git a/xen/include/asm-arm/cpufeature.h 
>>>> b/xen/include/asm-arm/cpufeature.h
>>>> index 674beb0353..588089e5ae 100644
>>>> --- a/xen/include/asm-arm/cpufeature.h
>>>> +++ b/xen/include/asm-arm/cpufeature.h
>>>> @@ -13,8 +13,8 @@
>>>> #define cpu_has_el2_64    (boot_cpu_feature64(el2) >= 1)
>>>> #define cpu_has_el3_32    (boot_cpu_feature64(el3) == 2)
>>>> #define cpu_has_el3_64    (boot_cpu_feature64(el3) >= 1)
>>>> -#define cpu_has_fp        (boot_cpu_feature64(fp) == 0)
>>>> -#define cpu_has_simd      (boot_cpu_feature64(simd) == 0)
>>>> +#define cpu_has_fp        (boot_cpu_feature64(fp) <= 1)
>>>> +#define cpu_has_simd      (boot_cpu_feature64(simd) <= 1)
>>> 
>>> But this is only good until the next feature bump. I think we should be
>>> more future-proof here. The architecture describes those two fields as
>>> "signed"[1], and guarantees that "if value >= 0" is a valid test for the
>>> feature. Which means we are good as long as the sign bit (bit 3) is
>>> clear, which translates into:
>>> #define cpu_has_fp        (boot_cpu_feature64(fp) < 8)
>>> Same for simd.
>>> 
>> 
>> We cannot really be sure that a new version introduced will require the
>> same context save/restore so it might dangerous to claim we support
>> something we have no idea about.
> 
> I am pretty sure we can, because this is what the FP feature describes.
> If a feature bump would introduce a larger state to be saved and
> restored, that would be covered by a new field, look at AdvSIMD and SVE
> for examples.
> The feature number would only be bumped if it's compatible:
> ====================
> · The field holds a signed value.
> · The field value 0xF indicates that the feature is not implemented.
> · The field value 0x0 indicates that the feature is implemented.
> · Software that depends on the feature can use the test:
>      if value >= 0 {  // Software features that depend on the presence
> of the hardware feature }
> ====================
> (ARMv8 ARM D13.1.3)
> 
> And this is how Linux handles this.

Then changing the code to use <8 should be ok.

Cheers
Bertrand

> 
> Cheers,
> Andre
> 
>> I agree though about the analysis on the fact that values under 8 should
>> be valid but only 0 and 1 currently exist [1], other values are reserved.
>> 
>> So I would vote to keep the 1 for now there.
>> 
>> Cheers
>> Bertrand
>> 
>> [1] 
>> https://developer.arm.com/docs/ddi0595/h/aarch64-system-registers/id_aa64pfr0_el1


 


Rackspace

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