Re: [edk2-devel] CpuDeadLoop() is optimized by compiler

2024-06-05 Thread Oliver Smith-Denny
Cran ; Hernandez Miramontes, Jose Miguel *Cc:* Kinney, Michael D *Subject:* RE: [edk2-devel] CpuDeadLoop() is optimized by compiler Right. But if you break in with debugger, you can still skip over the jmp instruction and continue. I agree XIP does not allow variable value to be updated, but we

Re: [edk2-devel] CpuDeadLoop() is optimized by compiler

2023-10-31 Thread Michael D Kinney
31, 2023 1:31 AM To: Kinney, Michael D ; Andrew (EFI) Fish ; edk2-devel-groups-io ; Rebecca Cran ; Hernandez Miramontes, Jose Miguel Subject: Re: [edk2-devel] CpuDeadLoop() is optimized by compiler Mike, This is not friendly for XIP code. With XIP code, the global variable is not able to be

Re: [edk2-devel] CpuDeadLoop() is optimized by compiler

2023-10-31 Thread Ni, Ray
-groups-io ; Rebecca Cran ; Hernandez Miramontes, Jose Miguel Cc: Kinney, Michael D Subject: RE: [edk2-devel] CpuDeadLoop() is optimized by compiler Does using a static volatile global instead of a volatile local work? Mike From: Ni, Ray Sent: Monday, October 30, 2023 7:52 PM To: Andrew

Re: [edk2-devel] CpuDeadLoop() is optimized by compiler

2023-10-30 Thread Michael D Kinney
2.groups.io>>; Rebecca Cran mailto:rebe...@bsdio.com>> Cc: Ni, Ray mailto:ray...@intel.com>>; Kinney, Michael D mailto:michael.d.kin...@intel.com>> Subject: Re: [edk2-devel] CpuDeadLoop() is optimized by compiler I don't think the atomic is going to help. The compiler ho

Re: [edk2-devel] CpuDeadLoop() is optimized by compiler

2023-10-30 Thread Ni, Ray
t find a dead-loop intrinsic function in MSVC. Any better idea? Thanks, Ray *From:* Andrew (EFI) Fish *Sent:* Friday, May 19, 2023 8:42 AM *To:* devel@edk2.groups.io; Kinney, Michael D *Cc:* Ni, Ray ; Rebecca Cran *Subject:* Re: [edk2-devel] CpuDeadLoop() is optimized by compiler Mike, So

Re: [edk2-devel] CpuDeadLoop() is optimized by compiler

2023-05-19 Thread Andrew Fish via groups.io
ter idea? >> >> Thanks, >> >> Ray >> >> *From:* Andrew (EFI) Fish >> *Sent:* Friday, May 19, 2023 8:42 AM >> *To:* devel@edk2.groups.io; Kinney, Michael D >> *Cc:* Ni, Ray ; Rebecca Cran >> *Subject:* Re: [edk2-devel] CpuDeadLoop()

Re: [edk2-devel] CpuDeadLoop() is optimized by compiler

2023-05-19 Thread Rebecca Cran
I've submitted a bug report at https://developercommunity.visualstudio.com/t/x64-codegen-with-optimizations-wrong-for/10369557 . -- Rebecca Cran On 5/19/23 09:31, Rebecca Cran wrote: Just to add more data, I also tried with "volatile sig_atomic_t" as someone suggested and both "/volatile:i

Re: [edk2-devel] CpuDeadLoop() is optimized by compiler

2023-05-19 Thread Rebecca Cran
Thanks, Ray *From:* Andrew (EFI) Fish *Sent:* Friday, May 19, 2023 8:42 AM *To:* devel@edk2.groups.io; Kinney, Michael D *Cc:* Ni, Ray ; Rebecca Cran *Subject:* Re: [edk2-devel] CpuDeadLoop() is optimized by compiler Mike, Sorry static was just to scope the name to the file since it is a lib

Re: [edk2-devel] CpuDeadLoop() is optimized by compiler

2023-05-18 Thread Jeff Fan via groups.io
ps.io; Kinney, Michael D CC: Rebecca Cran Subject: Re: [edk2-devel] CpuDeadLoop() is optimized by compiler I think all the options we considered are workarounds. These might break again if compiler is “cleverer” in future. Unless some Cxx spec clearly guarantees that. I like Mike’s idea to use ass

Re: [edk2-devel] CpuDeadLoop() is optimized by compiler

2023-05-18 Thread Ni, Ray
-loop intrinsic function in MSVC. Any better idea? Thanks, Ray From: Andrew (EFI) Fish Sent: Friday, May 19, 2023 8:42 AM To: devel@edk2.groups.io; Kinney, Michael D Cc: Ni, Ray ; Rebecca Cran Subject: Re: [edk2-devel] CpuDeadLoop() is optimized by compiler Mike, Sorry static was just to

Re: [edk2-devel] CpuDeadLoop() is optimized by compiler

2023-05-18 Thread Andrew Fish via groups.io
f...@apple.com>> > Sent: Thursday, May 18, 2023 1:45 PM > To: edk2-devel-groups-io <mailto:devel@edk2.groups.io>>; Andrew Fish <mailto:af...@apple.com>> > Cc: Kinney, Michael D <mailto:michael.d.kin...@intel.com>>; Ni, Ray <mailto:ray...@intel.com>

Re: [edk2-devel] CpuDeadLoop() is optimized by compiler

2023-05-18 Thread Michael D Kinney
0_1 ret Mike From: Andrew (EFI) Fish Sent: Thursday, May 18, 2023 1:45 PM To: edk2-devel-groups-io ; Andrew Fish Cc: Kinney, Michael D ; Ni, Ray ; Rebecca Cran Subject: Re: [edk2-devel] CpuDeadLoop() is optimized by compiler Whoops wrong compiler. Here is an update. I added the flags so this

Re: [edk2-devel] CpuDeadLoop() is optimized by compiler

2023-05-18 Thread Andrew Fish via groups.io
gt;>> When deadloop is entered, developer can not change value of mDeadLoopCount, >>> but they can use debugger to force exit loop and return from function. >>> >>> Mike >>> >>> >>> From: Andrew (EFI) Fish mailto:af...@apple.com>> >>

Re: [edk2-devel] CpuDeadLoop() is optimized by compiler

2023-05-18 Thread Andrew Fish via groups.io
ilto:af...@apple.com>> >> Sent: Thursday, May 18, 2023 10:09 AM >> To: Kinney, Michael D > <mailto:michael.d.kin...@intel.com>> >> Cc: edk2-devel-groups-io > <mailto:devel@edk2.groups.io>>; Ni, Ray > <mailto:ray...@intel.com>>; Rebecca

Re: [edk2-devel] CpuDeadLoop() is optimized by compiler

2023-05-18 Thread Andrew Fish via groups.io
Rebecca, It looks like VC++ is trying to honor the volatile by reading the variable, incase that has side effects. But the loop is not checking the value of the variable and it is just doing an unconditional jump. This is why I think it is likely a compiler bug. Since the compiler emitted a har

Re: [edk2-devel] CpuDeadLoop() is optimized by compiler

2023-05-18 Thread Rebecca Cran
When I use CpuDeadLoop for debugging on Aarch64 I have symbols loaded so I can just do ‘set Index=1’ and resume, but it sounds like the issue is that people want to sometimes debug without symbols/source, and the generated assembly is making that difficult. Rebecca On Thu, May 18, 2023, at 9:3

Re: [edk2-devel] CpuDeadLoop() is optimized by compiler

2023-05-18 Thread Andrew Fish via groups.io
, May 18, 2023 10:09 AM > To: Kinney, Michael D <mailto:michael.d.kin...@intel.com>> > Cc: edk2-devel-groups-io <mailto:devel@edk2.groups.io>>; Ni, Ray <mailto:ray...@intel.com>>; Rebecca Cran <mailto:rebe...@bsdio.com>> > Subject: Re: [edk2-devel]

Re: [edk2-devel] CpuDeadLoop() is optimized by compiler

2023-05-18 Thread Andrew Fish via groups.io
May 18, 2023 10:09 AM > To: Kinney, Michael D > Cc: edk2-devel-groups-io ; Ni, Ray ; > Rebecca Cran > Subject: Re: [edk2-devel] CpuDeadLoop() is optimized by compiler > > Mike, > > Good point, that is why we are using the stack …. > > The only other thing I can think of i

Re: [edk2-devel] CpuDeadLoop() is optimized by compiler

2023-05-18 Thread Michael D Kinney
mDeadLoopCount, but they can use debugger to force exit loop and return from function. Mike From: Andrew (EFI) Fish Sent: Thursday, May 18, 2023 10:09 AM To: Kinney, Michael D Cc: edk2-devel-groups-io ; Ni, Ray ; Rebecca Cran Subject: Re: [edk2-devel] CpuDeadLoop() is optimized by compiler

Re: [edk2-devel] CpuDeadLoop() is optimized by compiler

2023-05-18 Thread Andrew Fish via groups.io
ney, Michael D > wrote: > > Static global will not work for XIP > > Mike > > From: Andrew (EFI) Fish > Sent: Thursday, May 18, 2023 9:49 AM > To: edk2-devel-groups-io ; Kinney, Michael D > > Cc: Ni, Ray ; Rebecca Cran > Subject: Re: [edk2-devel]

Re: [edk2-devel] CpuDeadLoop() is optimized by compiler

2023-05-18 Thread Michael D Kinney
Static global will not work for XIP Mike From: Andrew (EFI) Fish Sent: Thursday, May 18, 2023 9:49 AM To: edk2-devel-groups-io ; Kinney, Michael D Cc: Ni, Ray ; Rebecca Cran Subject: Re: [edk2-devel] CpuDeadLoop() is optimized by compiler Mike, I pinged some compiler experts to see if our

Re: [edk2-devel] CpuDeadLoop() is optimized by compiler

2023-05-18 Thread Andrew Fish via groups.io
Mike, I pinged some compiler experts to see if our code is correct, or if the compiler has an issue. Seems to be trending compiler issue right now, but I’ve NOT gotten feedback from anyone on the spec committee yet. If we move Index to a static global that would likely work around the compiler

Re: [edk2-devel] CpuDeadLoop() is optimized by compiler

2023-05-18 Thread Michael D Kinney
Hi Ray, So the code generated does deadloop, but is just not easy to resume from as we have been able to do in the past. We use CpuDeadloop() for 2 purposes. One is a terminal condition with no reason to ever continue. The 2nd is a debug aide for developers to halt the system at a specific l

Re: [edk2-devel] CpuDeadLoop() is optimized by compiler

2023-05-18 Thread Pedro Falcato
On Thu, May 18, 2023 at 10:59 AM Ni, Ray wrote: > > Hi, > > Starting from certain version of Visual Studio C compiler (I don’t have the > exact version. I am using VS2019), CpuDeadLoop is now optimized quite well by > compiler. > > > > The optimization is so “good” that it becomes harder for dev

[edk2-devel] CpuDeadLoop() is optimized by compiler

2023-05-18 Thread Ni, Ray
Hi, Starting from certain version of Visual Studio C compiler (I don't have the exact version. I am using VS2019), CpuDeadLoop is now optimized quite well by compiler. The optimization is so "good" that it becomes harder for developers to break out of the deadloop. I copied the assembly instru