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

[PATCH] x86/amd: Fix DE_CFG truncation in amd_check_zenbleed()


  • To: Xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • Date: Fri, 28 Jul 2023 19:17:30 +0100
  • Authentication-results: esa3.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Jan Beulich <JBeulich@xxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>
  • Delivery-date: Fri, 28 Jul 2023 18:17:45 +0000
  • Ironport-data: A9a23:O+pExqIrBwwCgHh4FE+R0ZUlxSXFcZb7ZxGr2PjKsXjdYENSgzIEm GUdX26EaPqKZmqkL9AlYNiy9hkAsJbWndRlSAplqX01Q3x08seUXt7xwmUcnc+xBpaaEB84t ZV2hv3odp1coqr0/0/1WlTZhSAgk/rOHvykU7Ss1hlZHWdMUD0mhQ9oh9k3i4tphcnRKw6Ws Jb5rta31GWNglaYCUpKrfrawP9TlK6q4mhA4QZuPaojUGL2zBH5MrpOfcldEFOgKmVkNrbSb /rOyri/4lTY838FYj9yuu+mGqGiaue60Tmm0hK6aYD76vRxjnVaPpIAHOgdcS9qZwChxLid/ jnvWauYEm/FNoWU8AgUvoIx/ytWZcWq85efSZSzXFD6I+QrvBIAzt03ZHzaM7H09c5NPUQW0 9hIdwsIRT+OoPu24J+xFuZF05FLwMnDZOvzu1llxDDdS/0nXYrCU+PB4towMDUY354UW6yEP oxANGQpNU6bC/FMEg5/5JYWteGknHTgNRZfr0qYv/Ef6GnP1g1hlrPqNbI5f/TTHJoFxBrB+ juuE2LRLRYkb4G+62u+qHOKguvGui/5XIIbLejtnhJtqALKnTFCYPEMbnOrrP/8hkOgVtZ3L 00P5jFovaU07FasTNT2Q1u/unHsljw2VsdUEuY6wBqQ0aeS6AGcbkAbShZRZdpgs9U5LQHGz XfQwYmvX2Y29uTIFzTErOz8QS6O1TY9F1MnPQkgHVQ+5vLMraYqjjLiRIpsOfvg5jHqIg0c0 wxmvQBn2eRL0JBVifvrlbzUq2ny/8aUF2bZ8i2SBzv4tV0hOeZJcqTysTDmAeB8wJF1p7Vrl FwNgICg4e8HFvlhfwTdEbxWTNlFCxtoWQAwYGKD/LF7rVxBA1b5IehtDMhWfS+FyPosdz7ze 1P0sghM/pJVN3bCRfYpMtrtW550nfa7T4uNuhXogjxmOMUZmOivpXEGWKJt9zq1zBhEfV8XZ /93jvpA/V5FUP86nVJats8W0KMxxzBW+I8gbcmT8vhT6pLHPCT9Ye5cYDOzghURsPvsTPP9r 4wOaKNnCnx3DIXDX8Ug2ddCdglTfSBrX8CeRg4+XrfrHzeK0VoJU5f5qY7NsaQ890iJvo8kJ k2AZ3I=
  • Ironport-hdrordr: A9a23:ykANl6PXskYv3MBcTs+jsMiBIKoaSvp037BL7TEXdfUxSKalfq +V8sjzuSWatN9zYgBDpTnjAtjlfZq0z/ccjbX5W43SPzUO0FHCEGgI1+rfKlPbexEWptQx6U 8jG5IObeHNMQ==
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

This line:

        val &= ~chickenbit;

ends up truncating val to 32 bits, and turning off various errata workarounds
in Zen2 systems.

Fixes: f91c5ea97067 ("x86/amd: Mitigations for Zenbleed")
Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
---
CC: Jan Beulich <JBeulich@xxxxxxxx>
CC: Roger Pau Monné <roger.pau@xxxxxxxxxx>
CC: Wei Liu <wl@xxxxxxx>

The choice is between int or uint64_t.  This is one case where the insistence
on using unsigned int as a default data type is genuinely unsafe.
---
 xen/arch/x86/cpu/amd.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/xen/arch/x86/cpu/amd.c b/xen/arch/x86/cpu/amd.c
index 3ed06f670491..089038bf62c5 100644
--- a/xen/arch/x86/cpu/amd.c
+++ b/xen/arch/x86/cpu/amd.c
@@ -909,8 +909,9 @@ void __init detect_zen2_null_seg_behaviour(void)
 void amd_check_zenbleed(void)
 {
        const struct cpu_signature *sig = &this_cpu(cpu_sig);
-       unsigned int good_rev, chickenbit = (1 << 9);
+       unsigned int good_rev;
        uint64_t val, old_val;
+       int chickenbit = (1 << 9);
 
        /*
         * If we're virtualised, we can't do family/model checks safely, and
-- 
2.30.2




 


Rackspace

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