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

Re: [RFC PATCH 3/4] xen/arm: Sanitize cpuinfo ID registers fields


  • To: Julien Grall <julien@xxxxxxx>
  • From: Bertrand Marquis <Bertrand.Marquis@xxxxxxx>
  • Date: Fri, 16 Jul 2021 17:14:57 +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=2RmLbxYMrjGdHwXqqepCVjrYipANuFQ65uYhsQNnKMU=; b=bZbSP01G/XaAjBdhYQ/ZcZPJoeJlPJteM2zt1tQV6Khbt50UDi2qMD3cPswC7Zz/2nagmoyPz3nIfaZ4LhUN/QxM/NuRXS94dyApTVwkyNgZvdZek+4PmwTuuSAxC8NStvsr6JWM71J2C7kLKI6YCguwZJ4TS7x8+zunMRr1G7GEAWekgOFwDLBl8X/Qxxl0CqE2ueuxY72Zuvt3Sxrno+lzJ32DcwdN2djR9ZnjpgCVNBsS3WRqlk9bT3Ntmmorp+CKA0C46ld8bN3nNX18NB1Sbca3AIMA+YYkMt+uolY2z1hSEpVy1yEKdbATP3c0NzFFfCc/Gxx8GLnahYKOfA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KKZOZ3DFta9ieR4ntYAFQVf/zchjyzbef5JKeiET0cPprL7nkUgIftPkH0IBvN6XYrG2nkBvj+SS1pxdZtmjLGES9Pr0KYfEV1+V4Jndp5Nxvci+3bT6AQcAarT2pt5Z+0fUyTc2CmSKlPKny1DvBbPhjDtt3M+3XLRy1argRZvM5N6m74FXCrJCNqqO1IM69JwNejd80y2xz6lHz3dR4o3lshIQ8xNuiYxYspYWrXEHR1zMfpl1HIDcePgmw0jGsdXytYx6IQjFcRK+Fx3m/qJnOlwUUyfKF5mrh+cTepHq5RtPd195iL631Fn0/+/PvyAGQgs5zpM1q3EDnSSE+g==
  • Authentication-results-original: xen.org; dkim=none (message not signed) header.d=none;xen.org; dmarc=none action=none header.from=arm.com;
  • Cc: Xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>
  • Delivery-date: Fri, 16 Jul 2021 17:15:20 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Nodisclaimer: true
  • Original-authentication-results: xen.org; dkim=none (message not signed) header.d=none;xen.org; dmarc=none action=none header.from=arm.com;
  • Thread-index: AQHXbQmqqZ2dUoMblUy//wgHf+AX8qs/M8QAgAa+XIA=
  • Thread-topic: [RFC PATCH 3/4] xen/arm: Sanitize cpuinfo ID registers fields

Hi Julien

[…]
>> 
>> +
>> +    if ( old_reg != new_reg )
>> +        printk(XENLOG_DEBUG "SANITY DIF: %s 0x%"PRIx64" -> 0x%"PRIx64"\n",
>> +               reg_name, old_reg, new_reg);
>> +    if ( old_reg != *cur_reg )
>> +        printk(XENLOG_DEBUG "SANITY FIX: %s 0x%"PRIx64" -> 0x%"PRIx64"\n",
>> +               reg_name, old_reg, *cur_reg);
>> +
>> +    if ( taint )
>> +    {
>> +        printk(XENLOG_WARNING "SANITY CHECK: Unexpected variation in %s.\n",
>> +                reg_name);
>> +        add_taint(TAINT_CPU_OUT_OF_SPEC);
>> +    }
>> +}
>> +
>> +
>> +/*
>> + * This function should be called on secondary cores to sanitize the boot 
>> cpu
>> + * cpuinfo.
> 
> Can we renamed boot_cpu_data to system_cpuinfo (or something similar)? This 
> would make clear this is not only the features for the boot CPU?

While looking at this request, I checked a bit how boot_cpu_data and cpu_data 
overall are used:
- boot_cpu_data is only used in setup.c, by boot_cpu_features macros, in 
smpboot to retrieve the bootcpu midr, in p2m and by cpufeatures
- cpu_data[] is used in smpboot, in errata handling to test for csv2, and in 
vcpreg to access the midr

So we have a bunch of cpuinfo structures as global variables but most of them 
are not really used or did I miss something ?

So I am wondering if we should not reduce a bit the amount of global data and:
- introduce a global system_cpuinfo
- remove cpu_data[] and use a temp structure in the stack of the cpu booting
- read midr directly in vcpreg
- use boot_cpu_data in errata for csv2
- use system_cpuinfo in p2m

It could even be possible to remove boot_cpu_data and put it on the stack of 
the boot cpu and only use system_cpuinfo but I did not investigate this.

Cheers
Bertrand


 


Rackspace

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