Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'x86_urgent_for_v6.2_rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip

Pull x86 fix from Borislav Petkov:

- Prevent the compiler from reordering accesses to debug regs which
could cause a #VC exception in SEV-ES guests at the wrong place in
the NMI handling path

* tag 'x86_urgent_for_v6.2_rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
x86/debug: Fix stack recursion caused by wrongly ordered DR7 accesses

+24 -2
+24 -2
arch/x86/include/asm/debugreg.h
··· 39 39 asm("mov %%db6, %0" :"=r" (val)); 40 40 break; 41 41 case 7: 42 - asm("mov %%db7, %0" :"=r" (val)); 42 + /* 43 + * Apply __FORCE_ORDER to DR7 reads to forbid re-ordering them 44 + * with other code. 45 + * 46 + * This is needed because a DR7 access can cause a #VC exception 47 + * when running under SEV-ES. Taking a #VC exception is not a 48 + * safe thing to do just anywhere in the entry code and 49 + * re-ordering might place the access into an unsafe location. 50 + * 51 + * This happened in the NMI handler, where the DR7 read was 52 + * re-ordered to happen before the call to sev_es_ist_enter(), 53 + * causing stack recursion. 54 + */ 55 + asm volatile("mov %%db7, %0" : "=r" (val) : __FORCE_ORDER); 43 56 break; 44 57 default: 45 58 BUG(); ··· 79 66 asm("mov %0, %%db6" ::"r" (value)); 80 67 break; 81 68 case 7: 82 - asm("mov %0, %%db7" ::"r" (value)); 69 + /* 70 + * Apply __FORCE_ORDER to DR7 writes to forbid re-ordering them 71 + * with other code. 72 + * 73 + * While is didn't happen with a DR7 write (see the DR7 read 74 + * comment above which explains where it happened), add the 75 + * __FORCE_ORDER here too to avoid similar problems in the 76 + * future. 77 + */ 78 + asm volatile("mov %0, %%db7" ::"r" (value), __FORCE_ORDER); 83 79 break; 84 80 default: 85 81 BUG();