Skip to content

Commit 3484127

Browse files
ubizjakliuw
authored andcommitted
x86/hyperv: Save segment registers directly to memory in hv_hvcrash_ctxt_save()
hv_hvcrash_ctxt_save() in arch/x86/hyperv/hv_crash.c currently saves segment registers via a general-purpose register (%eax). Update the code to save segment registers (cs, ss, ds, es, fs, gs) directly to the crash context memory using movw. This avoids unnecessary use of a general-purpose register, making the code simpler and more efficient. The size of the corresponding object file improves as follows: text data bss dec hex filename 4167 176 200 4543 11bf hv_crash-old.o 4151 176 200 4527 11af hv_crash-new.o No functional change occurs to the saved context contents; this is purely a code-quality improvement. Signed-off-by: Uros Bizjak <ubizjak@gmail.com> Cc: K. Y. Srinivasan <kys@microsoft.com> Cc: Haiyang Zhang <haiyangz@microsoft.com> Cc: Wei Liu <wei.liu@kernel.org> Cc: Dexuan Cui <decui@microsoft.com> Cc: Long Li <longli@microsoft.com> Cc: Thomas Gleixner <tglx@kernel.org> Cc: Ingo Molnar <mingo@kernel.org> Cc: Borislav Petkov <bp@alien8.de> Cc: Dave Hansen <dave.hansen@linux.intel.com> Cc: H. Peter Anvin <hpa@zytor.com> Signed-off-by: Wei Liu <wei.liu@kernel.org>
1 parent 3fde528 commit 3484127

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

arch/x86/hyperv/hv_crash.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -207,12 +207,12 @@ static void hv_hvcrash_ctxt_save(void)
207207
asm volatile("movq %%cr2, %0" : "=a"(ctxt->cr2));
208208
asm volatile("movq %%cr8, %0" : "=a"(ctxt->cr8));
209209

210-
asm volatile("movl %%cs, %%eax" : "=a"(ctxt->cs));
211-
asm volatile("movl %%ss, %%eax" : "=a"(ctxt->ss));
212-
asm volatile("movl %%ds, %%eax" : "=a"(ctxt->ds));
213-
asm volatile("movl %%es, %%eax" : "=a"(ctxt->es));
214-
asm volatile("movl %%fs, %%eax" : "=a"(ctxt->fs));
215-
asm volatile("movl %%gs, %%eax" : "=a"(ctxt->gs));
210+
asm volatile("movw %%cs, %0" : "=m"(ctxt->cs));
211+
asm volatile("movw %%ss, %0" : "=m"(ctxt->ss));
212+
asm volatile("movw %%ds, %0" : "=m"(ctxt->ds));
213+
asm volatile("movw %%es, %0" : "=m"(ctxt->es));
214+
asm volatile("movw %%fs, %0" : "=m"(ctxt->fs));
215+
asm volatile("movw %%gs, %0" : "=m"(ctxt->gs));
216216

217217
native_store_gdt(&ctxt->gdtr);
218218
store_idt(&ctxt->idtr);

0 commit comments

Comments
 (0)