From: Gabe Black Date: Wed, 18 Nov 2020 05:45:55 +0000 (-0800) Subject: x86: Fix object scope in the CPUID code. X-Git-Tag: develop-gem5-snapshot~452 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=7039662eeba5ba6ff56b258a0a25236a8a4f0c83;p=gem5.git x86: Fix object scope in the CPUID code. The original version of the code takes a pointer from a temporary object which gets destroyed before the pointer is used. Change-Id: I16af4eefdf202f769a672e230330d8e0bfce3bb7 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/37695 Reviewed-by: Matthew Poremba Reviewed-by: Jason Lowe-Power Maintainer: Jason Lowe-Power Tested-by: kokoro --- diff --git a/src/arch/x86/cpuid.cc b/src/arch/x86/cpuid.cc index 8c9f29cef..2a560f510 100644 --- a/src/arch/x86/cpuid.cc +++ b/src/arch/x86/cpuid.cc @@ -94,12 +94,12 @@ namespace X86ISA { case VendorAndLargestExtFunc: { ISA *isa = dynamic_cast(tc->getIsaPtr()); - const char *vendor_string = isa->getVendorString().c_str(); + auto vendor_string = isa->getVendorString(); result = CpuidResult( 0x80000000 + NumExtendedCpuidFuncs - 1, - stringToRegister(vendor_string), - stringToRegister(vendor_string + 4), - stringToRegister(vendor_string + 8)); + stringToRegister(vendor_string.c_str()), + stringToRegister(vendor_string.c_str() + 4), + stringToRegister(vendor_string.c_str() + 8)); } break; case FamilyModelSteppingBrandFeatures: @@ -155,12 +155,12 @@ namespace X86ISA { case VendorAndLargestStdFunc: { ISA *isa = dynamic_cast(tc->getIsaPtr()); - const char *vendor_string = isa->getVendorString().c_str(); + auto vendor_string = isa->getVendorString(); result = CpuidResult( NumExtendedCpuidFuncs - 1, - stringToRegister(vendor_string), - stringToRegister(vendor_string + 4), - stringToRegister(vendor_string + 8)); + stringToRegister(vendor_string.c_str()), + stringToRegister(vendor_string.c_str() + 4), + stringToRegister(vendor_string.c_str() + 8)); } break; case FamilyModelStepping: